Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2175363pxb; Fri, 5 Feb 2021 10:42:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJyh11AzdtFnxZBD+7Y2+9KSeFF5NGjIuxayxhim+QzuKpZm169CIfpwW0xzRSCS8C8hKQcg X-Received: by 2002:aa7:d60f:: with SMTP id c15mr4938480edr.291.1612550554910; Fri, 05 Feb 2021 10:42:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612550554; cv=none; d=google.com; s=arc-20160816; b=f39DqZhSyIm29gfC6xitrpVB5peXQRHliu6qulrue4c2g6hDVlOzTS3FimfzW1Wg5U Q5AvcInDFWbkDhgov4uhPxOlc8jMeayYPT+0SXQunjhrC0QmhPnfo+pvE/1kz57fDQkG cT4wCrhtRnv6UOn8k4eyVqzQSmhazEaqBaKe7ZARzB92aAZ2kLDvf2T0AlRiz6Ly2tFm RNgAMOQRBl5mkx+wv2DKIq+JMbJcQpgJ++Jiv4dsjw1Vt7XUR5Yni6ay1O6nZjxixsVr E3vA0NumKlq7vQEUveKtyKPki0R0Jc1rp9Fe1rfTLlZpDSt9xUleL/uDSMvGcP+p4n+v QRbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cyRE6cACCpenz5S22wUDNGiEebDEXlsVuxUU66sedEg=; b=UNDuptZplJ6MX0kzwhiy1N12/0sQueR2nwLVu7ab7Suv44+lIYozp4KVVCKXjJdTxU Tz8id1OJLv+6lo/KKinAYLD1OAfimGISHNbbVGwUXYvsVAOFnAHsdtVtHQTyJTzWZhSJ a68pc/xT3PW4qViIEXKonV3Ubc2H+dbkhB5BjnqsKLBxC2WjDFyd+DJhMp/WDZ9NvhJ2 zgJqlFwzw5X00RQVGaoSsjdbgUyOOlhvMhXcOWhzGwS8L4xGpAoe+93Ix0CubQG6pZ4+ uGjXUKpybBgPXY/OX76I5CanS8V253oPwIvNvu982gF8hja4bg+8trvKLm2IpbK8FcLB CXrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=icEoG5fv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id n8si6059161eji.230.2021.02.05.10.42.09; Fri, 05 Feb 2021 10:42:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=icEoG5fv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S233403AbhBEQ55 (ORCPT + 99 others); Fri, 5 Feb 2021 11:57:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233708AbhBEQru (ORCPT ); Fri, 5 Feb 2021 11:47:50 -0500 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7318BC061222 for ; Fri, 5 Feb 2021 10:28:30 -0800 (PST) Received: by mail-qk1-x72f.google.com with SMTP id n15so7849141qkh.8 for ; Fri, 05 Feb 2021 10:28:30 -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=cyRE6cACCpenz5S22wUDNGiEebDEXlsVuxUU66sedEg=; b=icEoG5fvED4gxDkodWySfEiJNdvHYTrXwyvRJR/NMlNgXGomJfFsLQ0X1Z7EzQefwS rfW+aNcKIIETp0qQ7BgaL+bHxz9JDwG8D0DQ7OfBTQMxsMX1PKR5GEDlskiULC37oHzk snxN/HmpVBXYD1Azekn8O3eQqv9R8NTKfz3zGLkjSAnFLNp0F5ChuS6QLvZs+NwzrOXa MTt6ZuHZmnFc/5tqEtOoAJV4yDeMqaNNC3TDVMuNTyayv8+BojubGAjU9FECgFSvq0Rv itLqqfmn0+w1v9I4LLhobur8A2NlT6lqld3Lz3oem56U7oDrlQVEEyGhxQWCkJGnDPAB gMwQ== 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=cyRE6cACCpenz5S22wUDNGiEebDEXlsVuxUU66sedEg=; b=G6xp58m/pZNd7gsn3yQ+s7POmfYxESKRaP95kjxFgiysZRqwR/ddWJMF4aoPwpPwL5 Cce6aZit2pW4RKEntxIsSjbfzXWUt4wFP5e9AOa83HtsSZlnUVh1qHYo7zQr+OTb5KKe Iljdk+rh56u6WIXbffTUbrgHxmVpfDYHZiN8hpYn/oHRjrgnU4XEkq2jLPvA9PC0QhM2 /MjKtLimtSC262dsJT4lnIUvDPB5XMao59kghTq3aSGnpL/5w/o3lUP6Bd/fO1KGT0NI GCEYIZpBDuShxafu1hK44BZgH2RTQxiy1ISI+WAu5DTqgJ7+Gyz2xWOKmM5daY4OlK2M vEog== X-Gm-Message-State: AOAM531fQgAz4W7PUghBgMVJJbc+qGSlxqJgj7O6kvegIcJTMlDVt1Az Ltd5LKr9zD4gZJE7RHHYt84PMLuc27fSLg== X-Received: by 2002:a05:620a:2226:: with SMTP id n6mr5435497qkh.193.1612549709755; Fri, 05 Feb 2021 10:28:29 -0800 (PST) Received: from localhost (70.44.39.90.res-cmts.bus.ptd.net. [70.44.39.90]) by smtp.gmail.com with ESMTPSA id 2sm9983861qkf.97.2021.02.05.10.28.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 10:28:29 -0800 (PST) From: Johannes Weiner To: Andrew Morton , Tejun Heo Cc: Michal Hocko , Roman Gushchin , Shakeel Butt , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 3/8] mm: memcontrol: privatize memcg_page_state query functions Date: Fri, 5 Feb 2021 13:28:01 -0500 Message-Id: <20210205182806.17220-4-hannes@cmpxchg.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210205182806.17220-1-hannes@cmpxchg.org> References: <20210205182806.17220-1-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are no users outside of the memory controller itself. The rest of the kernel cares either about node or lruvec stats. Signed-off-by: Johannes Weiner Reviewed-by: Shakeel Butt Reviewed-by: Roman Gushchin Acked-by: Michal Hocko --- include/linux/memcontrol.h | 44 -------------------------------------- mm/memcontrol.c | 32 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 44 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index c7f387a6233e..20ecdfae3289 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -867,39 +867,6 @@ struct mem_cgroup *lock_page_memcg(struct page *page); void __unlock_page_memcg(struct mem_cgroup *memcg); void unlock_page_memcg(struct page *page); -/* - * idx can be of type enum memcg_stat_item or node_stat_item. - * Keep in sync with memcg_exact_page_state(). - */ -static inline unsigned long memcg_page_state(struct mem_cgroup *memcg, int idx) -{ - long x = atomic_long_read(&memcg->vmstats[idx]); -#ifdef CONFIG_SMP - if (x < 0) - x = 0; -#endif - return x; -} - -/* - * idx can be of type enum memcg_stat_item or node_stat_item. - * Keep in sync with memcg_exact_page_state(). - */ -static inline unsigned long memcg_page_state_local(struct mem_cgroup *memcg, - int idx) -{ - long x = 0; - int cpu; - - for_each_possible_cpu(cpu) - x += per_cpu(memcg->vmstats_local->stat[idx], cpu); -#ifdef CONFIG_SMP - if (x < 0) - x = 0; -#endif - return x; -} - void __mod_memcg_state(struct mem_cgroup *memcg, int idx, int val); /* idx can be of type enum memcg_stat_item or node_stat_item */ @@ -1337,17 +1304,6 @@ static inline void mem_cgroup_print_oom_group(struct mem_cgroup *memcg) { } -static inline unsigned long memcg_page_state(struct mem_cgroup *memcg, int idx) -{ - return 0; -} - -static inline unsigned long memcg_page_state_local(struct mem_cgroup *memcg, - int idx) -{ - return 0; -} - static inline void __mod_memcg_state(struct mem_cgroup *memcg, int idx, int nr) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 7e05a4ebf80f..2f97cb4cef6d 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -789,6 +789,38 @@ void __mod_memcg_state(struct mem_cgroup *memcg, int idx, int val) __this_cpu_write(memcg->vmstats_percpu->stat[idx], x); } +/* + * idx can be of type enum memcg_stat_item or node_stat_item. + * Keep in sync with memcg_exact_page_state(). + */ +static unsigned long memcg_page_state(struct mem_cgroup *memcg, int idx) +{ + long x = atomic_long_read(&memcg->vmstats[idx]); +#ifdef CONFIG_SMP + if (x < 0) + x = 0; +#endif + return x; +} + +/* + * idx can be of type enum memcg_stat_item or node_stat_item. + * Keep in sync with memcg_exact_page_state(). + */ +static unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx) +{ + long x = 0; + int cpu; + + for_each_possible_cpu(cpu) + x += per_cpu(memcg->vmstats_local->stat[idx], cpu); +#ifdef CONFIG_SMP + if (x < 0) + x = 0; +#endif + return x; +} + static struct mem_cgroup_per_node * parent_nodeinfo(struct mem_cgroup_per_node *pn, int nid) { -- 2.30.0