Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Shakeel Butt" <shakeel.butt@linux.dev>, "Tejun Heo" <tj@kernel.org>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Michal Koutny" <mkoutny@suse.com>,
	"Michal Hocko" <mhocko@kernel.org>,
	"Roman Gushchin" <roman.gushchin@linux.dev>,
	"Christian Brauner" <brauner@kernel.org>,
	"Oleg Nesterov" <oleg@redhat.com>,
	"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"T . J . Mercier" <tjmercier@google.com>,
	"Usama Arif" <usama.arif@linux.dev>,
	"Meta kernel team" <kernel-team@meta.com>,
	linux-mm@kvack.org
Subject: Re: [PATCH v3 08/12] selftests/cgroup: test the frozen state of a cgroup with tasks and children
Date: Sat, 05 Dec 2026 18:42:23 +0000	[thread overview]
Message-ID: <sashiko-outbox-251805@kernel.org> (raw)
In-Reply-To: <20261204184041.1489976-9-shakeel.butt@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] selftests/cgroup: test_cgfreezer_nonleaf() omits frozen-child
  unfrozen-parent
--

commit 50b37a92c7dfe03a60048f4a7da721b1bcd9ef30
Author: Shakeel Butt <shakeel.butt@linux.dev>

selftests/cgroup: test the frozen state of a cgroup with tasks and children

This commit adds test_cgfreezer_nonleaf() to test_freezer.c to verify
that a cgroup with both its own tasks and a child cgroup reports frozen
only once all own tasks and descendants are frozen, and does not stay
frozen after a thaw.

> diff --git a/tools/testing/selftests/cgroup/test_freezer.c b/tools/testing/selftests/cgroup/test_freezer.c
> index 266b1a0f889f5..92dd743ca7bb6 100644
> --- a/tools/testing/selftests/cgroup/test_freezer.c
> +++ b/tools/testing/selftests/cgroup/test_freezer.c

[ ... ]

> @@ -804,6 +805,112 @@ static int test_cgfreezer_vfork(const char *root)
>  	return ret;
>  }
>  
> +/*
> + * A cgroup with tasks of its own and child cgroups is frozen only once its
> + * tasks and all its descendants are frozen.
> + *

[ ... ]

> +static int test_cgfreezer_nonleaf(const char *root)
> +{

[ ... ]

> +	frozen_pid = cg_run_nowait(child, child_fn, NULL);
> +	stopped_pid = cg_run_nowait(staging, child_fn, NULL);
> +	if (frozen_pid < 0 || stopped_pid < 0 ||
> +	    cg_wait_for_proc_count(child, 1) ||
> +	    cg_wait_for_proc_count(staging, 1))
> +		goto cleanup;
> +
> +	/* Freeze one task in the v1 hierarchy and stop the other. */
> +	if (cg_enter(v1cg, frozen_pid) ||
> +	    cg_write(v1cg, "freezer.state", "FROZEN") ||
> +	    cg_read_strcmp_wait(v1cg, "freezer.state", "FROZEN\n"))
> +		goto cleanup;
> +
> +	if (kill(stopped_pid, SIGSTOP) ||
> +	    waitpid(stopped_pid, NULL, WUNTRACED) != stopped_pid)
> +		goto cleanup;
> +
> +	/*
> +	 * Freeze the parent and move the stopped task in.  All of the
> +	 * parent's own tasks are frozen now, but its child isn't.
> +	 */
> +	if (cg_freeze_nowait(parent, true) || cg_enter(parent, stopped_pid))
> +		goto cleanup;
> +
> +	for (i = 0; i < 50; i++) {
> +		if (cg_check_frozen(parent, false) ||
> +		    cg_check_frozen(child, false))
> +			goto cleanup;
> +		usleep(10000);
> +	}
> +
> +	/* The thaw doesn't wake the stopped task, the parent stays thawed. */
> +	if (cg_freeze_nowait(parent, false) || cg_check_frozen(parent, false))
> +		goto cleanup;
> +
> +	/* Once the task is thawed in v1, the whole subtree can freeze. */
> +	if (cg_write(v1cg, "freezer.state", "THAWED"))
> +		goto cleanup;
> +
> +	if (cg_freeze_wait(parent, true) || cg_check_frozen(child, true))
> +		goto cleanup;

[Severity: Low]
Should test_cgfreezer_nonleaf() also cover the symmetric case where child
reaches frozen=1 while parent still has an unfrozen task of its own?

Right now, frozen_pid is only placed in child and stopped_pid in parent, so
only the frozen-parent, unfrozen-child case is tested.

Commit "cgroup/freezer: check own tasks and descendants for the frozen state"
also fixed upward propagation when a child finishes freezing while its parent
still has unfrozen own tasks.  Without testing that direction, a regression
in that half of cgroup_frozen_state() would pass undetected.

Reusing parent, child, and v1cg to place a v1-frozen task in parent while
letting child freeze to frozen=1 and checking that parent stays frozen=0
would cover both halves.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204184041.1489976-1-shakeel.butt@linux.dev?part=8


  reply	other threads:[~2026-12-05 18:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 18:40 [PATCH v3 00/12] cgroup: don't hold cgroup_mutex for cgroup.kill and cgroup.freeze Shakeel Butt
2026-12-04 18:40 ` [PATCH v3 01/12] cgroup: don't lose a task in css_task_iter when a migration fails Shakeel Butt
2026-12-05  7:54   ` Tejun Heo
2026-12-04 18:40 ` [PATCH v3 02/12] cgroup: kill a child forked while cgroup.kill runs Shakeel Butt
2026-12-04 18:40 ` [PATCH v3 03/12] cgroup: refuse cgroup.kill below a threaded cgroup Shakeel Butt
2026-12-04 18:40 ` [PATCH v3 04/12] cgroup/freezer: check own tasks and descendants for the frozen state Shakeel Butt
2026-12-04 18:40 ` [PATCH v3 05/12] cgroup/freezer: don't update the frozen state of removed cgroups Shakeel Butt
2026-12-05 18:42   ` sashiko-bot
2026-12-04 18:40 ` [PATCH v3 06/12] cgroup/freezer: test the freeze trap bit under siglock Shakeel Butt
2026-12-04 18:40 ` [PATCH v3 07/12] selftests/cgroup: test cgroup.procs reads across a failed migration Shakeel Butt
2026-12-05 18:42   ` sashiko-bot
2026-12-04 18:40 ` [PATCH v3 08/12] selftests/cgroup: test the frozen state of a cgroup with tasks and children Shakeel Butt
2026-12-05 18:42   ` sashiko-bot [this message]
2026-12-04 18:40 ` [PATCH v3 09/12] selftests/cgroup: test cgroup.kill in and below a threaded cgroup Shakeel Butt
2026-12-05 18:42   ` sashiko-bot
2026-12-04 18:40 ` [PATCH v3 10/12] cgroup: factor out cgroup_kn_break_active() and cgroup_kn_unbreak_active() Shakeel Butt
2026-12-04 18:40 ` [PATCH v3 11/12] cgroup: don't hold cgroup_mutex for cgroup.kill Shakeel Butt
2026-12-05 18:42   ` sashiko-bot
2026-12-04 18:40 ` [PATCH v3 12/12] cgroup/freezer: don't hold cgroup_mutex for cgroup.freeze Shakeel Butt
2026-12-05 18:42   ` sashiko-bot
2026-12-04 18:54 ` [PATCH v3 00/12] cgroup: don't hold cgroup_mutex for cgroup.kill and cgroup.freeze Shakeel Butt

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=sashiko-outbox-251805@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=bigeasy@linutronix.de \
    --cc=brauner@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@meta.com \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=mkoutny@suse.com \
    --cc=oleg@redhat.com \
    --cc=roman.gushchin@linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    --cc=tj@kernel.org \
    --cc=tjmercier@google.com \
    --cc=usama.arif@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