Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1022647img; Thu, 28 Feb 2019 11:40:02 -0800 (PST) X-Google-Smtp-Source: APXvYqzmiLr5DRyLmxhLGfD2A1Lg0OKL5obvL3KfsMRyRq3ohDcPgN79XkRVFs6lLQLQfbRF7iGR X-Received: by 2002:a17:902:27a8:: with SMTP id d37mr1101540plb.164.1551382802362; Thu, 28 Feb 2019 11:40:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551382802; cv=none; d=google.com; s=arc-20160816; b=SxvTMtloaW6um6uL10+gZ+BgqI9pj8pAfHawvCuDK8+dcHm/j142Ya3O42Q2nNYNIQ Orffaks1eF8/+2UbozaWh8M9X5XlcW3rpDpZj4xr5JOecZLtb7OrNR+6i/yCd1FTmSin u0k/fMk5A3bLJMDbWZerzYeBtMeZi9tyjb8G6Ih98iWI7TNSQPRxnxZYfbihjuc23xyc TDwszfvQEdcmONc65wDaZAb0YQ+0N2XXIConClnWSXfkfY++koCRuio0pQ4bDjO3FGDr HNFO5L7dt56MdgA/Y7VZYdTF8IbdePAeSVKnjMQszkDryz49tc+tJT2l0+aAKwfmlf/e 9wIQ== 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=+fTCozRbLMGgETAnd6XOzTuCoFNGxxYSxApGaKudEvQ=; b=wjyiuFo+m0IGpAcdpKgWLz4VBhztyOhLlVWJ1Mq81eEYNk6aasPpZ/eFTManV/7FIg wBmx32XCfDBFe3WPDTibEJhVDSyyVmKKRFXyvFJf99qgYzuPyTn+8NJqouJCCvd+LjNt TYRKtbS4hpaP6UYNI1RXfMMj/WMVqCcJ5UOgjwlhViIX5GwaJ66eX9gvsYoMh5ro9lEq wbXjNQ9E8UluiszIHpmnundpaNZrC0gMnyxSbyKdJqqOe4X8il2TJGtqWys7tXBhdupx ssHw8e26IB590pSLDgYJIyE43USTLXr2SgsNH7As+OpelA7jwJi3Gsx1AUFaJMpllLxx UlxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=x12aerec; 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 l70si18139272pgd.470.2019.02.28.11.39.46; Thu, 28 Feb 2019 11:40:02 -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=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=x12aerec; 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 S1732836AbfB1Qav (ORCPT + 99 others); Thu, 28 Feb 2019 11:30:51 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:33620 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731153AbfB1Qas (ORCPT ); Thu, 28 Feb 2019 11:30:48 -0500 Received: by mail-yw1-f68.google.com with SMTP id i204so9043162ywb.0 for ; Thu, 28 Feb 2019 08:30:47 -0800 (PST) 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=+fTCozRbLMGgETAnd6XOzTuCoFNGxxYSxApGaKudEvQ=; b=x12aerecO+G2Qi8DCMF2xSNAdXP6sBfvJQFyXJRVQZzC59w0Li6KJcU2pImtwibxdU jf1dSlSsVetoPQrYlc7ADovX4Z9ahMPqkLwaA10S6bLaHVLA0w9hGYX7L83qslBlCUmp yQyO2YHvfGJbtpNNJp4Jt1rHJvl3Pr7QmtLNylzcYOSY+44ehQkUBWAdlWVslNo6ftDg LJM1d+pyrMy9ErHzmV1drh8f3anJphXWFWrNeCPNNAOiRhhiNIVgIEMRO0MCXqL/o+wv tTccoxWk0I9ROwOYBJAZIuuupIO4nyL1sRD41Cfz+2izzbY8daIyH18gtRXknFFHxHoI 6Gpg== 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=+fTCozRbLMGgETAnd6XOzTuCoFNGxxYSxApGaKudEvQ=; b=h3s4ciSDuC/O1qsJpGom2aAybDKgg8Hmtl6veF/oZ/kGWC9yRV8k8l6lH1AxEXNg2R 5unxmoUoc/E0zj1BIfp60FhkEQ/eNUwHkwrjc7YahwwFZ6WK9DDtVFjmlx0DrXhhQBIz B5gPSZGhaUA5YfjhAPB6q0nkoQ33zpjAL12meY8MvElOchGGQummH5ZjVaIsFfT/v6cl PspkEgFimnvTkvpGV9dnESCnbpk/OUFPrLK5EEEKPz4mUMOqN4ClfvTCj3v7qQcS5Zz7 nMKVLW2/6unmgojFZ5y/EFoty+HatlOFIskSm6RFK3tGIwY3AjD0RkVGi2UgPhUlv5Uq bn9w== X-Gm-Message-State: AHQUAuZ1WklC1lu7tBCy7AC5McauEw3kUcu4/FDQbRySQblljyWtVESB BUoUl5PhBS0Q524YromPtJ3yZg== X-Received: by 2002:a0d:d3c3:: with SMTP id v186mr6413209ywd.15.1551371446919; Thu, 28 Feb 2019 08:30:46 -0800 (PST) Received: from localhost ([2620:10d:c091:200::3:da64]) by smtp.gmail.com with ESMTPSA id e21sm1132279ywe.77.2019.02.28.08.30.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 08:30:46 -0800 (PST) From: Johannes Weiner To: Andrew Morton Cc: Tejun Heo , Roman Gushchin , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 4/6] mm: memcontrol: push down mem_cgroup_node_nr_lru_pages() Date: Thu, 28 Feb 2019 11:30:18 -0500 Message-Id: <20190228163020.24100-5-hannes@cmpxchg.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190228163020.24100-1-hannes@cmpxchg.org> References: <20190228163020.24100-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 mem_cgroup_node_nr_lru_pages() is just a convenience wrapper around lruvec_page_state() that takes bitmasks of lru indexes and aggregates the counts for those. Replace callsites where the bitmask is simple enough with direct lruvec_page_state() calls. This removes the last extern user of mem_cgroup_node_nr_lru_pages(), so make that function private again, too. Signed-off-by: Johannes Weiner --- include/linux/memcontrol.h | 10 ---------- mm/memcontrol.c | 10 +++++++--- mm/workingset.c | 5 +++-- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 5050d281f67d..57029eefd225 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -514,9 +514,6 @@ int mem_cgroup_select_victim_node(struct mem_cgroup *memcg); void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru, int zid, int nr_pages); -unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg, - int nid, unsigned int lru_mask); - static inline unsigned long mem_cgroup_get_zone_lru_size(struct lruvec *lruvec, enum lru_list lru, int zone_idx) @@ -979,13 +976,6 @@ unsigned long mem_cgroup_get_zone_lru_size(struct lruvec *lruvec, return 0; } -static inline unsigned long -mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg, - int nid, unsigned int lru_mask) -{ - return 0; -} - static inline unsigned long mem_cgroup_get_max(struct mem_cgroup *memcg) { return 0; diff --git a/mm/memcontrol.c b/mm/memcontrol.c index e702b67cde41..ad6214b3d20b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -725,7 +725,7 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *memcg, __this_cpu_add(memcg->vmstats_percpu->nr_page_events, nr_pages); } -unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg, +static unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg, int nid, unsigned int lru_mask) { struct lruvec *lruvec = mem_cgroup_lruvec(NODE_DATA(nid), memcg); @@ -1430,11 +1430,15 @@ static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, static bool test_mem_cgroup_node_reclaimable(struct mem_cgroup *memcg, int nid, bool noswap) { - if (mem_cgroup_node_nr_lru_pages(memcg, nid, LRU_ALL_FILE)) + struct lruvec *lruvec = mem_cgroup_lruvec(NODE_DATA(nid), memcg); + + if (lruvec_page_state(lruvec, NR_INACTIVE_FILE) || + lruvec_page_state(lruvec, NR_ACTIVE_FILE)) return true; if (noswap || !total_swap_pages) return false; - if (mem_cgroup_node_nr_lru_pages(memcg, nid, LRU_ALL_ANON)) + if (lruvec_page_state(lruvec, NR_INACTIVE_ANON) || + lruvec_page_state(lruvec, NR_ACTIVE_ANON)) return true; return false; diff --git a/mm/workingset.c b/mm/workingset.c index dcb994f2acc2..dbc333a21254 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -427,10 +427,11 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker, #ifdef CONFIG_MEMCG if (sc->memcg) { struct lruvec *lruvec; + int i; - pages = mem_cgroup_node_nr_lru_pages(sc->memcg, sc->nid, - LRU_ALL); lruvec = mem_cgroup_lruvec(NODE_DATA(sc->nid), sc->memcg); + for (pages = 0, i = 0; i < NR_LRU_LISTS; i++) + pages += lruvec_page_state(lruvec, NR_LRU_BASE + i); pages += lruvec_page_state(lruvec, NR_SLAB_RECLAIMABLE); pages += lruvec_page_state(lruvec, NR_SLAB_UNRECLAIMABLE); } else -- 2.20.1