On Sat 11-06-22 10:06:18, Christian König wrote:
Am 10.06.22 um 16:16 schrieb Michal Hocko:[...]
I could of course add something to struct page to track which memcg (orStruct page already maintains is memcg. The one which has charged it and
process) it was charged against, but extending struct page is most likely a
no-go.
it will stay constatnt throughout of the allocation lifetime (cgroup v1
has a concept of the charge migration but this hasn't been adopted in
v2).
We have a concept of active_memcg which allows to charge against a
different memcg than the allocating context. From your example above I
do not think this is really usable for the described usecase as the X is
not aware where the request comes from?
Alternative I could try to track the "owner" of a buffer (e.g. a shmemIf you can enforce that the owner is really responsible for the
file), but then it can happen that one processes creates the object and
another one is writing to it and actually allocating the memory.
allocation then all should be fine. That would require MAP_POPULATE like
semantic and I suspect this is not really feasible with the existing
userspace. It would be certainly hard to enforce for bad players.