Skip to contentSkip to conversation

mm/percpu: mark pcpu_chunk_type() as __maybe_unused

PATCH In review Bixuan Cui 3 participants 12 messages Jul 14, 2020 – Jul 15, 2020

Subsystems (3)
lore
Share & tools
lore

Bixuan Cui

author
#0 lore raw

PATCH 1/1 mm/percpu: mark pcpu_chunk_type() as __maybe_unused

Gcc report the following warning without CONFIG_MEMCG_KMEM:

mm/percpu-internal.h:145:29: warning: ‘pcpu_chunk_type’ defined but not used [-Wunused-function]
static enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)

                             ^~~~~~~~~~~~~~~

Mark pcpu_chunk_type() as __maybe_unused to make it clear.

---
 mm/percpu-internal.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/percpu-internal.h +2 -2
index 7983455842ff..8a8a230bd957 100644
@@ -129,7 +129,7 @@ static inline int pcpu_chunk_map_bits(struct pcpu_chunk *chunk)
 }
 
 #ifdef CONFIG_MEMCG_KMEM
-static enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)
+static enum pcpu_chunk_type __maybe_unused pcpu_chunk_type(struct pcpu_chunk *chunk)
 {
 	if (chunk->obj_cgroups)
 		return PCPU_CHUNK_MEMCG;
@@ -142,7 +142,7 @@ static bool pcpu_is_memcg_chunk(enum pcpu_chunk_type chunk_type)
 }
 
 #else
-static enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)
+static enum pcpu_chunk_type __maybe_unused pcpu_chunk_type(struct pcpu_chunk *chunk)
 {
 	return PCPU_CHUNK_ROOT;
 }

--
2.17.1

#1 lore raw

Hi Bixuan,

Quoted 9 lines · On Tue, 14 Jul 2020 13:41:01 +0000 Bixuan Cui <[email protected]> wrote:

Gcc report the following warning without CONFIG_MEMCG_KMEM:

mm/percpu-internal.h:145:29: warning: ‘pcpu_chunk_type’ defined but not used [-Wunused-function]
static enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)

                             ^~~~~~~~~~~~~~~

Mark pcpu_chunk_type() as __maybe_unused to make it clear.

Given that it is in a header file, it should probably just be "static inline" (which will also suppress the warning). As should pcpu_is_memcg_chunk() and pcpu_chunk_list(). Also, without them being inline, there will be a new copy for each file that mm/percpu-internal.h is included in.

And that should be considered a fix for "mm: memcg/percpu: account percpu memory to memory cgroups".

Signature · 2 lines
Cheers,
Stephen Rothwell
author
#2 lore raw
Quoted 11 lines · Stephen Rothwell

Hi Bixuan,

Quoted 8 lines · On Tue, 14 Jul 2020 13:41:01 +0000 Bixuan Cui <[email protected]> wrote:

Gcc report the following warning without CONFIG_MEMCG_KMEM:

mm/percpu-internal.h:145:29: warning: ‘pcpu_chunk_type’ defined but not used [-Wunused-function]
static enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)

                             ^~~~~~~~~~~~~~~

Mark pcpu_chunk_type() as __maybe_unused to make it clear.

Quoted 8 lines

Given that it is in a header file, it should probably just be "static inline" (which will also suppress the warning). As should pcpu_is_memcg_chunk() and pcpu_chunk_list(). Also, without them being inline, there will be a new copy for each file that mm/percpu-internal.h is included in.

And that should be considered a fix for "mm: memcg/percpu: account percpu memory to memory cgroups".

Thinks,i will fix it.

author
#3 lore raw

PATCH v2 1/1 mm/percpu: fix 'defined but not used' warning

In reply to Stephen Rothwell

Gcc report the following warning without CONFIG_MEMCG_KMEM:

mm/percpu-internal.h:145:29: warning: ‘pcpu_chunk_type’ defined but not used [-Wunused-function]
static enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)

                             ^~~~~~~~~~~~~~~

Add 'inline' to pcpu_chunk_type(),pcpu_is_memcg_chunk() and pcpu_chunk_list() to clear warning.

Fixes 26c99879ef01 ("mm: memcg/percpu: account percpu memory to memory cgroups")
---
 mm/percpu-internal.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
mm/percpu-internal.h +5 -5
index 7983455842ff..18b768ac7dca 100644
@@ -129,31 +129,31 @@ static inline int pcpu_chunk_map_bits(struct pcpu_chunk *chunk)
 }
 
 #ifdef CONFIG_MEMCG_KMEM
-static enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)
+static inline enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)
 {
 	if (chunk->obj_cgroups)
 		return PCPU_CHUNK_MEMCG;
 	return PCPU_CHUNK_ROOT;
 }
 
-static bool pcpu_is_memcg_chunk(enum pcpu_chunk_type chunk_type)
+static inline bool pcpu_is_memcg_chunk(enum pcpu_chunk_type chunk_type)
 {
 	return chunk_type == PCPU_CHUNK_MEMCG;
 }
 
 #else
-static enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)
+static inline enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)
 {
 	return PCPU_CHUNK_ROOT;
 }
 
-static bool pcpu_is_memcg_chunk(enum pcpu_chunk_type chunk_type)
+static inline bool pcpu_is_memcg_chunk(enum pcpu_chunk_type chunk_type)
 {
 	return false;
 }
 #endif
 
-static struct list_head *pcpu_chunk_list(enum pcpu_chunk_type chunk_type)
+static inline struct list_head *pcpu_chunk_list(enum pcpu_chunk_type chunk_type)
 {
 	return &pcpu_chunk_lists[pcpu_nr_slots *
 				 pcpu_is_memcg_chunk(chunk_type)];
Signature · 4 lines
2.17.1


.
author
#4 lore raw

Re: [PATCH v2] mm/percpu: fix 'defined but not used' warning

Quoted 2 lines · Bixuan Cui

mm/percpu-internal.h:145:29: warning: ‘pcpu_chunk_type’ defined but not used [-Wunused-function]

Please ignore this email, I will resend the v2 patch.

author
#5 lore raw

PATCH v2 1/1 mm/percpu: fix 'defined but not used' warning

In reply to Stephen Rothwell

Gcc report the following warning without CONFIG_MEMCG_KMEM:

mm/percpu-internal.h:145:29: warning: 'pcpu_chunk_type' defined but not used [-Wunused-function]
static enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)

                             ^~~~~~~~~~~~~~~

Add 'inline' to pcpu_chunk_type(),pcpu_is_memcg_chunk() and pcpu_chunk_list() to clear warning.

Fixes 26c99879ef01 ("mm: memcg/percpu: account percpu memory to memory cgroups")
---
 mm/percpu-internal.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
mm/percpu-internal.h +5 -5
index 7983455842ff..18b768ac7dca 100644
@@ -129,31 +129,31 @@ static inline int pcpu_chunk_map_bits(struct pcpu_chunk *chunk)
 }
 
 #ifdef CONFIG_MEMCG_KMEM
-static enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)
+static inline enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)
 {
 	if (chunk->obj_cgroups)
 		return PCPU_CHUNK_MEMCG;
 	return PCPU_CHUNK_ROOT;
 }
 
-static bool pcpu_is_memcg_chunk(enum pcpu_chunk_type chunk_type)
+static inline bool pcpu_is_memcg_chunk(enum pcpu_chunk_type chunk_type)
 {
 	return chunk_type == PCPU_CHUNK_MEMCG;
 }
 
 #else
-static enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)
+static inline enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)
 {
 	return PCPU_CHUNK_ROOT;
 }
 
-static bool pcpu_is_memcg_chunk(enum pcpu_chunk_type chunk_type)
+static inline bool pcpu_is_memcg_chunk(enum pcpu_chunk_type chunk_type)
 {
 	return false;
 }
 #endif
 
-static struct list_head *pcpu_chunk_list(enum pcpu_chunk_type chunk_type)
+static inline struct list_head *pcpu_chunk_list(enum pcpu_chunk_type chunk_type)
 {
 	return &pcpu_chunk_lists[pcpu_nr_slots *
 				 pcpu_is_memcg_chunk(chunk_type)];
Signature · 8 lines
2.17.1


.



.
Acked-by on v2 1/1
#6 lore raw

Re: [PATCH v2] mm/percpu: fix 'defined but not used' warning

Quoted 9 lines · Bixuan Cui

Gcc report the following warning without CONFIG_MEMCG_KMEM:

mm/percpu-internal.h:145:29: warning: 'pcpu_chunk_type' defined but not used [-Wunused-function]
static enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)

                             ^~~~~~~~~~~~~~~

Add 'inline' to pcpu_chunk_type(),pcpu_is_memcg_chunk() and pcpu_chunk_list() to clear warning.

Thank you!

Quoted 2 lines
Fixes 26c99879ef01 ("mm: memcg/percpu: account percpu memory to memory cgroups")

The "fixes" tag is not valid: the patch is in the mm queue, so it doesn't have a stable hash. Usually Andrew squashes such fixes into the original patch on merging.

Thanks!

author
#7 lore raw

Re: [PATCH v2] mm/percpu: fix 'defined but not used' warning

Quoted 4 lines · Roman Gushchin
Quoted 1 line
Fixes 26c99879ef01 ("mm: memcg/percpu: account percpu memory to memory cgroups")

The "fixes" tag is not valid: the patch is in the mm queue, so it doesn't have a stable hash. Usually Andrew squashes such fixes into the original patch on merging.

Thanks for your advice,delete it.

#8 lore raw

Re: [PATCH v2] mm/percpu: fix 'defined but not used' warning

In reply to Bixuan Cui

Hi Bixuan,

Thanks for this.

Quoted 6 lines · On Tue, 14 Jul 2020 21:46:18 +0800 Bixuan Cui <[email protected]> wrote:

Gcc report the following warning without CONFIG_MEMCG_KMEM:

mm/percpu-internal.h:145:29: warning: 'pcpu_chunk_type' defined but not used [-Wunused-function]
static enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)

Quoted 7 lines
                             ^~~~~~~~~~~~~~~

Add 'inline' to pcpu_chunk_type(),pcpu_is_memcg_chunk() and pcpu_chunk_list() to clear warning.

Fixes 26c99879ef01 ("mm: memcg/percpu: account percpu memory to memory cgroups")

You really should not add SUB lines for others - in this case a Suggested-by is more appropriate.

Signature · 2 lines
Cheers,
Stephen Rothwell
author
#9 lore raw

PATCH v3 1/1 mm/percpu: fix 'defined but not used' warning

Gcc report the following warning without CONFIG_MEMCG_KMEM:

mm/percpu-internal.h:145:29: warning: 'pcpu_chunk_type' defined but not used [-Wunused-function]
static enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)

                             ^~~~~~~~~~~~~~~

Add 'inline' to pcpu_chunk_type(),pcpu_is_memcg_chunk() and pcpu_chunk_list() to clear warning.

---
 mm/percpu-internal.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
mm/percpu-internal.h +5 -5
index 7983455842ff..18b768ac7dca 100644
@@ -129,31 +129,31 @@ static inline int pcpu_chunk_map_bits(struct pcpu_chunk *chunk)
 }
 
 #ifdef CONFIG_MEMCG_KMEM
-static enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)
+static inline enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)
 {
 	if (chunk->obj_cgroups)
 		return PCPU_CHUNK_MEMCG;
 	return PCPU_CHUNK_ROOT;
 }
 
-static bool pcpu_is_memcg_chunk(enum pcpu_chunk_type chunk_type)
+static inline bool pcpu_is_memcg_chunk(enum pcpu_chunk_type chunk_type)
 {
 	return chunk_type == PCPU_CHUNK_MEMCG;
 }
 
 #else
-static enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)
+static inline enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)
 {
 	return PCPU_CHUNK_ROOT;
 }
 
-static bool pcpu_is_memcg_chunk(enum pcpu_chunk_type chunk_type)
+static inline bool pcpu_is_memcg_chunk(enum pcpu_chunk_type chunk_type)
 {
 	return false;
 }
 #endif
 
-static struct list_head *pcpu_chunk_list(enum pcpu_chunk_type chunk_type)
+static inline struct list_head *pcpu_chunk_list(enum pcpu_chunk_type chunk_type)
 {
 	return &pcpu_chunk_lists[pcpu_nr_slots *
 				 pcpu_is_memcg_chunk(chunk_type)];
Signature · 4 lines
2.17.1


.
#10 lore raw

Re: [PATCH v3] mm/percpu: fix 'defined but not used' warning

Hi all,

Quoted 11 lines · On Wed, 15 Jul 2020 08:25:19 +0800 Bixuan Cui <[email protected]> wrote:

Gcc report the following warning without CONFIG_MEMCG_KMEM:

mm/percpu-internal.h:145:29: warning: 'pcpu_chunk_type' defined but not used [-Wunused-function]
static enum pcpu_chunk_type pcpu_chunk_type(struct pcpu_chunk *chunk)

                             ^~~~~~~~~~~~~~~

Add 'inline' to pcpu_chunk_type(),pcpu_is_memcg_chunk() and pcpu_chunk_list() to clear warning.

Quoted 6 lines
---
 mm/percpu-internal.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

I have added this patch to linux-next today.

Signature · 2 lines
Cheers,
Stephen Rothwell
author
#11 lore raw

Re: [PATCH v3] mm/percpu: fix 'defined but not used' warning

Quoted 1 line · Stephen Rothwell

I have added this patch to linux-next today.

thanks.