Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1238329imm; Fri, 8 Jun 2018 12:23:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLHxeXKm3qTmqUi7oJxL3jXQo8mvToqRfrC00ZH2LLXgoRAk6P8WRdZcwI+zlx9sVIj2Vii X-Received: by 2002:a17:902:9a4b:: with SMTP id x11-v6mr7981488plv.176.1528485805786; Fri, 08 Jun 2018 12:23:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528485805; cv=none; d=google.com; s=arc-20160816; b=etRb++YM/eU8IPmMpskVzBy9us1YzNl+ZO0wLV+u6jPXGvbEnfWREbxgvB83Tdl/k7 gP9B+Te5YQoJXqFeYyOnLA4I54hjzguC4SErhY9dz1DAV2lWncHkQT4diXhPYLpPNtud z4eGJqTl/s5pX+7UaKwTUBhGtSradeSJJIh4Z8zEXT4JbYNUmSIxJCF2wInOkU+nQVV3 accmAg2MBtqYDid6sWKdDT3hWXU3uXmxJqdBiQ1b8UyQXYPYgYu/ATv5FtIdHdRGN1Vy YpczogZCo67uTMpjdQ7f5XcxYDkLymhvyvIujGL6oFd2g3MQkFu2tPfoSYa05BkYv4/F OWIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=Q53QBDXnxlR4sc3eEHSrM160BdAoCRY2jD5oHnn6Lss=; b=jxKsgWBMx371paAgvJisFNHqCjj/A/sgZduJjYorLfBLccYQaiDXFsYz7eVCNFwPUh uOCVIlveDATllKXEnfzyAiRC8xY1U6EwTDQBXzvDUxtdAd/KBQabPLMmht5jZcojM52K Q+B6pQ3cGC3WjlZ+Ugck2kM8Ne9HEuMFrmg0skaPup3Ruzh0yOceHJJbRuV+mTu6V/40 B1GqWKkMBnHjDpVvCGupd4PH5hgQlm8BDZ/rOAmpt8yN02gHUkWLUB/IzvorBQPvG5gE aVO7cl4hBMrP1eipzIAhxZCUrpI8QeM1KITdQ52hj6TOGNYT18rzx6M6TtGqZmVufgb2 9H9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jfesLKBL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1-v6si56354642plb.8.2018.06.08.12.23.11; Fri, 08 Jun 2018 12:23:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jfesLKBL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753067AbeFHTVY (ORCPT + 99 others); Fri, 8 Jun 2018 15:21:24 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:37541 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752883AbeFHTVX (ORCPT ); Fri, 8 Jun 2018 15:21:23 -0400 Received: by mail-wr0-f195.google.com with SMTP id d8-v6so14413770wro.4 for ; Fri, 08 Jun 2018 12:21:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Q53QBDXnxlR4sc3eEHSrM160BdAoCRY2jD5oHnn6Lss=; b=jfesLKBLREVJZzO0Ku7203ztEv3W52BOhq4mqvRGt/Q1o0WRBPu41afYOve99v8QSC kGkuZcnqiXWDLMk8lEdzbBXQ2BxdXhJUE6kpC44xejTx/RUuwsxcPjQUYM+lcewLA0mV xGRizHSqaw1OjmVPpqGrWqb9GdTt5T4mm/TssPGWUnWUhoX5tDU9VclKnSltFaKIaIbE oKb/utlBodRpBmt9cgMmkmnktQmR6aNwb3YeKnGbNKhy+U+XxQCmBOkcHFiBzUjPHYLG S5GcS33WGIqsHg8eRLkV9KHaBQcX1S9HuC6/HU1LvicU9bKtIRch/OV+19N6/hZLJQ2X HF7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Q53QBDXnxlR4sc3eEHSrM160BdAoCRY2jD5oHnn6Lss=; b=hbEYMvtEtQgTNNmJ7xy9qEKhD6wMfkp16d1cfQ7hAZwHaVl4Lwerq5g398Pgy9GfKH meb6+P3+J1Ptb23DPHkvJhA4vHBaJlKQFZjLFGcdyqL24iq2KTwfxicsnsR4HP/CBIqt PgaFolwlHhd6Q+/fQ4n/HhTFF/Rz2xscyZ34tM9MF8ptxvFOffw7zAyflUJAICX1Arrd vxNM360FOFVTuFy19TEIbcCEevtqDQMDerCA4gC71x3oBFsgGqWv/zU4AVbOWEjnMRCT TfKHb1suA7FGJTYUz80MQSDRDsoBE3TbQLXxvPV1y+ph5CeedrTtks5acPavK/YSGFUQ zloQ== X-Gm-Message-State: APt69E0P9zdYImjuWrxqmf+fMa9cifvHlYqFldZ/q6y5zn4N6bHhp2pw UC7o5fnnpYW5qQvAJp6OvbyJsp9g8bsf5aDIEHzMUw== X-Received: by 2002:adf:e48e:: with SMTP id i14-v6mr6540348wrm.8.1528485682094; Fri, 08 Jun 2018 12:21:22 -0700 (PDT) MIME-Version: 1.0 References: <152698356466.3393.5351712806709424140.stgit@localhost.localdomain> <152698379298.3393.3040399931339145602.stgit@localhost.localdomain> In-Reply-To: <152698379298.3393.3040399931339145602.stgit@localhost.localdomain> From: Shakeel Butt Date: Fri, 8 Jun 2018 12:21:10 -0700 Message-ID: Subject: Re: [PATCH v7 15/17] mm: Generalize shrink_slab() calls in shrink_node() To: Kirill Tkhai Cc: Andrew Morton , Vladimir Davydov , Alexander Viro , Johannes Weiner , Michal Hocko , Thomas Gleixner , Philippe Ombredanne , stummala@codeaurora.org, gregkh@linuxfoundation.org, Stephen Rothwell , Roman Gushchin , mka@chromium.org, Tetsuo Handa , Chris Wilson , longman@redhat.com, Minchan Kim , Huang Ying , Mel Gorman , jbacik@fb.com, Guenter Roeck , LKML , Linux MM , Matthew Wilcox , lirongqing@baidu.com, Andrey Ryabinin Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 22, 2018 at 3:09 AM Kirill Tkhai wrote: > > From: Vladimir Davydov > > The patch makes shrink_slab() be called for root_mem_cgroup > in the same way as it's called for the rest of cgroups. > This simplifies the logic and improves the readability. > > Signed-off-by: Vladimir Davydov > ktkhai: Description written. > Signed-off-by: Kirill Tkhai > --- > mm/vmscan.c | 21 ++++++--------------- > 1 file changed, 6 insertions(+), 15 deletions(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index f26ca1e00efb..6dbc659db120 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -628,10 +628,8 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid, > * @nid is passed along to shrinkers with SHRINKER_NUMA_AWARE set, > * unaware shrinkers will receive a node id of 0 instead. > * > - * @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, only unaware > - * shrinkers are called. > + * @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. > @@ -645,7 +643,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, > struct shrinker *shrinker; > unsigned long freed = 0; > Shouldn't there be a VM_BUG_ON(!memcg) here? > - if (memcg && !mem_cgroup_is_root(memcg)) > + if (!mem_cgroup_is_root(memcg)) > return shrink_slab_memcg(gfp_mask, nid, memcg, priority); > > if (!down_read_trylock(&shrinker_rwsem)) > @@ -658,9 +656,6 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, > .memcg = memcg, > }; > > - if (!!memcg != !!(shrinker->flags & SHRINKER_MEMCG_AWARE)) > - continue; > - > if (!(shrinker->flags & SHRINKER_NUMA_AWARE)) > sc.nid = 0; > > @@ -690,6 +685,7 @@ void drop_slab_node(int nid) > struct mem_cgroup *memcg = NULL; > > freed = 0; > + memcg = mem_cgroup_iter(NULL, NULL, NULL); > do { > freed += shrink_slab(GFP_KERNEL, nid, memcg, 0); > } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL); > @@ -2709,9 +2705,8 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc) > shrink_node_memcg(pgdat, memcg, sc, &lru_pages); > node_lru_pages += lru_pages; > > - if (memcg) > - shrink_slab(sc->gfp_mask, pgdat->node_id, > - memcg, sc->priority); > + shrink_slab(sc->gfp_mask, pgdat->node_id, > + memcg, sc->priority); > > /* Record the group's reclaim efficiency */ > vmpressure(sc->gfp_mask, memcg, false, > @@ -2735,10 +2730,6 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc) > } > } while ((memcg = mem_cgroup_iter(root, memcg, &reclaim))); > > - if (global_reclaim(sc)) > - shrink_slab(sc->gfp_mask, pgdat->node_id, NULL, > - sc->priority); > - > if (reclaim_state) { > sc->nr_reclaimed += reclaim_state->reclaimed_slab; > reclaim_state->reclaimed_slab = 0; >