Commit 0fc9f58a authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Linus Torvalds

mm: vmscan: pass root_mem_cgroup instead of NULL to memcg aware shrinker

It's just convenient to implement a memcg aware shrinker when you know
that shrink_control->memcg != NULL unless memcg_kmem_enabled() returns
false.
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 b313aeee
...@@ -382,9 +382,8 @@ static unsigned long do_shrink_slab(struct shrink_control *shrinkctl, ...@@ -382,9 +382,8 @@ static unsigned long do_shrink_slab(struct shrink_control *shrinkctl,
* *
* @memcg specifies the memory cgroup to target. If it is not NULL, * @memcg specifies the memory cgroup to target. If it is not NULL,
* only shrinkers with SHRINKER_MEMCG_AWARE set will be called to scan * only shrinkers with SHRINKER_MEMCG_AWARE set will be called to scan
* objects from the memory cgroup specified. Otherwise all shrinkers * objects from the memory cgroup specified. Otherwise, only unaware
* are called, and memcg aware shrinkers are supposed to scan the * shrinkers are called.
* global list then.
* *
* @nr_scanned and @nr_eligible form a ratio that indicate how much of * @nr_scanned and @nr_eligible form a ratio that indicate how much of
* the available objects should be scanned. Page reclaim for example * the available objects should be scanned. Page reclaim for example
...@@ -404,7 +403,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, ...@@ -404,7 +403,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
struct shrinker *shrinker; struct shrinker *shrinker;
unsigned long freed = 0; unsigned long freed = 0;
if (memcg && !memcg_kmem_online(memcg)) if (memcg && (!memcg_kmem_enabled() || !mem_cgroup_online(memcg)))
return 0; return 0;
if (nr_scanned == 0) if (nr_scanned == 0)
...@@ -428,7 +427,13 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, ...@@ -428,7 +427,13 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
.memcg = memcg, .memcg = memcg,
}; };
if (memcg && !(shrinker->flags & SHRINKER_MEMCG_AWARE)) /*
* If kernel memory accounting is disabled, we ignore
* SHRINKER_MEMCG_AWARE flag and call all shrinkers
* passing NULL for memcg.
*/
if (memcg_kmem_enabled() &&
!!memcg != !!(shrinker->flags & SHRINKER_MEMCG_AWARE))
continue; continue;
if (!(shrinker->flags & SHRINKER_NUMA_AWARE)) if (!(shrinker->flags & SHRINKER_NUMA_AWARE))
......
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