From patchwork Wed Jan 8 16:03:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11323991 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 BD675138C for ; Wed, 8 Jan 2020 16:04:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7C73A2070E for ; Wed, 8 Jan 2020 16:04:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B5fOQPY0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C73A2070E 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 97D0C8E0009; Wed, 8 Jan 2020 11:04:24 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9077A8E0001; Wed, 8 Jan 2020 11:04:24 -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 7A59B8E0009; Wed, 8 Jan 2020 11:04:24 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0195.hostedemail.com [216.40.44.195]) by kanga.kvack.org (Postfix) with ESMTP id 6562E8E0001 for ; Wed, 8 Jan 2020 11:04:24 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 12AB3180388DC for ; Wed, 8 Jan 2020 16:04:24 +0000 (UTC) X-FDA: 76354939248.04.time84_436d59b9ca417 X-Spam-Summary: 2,0,0,920fdfa6be744051,d41d8cd98f00b204,laoar.shao@gmail.com,: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::linux-fsdevel@vger.kernel.org: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:11658:11914:12048:12294:12296:12297:12517:12519:12555:12895:12986: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.215.193:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.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:25,LUA_SUMMAR Y:none X-HE-Tag: time84_436d59b9ca417 X-Filterd-Recvd-Size: 6553 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Wed, 8 Jan 2020 16:04:23 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id k3so1801714pgc.3 for ; Wed, 08 Jan 2020 08:04:23 -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=6tDRHfnOHhoFqOdXrEqpx02xS4p7Z8x/5vQQY0aLm8A=; b=B5fOQPY05C9Lq+n9bt52buT2A7zkUL4sgv4b5/aECGwJd39DWMxRsy2c8cF/pkfLyU WfKb7TzULr/fJztTjK8x2Ui/8G47hn0Y5MfDn10NN0zXi7fXrY921d+aW4z5EsMaQGHl 1nMAkJPUXIe0WM2pBF51WSkdzUJC2fR20TYqFFckLRPZURcOZOlQVOctax8yGfmmAETM ZwsFdFiQR+5CVXOF9LYIPsDlrakNHc6JzoFI2UexDMfzdNQwGjCKls1cqjYlaKO2dpNa JkFTLjRci3FahIpEeUq0kC6qrHFqK2UwB786bPemUQg35E8ECpLqlhqSxw52rdXrclg9 5bdw== 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=6tDRHfnOHhoFqOdXrEqpx02xS4p7Z8x/5vQQY0aLm8A=; b=OV42OUChwcGjnsAmIyUQv40TOqWm8L9Y+WUNMEtbDvl/ct4/Wd0cW9gBdHucPAsjg8 enfmC/CYwzHDn3cbOnvJj00Zpnoneriq4Ga+T9pFWIEOOyysKBswhgbdhGzPWjVqI0Qo omjeLHstDGGpUlYB0DrWrMjOOKsOc33yAS6QwzAbFfhg4fzEeq+T1Wfps8YxiShc1r9a AS/apDs4/vCdOkhiStDh7OXAmUM5+Ryxm8HcGLM9rQzQqrJV0ZEV22FMdJx7/d3F4nRK cbD7DPO6hvqVlpCYIFGbSbkuDuXs7Flm/fTqNwF2L2FNzJS1Wih13QZrbRgwdl7EsFpN LoEw== X-Gm-Message-State: APjAAAUGJBUsbfoQ8IL9T/Dwh1UsIgSLyXqDm/na0EPUPHKqhFd6A311 lT8M3ob1c3nbTHHd0KB8w1U= X-Google-Smtp-Source: APXvYqwfRgPZUp3MgB5cdkyxCriBpjrgtBHzNG9GXRLTGn33q60rXLqX9nFm9V64JP+A+KjED3q8EQ== X-Received: by 2002:a62:ee11:: with SMTP id e17mr5905285pfi.48.1578499462405; Wed, 08 Jan 2020 08:04:22 -0800 (PST) Received: from dev.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id d22sm4079894pfo.187.2020.01.08.08.04.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jan 2020 08:04:21 -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 v3 2/3] mm, shrinker: make memcg low reclaim visible to lru walker isolation function Date: Wed, 8 Jan 2020 11:03:56 -0500 Message-Id: <1578499437-1664-3-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1578499437-1664-1-git-send-email-laoar.shao@gmail.com> References: <1578499437-1664-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 5a6445e..c97d005 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -639,10 +639,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. * @@ -652,15 +651,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; @@ -682,6 +684,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); @@ -708,6 +711,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; @@ -715,7 +721,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); } @@ -2684,8 +2690,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,