> diff --git a/tools/testing/selftests/bpf/prog_tests/cgroup_iter_memcg.c
> b/tools/testing/selftests/bpf/prog_tests/cgroup_iter_memcg.c
> --- a/tools/testing/selftests/bpf/prog_tests/cgroup_iter_memcg.c
> +++ b/tools/testing/selftests/bpf/prog_tests/cgroup_iter_memcg.c
[ ... ]
> +static bool cmdline_has(const char *arg)
> +{
[ ... ]
> + cmdline[len] = '\0';
> + if (strstr(cmdline, arg))
> + ret = true;
> +
> + return ret;
> +}
[ ... ]
> + if (cmdline_has("cgroup.memory=nokmem")) {
The kernel's cgroup.memory= parameter accepts a comma-separated list
of options. The parser in mm/memcontrol.c cgroup_memory() splits the
value on commas with strsep():
mm/memcontrol.c:cgroup_memory() {
while ((token = strsep(&s, ",")) != NULL) {
...
if (!strcmp(token, "nokmem"))
cgroup_memory_nokmem = true;
...
}
}
This means valid command lines include configurations like
"cgroup.memory=nosocket,nokmem" or "cgroup.memory=nobpf,nokmem".
Since cmdline_has() uses strstr() to match the full literal string
"cgroup.memory=nokmem", it only matches when nokmem is the first (or
only) option. For "cgroup.memory=nosocket,nokmem", strstr() won't
find "cgroup.memory=nokmem" as a substring, so the check returns
false even though nokmem is active.
Would it be more robust to search for just "nokmem" within the
cgroup.memory= value, or to split on commas similar to how the kernel
parses it?
> + if (!ASSERT_OK(read_stats(link), "read stats"))
> + return;
> + ASSERT_EQ(memcg_query->memcg_kmem, 0, "kmem value");
> + return;
> + }
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/21978734425
AI-authorship-score: low
AI-authorship-explanation: The patch addresses a specific real-world
back-porting issue, shows iterative development across versions in response to
human reviewer feedback, and uses standard kernel C patterns with no hallmarks
of AI generation.
issues-found: 1
issue-severity-score: low
issue-severity-explanation: The strstr-based cmdline check misses nokmem when
it is not the first option in a comma-separated cgroup.memory= value, causing
the test to fail on those configurations instead of being skipped.