The hierarchical nature of memcg makes that a bit complicated. We have
something similar for memcg stats which is rstat infra where the stats are
saved per-memcg per-cpu and get accumulated hierarchically every 2
seconds. This works fine for stats but for limits there would be a need for
some additional restrictions.
Also sometime ago Andrew asked me to explore replacing the atomic counter
in page_counter with percpu_counter. Intuition is that most of the time the
usage is not hitting the limit, so we can use __percpu_counter_compare for
enforcement.
Let me spend some time to explore per-memcg per-cpu cache or if
percpu_counter would be better.
Greetings Shakeel,
Hope this message finds you well. I want to inquiry about the current status of
the fixing. Have you completed the evaluation and started working on the final
solution?
For now, this patch is more like an RFC.