From patchwork Mon Mar 16 10:39:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11440123 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 A58C392A for ; Mon, 16 Mar 2020 10:40:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 677A220658 for ; Mon, 16 Mar 2020 10:40:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IkCicFVa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 677A220658 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 ABA9F6B0007; Mon, 16 Mar 2020 06:40:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A6C2E6B0008; Mon, 16 Mar 2020 06:40:38 -0400 (EDT) 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 9819D6B000A; Mon, 16 Mar 2020 06:40:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0121.hostedemail.com [216.40.44.121]) by kanga.kvack.org (Postfix) with ESMTP id 7D2266B0007 for ; Mon, 16 Mar 2020 06:40:38 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 564E98777 for ; Mon, 16 Mar 2020 10:40:38 +0000 (UTC) X-FDA: 76600881756.02.crow50_22a46b8f7d748 X-Spam-Summary: 2,0,0,6ecd1c8fec6e8072,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: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.210.195:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.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:25,LUA_SUMMARY:none X-HE-Tag: crow50_22a46b8f7d748 X-Filterd-Recvd-Size: 6582 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Mon, 16 Mar 2020 10:40:37 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id c144so9691240pfb.10 for ; Mon, 16 Mar 2020 03:40:37 -0700 (PDT) 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=vY2V4Msx6oxN9LJCRiKwHFiisubxDrfzwxG6lOa9dNU=; b=IkCicFVaHxkWKrGSUxrZpHqQj9D/t3mOLXb5kShBej3eTD5sYwXm9X3p4YWr5Gzm+x uJP3PkLtPqj7wDEK5JGRSu5vutp/fJZhT5xhC4wL1ARSWkiOTebAc7xq8wVFfb7opWtP bYkyFe8nefFlO094Bs/19gEBgiYAIn0974G/QbHc43y4F5+dsheomEAyaEl1D3BeaFn2 qX1pF0ENmCLYXTiKmQl2A2ipBjagoqoO5qQUYLd4ra0pSq3EURChDalYBAlj70XEb3Ku wJ9Y5CvNB1huHe7dqfHdRHqWFgag3RD7kY0Q1m+TwboHVdFlsLyX6zKRWR0/0iPP/Lud m/sw== 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=vY2V4Msx6oxN9LJCRiKwHFiisubxDrfzwxG6lOa9dNU=; b=T4xDR+GFvyd2qQFH5l2DekprpSFs3AAMtCq6xIAZOZUcC0Maxm1+lgInbkdXRZ2u3b Yzzh0tmhTIV+GtlcHMv53A482RsgYY1SB3/kkCN7IF26oliVOGjcrG6Ppd4qq3ttCJNp LJxO6TLIi4cBx7CLo0C/oHx17gEH6EwhJVeFLm9Gq2fUMKLagTVdHFGwazKdGUAkQ420 knBf7c5vQ2mtjflID132qb3oe8jkyvetFVagSo0rFZ6G/QrM+DzuTAU4nd0fxWkbzQiQ hpoHJPsXvDK6jSo2TmEElWbUaFjHX0NgIYzmFT3G2LRzx7SErgFwpJ5QnTcAgnLjkvyo fTkQ== X-Gm-Message-State: ANhLgQ30PtATAYcgkVBkfvNiY5uJ84hJ+x8jMya1nmcQd3lHgpgDb8HV plE73cT1Z3OC9Him95g5gM8= X-Google-Smtp-Source: ADFU+vvuCGJScZZkfVQplCLS3rrwKochvebnJHsILTRfc2PNbM4o3inEYYU3KocRr5PPgQyktY6Cdw== X-Received: by 2002:a62:5544:: with SMTP id j65mr28084461pfb.121.1584355236772; Mon, 16 Mar 2020 03:40:36 -0700 (PDT) Received: from dev.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id h2sm19834276pjc.7.2020.03.16.03.40.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Mar 2020 03:40:36 -0700 (PDT) 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, willy@infradead.org Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Yafang Shao Subject: [PATCH v6 2/3] mm, shrinker: make memcg low reclaim visible to lru walker isolation function Date: Mon, 16 Mar 2020 06:39:57 -0400 Message-Id: <1584355198-10137-3-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1584355198-10137-1-git-send-email-laoar.shao@gmail.com> References: <1584355198-10137-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 8763705..3857508 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,