Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1106560pxb; Tue, 9 Feb 2021 23:31:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJyyu/j8/iWF+6+h+aJeNVwDZmP29EMF6VZIP4xCnCzLMSDuX5AB+ng7Wm5AKmp5xPuV5doI X-Received: by 2002:a17:906:8252:: with SMTP id f18mr1708212ejx.418.1612942301754; Tue, 09 Feb 2021 23:31:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612942301; cv=none; d=google.com; s=arc-20160816; b=It7uxsYZDkzbtAat39dVTt5Ta4gZWtgvnghE8TO2Y9r3E5KpI/NPcRL3VubnfvmUAI ZciRg+AMRzQVZLCfxqAs4RxQ8ndyRNNXwrMURdQpzUkBa/KKqWMNzZx3rgyy0vsnVqoe EYH/Zk8uQxjhpfMU5BlGOMBrtRUVXDnV+vxyp3dTGcDPDM+8tyNoK1h6rtEABfQj5+tx dUelWe326CC8iSLHGiFjoZp+yxbPrCbvy6Px9QJNsRKAdvDCi3Q87RvtSr936mIz5yNf 3hauiSzZcNMUlMvILpwiqOIYmJtz5GJtdlKM+pzPLaJvKcJYSKunelb7UBa4/IyKVlLE Ylag== 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=N6j0c7zFsF1t+u02shqxpbwtvLfmrLmBO38ZPrXs+YnpbJBOE3hY+da+4ZkJXTnWSq oJZ/Orl8CICTdcvbHktfpbvx68kjupxGaGDAV72wfWlyhpNCBIYw6DKj/GBAX2k2bHYz 62nfb4VIwR2+O4gapyq1ag4xOYmFcK+ekK2YBR6YgcnqqNQE1UGJruqY/fqwG0go2KLM C/yK8BIcX7ERkfzbGruCnPXcLfF3Hgy1c3ArSykyhke6LbkMtZE9HObsMqDmmWPXyuXM x4t3yLq3u5hZlnac1kIjrSDiPdrqJW2Q4M83BJfIRyRJj3+V7BtvmUHAIvPWJ9XqzFhD sUMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b="u/HDSEYp"; 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 v10si798618ejj.589.2021.02.09.23.31.18; Tue, 09 Feb 2021 23:31:41 -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="u/HDSEYp"; 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 S232692AbhBIQfs (ORCPT + 99 others); Tue, 9 Feb 2021 11:35:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232935AbhBIQfN (ORCPT ); Tue, 9 Feb 2021 11:35:13 -0500 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44C19C06178C for ; Tue, 9 Feb 2021 08:33:32 -0800 (PST) Received: by mail-qt1-x82a.google.com with SMTP id c5so4569568qth.2 for ; Tue, 09 Feb 2021 08:33:32 -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=u/HDSEYp99RhO8kqQIIVwaAns/CtmccQ9gChZtsKMsP0WJwv841qFHb0cD60Q1fWDw 4GCwEjU06NTqK4M7OtBfHWm7a7XidL/c7E5qvQynNhyS2gI/r0t0ePrvf2mHSGJAsuz7 mLn4QMKjqClvDuKnSV7hLFm7zyh3SrC8zrxhLdphwbQdNDKUD8WVPzgHw5JEGhGBsuIo Bf1KKn8yNDd01l4N1+6FLn0twzj4sbVI3Cc/py4066Q0MMnghnKnqlv9xjpoxstEuYBA 8/rM8j9Jb+ofG8V/fm0+LiysJI5wyCtSfbnO3ey11h6wn832ocT1rayRg9twROQXCoTK CrTw== 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=ntjaFyezYl9ENsld1/755GEy4CWmJ1OwvNHPw+eApJMmBKyD1nUhTp63+8yCL8a/02 5TuJwRnKC0uWvqwntQ9djXh918nAexC12ixMI+L62RUZ18NxEgzFI0clf1591f3+dYBN X5PGmurY6aEa63Xq5wbt7iB867fnydLaZMWaabAt/uhl37VVk0gnldjfsWoP/QXIy8l1 25pX/XD4YAGwg+AqkKsoni0Mp5qb5qc+Pj9DpjKQpnhz0mjXpQASmGaQ0AZ6QjOpraf3 HZGFui3/61FFK1Rqu8/cCs9+oDJ+8DmWOrzF6VjK7yCnjQWZzYRGmQXUsqz/0aHT4CVd 4huQ== X-Gm-Message-State: AOAM532s31p6lxd6m0HMV2Eq82lzcj4LiFEwD0m9wfqIphW0dMhRQKbK iivAc0zWYFmkgaexR6FfrJwmhw== X-Received: by 2002:ac8:5714:: with SMTP id 20mr20670731qtw.197.1612888411536; Tue, 09 Feb 2021 08:33:31 -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 o17sm18065496qtl.47.2021.02.09.08.33.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 08:33:30 -0800 (PST) From: Johannes Weiner To: Andrew Morton Cc: Tejun Heo , 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 v3 3/8] mm: memcontrol: privatize memcg_page_state query functions Date: Tue, 9 Feb 2021 11:32:59 -0500 Message-Id: <20210209163304.77088-4-hannes@cmpxchg.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210209163304.77088-1-hannes@cmpxchg.org> References: <20210209163304.77088-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