Commit 4c56a8a
committed
cgroup: Fix cgroup_drain_dying() testing the wrong condition
cgroup_drain_dying() was using cgroup_is_populated() to test whether there are
dying tasks to wait for. cgroup_is_populated() tests nr_populated_csets,
nr_populated_domain_children and nr_populated_threaded_children, but
cgroup_drain_dying() only needs to care about this cgroup's own tasks - whether
there are children is cgroup_destroy_locked()'s concern.
This caused hangs during shutdown. When systemd tried to rmdir a cgroup that had
no direct tasks but had a populated child, cgroup_drain_dying() would enter its
wait loop because cgroup_is_populated() was true from
nr_populated_domain_children. The task iterator found nothing to wait for, yet
the populated state never cleared because it was driven by live tasks in the
child cgroup.
Fix it by using cgroup_has_tasks() which only tests nr_populated_csets.
v3: Fix cgroup_is_populated() -> cgroup_has_tasks() (Sebastian).
v2: https://lore.kernel.org/r/20260323200205.1063629-1-tj@kernel.org
Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Fixes: 1b164b8 ("cgroup: Wait for dying tasks to leave on rmdir")
Signed-off-by: Tejun Heo <tj@kernel.org>
Tested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>1 parent 6680c16 commit 4c56a8a
1 file changed
Lines changed: 22 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6229 | 6229 | | |
6230 | 6230 | | |
6231 | 6231 | | |
6232 | | - | |
6233 | | - | |
6234 | | - | |
6235 | | - | |
| 6232 | + | |
| 6233 | + | |
| 6234 | + | |
| 6235 | + | |
6236 | 6236 | | |
6237 | | - | |
6238 | | - | |
| 6237 | + | |
| 6238 | + | |
| 6239 | + | |
| 6240 | + | |
| 6241 | + | |
| 6242 | + | |
| 6243 | + | |
| 6244 | + | |
6239 | 6245 | | |
6240 | | - | |
6241 | | - | |
6242 | | - | |
6243 | | - | |
6244 | | - | |
6245 | | - | |
| 6246 | + | |
| 6247 | + | |
6246 | 6248 | | |
6247 | 6249 | | |
6248 | 6250 | | |
| |||
6258 | 6260 | | |
6259 | 6261 | | |
6260 | 6262 | | |
6261 | | - | |
| 6263 | + | |
6262 | 6264 | | |
6263 | 6265 | | |
6264 | 6266 | | |
| |||
6273 | 6275 | | |
6274 | 6276 | | |
6275 | 6277 | | |
6276 | | - | |
6277 | | - | |
6278 | | - | |
6279 | | - | |
6280 | | - | |
6281 | | - | |
| 6278 | + | |
| 6279 | + | |
| 6280 | + | |
| 6281 | + | |
| 6282 | + | |
| 6283 | + | |
6282 | 6284 | | |
6283 | 6285 | | |
6284 | | - | |
| 6286 | + | |
6285 | 6287 | | |
6286 | 6288 | | |
6287 | 6289 | | |
| |||
0 commit comments