Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031489AbbKDWWk (ORCPT ); Wed, 4 Nov 2015 17:22:40 -0500 Received: from gum.cmpxchg.org ([85.214.110.215]:41668 "EHLO gum.cmpxchg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030839AbbKDWWf (ORCPT ); Wed, 4 Nov 2015 17:22:35 -0500 From: Johannes Weiner To: David Miller , Andrew Morton Cc: Michal Hocko , Vladimir Davydov , Tejun Heo , netdev@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 2/8] mm: vmscan: simplify memcg vs. global shrinker invocation Date: Wed, 4 Nov 2015 17:22:08 -0500 Message-Id: <1446675734-25671-3-git-send-email-hannes@cmpxchg.org> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1446675734-25671-1-git-send-email-hannes@cmpxchg.org> References: <1446675734-25671-1-git-send-email-hannes@cmpxchg.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2963 Lines: 92 Letting shrink_slab() handle the root_mem_cgroup, and implicitely the !CONFIG_MEMCG case, allows shrink_zone() to invoke the shrinkers unconditionally from within the memcg iteration loop. Signed-off-by: Johannes Weiner Acked-by: Michal Hocko --- include/linux/memcontrol.h | 2 ++ mm/vmscan.c | 31 ++++++++++++++++--------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 19ff87b..8929685 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -502,6 +502,8 @@ void mem_cgroup_split_huge_fixup(struct page *head); #else /* CONFIG_MEMCG */ struct mem_cgroup; +#define root_mem_cgroup NULL + static inline void mem_cgroup_events(struct mem_cgroup *memcg, enum mem_cgroup_events_index idx, unsigned int nr) diff --git a/mm/vmscan.c b/mm/vmscan.c index 9b52ecf..ecc2125 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -411,6 +411,10 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, struct shrinker *shrinker; unsigned long freed = 0; + /* Global shrinker mode */ + if (memcg == root_mem_cgroup) + memcg = NULL; + if (memcg && !memcg_kmem_is_active(memcg)) return 0; @@ -2417,11 +2421,22 @@ static bool shrink_zone(struct zone *zone, struct scan_control *sc, shrink_lruvec(lruvec, swappiness, sc, &lru_pages); zone_lru_pages += lru_pages; - if (memcg && is_classzone) + /* + * Shrink the slab caches in the same proportion that + * the eligible LRU pages were scanned. + */ + if (is_classzone) { shrink_slab(sc->gfp_mask, zone_to_nid(zone), memcg, sc->nr_scanned - scanned, lru_pages); + if (reclaim_state) { + sc->nr_reclaimed += + reclaim_state->reclaimed_slab; + reclaim_state->reclaimed_slab = 0; + } + } + /* * Direct reclaim and kswapd have to scan all memory * cgroups to fulfill the overall scan target for the @@ -2439,20 +2454,6 @@ static bool shrink_zone(struct zone *zone, struct scan_control *sc, } } while ((memcg = mem_cgroup_iter(root, memcg, &reclaim))); - /* - * Shrink the slab caches in the same proportion that - * the eligible LRU pages were scanned. - */ - if (global_reclaim(sc) && is_classzone) - shrink_slab(sc->gfp_mask, zone_to_nid(zone), NULL, - sc->nr_scanned - nr_scanned, - zone_lru_pages); - - if (reclaim_state) { - sc->nr_reclaimed += reclaim_state->reclaimed_slab; - reclaim_state->reclaimed_slab = 0; - } - vmpressure(sc->gfp_mask, sc->target_mem_cgroup, sc->nr_scanned - nr_scanned, sc->nr_reclaimed - nr_reclaimed); -- 2.6.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/