mm/percpu: mark pcpu_chunk_type() as __maybe_unused
diff mbox series

Message ID 20200714134101.80534-1-cuibixuan@huawei.com
State New
Headers show
Series
  • mm/percpu: mark pcpu_chunk_type() as __maybe_unused
Related show

Commit Message

Bixuan Cui July 14, 2020, 1:41 p.m. UTC
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.

Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
---
 mm/percpu-internal.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--
2.17.1

Comments

Stephen Rothwell July 14, 2020, 12:53 p.m. UTC | #1
Hi Bixuan,

On Tue, 14 Jul 2020 13:41:01 +0000 Bixuan Cui <cuibixuan@huawei.com> 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".
Bixuan Cui July 14, 2020, 1:33 p.m. UTC | #2
On 2020/7/14 20:53, Stephen Rothwell wrote:
> Hi Bixuan,
> 
> On Tue, 14 Jul 2020 13:41:01 +0000 Bixuan Cui <cuibixuan@huawei.com> 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".
Thinks,i will fix it.

Patch
diff mbox series

diff --git a/mm/percpu-internal.h b/mm/percpu-internal.h
index 7983455842ff..8a8a230bd957 100644
--- a/mm/percpu-internal.h
+++ b/mm/percpu-internal.h
@@ -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;
 }