Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp376297ybx; Wed, 6 Nov 2019 18:53:40 -0800 (PST) X-Google-Smtp-Source: APXvYqw6EdS+99m7l4uQtoh/YOGBHzhbmRu7DD+PUAsnkRdaZxh0hvSsS28vJnQRW07hULuQiAMo X-Received: by 2002:a17:906:4bd4:: with SMTP id x20mr901679ejv.200.1573095220242; Wed, 06 Nov 2019 18:53:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573095220; cv=none; d=google.com; s=arc-20160816; b=prIpHfJ2JGDYJ/hzkOq0lvqfP/ZEf8d7p7o+5mZ7BlEsZ1znlUzbWYFy12PHjTUA0Q i/k3EaGkzv1vXgyx0WzAwXzm4dTKYhwNMPlL+aZ2tiabN/Y/VzbnHpOblEnOyFmUucTW nzEl2hC4y8uPD5Bt1RmLvfEcaFgnSESXZ6ANxEpRNd5BVJWShA2hQQSMVTw24rUBMk4u 5Y/mVJLsYgJrb0AdGYcmysklEbkCdl7j48P/fSHyQrO7sb7Xk7o63KQe+txMknMT8ZtR DHGPJHzzMdwS72+4Q+sjn8fEzEWjfyV/KqNb8IRoTg2qg/344p2DJf1rA8bjkodpQ0fr DrQw== 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; bh=kDdLz2dgz8WJIiGMPPdO9wrz/4A63qBVRe550gS0EUs=; b=nJNyvi+9+sOVMP9+hjtFj7Wi2mI6NH0TcvelKoN4PdRa8GJxN2xlwiR/YxVNkCXm9q n9hgARaQJTDtxHhU/cjYYeOEZOV8ng3J/tt3jLmgz+xT9V1af/RoTjw64sP8DBh8/Lix D3ojujRlANcbrYAd85UITLXUmmFpVDFQw7xcuh7BhUVFvWyzrWl0vpeQN3HF48tMUERH goztcb0odDZ9hq3XVyM/3KMFu9Z93B1qum3gK3cxIHrlI0GhObAOOiyzlEbjrOueQxRJ yqkm+eOjwyfGYHGQqcgeh741Y0tb9LwUdZlrEYIg9OJfGn0fZuDYdTlQNbMui+TEUNGp WszQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bG2hARxl; 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 25si547112ejw.349.2019.11.06.18.53.17; Wed, 06 Nov 2019 18:53:40 -0800 (PST) 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=bG2hARxl; 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 S1733094AbfKGCwE (ORCPT + 99 others); Wed, 6 Nov 2019 21:52:04 -0500 Received: from mail-oi1-f196.google.com ([209.85.167.196]:37254 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732382AbfKGCwE (ORCPT ); Wed, 6 Nov 2019 21:52:04 -0500 Received: by mail-oi1-f196.google.com with SMTP id y194so665630oie.4 for ; Wed, 06 Nov 2019 18:52:03 -0800 (PST) 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=kDdLz2dgz8WJIiGMPPdO9wrz/4A63qBVRe550gS0EUs=; b=bG2hARxlz9n/7uJUPESjTyuodO57X2/iCCk60Vl5V8zXwbQnnPstUSNKmrtIQ5HD3k epZTCMPvKmhpCHIOmLmmlN/MNEojn488H/JwDjSelciE6M0ds2/v36CNQWAstLIldGen L0DzEVJup+j3Tk55B4PcGE0F0HlfLIi4E0wiXL41BtXNYZrPkrjuvibgOL0Y6/dRh3WF +0rP/IgC9qirNn+Ftu0BchZ64hVBMeLUbHzslk/uENviWfrpjvxFzhdKdp4FOcVLDEXy 429yPE0Hjjq6iNirVRV20WqQ6yzYriGgRi3YjwVIcs5bOxjI5WlCIPsk6RuvQfTmRL3t pfBQ== 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=kDdLz2dgz8WJIiGMPPdO9wrz/4A63qBVRe550gS0EUs=; b=Jbk0N5Vw47+MqgG9nJ7nZvuUsktAPXFdAR+/3+IyI/oh3PHBFVB4GSagol+9tv/pe/ Hh/UMfqBR5Z9vZzjb3k22hVEDL/bITvtUJ8yj5CX+qRUwWkX3dnOPasMf3t07N/XYXGC eNJvXt0qaIAEOBdrC2wCu6ofnQEFXV9oIuGnsC7fC5QS+jCQ8jVDwVqa+hIE1dDq8QNQ bBZejuqwpVSRafmdMt8wJVUPcv8+dGkgCtoUhfJZbQGOZhQMK9vFE55iWezX0UcVwZpt cobirHOL2IkJzDk5WWOF7Y3CZWkS7lju89/ipXjQ/bFsTPOYPF4t/XiJqUsLJoufUolU qMhA== X-Gm-Message-State: APjAAAW/Ii/dmDpldUNbpQVHwV3i7AnIyL1JawsKtYN0O+2boZ11VnrH lOANbRHJ4th8BC/Ayx1+w8EXwqz7+A0BFmdvpnnfow== X-Received: by 2002:aca:7516:: with SMTP id q22mr1098320oic.144.1573095122710; Wed, 06 Nov 2019 18:52:02 -0800 (PST) MIME-Version: 1.0 References: <20190603210746.15800-1-hannes@cmpxchg.org> <20190603210746.15800-7-hannes@cmpxchg.org> In-Reply-To: <20190603210746.15800-7-hannes@cmpxchg.org> From: Shakeel Butt Date: Wed, 6 Nov 2019 18:51:51 -0800 Message-ID: Subject: Re: [PATCH 06/11] mm: vmscan: turn shrink_node_memcg() into shrink_lruvec() To: Johannes Weiner Cc: Andrew Morton , Andrey Ryabinin , Suren Baghdasaryan , Michal Hocko , Linux MM , Cgroups , LKML , Kernel Team 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 Mon, Jun 3, 2019 at 3:07 PM Johannes Weiner wrote: > > A lruvec holds LRU pages owned by a certain NUMA node and cgroup. > Instead of awkwardly passing around a combination of a pgdat and a > memcg pointer, pass down the lruvec as soon as we can look it up. > > Nested callers that need to access node or cgroup properties can look > them them up if necessary, but there are only a few cases. *them > > Signed-off-by: Johannes Weiner Reviewed-by: Shakeel Butt > --- > mm/vmscan.c | 21 ++++++++++----------- > 1 file changed, 10 insertions(+), 11 deletions(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 304974481146..b85111474ee2 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -2210,9 +2210,10 @@ enum scan_balance { > * nr[0] = anon inactive pages to scan; nr[1] = anon active pages to scan > * nr[2] = file inactive pages to scan; nr[3] = file active pages to scan > */ > -static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg, > - struct scan_control *sc, unsigned long *nr) > +static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, > + unsigned long *nr) > { > + struct mem_cgroup *memcg = lruvec_memcg(lruvec); > int swappiness = mem_cgroup_swappiness(memcg); > struct zone_reclaim_stat *reclaim_stat = &lruvec->reclaim_stat; > u64 fraction[2]; > @@ -2460,13 +2461,8 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg, > } > } > > -/* > - * This is a basic per-node page freer. Used by both kswapd and direct reclaim. > - */ > -static void shrink_node_memcg(struct pglist_data *pgdat, struct mem_cgroup *memcg, > - struct scan_control *sc) > +static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc) > { > - struct lruvec *lruvec = mem_cgroup_lruvec(memcg, pgdat); > unsigned long nr[NR_LRU_LISTS]; > unsigned long targets[NR_LRU_LISTS]; > unsigned long nr_to_scan; > @@ -2476,7 +2472,7 @@ static void shrink_node_memcg(struct pglist_data *pgdat, struct mem_cgroup *memc > struct blk_plug plug; > bool scan_adjusted; > > - get_scan_count(lruvec, memcg, sc, nr); > + get_scan_count(lruvec, sc, nr); > > /* Record the original scan target for proportional adjustments later */ > memcpy(targets, nr, sizeof(nr)); > @@ -2689,6 +2685,7 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc) > > memcg = mem_cgroup_iter(root, NULL, &reclaim); > do { > + struct lruvec *lruvec = mem_cgroup_lruvec(memcg, pgdat); > unsigned long reclaimed; > unsigned long scanned; > > @@ -2725,7 +2722,8 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc) > > reclaimed = sc->nr_reclaimed; > scanned = sc->nr_scanned; > - shrink_node_memcg(pgdat, memcg, sc); > + > + shrink_lruvec(lruvec, sc); > > if (sc->may_shrinkslab) { > shrink_slab(sc->gfp_mask, pgdat->node_id, > @@ -3243,6 +3241,7 @@ unsigned long mem_cgroup_shrink_node(struct mem_cgroup *memcg, > pg_data_t *pgdat, > unsigned long *nr_scanned) > { > + struct lruvec *lruvec = mem_cgroup_lruvec(memcg, pgdat); > struct scan_control sc = { > .nr_to_reclaim = SWAP_CLUSTER_MAX, > .target_mem_cgroup = memcg, > @@ -3268,7 +3267,7 @@ unsigned long mem_cgroup_shrink_node(struct mem_cgroup *memcg, > * will pick up pages from other mem cgroup's as well. We hack > * the priority and make it zero. > */ > - shrink_node_memcg(pgdat, memcg, &sc); > + shrink_lruvec(lruvec, &sc); > > trace_mm_vmscan_memcg_softlimit_reclaim_end( > cgroup_ino(memcg->css.cgroup), > -- > 2.21.0 >