From patchwork Sun Feb 23 09:31:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11398749 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49BBD930 for ; Sun, 23 Feb 2020 09:32:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 008C7208C4 for ; Sun, 23 Feb 2020 09:32:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bQCDECan" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 008C7208C4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 160346B0007; Sun, 23 Feb 2020 04:32:10 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0ECFF6B0008; Sun, 23 Feb 2020 04:32:10 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECF826B000A; Sun, 23 Feb 2020 04:32:09 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0065.hostedemail.com [216.40.44.65]) by kanga.kvack.org (Postfix) with ESMTP id CB8656B0007 for ; Sun, 23 Feb 2020 04:32:09 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 78358824556B for ; Sun, 23 Feb 2020 09:32:09 +0000 (UTC) X-FDA: 76520875578.17.push89_2fe0000c53117 X-Spam-Summary: 2,0,0,dabc236ddd8ddd90,d41d8cd98f00b204,laoar.shao@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:966:973:988:989:1260:1345:1359:1437:1535:1543:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2693:2731:3138:3139:3140:3141:3142:3355:3865:3866:3867:3868:3870:3871:3872:4117:4321:4385:4605:5007:6261:6653:7514:7550:7875:7903:8660:9036:9413:10004:11026:11232:11658:11914:12048:12294:12296:12297:12517:12519:12555:13148:13161:13229:13230:13255:14096:14181:14394:14687:14721:14877:21080:21433:21444:21451:21627:21666:21972:21990:30004:30034:30054,0,RBL:209.85.216.68:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: push89_2fe0000c53117 X-Filterd-Recvd-Size: 6561 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Sun, 23 Feb 2020 09:32:08 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id r67so2736569pjb.0 for ; Sun, 23 Feb 2020 01:32:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GJtxJvSc58vjyddnB/C/XHPYzi3+0cfBzGH9GFwf45I=; b=bQCDECanAhRGQQRTAd6yocWkVda+KDrS0dn/+9oCiTuHCbm0uZglkg4ccN2tNKHayN CFHLGLBWD8sHqlf/VBu3xQUT7cV4A9dJQx0GNq27ROSlqjPBOzsuDh+WqW5C5HyGNtRf qvud8z1QFxILnAqGmtHNnIcwd/FK9ZBFkJlJFveXRFwHBok7mzZa2FBIC9NdmVPjWOwQ tq6A5PHK25PzPf48f/jZ4h5aOYP2bJCkAgqcXe6ppf5c9pB0Ci2auXlrH/gHwD5JWo7l v9BurOb6Br/aPGeTaiJl70DKG8mZEFcdIHdBaikpdyOdloh8h4qsl2jBRs9TL7Mjgfk9 5q6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GJtxJvSc58vjyddnB/C/XHPYzi3+0cfBzGH9GFwf45I=; b=IsaphUcHUkzZFDiBbF1y8EIQazhDXDBupsOWgtnQG1xgAeHx2utOSLFzICxvQMF8NZ Gb6J3yLTFvHAttzqk73XEOWEWLuEamQpHQBy5z0/gtWzflQIGj488K3PFmNIJAk5AbmR jy3dUExffKP7z75IofLvnsFj0MjxYk5EvpIhVjVcJCygM+PKCYfhozioKzCkhVp/3LI1 xLYd0LqRoUPEAJue6DSRQYzx0Eo1Qx13nvYHkvdgaV/dFyZG7vMyf3vlrGzySGVdDfUD rAF2t4x0J98im8lSg8oslr+lXm/osgvSS9OZGJoz99Rntp3B66xl7mws7WOE2OIMsyNi u2Ng== X-Gm-Message-State: APjAAAUCgiDhxdcTlUPwh0M6Dz87fAbLKSaLCteCMA2xrxR6pyQFux3s c+aBwc8/wiVEei6pJvpDbEQ= X-Google-Smtp-Source: APXvYqwv5eVkXNOBrbBo/0ywINZyJ5hpO+6pKnGtIr2ORGOQBfe3SJUAa9ZwaanqoTyVALmizu1sCg== X-Received: by 2002:a17:902:b206:: with SMTP id t6mr46058940plr.211.1582450327847; Sun, 23 Feb 2020 01:32:07 -0800 (PST) Received: from dev.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id t19sm8346011pgg.23.2020.02.23.01.32.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Feb 2020 01:32:07 -0800 (PST) From: Yafang Shao To: dchinner@redhat.com, hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, guro@fb.com, akpm@linux-foundation.org, viro@zeniv.linux.org.uk Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Yafang Shao Subject: [PATCH v4 2/3] mm, shrinker: make memcg low reclaim visible to lru walker isolation function Date: Sun, 23 Feb 2020 04:31:33 -0500 Message-Id: <1582450294-18038-3-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582450294-18038-1-git-send-email-laoar.shao@gmail.com> References: <1582450294-18038-1-git-send-email-laoar.shao@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: A new member memcg_low_reclaim is introduced in shrink_control struct, which is derived from scan_control struct, in order to tell the shrinker whether the reclaim session is under memcg low reclaim or not. The followup patch will use this new member. Cc: Dave Chinner Signed-off-by: Yafang Shao --- include/linux/shrinker.h | 3 +++ mm/vmscan.c | 27 ++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h index 0f80123..dc42ae5 100644 --- a/include/linux/shrinker.h +++ b/include/linux/shrinker.h @@ -31,6 +31,9 @@ struct shrink_control { /* current memcg being shrunk (for memcg aware shrinkers) */ struct mem_cgroup *memcg; + + /* derived from struct scan_control */ + bool memcg_low_reclaim; }; #define SHRINK_STOP (~0UL) diff --git a/mm/vmscan.c b/mm/vmscan.c index f14c8c6..c6e1ad8 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -625,10 +625,9 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid, /** * shrink_slab - shrink slab caches - * @gfp_mask: allocation context - * @nid: node whose slab caches to target * @memcg: memory cgroup whose slab caches to target - * @priority: the reclaim priority + * @sc: scan_control struct for this reclaim session + * @nid: node whose slab caches to target * * Call the shrink functions to age shrinkable caches. * @@ -638,15 +637,18 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid, * @memcg specifies the memory cgroup to target. Unaware shrinkers * are called only if it is the root cgroup. * - * @priority is sc->priority, we take the number of objects and >> by priority - * in order to get the scan target. + * @sc is the scan_control struct, we take the number of objects + * and >> by sc->priority in order to get the scan target. * * Returns the number of reclaimed slab objects. */ -static unsigned long shrink_slab(gfp_t gfp_mask, int nid, - struct mem_cgroup *memcg, - int priority) +static unsigned long shrink_slab(struct mem_cgroup *memcg, + struct scan_control *sc, + int nid) { + bool memcg_low_reclaim = sc->memcg_low_reclaim; + gfp_t gfp_mask = sc->gfp_mask; + int priority = sc->priority; unsigned long ret, freed = 0; struct shrinker *shrinker; @@ -668,6 +670,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, .gfp_mask = gfp_mask, .nid = nid, .memcg = memcg, + .memcg_low_reclaim = memcg_low_reclaim, }; ret = do_shrink_slab(&sc, shrinker, priority); @@ -694,6 +697,9 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, void drop_slab_node(int nid) { unsigned long freed; + struct scan_control sc = { + .gfp_mask = GFP_KERNEL, + }; do { struct mem_cgroup *memcg = NULL; @@ -701,7 +707,7 @@ void drop_slab_node(int nid) freed = 0; memcg = mem_cgroup_iter(NULL, NULL, NULL); do { - freed += shrink_slab(GFP_KERNEL, nid, memcg, 0); + freed += shrink_slab(memcg, &sc, nid); } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL); } while (freed > 10); } @@ -2673,8 +2679,7 @@ static void shrink_node_memcgs(pg_data_t *pgdat, struct scan_control *sc) shrink_lruvec(lruvec, sc); - shrink_slab(sc->gfp_mask, pgdat->node_id, memcg, - sc->priority); + shrink_slab(memcg, sc, pgdat->node_id); /* Record the group's reclaim efficiency */ vmpressure(sc->gfp_mask, memcg, false,