From patchwork Fri Apr 19 23:39:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shakeel Butt X-Patchwork-Id: 13636794 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24CB1C04FF6 for ; Fri, 19 Apr 2024 23:40:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 787EB6B007B; Fri, 19 Apr 2024 19:40:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 737136B0082; Fri, 19 Apr 2024 19:40:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5FEC66B0083; Fri, 19 Apr 2024 19:40:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4242C6B007B for ; Fri, 19 Apr 2024 19:40:33 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id AE37A1215D4 for ; Fri, 19 Apr 2024 23:40:32 +0000 (UTC) X-FDA: 82027903104.15.4BDB5EC Received: from out-185.mta1.migadu.com (out-185.mta1.migadu.com [95.215.58.185]) by imf06.hostedemail.com (Postfix) with ESMTP id CEFB218000D for ; Fri, 19 Apr 2024 23:40:30 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=e9L+opHz; spf=pass (imf06.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.185 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713570031; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=VhNe9L9WlP0pwfASSTxQQWmISeuCRlC00Foy7ie5Qdo=; b=skXEbOsmGGACl0m96O8xG3CZfvJsCN+pVdv548fjT9EMwQ8qu0+XD5CYeL/QgWdVgdAPqQ ujlJ722OR7I75vauBdPvPNTyqbY5dRShyHYV+w6buA3kzAeQRbQnHfa5vb0OCPmWso6Ktz jlCeDYKNxzJwaZ1KdSqB42SFae34sNM= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=e9L+opHz; spf=pass (imf06.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.185 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713570031; a=rsa-sha256; cv=none; b=ciNbyCJYVORIlHCyE6fSk25lRXbdM/QrwgYT9n+RvAZO14d9dENvma2xMxFBfY/qBnWYSZ K8PQvYHZven8e7UbKGJ6dT34J+p4xRAQysgqT9glt1Pky0Q7OljRMJ5KN+xMmxYkLVSm34 C1+oISgChesF4XJ6ngnWMX+585wS/nc= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1713570028; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=VhNe9L9WlP0pwfASSTxQQWmISeuCRlC00Foy7ie5Qdo=; b=e9L+opHzddbLtsvhZLWzIM2X5TCbhvAWPeYigIFpLpXDCZRzSqdbfgAAaw0mM4ZcnzB6tF Aw5JS+6JDBgK7z23OLl5DwkQK5VspGZGvLbrlrcFDfUydkTARYT2qSt8eqX23c3gSZz09Y 8yS8Y1w7EhLW1yywzb9JN/i5akFe3UQ= From: Shakeel Butt To: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] memcg: simple cleanup of stats update functions Date: Fri, 19 Apr 2024 16:39:49 -0700 Message-ID: <20240419233949.2326100-1-shakeel.butt@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Stat-Signature: nnpw944uxiouq8zos39o7hydwu38nwss X-Rspamd-Queue-Id: CEFB218000D X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1713570030-738013 X-HE-Meta: U2FsdGVkX1/a/r4OtsKWK6lTqQK662ZJgexup3nlqvxni2RPMTkOKPR7Zf2vXeeZ8P0bWssAHDNF4UHKKGDB7HajjVHmyHTyo1c0k08ZKLx9xhRyAB1T5qpumXFX+sWVuf/wUHw/kfbhbx1IIQ5MsMbbRA+pd4YdAOPltc8xuzwyIGvF7KkfjmGVu1jkySOfhC7uKgTcpF5z9byuUseXykEske57KdTwOPltYEabDVYd72bQWowcUnfBChHATxNJiLSWo0QeBYm9MEZOUAjwshmaKy7qRnQ+uTrXqkDDGbbMc1HgFAsPJC/6La0YcgPi1gsOvpFg/m+q0UC/FN1kZfUn+03iFBmqp+5IeMFqJFCukQnZmIaqYKygVzxPGUewzgrEZS4ONsRR9aEHGWSFnq5Wm/ELif/pviAVt/yCb9pHA4Bk5rXDSyRePSBzMC4IMb5Pn+iyy+584u95FdEiymQ+GyR5PHZ+3Ra0qkblxLvC1ggtsQqDyExKq0F78eZUmx8NVfUyKJP/jT8pRMqBeGjh4Z71/opI/jDW1gK7d7tEnSy6NvJ9xn4ffEoP5xdS186xX2aM7mqHQRNi8sTNK5OkfHCOF5kwe2rtzC9o9VhzC/7UOjueqqRxrtx9YxbPsdbisRXXS/p/nfF6CxcRH2KcE0EUCOG6BoJVjRDM/n2XQrtE3YopiKpewX7xh1pmoZ5ItFw08y3pglaMVkqC6zvi78qb/vJMlFk8xv6cJn1O93+WBNhi3RnNd85pZ/AROCjO3mneOC5aXRZnwdEgntOrbovQmNJ+EqIAjqvA+lFUkNPYFsMXRICt5SxVidte+DGw4D8sQMYNelrMw3n8fm/Bwim4T5cAzq8h/ZdxI2f2zxJnwWgJGD4SWTLh1duTy074ZMIvgCWm0Ii6fc/UpvHhVr4XI7C9Ye4HcUV+E6KBUdf2ORCljlUncugW8Xdog4acrAVTc/1n96xo+cn KqBFmlCk EPtr7V3ROzhd5SHCpiMP0PInjsfe7M0o+TGTZWZIzQzmYA3uIH81maq4LHdMSKEL/OgaZ5sS0XPvqHHw= 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: List-Subscribe: List-Unsubscribe: mod_memcg_lruvec_state() is never called from outside of memcontrol.c and with always irq disabled. So, replace it with the irq disabled version and add an assert that irq is disabled in the caller. Similarly mod_objcg_state() is not called from outside of memcontrol.c, so simply make it static. Signed-off-by: Shakeel Butt Acked-by: Johannes Weiner --- include/linux/memcontrol.h | 17 ----------------- mm/memcontrol.c | 15 +++++++-------- mm/slab.h | 2 -- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 8f332b4ae84c..9aba0d0462ca 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1077,8 +1077,6 @@ static inline unsigned long lruvec_page_state_local(struct lruvec *lruvec, void mem_cgroup_flush_stats(struct mem_cgroup *memcg); void mem_cgroup_flush_stats_ratelimited(struct mem_cgroup *memcg); -void __mod_memcg_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx, - int val); void __mod_lruvec_kmem_state(void *p, enum node_stat_item idx, int val); static inline void mod_lruvec_kmem_state(void *p, enum node_stat_item idx, @@ -1091,16 +1089,6 @@ static inline void mod_lruvec_kmem_state(void *p, enum node_stat_item idx, local_irq_restore(flags); } -static inline void mod_memcg_lruvec_state(struct lruvec *lruvec, - enum node_stat_item idx, int val) -{ - unsigned long flags; - - local_irq_save(flags); - __mod_memcg_lruvec_state(lruvec, idx, val); - local_irq_restore(flags); -} - void __count_memcg_events(struct mem_cgroup *memcg, enum vm_event_item idx, unsigned long count); @@ -1594,11 +1582,6 @@ static inline void mem_cgroup_flush_stats_ratelimited(struct mem_cgroup *memcg) { } -static inline void __mod_memcg_lruvec_state(struct lruvec *lruvec, - enum node_stat_item idx, int val) -{ -} - static inline void __mod_lruvec_kmem_state(void *p, enum node_stat_item idx, int val) { diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 7703ced535a3..c6b08e6d7499 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -837,8 +837,9 @@ static unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx) return x; } -void __mod_memcg_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx, - int val) +static void __mod_memcg_lruvec_state(struct lruvec *lruvec, + enum node_stat_item idx, + int val) { struct mem_cgroup_per_node *pn; struct mem_cgroup *memcg; @@ -2983,10 +2984,6 @@ void mem_cgroup_commit_charge(struct folio *folio, struct mem_cgroup *memcg) #ifdef CONFIG_MEMCG_KMEM -/* - * mod_objcg_mlstate() may be called with irq enabled, so - * mod_memcg_lruvec_state() should be used. - */ static inline void mod_objcg_mlstate(struct obj_cgroup *objcg, struct pglist_data *pgdat, enum node_stat_item idx, int nr) @@ -2994,10 +2991,12 @@ static inline void mod_objcg_mlstate(struct obj_cgroup *objcg, struct mem_cgroup *memcg; struct lruvec *lruvec; + lockdep_assert_irqs_disabled(); + rcu_read_lock(); memcg = obj_cgroup_memcg(objcg); lruvec = mem_cgroup_lruvec(memcg, pgdat); - mod_memcg_lruvec_state(lruvec, idx, nr); + __mod_memcg_lruvec_state(lruvec, idx, nr); rcu_read_unlock(); } @@ -3317,7 +3316,7 @@ void __memcg_kmem_uncharge_page(struct page *page, int order) obj_cgroup_put(objcg); } -void mod_objcg_state(struct obj_cgroup *objcg, struct pglist_data *pgdat, +static void mod_objcg_state(struct obj_cgroup *objcg, struct pglist_data *pgdat, enum node_stat_item idx, int nr) { struct memcg_stock_pcp *stock; diff --git a/mm/slab.h b/mm/slab.h index e32d9cf1077a..5f8f47c5bee0 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -578,8 +578,6 @@ bool __memcg_slab_post_alloc_hook(struct kmem_cache *s, struct list_lru *lru, gfp_t flags, size_t size, void **p); void __memcg_slab_free_hook(struct kmem_cache *s, struct slab *slab, void **p, int objects, struct slabobj_ext *obj_exts); -void mod_objcg_state(struct obj_cgroup *objcg, struct pglist_data *pgdat, - enum node_stat_item idx, int nr); #endif size_t __ksize(const void *objp);