Re: [PATCH] memcg: no refill for offlined objcg

From: Roman Gushchin
Date: Thu Apr 10 2025 - 20:00:18 EST


Shakeel Butt <shakeel.butt@xxxxxxxxx> writes:

> In our fleet, we are observing refill_obj_stock() spending a lot of cpu
> in obj_cgroup_get() and on further inspection it seems like the given
> objcg is offlined and the kernel has to take the slow path i.e. atomic
> operations for objcg reference counting.
>
> Other than expensive atomic operations, refilling stock of an offlined
> objcg is a waster as there will not be new allocations for the offlined
> objcg. In addition, refilling triggers flush of the previous objcg which
> might be used in future. So, let's just avoid refilling the stock with
> the offlined objcg.

Hm, but on the other side if there are multiple uncharges in a row,
refilling obj stocks might be still cheaper?

In general I think that switching to atomic css refcnt on memcg
offlining is a mistake - it makes memory reclaim generally more
expensive. We can simple delay it until the approximate refcnt
number reaches some low value, e.g. 100 objects.