From: sashiko-bot@kernel.org
To: "Hui Zhu" <hui.zhu@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 2/2] selftests/bpf: add memcg async reclaim test
Date: Wed, 19 Aug 2026 06:46:07 +0000 [thread overview]
Message-ID: <20260819064608.176581F000E9@smtp.kernel.org> (raw)
In-Reply-To: <052d445fe9d7741729447f1b90277dcdc6541b4f.1787120833.git.zhuhui@kylinos.cn>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Process leak due to overwriting child PID variable with the result of waitpid().
- [Low] BPF comment style violation for multiline comments.
--
--- Patch [2]: [PATCH bpf-next v3 2/2] selftests/bpf: add memcg async reclaim test ---
commit 4779648533dd0e49d1c2f5c9bdbbad1260ba333c
Author: Hui Zhu <zhuhui@kylinos.cn>
selftests/bpf: add memcg async reclaim test
Add memcg_async_reclaim selftest that verifies BPF-driven async proactive
reclaim can mitigate refault-induced slowdown under memory pressure.
> diff --git a/tools/testing/selftests/bpf/prog_tests/memcg_async_reclaim.c b/tools/testing/selftests/bpf/prog_tests/memcg_async_reclaim.c
> new file mode 100644
> index 0000000000000..e990d1fdc79fd
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/memcg_async_reclaim.c
[ ... ]
> + low_pid = fork();
> + if (!ASSERT_GE(low_pid, 0, "fork low"))
> + goto cleanup;
> + if (low_pid == 0)
> + exit(real_test_child_work(CG_LOW_DIR, low_data_file,
> + low_time_file, read_times));
> +
> + high_pid = fork();
> + if (!ASSERT_GE(high_pid, 0, "fork high"))
> + goto cleanup;
> + if (high_pid == 0)
> + exit(real_test_child_work(CG_HIGH_DIR, high_data_file,
> + high_time_file, read_times));
> +
> + low_pid = waitpid(low_pid, &status, 0);
> + if (!ASSERT_GT(low_pid, 0, "low waitpid"))
> + goto cleanup;
[Severity: Medium]
If waitpid() fails and returns -1, does this overwrite low_pid with the error
value?
Later in the cleanup path, the code relies on the PID being positive to kill
the left-behind child processes:
if (ret) {
if (high_pid > 0) {
...
}
if (low_pid > 0) {
kill(low_pid, SIGKILL);
(void)waitpid(low_pid, NULL, 0);
}
}
Since low_pid was overwritten with -1, the cleanup logic will fail to kill the
child process, potentially leaving it running and consuming resources. Would it
be safer to store the waitpid() return value in a separate status or pid
variable?
> + /*
> + * The child has been reaped and its PID can already be reused,
> + * so mark it to keep cleanup from signaling an unrelated process.
> + */
> + low_pid = -1;
> + if (!ASSERT_TRUE(WIFEXITED(status), "low exited"))
> + goto cleanup;
> + if (WEXITSTATUS(status) != CHILD_EXIT_OK) {
> + PRINT_FAIL("low child failed at: %s (exit status %d)",
> + child_exit_str(WEXITSTATUS(status)),
> + WEXITSTATUS(status));
> + goto cleanup;
> + }
> +
> + high_pid = waitpid(high_pid, &status, 0);
> + if (!ASSERT_GT(high_pid, 0, "high waitpid"))
> + goto cleanup;
[Severity: Medium]
Similar to the issue above, if waitpid() returns an error, high_pid is
overwritten. This prevents the cleanup code from terminating the high_pid child
process if the wait call is interrupted.
[ ... ]
> diff --git a/tools/testing/selftests/bpf/progs/memcg_async_reclaim.c b/tools/testing/selftests/bpf/progs/memcg_async_reclaim.c
> new file mode 100644
> index 0000000000000..225f0bc667113
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/memcg_async_reclaim.c
[ ... ]
> +static u64 wq_high_cgroup_id;
> +static u64 wq_low_cgroup_id;
> +
> +/* Statistics exposed to userspace through .bss, so the test can verify
> + * that reclaim actually happened instead of relying on timing alone.
> + */
[Severity: Low]
This isn't a bug, but the BPF subsystem prefers multi-line comments to have
the opening /* on its own line:
/*
* Statistics exposed to userspace through .bss, so the test can verify
* that reclaim actually happened instead of relying on timing alone.
*/
> +u64 reclaim_calls;
> +u64 reclaimed_pages;
> +
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1787120833.git.zhuhui@kylinos.cn?part=2
next prev parent reply other threads:[~2026-08-19 6:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 6:35 [PATCH bpf-next v3 0/2] bpf: BPF-driven proactive memcg reclaim Hui Zhu
2026-08-19 6:35 ` [PATCH bpf-next v3 1/2] mm/bpf: Add bpf_proactive_reclaim kfuncs Hui Zhu
2026-08-19 7:16 ` bot+bpf-ci
2026-08-19 6:35 ` [PATCH bpf-next v3 2/2] selftests/bpf: add memcg async reclaim test Hui Zhu
2026-08-19 6:46 ` sashiko-bot [this message]
2026-08-19 7:16 ` bot+bpf-ci
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260819064608.176581F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=hui.zhu@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox