linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/memcontrol.c: fix another unused function warning
@ 2019-10-01 14:22 Arnd Bergmann
  2019-10-01 14:40 ` Qian Cai
  2019-10-01 16:36 ` Nick Desaulniers
  0 siblings, 2 replies; 7+ messages in thread
From: Arnd Bergmann @ 2019-10-01 14:22 UTC (permalink / raw)
  To: Johannes Weiner, Michal Hocko, Vladimir Davydov
  Cc: Arnd Bergmann, Qian Cai, Michal Hocko, Andrew Morton,
	Roman Gushchin, Shakeel Butt, Chris Down, Tejun Heo, cgroups,
	linux-mm, linux-kernel, clang-built-linux

Removing the mem_cgroup_id_get() stub function introduced a new warning
of the same kind when CONFIG_MMU is disabled:

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

Address this using a __maybe_unused annotation.

Note: alternatively, this could be moved into an #ifdef block.  Marking it
'static inline' would not work here as that would still produce the
warning on clang, which only ignores unused inline functions declared
in header files instead of .c files.

Fixes: 4d0e3230a56a ("mm/memcontrol.c: fix a -Wunused-function warning")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 mm/memcontrol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index c313c49074ca..5f9f90e3cef8 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4921,7 +4921,8 @@ static void mem_cgroup_id_remove(struct mem_cgroup *memcg)
 	}
 }
 
-static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n)
+static void __maybe_unused
+mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n)
 {
 	refcount_add(n, &memcg->id.ref);
 }
-- 
2.20.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm/memcontrol.c: fix another unused function warning
  2019-10-01 14:22 [PATCH] mm/memcontrol.c: fix another unused function warning Arnd Bergmann
@ 2019-10-01 14:40 ` Qian Cai
  2019-10-01 16:00   ` Arnd Bergmann
  2019-10-02  7:53   ` Michal Hocko
  2019-10-01 16:36 ` Nick Desaulniers
  1 sibling, 2 replies; 7+ messages in thread
From: Qian Cai @ 2019-10-01 14:40 UTC (permalink / raw)
  To: Arnd Bergmann, Johannes Weiner, Michal Hocko, Vladimir Davydov
  Cc: Michal Hocko, Andrew Morton, Roman Gushchin, Shakeel Butt,
	Chris Down, Tejun Heo, cgroups, linux-mm, linux-kernel,
	clang-built-linux

On Tue, 2019-10-01 at 16:22 +0200, Arnd Bergmann wrote:
> Removing the mem_cgroup_id_get() stub function introduced a new warning
> of the same kind when CONFIG_MMU is disabled:

Shouldn't CONFIG_MEMCG depends on CONFIG_MMU instead?

> 
> mm/memcontrol.c:4929:13: error: unused function 'mem_cgroup_id_get_many' [-Werror,-Wunused-function]
> 
> Address this using a __maybe_unused annotation.
> 
> Note: alternatively, this could be moved into an #ifdef block.  Marking it
> 'static inline' would not work here as that would still produce the
> warning on clang, which only ignores unused inline functions declared
> in header files instead of .c files.
> 
> Fixes: 4d0e3230a56a ("mm/memcontrol.c: fix a -Wunused-function warning")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  mm/memcontrol.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index c313c49074ca..5f9f90e3cef8 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -4921,7 +4921,8 @@ static void mem_cgroup_id_remove(struct mem_cgroup *memcg)
>  	}
>  }
>  
> -static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n)
> +static void __maybe_unused
> +mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n)
>  {
>  	refcount_add(n, &memcg->id.ref);
>  }


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm/memcontrol.c: fix another unused function warning
  2019-10-01 14:40 ` Qian Cai
@ 2019-10-01 16:00   ` Arnd Bergmann
  2019-10-01 16:44     ` Qian Cai
  2019-10-02  7:53   ` Michal Hocko
  1 sibling, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2019-10-01 16:00 UTC (permalink / raw)
  To: Qian Cai
  Cc: Johannes Weiner, Michal Hocko, Vladimir Davydov, Michal Hocko,
	Andrew Morton, Roman Gushchin, Shakeel Butt, Chris Down,
	Tejun Heo, cgroups, Linux-MM, linux-kernel, clang-built-linux

On Tue, Oct 1, 2019 at 4:40 PM Qian Cai <cai@lca.pw> wrote:
>
> On Tue, 2019-10-01 at 16:22 +0200, Arnd Bergmann wrote:
> > Removing the mem_cgroup_id_get() stub function introduced a new warning
> > of the same kind when CONFIG_MMU is disabled:
>
> Shouldn't CONFIG_MEMCG depends on CONFIG_MMU instead?

Maybe. Generally we allow building a lot of stuff without CONFIG_MMU that
may not make sense, so I just followed the same idea here.

      Arnd


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm/memcontrol.c: fix another unused function warning
  2019-10-01 14:22 [PATCH] mm/memcontrol.c: fix another unused function warning Arnd Bergmann
  2019-10-01 14:40 ` Qian Cai
@ 2019-10-01 16:36 ` Nick Desaulniers
  2019-10-02  7:54   ` Michal Hocko
  1 sibling, 1 reply; 7+ messages in thread
From: Nick Desaulniers @ 2019-10-01 16:36 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Johannes Weiner, Michal Hocko, Vladimir Davydov, Qian Cai,
	Michal Hocko, Andrew Morton, Roman Gushchin, Shakeel Butt,
	Chris Down, Tejun Heo, cgroups, Linux Memory Management List,
	LKML, clang-built-linux

On Tue, Oct 1, 2019 at 7:22 AM Arnd Bergmann <arnd@arndb.de> wrote:
>
> Removing the mem_cgroup_id_get() stub function introduced a new warning
> of the same kind when CONFIG_MMU is disabled:
>
> mm/memcontrol.c:4929:13: error: unused function 'mem_cgroup_id_get_many' [-Werror,-Wunused-function]
>
> Address this using a __maybe_unused annotation.
>
> Note: alternatively, this could be moved into an #ifdef block.  Marking it

Hi Arnd,
Thank you for the patch!  I would prefer to move the definition to the
correct set of #ifdef guards rather than __maybe_unused.  Maybe move
the definition of mem_cgroup_id_get_many() to just before
__mem_cgroup_clear_mc()?  I find __maybe_unused to be a code smell.

> 'static inline' would not work here as that would still produce the
> warning on clang, which only ignores unused inline functions declared
> in header files instead of .c files.
>
> Fixes: 4d0e3230a56a ("mm/memcontrol.c: fix a -Wunused-function warning")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  mm/memcontrol.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index c313c49074ca..5f9f90e3cef8 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -4921,7 +4921,8 @@ static void mem_cgroup_id_remove(struct mem_cgroup *memcg)
>         }
>  }
>
> -static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n)
> +static void __maybe_unused
> +mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n)
>  {
>         refcount_add(n, &memcg->id.ref);
>  }
> --

-- 
Thanks,
~Nick Desaulniers


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm/memcontrol.c: fix another unused function warning
  2019-10-01 16:00   ` Arnd Bergmann
@ 2019-10-01 16:44     ` Qian Cai
  0 siblings, 0 replies; 7+ messages in thread
From: Qian Cai @ 2019-10-01 16:44 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Johannes Weiner, Michal Hocko, Vladimir Davydov, Michal Hocko,
	Andrew Morton, Roman Gushchin, Shakeel Butt, Chris Down,
	Tejun Heo, cgroups, Linux-MM, linux-kernel, clang-built-linux

On Tue, 2019-10-01 at 18:00 +0200, Arnd Bergmann wrote:
> On Tue, Oct 1, 2019 at 4:40 PM Qian Cai <cai@lca.pw> wrote:
> > 
> > On Tue, 2019-10-01 at 16:22 +0200, Arnd Bergmann wrote:
> > > Removing the mem_cgroup_id_get() stub function introduced a new warning
> > > of the same kind when CONFIG_MMU is disabled:
> > 
> > Shouldn't CONFIG_MEMCG depends on CONFIG_MMU instead?
> 
> Maybe. Generally we allow building a lot of stuff without CONFIG_MMU that
> may not make sense, so I just followed the same idea here.

Those blindly mark __maybe_unused might just mask important warnings off in the
future, and they are ugly. Let's fix it properly.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm/memcontrol.c: fix another unused function warning
  2019-10-01 14:40 ` Qian Cai
  2019-10-01 16:00   ` Arnd Bergmann
@ 2019-10-02  7:53   ` Michal Hocko
  1 sibling, 0 replies; 7+ messages in thread
From: Michal Hocko @ 2019-10-02  7:53 UTC (permalink / raw)
  To: Qian Cai
  Cc: Arnd Bergmann, Johannes Weiner, Vladimir Davydov, Andrew Morton,
	Roman Gushchin, Shakeel Butt, Chris Down, Tejun Heo, cgroups,
	linux-mm, linux-kernel, clang-built-linux

On Tue 01-10-19 10:40:05, Qian Cai wrote:
> On Tue, 2019-10-01 at 16:22 +0200, Arnd Bergmann wrote:
> > Removing the mem_cgroup_id_get() stub function introduced a new warning
> > of the same kind when CONFIG_MMU is disabled:
> 
> Shouldn't CONFIG_MEMCG depends on CONFIG_MMU instead?

I wanted to do that in the past but there was a clear disagreement from
Johannes.
-- 
Michal Hocko
SUSE Labs


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm/memcontrol.c: fix another unused function warning
  2019-10-01 16:36 ` Nick Desaulniers
@ 2019-10-02  7:54   ` Michal Hocko
  0 siblings, 0 replies; 7+ messages in thread
From: Michal Hocko @ 2019-10-02  7:54 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Arnd Bergmann, Johannes Weiner, Vladimir Davydov, Qian Cai,
	Andrew Morton, Roman Gushchin, Shakeel Butt, Chris Down,
	Tejun Heo, cgroups, Linux Memory Management List, LKML,
	clang-built-linux

On Tue 01-10-19 09:36:24, Nick Desaulniers wrote:
> On Tue, Oct 1, 2019 at 7:22 AM Arnd Bergmann <arnd@arndb.de> wrote:
> >
> > Removing the mem_cgroup_id_get() stub function introduced a new warning
> > of the same kind when CONFIG_MMU is disabled:
> >
> > mm/memcontrol.c:4929:13: error: unused function 'mem_cgroup_id_get_many' [-Werror,-Wunused-function]
> >
> > Address this using a __maybe_unused annotation.
> >
> > Note: alternatively, this could be moved into an #ifdef block.  Marking it
> 
> Hi Arnd,
> Thank you for the patch!  I would prefer to move the definition to the
> correct set of #ifdef guards rather than __maybe_unused.  Maybe move
> the definition of mem_cgroup_id_get_many() to just before
> __mem_cgroup_clear_mc()?  I find __maybe_unused to be a code smell.

Agreed!
-- 
Michal Hocko
SUSE Labs


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-10-02  7:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-01 14:22 [PATCH] mm/memcontrol.c: fix another unused function warning Arnd Bergmann
2019-10-01 14:40 ` Qian Cai
2019-10-01 16:00   ` Arnd Bergmann
2019-10-01 16:44     ` Qian Cai
2019-10-02  7:53   ` Michal Hocko
2019-10-01 16:36 ` Nick Desaulniers
2019-10-02  7:54   ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).