Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1330252

[PATCH v2 2/6] mm: vmscan: pass root_mem_cgroup instead of NULL to memcg aware shrinker

From Vladimir Davydov <vdavydov@virtuozzo.com>
Newsgroups linux.kernel
Subject [PATCH v2 2/6] mm: vmscan: pass root_mem_cgroup instead of NULL to memcg aware shrinker
Date 2016-02-09 15:00 +0100
Message-ID <r0gZK-4N6-37@gated-at.bofh.it> (permalink)
References <r0gZH-4N6-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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: Vladimir Davydov <vdavydov@virtuozzo.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/vmscan.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 18b3767136f4..bae8f32ad9cb 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -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,
  * only shrinkers with SHRINKER_MEMCG_AWARE set will be called to scan
- * objects from the memory cgroup specified. Otherwise all shrinkers
- * are called, and memcg aware shrinkers are supposed to scan the
- * global list then.
+ * objects from the memory cgroup specified. Otherwise, only unaware
+ * shrinkers are called.
  *
  * @nr_scanned and @nr_eligible form a ratio that indicate how much of
  * 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,
 	struct shrinker *shrinker;
 	unsigned long freed = 0;
 
-	if (memcg && !memcg_kmem_online(memcg))
+	if (memcg && (!memcg_kmem_enabled() || !mem_cgroup_online(memcg)))
 		return 0;
 
 	if (nr_scanned == 0)
@@ -428,7 +427,13 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
 			.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;
 
 		if (!(shrinker->flags & SHRINKER_NUMA_AWARE))
-- 
2.1.4

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/6] mm: workingset: make shadow node shrinker memcg aware Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-02-09 15:00 +0100
  [PATCH v2 4/6] radix-tree: account radix_tree_node to memory cgroup Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-02-09 15:00 +0100
  [PATCH v2 5/6] mm: workingset: size shadow nodes lru basing on file cache size Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-02-09 15:00 +0100
    Re: [PATCH v2 5/6] mm: workingset: size shadow nodes lru basing on  file cache size Johannes Weiner <hannes@cmpxchg.org> - 2016-02-10 00:20 +0100
  [PATCH v2 2/6] mm: vmscan: pass root_mem_cgroup instead of NULL to memcg aware shrinker Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-02-09 15:00 +0100
  [PATCH v2 3/6] mm: memcontrol: zap memcg_kmem_online helper Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-02-09 15:00 +0100
  [PATCH v2 1/6] mm: memcontrol: enable kmem accounting for all cgroups in the legacy hierarchy Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-02-09 15:00 +0100

csiph-web