[LTP] mmapstress06: Convert to new API
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Sun Jun 7 10:02:12 CEST 2026
Hi Wei,
On Sun, 07 Jun 2026 04:52:06 +0000, Wei Gao wrote:
> mmapstress06: Convert to new API
> +static void cleanup(void)
> +{
> + if (child_pid > 0) {
> + SAFE_KILL(child_pid, SIGKILL);
> + SAFE_WAITPID(child_pid, NULL, 0);
> + }
> +
> + if (cg_child) {
> + SAFE_CG_PRINTF(tst_cg_drain, "cgroup.procs", "%d", getpid());
> + cg_child = tst_cg_group_rm(cg_child);
> + }
> +}
The drain step moves the parent process into tst_cg_drain, but the
parent was never placed into cg_child -- only the forked child was
(via SAFE_CG_PRINTF(cg_child, "cgroup.procs", ...) inside the child
block). After SAFE_KILL + SAFE_WAITPID, the child has exited and the
kernel has already removed it from cg_child, so the cgroup is empty
and tst_cg_group_rm() can be called directly.
Draining the parent out of its current cgroup (tst_cg, managed by the
framework) into tst_cg_drain leaves the test process in the wrong
cgroup after cleanup. Compare with ksm02.c, where the drain is correct
because the parent explicitly moves itself into a child cgroup first.
The fix is to drop the SAFE_CG_PRINTF(tst_cg_drain, ...) line:
if (cg_child)
cg_child = tst_cg_group_rm(cg_child);
Verdict: Needs revision
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
More information about the ltp
mailing list