Re: [PATCH] memcg: warn when memory cgroup IDs run out
From: Shakeel Butt
Date: Tue Nov 24 2026 - 13:09:21 EST
On Tue, Nov 24, 2026 at 09:52:26AM +0100, Michal Hocko wrote:
> On Mon 23-11-26 18:08:00, Shakeel Butt wrote:
> > Every memory cgroup gets a 16-bit private ID, so a host can have at most
> > 65,535 of them at a time, counting dead ones. A dead memcg keeps its ID
> > as long as any swap slot still records it. On Meta hosts that create
> > many short-lived cgroups, dead cgroups held this way filled the whole ID
> > space. After that, every mkdir of a cgroup with the memory controller
> > failed with -EBUSY: systemd could not start units, and container setup
> > failed.
> >
> > This was hard to see:
> >
> > - Nothing is logged when the ID allocation fails. The only sign is
> > -EBUSY from mkdir.
> > - Since commit 8290f45995f5 ("memcg: move memcg private ID refcount to
> > objcg"), a dead memcg is freed even while swap still holds its ID. So
> > nr_dying_subsys_memory in cgroup.stat can be 0 while the IDs run out.
> >
> > Print a rate limited warning when the ID allocation fails because all
> > IDs are in use.
>
> Not that I am against but isn't the issue clear by observing EBUSY from
> mkdir?
There are multiple software layers (binaries and libraries) between mkdir
operation and the folks debugging the failures. Not all software creating
cgroups log the returned errors. Also I am not sure EBUSY can only be when
we are out of memcg IDs. These errors can be transient as well. Initially I was
thinking of adding a vmstat but decided to go with a warning first.