On Wed 27-11-13 19:46:01, Vladimir Davydov wrote:We should start kmem accounting for a memory cgroup only after both itsThis should be vice-versa, no? ACTIVE is set after
kmem limit is set (KMEM_ACCOUNTED_ACTIVE) and related call sites are
patched (KMEM_ACCOUNTED_ACTIVATED).
static_key_slow_inc(&memcg_kmem_enabled_key) AFAICS.
Currently memcg_can_account_kmem() allows kmem accounting even if onlyIt would be nice to describe, what is the actual problem here. I assume
one of the conditions is true.
Fix it.
this is a charge vs. enable race. Let me try
So we have KMEM_ACCOUNTED_ACTIVATED (set by memcg_update_cache_sizes)
but the static key is not enabled yet (so KMEM_ACCOUNTED_ACTIVE is not
set yet). memcg_can_account_kmem is called from 2 contexts during charge
- memcg_kmem_get_cache via __memcg_kmem_get_cache
- memcg_kmem_newpage_charge via __memcg_kmem_newpage_charge
both of them start by checking memcg_kmem_enabled which is our
static key before memcg_can_account_kmem. This would suggest that
static_key+ACTIVE check memcg_can_account_kmem is sufficient. No?