Skip to contentSkip to conversation

mm: memcontrol: fix an unused-function warning

PATCH In review Arnd Bergmann 3 participants 3 messages May 28, 2020 – May 29, 2020

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

PATCH 1/1 mm: memcontrol: fix an unused-function warning

On NOMMU kernels without CONFIG_MEMCG_KMEM, we now get a harmless warning about an unused function:

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

Hide this function in a matching #ifdef.

Fixes 5bd144bf764c ("mm: memcontrol: drop unused try/commit/cancel charge API")
---
 mm/memcontrol.c | 2 ++
 1 file changed, 2 insertions(+)
mm/memcontrol.c +2 -0
index f14da7a7348b..7bfca0abb8e1 100644
@@ -2592,6 +2592,7 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
 	return 0;
 }
 
+#if defined(CONFIG_MEMCG_KMEM) || defined(CONFIG_MMU)
 static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
 {
 	if (mem_cgroup_is_root(memcg))
@@ -2603,6 +2604,7 @@ static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
 
 	css_put_many(&memcg->css, nr_pages);
 }
+#endif
 
 static void commit_charge(struct page *page, struct mem_cgroup *memcg)
 {
Signature · 1 line
2.26.2
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Arnd Bergmann

On NOMMU kernels without CONFIG_MEMCG_KMEM, we now get a harmless warning about an unused function:

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

Hide this function in a matching #ifdef.

Fixes 5bd144bf764c ("mm: memcontrol: drop unused try/commit/cancel charge API")

Thanks Arnd!

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 8 lines · Arnd Bergmann

On NOMMU kernels without CONFIG_MEMCG_KMEM, we now get a harmless warning about an unused function:

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

Hide this function in a matching #ifdef.

Fixes 5bd144bf764c ("mm: memcontrol: drop unused try/commit/cancel charge API")

This is a linux-next sha1 which is not valid anymore. I would just drop the tag.

Quoted 1 line

Thanks!

Quoted 27 lines
---
 mm/memcontrol.c | 2 ++
 1 file changed, 2 insertions(+)
mm/memcontrol.c +2 -0
index f14da7a7348b..7bfca0abb8e1 100644
@@ -2592,6 +2592,7 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
 	return 0;
 }
 
+#if defined(CONFIG_MEMCG_KMEM) || defined(CONFIG_MMU)
 static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
 {
 	if (mem_cgroup_is_root(memcg))
@@ -2603,6 +2604,7 @@ static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
 
 	css_put_many(&memcg->css, nr_pages);
 }
+#endif
 
 static void commit_charge(struct page *page, struct mem_cgroup *memcg)
 {
Signature · 1 line
2.26.2
Signature · 2 lines
Michal Hocko
SUSE Labs