Commit b6ecd2de authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Linus Torvalds

mm: memcontrol: zap memcg_kmem_online helper

As kmem accounting is now either enabled for all cgroups or disabled
system-wide, there's no point in having memcg_kmem_online() helper -
instead one can use memcg_kmem_enabled() and mem_cgroup_online(), as
shrink_slab() now does.

There are only two places left where this helper is used -
__memcg_kmem_charge() and memcg_create_kmem_cache().  The former can
only be called if memcg_kmem_enabled() returned true.  Since the cgroup
it operates on is online, mem_cgroup_is_root() check will be enough.

memcg_create_kmem_cache() can't use mem_cgroup_online() helper instead
of memcg_kmem_online(), because it relies on the fact that in
memcg_offline_kmem() memcg->kmem_state is changed before
memcg_deactivate_kmem_caches() is called, but there we can just
open-code the check.
Signed-off-by: default avatarVladimir Davydov <vdavydov@virtuozzo.com>
Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0fc9f58a
...@@ -795,11 +795,6 @@ static inline bool memcg_kmem_enabled(void) ...@@ -795,11 +795,6 @@ static inline bool memcg_kmem_enabled(void)
return static_branch_unlikely(&memcg_kmem_enabled_key); return static_branch_unlikely(&memcg_kmem_enabled_key);
} }
static inline bool memcg_kmem_online(struct mem_cgroup *memcg)
{
return memcg->kmem_state == KMEM_ONLINE;
}
/* /*
* In general, we'll do everything in our power to not incur in any overhead * In general, we'll do everything in our power to not incur in any overhead
* for non-memcg users for the kmem functions. Not even a function call, if we * for non-memcg users for the kmem functions. Not even a function call, if we
...@@ -909,11 +904,6 @@ static inline bool memcg_kmem_enabled(void) ...@@ -909,11 +904,6 @@ static inline bool memcg_kmem_enabled(void)
return false; return false;
} }
static inline bool memcg_kmem_online(struct mem_cgroup *memcg)
{
return false;
}
static inline int memcg_kmem_charge(struct page *page, gfp_t gfp, int order) static inline int memcg_kmem_charge(struct page *page, gfp_t gfp, int order)
{ {
return 0; return 0;
......
...@@ -2346,7 +2346,7 @@ int __memcg_kmem_charge(struct page *page, gfp_t gfp, int order) ...@@ -2346,7 +2346,7 @@ int __memcg_kmem_charge(struct page *page, gfp_t gfp, int order)
int ret = 0; int ret = 0;
memcg = get_mem_cgroup_from_mm(current->mm); memcg = get_mem_cgroup_from_mm(current->mm);
if (memcg_kmem_online(memcg)) if (!mem_cgroup_is_root(memcg))
ret = __memcg_kmem_charge_memcg(page, gfp, order, memcg); ret = __memcg_kmem_charge_memcg(page, gfp, order, memcg);
css_put(&memcg->css); css_put(&memcg->css);
return ret; return ret;
......
...@@ -510,7 +510,7 @@ void memcg_create_kmem_cache(struct mem_cgroup *memcg, ...@@ -510,7 +510,7 @@ void memcg_create_kmem_cache(struct mem_cgroup *memcg,
* The memory cgroup could have been offlined while the cache * The memory cgroup could have been offlined while the cache
* creation work was pending. * creation work was pending.
*/ */
if (!memcg_kmem_online(memcg)) if (memcg->kmem_state != KMEM_ONLINE)
goto out_unlock; goto out_unlock;
idx = memcg_cache_id(memcg); idx = memcg_cache_id(memcg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment