From patchwork Tue Feb 9 16:32:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 12078561 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA17FC433E6 for ; Tue, 9 Feb 2021 16:33:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7AA7E64EC0 for ; Tue, 9 Feb 2021 16:33:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7AA7E64EC0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 37DC66B0071; Tue, 9 Feb 2021 11:33:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B64C6B0072; Tue, 9 Feb 2021 11:33:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10A406B0073; Tue, 9 Feb 2021 11:33:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0030.hostedemail.com [216.40.44.30]) by kanga.kvack.org (Postfix) with ESMTP id EEAF36B0071 for ; Tue, 9 Feb 2021 11:33:32 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B7AD7A8EA for ; Tue, 9 Feb 2021 16:33:32 +0000 (UTC) X-FDA: 77799275064.22.test25_1f1402327608 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 92FDD1803AA73 for ; Tue, 9 Feb 2021 16:33:32 +0000 (UTC) X-HE-Tag: test25_1f1402327608 X-Filterd-Recvd-Size: 6448 Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Tue, 9 Feb 2021 16:33:32 +0000 (UTC) Received: by mail-qt1-f174.google.com with SMTP id h16so13339481qth.11 for ; Tue, 09 Feb 2021 08:33:31 -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=LY+6U9Z3Bwc6zBkQgpK/jIsA7sVel26r084cJiltqkhwUNRKsDMB/hhGgguafLwH+N IlhjXT+H7NFwh4RaXRTlhCYp2cXT7rNxiumFJD0yqf8KyLX6xrcjOI1MdKkUHvg51X23 g5rZLnxvajn67nj4Ku5XwKbauuTit6FHAtvCEiqUVAKyjlyrbNKcnUIS0FbQ3flnFEdM hIRtWUWTaxlpI4cRO9nS6hXGoNT2xcAGu1NmDpydJgXpK5KeXJFEvOgVUEuP+/1lSGMK GKL0TLsMYK9nQnK9yE0+f+Ou8bKpHGF5b9EepwSB0EwlxlR68I2QZrbwJU+JlqJ0+quq 95Qw== X-Gm-Message-State: AOAM530mNdYQn8W0dOIcMWMLuvsFBeZj1ApodOAbiTTkZ8Mn29BkC7E3 mJ2wuuKo2WDdMlOuKKLu9Sr28g== X-Google-Smtp-Source: ABdhPJxRXQumMAR1ctLKB+jTVaegvCZTuRwsfXwAurF9KHoCIWkzWWa88MdsYBcUeIpNop37kejzAw== 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Reviewed-by: Michal Koutný --- 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) {