mm/percpu: mark pcpu_chunk_type() as __maybe_unused
Subsystems (3)
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
@@ -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
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 enumpcpu_chunk_typepcpu_chunk_type(struct pcpu_chunk *chunk)^~~~~~~~~~~~~~~Mark
pcpu_chunk_type()as__maybe_unusedto 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
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 enumpcpu_chunk_typepcpu_chunk_type(struct pcpu_chunk *chunk)^~~~~~~~~~~~~~~Mark
pcpu_chunk_type()as__maybe_unusedto 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()andpcpu_chunk_list(). Also, without them being inline, there will be a new copy for each file thatmm/percpu-internal.his included in.And that should be considered a fix for "mm: memcg/percpu: account percpu memory to memory cgroups".
Thinks,i will fix it.
PATCH v2 1/1 mm/percpu: fix 'defined but not used' warning
In reply to Stephen RothwellGcc 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
@@ -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 .
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.
PATCH v2 1/1 mm/percpu: fix 'defined but not used' warning
In reply to Stephen RothwellGcc 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
@@ -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 . .
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 enumpcpu_chunk_typepcpu_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!
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.
Re: [PATCH v2] mm/percpu: fix 'defined but not used' warning
In reply to Bixuan CuiHi 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 enumpcpu_chunk_typepcpu_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")Signed-off-by Stephen Rothwell <[email protected]>
You really should not add SUB lines for others - in this case a Suggested-by is more appropriate.
Signature · 2 lines
Cheers, Stephen Rothwell
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
@@ -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 .
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 enumpcpu_chunk_typepcpu_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
Acked-by Roman Gushchin <[email protected]>Suggested-by Stephen Rothwell <[email protected]>Signed-off-by Bixuan Cui <[email protected]>--- 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
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.