Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

From: Richard Palethorpe
Date: Fri Oct 16 2020 - 01:43:15 EST


Hello Roman,

Roman Gushchin <guro@xxxxxx> writes:

> Hi Richard!
>
>> SLAB objects which outlive their memcg are moved to their parent
>> memcg where they may be uncharged. However if they are moved to the
>> root memcg, uncharging will result in negative page counter values as
>> root has no page counters.
>>
>> To prevent this, we check whether we are about to uncharge the root
>> memcg and skip it if we are. Possibly instead; the obj_cgroups should
>> be removed from their slabs and any per cpu stocks instead of
>> reparenting them to root?
>
> It would be really complex. I think your fix is totally fine.
> We have similar checks in cancel_charge(), uncharge_batch(),
> mem_cgroup_swapout(), mem_cgroup_uncharge_swap() etc.
>
>
> Acked-by: Roman Gushchin <guro@xxxxxx>
>
> Thanks!

Great I will respin.

--
Thank you,
Richard.