Re: [PATCH] memcg: warn when memory cgroup IDs run out

From: Muchun Song

Date: Mon Nov 23 2026 - 21:19:54 EST




> On Nov 24, 2026, at 10:08, Shakeel Butt <shakeel.butt@xxxxxxxxx> 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.
>
> Signed-off-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>

Reviewed-by: Muchun Song (ByteDance) <muchun.song@xxxxxxxxx>

Thanks.