Skip to contentSkip to conversation

memcg, kmem: mark cancel_charge() inline

PATCH In review Arnd Bergmann 3 participants 3 messages Oct 22, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memcg, kmem: mark cancel_charge() inline

From: Arnd Bergmann <[email protected]>

cancel_charge() is no longer called for CONFIG_MEMCG_KMEM on NOMMU targets, which causes a compiletime warning:

mm/memcontrol.c:2774:13: error: unused function 'cancel_charge' [-Werror,-Wunused-function]

Remove the now-incorrect #ifdef and just mark the function 'inline' like the other related helpers. This is simpler and means we no longer have to match the #ifdef with the caller.

Fixes 5f3345c17079 ("memcg, kmem: further deprecate kmem.limit_in_bytes")

---
The 5f3345c17079 commit is in -mm, so the commit ID is not stable. Feel free to just fold this into the other patch, or take out that reference

---
 mm/memcontrol.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
mm/memcontrol.c +1 -3
index 6538595994d2..9edccfeac804 100644
@@ -2770,8 +2770,7 @@ static inline int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
 	return try_charge_memcg(memcg, gfp_mask, nr_pages);
 }
 
-#if defined(CONFIG_MEMCG_KMEM) || defined(CONFIG_MMU)
-static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
+static inline void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
 {
 	if (mem_cgroup_is_root(memcg))
 		return;
@@ -2780,7 +2779,6 @@ static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
 	if (do_memsw_account())
 		page_counter_uncharge(&memcg->memsw, nr_pages);
 }
-#endif
 
 static void commit_charge(struct folio *folio, struct mem_cgroup *memcg)
 {
Signature · 1 line
2.29.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

cancel_charge() is no longer called for CONFIG_MEMCG_KMEM on NOMMU targets, which causes a compiletime warning:

mm/memcontrol.c:2774:13: error: unused function 'cancel_charge' [-Werror,-Wunused-function]

Quoted 7 lines

Remove the now-incorrect #ifdef and just mark the function 'inline' like the other related helpers. This is simpler and means we no longer have to match the #ifdef with the caller.

Fixes 5f3345c17079 ("memcg, kmem: further deprecate kmem.limit_in_bytes")

Thanks. I guess this should be squashed into the commit 5f3345c17079 ("memcg, kmem: further deprecate kmem.limit_in_bytes").

Quoted 33 lines

---
The 5f3345c17079 commit is in -mm, so the commit ID is not stable. Feel free to just fold this into the other patch, or take out that reference

---
 mm/memcontrol.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
mm/memcontrol.c +1 -4
index 6538595994d2..9edccfeac804 100644
@@ -2770,8 +2770,7 @@ static inline int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
        return try_charge_memcg(memcg, gfp_mask, nr_pages);
 }
 
-#if defined(CONFIG_MEMCG_KMEM) || defined(CONFIG_MMU)
-static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
+static inline void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
 {
        if (mem_cgroup_is_root(memcg))
                return;
@@ -2780,7 +2779,6 @@ static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
        if (do_memsw_account())
                page_counter_uncharge(&memcg->memsw, nr_pages);
 }
-#endif
 
 static void commit_charge(struct folio *folio, struct mem_cgroup *memcg)
 {
--

2.29.2

#2 lore raw
In reply to Arnd Bergmann

Hi all,

Quoted 48 lines · On Fri, 22 Oct 2021 09:05:35 +0200 Arnd Bergmann <[email protected]> wrote:

From: Arnd Bergmann <[email protected]>

cancel_charge() is no longer called for CONFIG_MEMCG_KMEM on NOMMU targets, which causes a compiletime warning:

mm/memcontrol.c:2774:13: error: unused function 'cancel_charge' [-Werror,-Wunused-function]

Remove the now-incorrect #ifdef and just mark the function 'inline' like the other related helpers. This is simpler and means we no longer have to match the #ifdef with the caller.

Fixes 5f3345c17079 ("memcg, kmem: further deprecate kmem.limit_in_bytes")

---
The 5f3345c17079 commit is in -mm, so the commit ID is not stable. Feel free to just fold this into the other patch, or take out that reference

---
 mm/memcontrol.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
mm/memcontrol.c +1 -3
index 6538595994d2..9edccfeac804 100644
@@ -2770,8 +2770,7 @@ static inline int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
 	return try_charge_memcg(memcg, gfp_mask, nr_pages);
 }
 
-#if defined(CONFIG_MEMCG_KMEM) || defined(CONFIG_MMU)
-static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
+static inline void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
 {
 	if (mem_cgroup_is_root(memcg))
 		return;
@@ -2780,7 +2779,6 @@ static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
 	if (do_memsw_account())
 		page_counter_uncharge(&memcg->memsw, nr_pages);
 }
-#endif
 
 static void commit_charge(struct folio *folio, struct mem_cgroup *memcg)
 {
Signature · 1 line
2.29.2

Added to linux-next today.

Signature · 2 lines
Cheers,
Stephen Rothwell