Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4666859ybi; Mon, 3 Jun 2019 15:08:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkZmN3iAE0hvg3wMJayzjBVzR/FKSA+u+JhrFDQ8jpMC5oCRl0iRU7cqqyKS8xQ/u6UC5r X-Received: by 2002:a63:1723:: with SMTP id x35mr14109475pgl.233.1559599730619; Mon, 03 Jun 2019 15:08:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559599730; cv=none; d=google.com; s=arc-20160816; b=AdyQ6IIe4/vbWUA77uYK5LyyOeuERZBk+IkXQ5gDX0HN4Z2xdy8yIiuCSiqaqsw9Ub /drbz5WWZSfExn4ounDkNILIHE9jkwQLspaGBuh+W1ZIX/und98J9YXNL0Zuiz4JOd1B T7ot9xBWzsyS2TUOEZ/u+/zKTSdOgxuydGrPFxKVnL0JNFKoFo105LiFaUiiwyHLQRCb 7dzTOYcftjZpXQzK0x7UaSHYWVo1wb68WDHSqHyxXo4wnbZ9FN3yrs4urcB8BM6gdE32 5yCP/i82f+cun/A+u2SGuMtuX0+9ncLPZ2R+FYQu6E8vQpeOg9W3ybV4RlXYTKu3P3pD IywA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TZYaz3eXPzGxVmhv3HMCDwJQRLheeIorOMAlH7HJ9WE=; b=GVT9ffbeq5EIG5TMGLu1jtPlDtKnefKHlBMdJbZmeICCGAJO8cE/4oH+rj8nA1cAm7 Yzz3bgJicwQiVG9s4Gk03AhcmkKkUh5af2j/e8Ba26ovZqY4KncZD6AN+Y81fNbCIjtf LHYWjOgKB2KkOtu+DOSTM58c2d/iYccS7w6N4udIzxhlD0rLHXCQ4pPw4Vw8+gVLOk2g Ee84M+x8Ag+moCWTLumPhq3VTEKtKkvMeuB4538tScq9Ur5rXOAmHYxT0/6/G7jg6ile ejhZcBtcWS5Zrnio05CMRrSqWEtjUFVLpU9a/azfugDnueAID8Q6Nau3m4DLluZXm+Em iqvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=WQm7ItMw; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h16si21497732pfn.162.2019.06.03.15.08.35; Mon, 03 Jun 2019 15:08:50 -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=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=WQm7ItMw; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726754AbfFCWHO (ORCPT + 99 others); Mon, 3 Jun 2019 18:07:14 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:41625 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726025AbfFCWHN (ORCPT ); Mon, 3 Jun 2019 18:07:13 -0400 Received: by mail-pg1-f194.google.com with SMTP id 83so2233179pgg.8 for ; Mon, 03 Jun 2019 15:07:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TZYaz3eXPzGxVmhv3HMCDwJQRLheeIorOMAlH7HJ9WE=; b=WQm7ItMwHktG69xBNCOEpRK0igijLT4KjtCpBChKUtJC8aBS9I40wEtrTmWdpuarBT EckEfBxI/uccO9dAsIBtIyhtxBfgqHV0832w0TwgkUwpZ7L5A7gL+qjqAq5+n37IDIcL QOnCWjesoJnT4Ik5GCuPeO/EyCm9kSCpcQ26IFQLfuLJY5XXNcXM+pfT84cIDT5o+y6o +MhC8h281MnBe0uI2y+qvuR2asCG9iNhPDsNn9dwW9QRXVOtO8309ZMSiP9qFEiRH84p fQJBUtGGkOa0hmoDQAgB3Q9oqONyoSWSGmot04Ty0joMo26ffwXfKHDAmgMunBMEa7eZ vQvw== 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:mime-version:content-transfer-encoding; bh=TZYaz3eXPzGxVmhv3HMCDwJQRLheeIorOMAlH7HJ9WE=; b=gnNZauc6hYQl5ZJjCt+umZJXrSf+NU56zuixEpV4jUQAJVDA045e4kSv+IH1KnJ1Ug AIrZQ3opzuKf4+UbiJ5VAI7QFRw2ViCNtMVXMfpiO0XZi2MnDN8/yn8BE43m3uvwfe0E i8vXKhK4trLwqzolDE9fjJZrqvTAjkbDAli4DkEWTjPSkmQcow+CB0XXSgwlh+8VHI+q HaAB360ugjqm0L7niIYraHcbstEYxSCbl2tTFjKxuog2+t5p1OfVgyfdHSbZkNy3gtcY V6O1xMPrAa69VmkoxQwq+x2aDFMoKYoP8Ni03dqcj4b+Api9YLrKmgK9Pkp0TxKIQErV lmuw== X-Gm-Message-State: APjAAAW01Ni37dgcMJLyiUneGPS3JccO3BmyrxsKscvHwR9fLJwk93tE yyrKIdp3/Np8Iv5GTBJo9QbTLRwXCjY= X-Received: by 2002:a65:494a:: with SMTP id q10mr30911726pgs.201.1559596115744; Mon, 03 Jun 2019 14:08:35 -0700 (PDT) Received: from localhost ([2620:10d:c091:500::1:9fa4]) by smtp.gmail.com with ESMTPSA id g8sm7238285pgd.29.2019.06.03.14.08.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Jun 2019 14:08:35 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Andrey Ryabinin , Suren Baghdasaryan , Michal Hocko , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 06/11] mm: vmscan: turn shrink_node_memcg() into shrink_lruvec() Date: Mon, 3 Jun 2019 17:07:41 -0400 Message-Id: <20190603210746.15800-7-hannes@cmpxchg.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190603210746.15800-1-hannes@cmpxchg.org> References: <20190603210746.15800-1-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Johannes Weiner --- 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