On Tue, Oct 03, 2023 at 11:01:46AM -0700, T.J. Mercier wrote: > On Tue, Oct 3, 2023 at 10:40 AM T.J. Mercier <tjmercier@xxxxxxxxxx> wrote: > > > > Hi all, > > > > Samsung reported an Android bug where over 1000 cgroups were left > > empty without being removed. These cgroups should have been removed > > after no processes were observed to be remaining in the cgroup by this > > code [1], which loops until cgroup.procs is empty and then attempts to > > rmdir the cgroup. That works most of the time, but occasionally the > > rmdir fails with EBUSY *after cgroup.procs is empty*, which seems > > wrong. No controllers are enabled in this cgroup v2 hierarchy; it's > > currently used only for freezer. I spoke with Suren about this, who > > recalled a similar problem and fix [2], but all the kernels I've > > tested contain this fix. I have been able to reproduce this on 5.10, > > 5.15, 6.1, and 6.3 on various hardware. I've written a reproducer > > (below) which typically hits the issue in under a minute. > > > > The trace events look like this when the problem occurs. I'm guessing > > the rmdir is attempted in that window between signal_deliver and > > cgroup_notify_populated = 0. So, the recommendation is to always trigger cleanup on the !populated notification. That said, I don't immediately see why your reproducer doesn't work. I'll dig into it later. Thanks. -- tejun