Re: [PATCH v2 cgroup/for-7.1-fixes sched_ext/for-7.1-fixes] cgroup: Defer css percpu_ref kill on rmdir until cgroup is depopulated

From: Martin Pitt

Date: Sun May 03 2026 - 09:54:07 EST


Hello Tejun and all,

Tejun Heo [2026-05-01 8:31 -1000]:
> A chain of commits going back to v7.0 reworked rmdir to satisfy the
> controller invariant that a subsystem's ->css_offline() must not run while
> tasks are still doing kernel-side work in the cgroup.
> [..]
> v2: Pin cgrp across the deferred destroy work with explicit
> cgroup_get()/cgroup_put() around queue_work() and the work_fn. v1
> wasn't actually broken (ordered cgroup_offline_wq + queue_work order
> in cgroup_task_dead() saved it) but the explicit ref removes the
> dependency on those non-obvious invariants. Also note the
> pre-existing cgroup_apply_control_disable() race in the description;
> a follow-up will defer kill_css_finish() there.
>
> Fixes: 1b164b876c36 ("cgroup: Wait for dying tasks to leave on rmdir")

Tested-by: Martin Pitt <martin@xxxxxxxxx>

> Could you give v2 a try? Same defer-the-percpu_ref-kill mechanism as
> v1, with an explicit cgroup_get/put around the deferred work to make
> the lifetime invariant obvious (Sashiko bot review on v1; v1 wasn't
> broken but the explicit ref removes a dependency on non-obvious
> ordering). Fix should behave identically to v1 for your reproducer.

Sorry for the delay, I haven't built a kernel in a decade and not ever for
Fedora.

I applied the patch to the Rawhide 7.1.0-0.rc1 kernel, it applies cleanly
there. (I first tried on top of 6.9.14, but there are conflicts.)

https://copr.fedorainfracloud.org/coprs/martinpitt/test-fixes/build/10419932/

Usage on Fedora 44:

dnf copr enable martinpitt/test-fixes
dnf update kernel-core kernel-modules-internal

(This assumes a cloud VM. If you use the full kernel, update the "kernel"
package as well).

I ran the cockpit-podman test that originally triggered the bug, as well as my
reduced variant, against that patched kernel for 50 rounds each, and it has
consistently succeeded.

So this works great, thanks a lot!

Martin