diff mbox series

mm: Make mem_cgroup_id_get_many dependent on MMU and MEMCG_SWAP

Message ID 20200304142348.48167-1-vincenzo.frascino@arm.com (mailing list archive)
State New, archived
Headers show
Series mm: Make mem_cgroup_id_get_many dependent on MMU and MEMCG_SWAP | expand

Commit Message

Vincenzo Frascino March 4, 2020, 2:23 p.m. UTC
mem_cgroup_id_get_many() is currently used only when MMU or MEMCG_SWAP
configuration options are enabled. Having them disabled triggers the
following warning at compile time:

linux/mm/memcontrol.c:4797:13: warning: ‘mem_cgroup_id_get_many’ defined
but not used [-Wunused-function]
 static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned
 int n)

Make mem_cgroup_id_get_many() dependent on MMU and MEMCG_SWAP to address
the issue.

Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 mm/memcontrol.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Michal Hocko March 4, 2020, 4:53 p.m. UTC | #1
On Wed 04-03-20 14:23:48, Vincenzo Frascino wrote:
> mem_cgroup_id_get_many() is currently used only when MMU or MEMCG_SWAP
> configuration options are enabled. Having them disabled triggers the
> following warning at compile time:
> 
> linux/mm/memcontrol.c:4797:13: warning: ‘mem_cgroup_id_get_many’ defined
> but not used [-Wunused-function]
>  static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned
>  int n)
> 
> Make mem_cgroup_id_get_many() dependent on MMU and MEMCG_SWAP to address
> the issue.

A similar patch has been proposed recently
http://lkml.kernel.org/r/87fthjh2ib.wl-kuninori.morimoto.gx@renesas.com.
The conclusion was that the warning is not really worth adding code.

> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Michal Hocko <mhocko@kernel.org>
> Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
>  mm/memcontrol.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index d09776cd6e10..628cebeb4bdd 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -4794,10 +4794,12 @@ static void mem_cgroup_id_remove(struct mem_cgroup *memcg)
>  	}
>  }
>  
> +#if defined(CONFIG_MEMCG_SWAP) || defined(CONFIG_MMU)
>  static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n)
>  {
>  	refcount_add(n, &memcg->id.ref);
>  }
> +#endif
>  
>  static void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n)
>  {
> -- 
> 2.25.1
Vincenzo Frascino March 5, 2020, 9:49 a.m. UTC | #2
Hi Michal,

On 3/4/20 4:53 PM, Michal Hocko wrote:
> On Wed 04-03-20 14:23:48, Vincenzo Frascino wrote:
>> mem_cgroup_id_get_many() is currently used only when MMU or MEMCG_SWAP
>> configuration options are enabled. Having them disabled triggers the
>> following warning at compile time:
>>
>> linux/mm/memcontrol.c:4797:13: warning: ‘mem_cgroup_id_get_many’ defined
>> but not used [-Wunused-function]
>>  static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned
>>  int n)
>>
>> Make mem_cgroup_id_get_many() dependent on MMU and MEMCG_SWAP to address
>> the issue.
> 
> A similar patch has been proposed recently
> http://lkml.kernel.org/r/87fthjh2ib.wl-kuninori.morimoto.gx@renesas.com.
> The conclusion was that the warning is not really worth adding code.
> 

Thank you for pointing this out, I was not aware of it. I understand that you
are against "#ifdeffery" in this case, but isn't it the case of adding at least
__maybe_unused? This would prevent people from reporting it over and over again
and you to have to push them back :) Let me know what do you think, in case I am
happy to change my patch accordingly.

[...]
Michal Hocko March 5, 2020, 10 a.m. UTC | #3
On Thu 05-03-20 09:49:23, Vincenzo Frascino wrote:
> Hi Michal,
> 
> On 3/4/20 4:53 PM, Michal Hocko wrote:
> > On Wed 04-03-20 14:23:48, Vincenzo Frascino wrote:
> >> mem_cgroup_id_get_many() is currently used only when MMU or MEMCG_SWAP
> >> configuration options are enabled. Having them disabled triggers the
> >> following warning at compile time:
> >>
> >> linux/mm/memcontrol.c:4797:13: warning: ‘mem_cgroup_id_get_many’ defined
> >> but not used [-Wunused-function]
> >>  static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned
> >>  int n)
> >>
> >> Make mem_cgroup_id_get_many() dependent on MMU and MEMCG_SWAP to address
> >> the issue.
> > 
> > A similar patch has been proposed recently
> > http://lkml.kernel.org/r/87fthjh2ib.wl-kuninori.morimoto.gx@renesas.com.
> > The conclusion was that the warning is not really worth adding code.
> > 
> 
> Thank you for pointing this out, I was not aware of it. I understand that you
> are against "#ifdeffery" in this case, but isn't it the case of adding at least
> __maybe_unused? This would prevent people from reporting it over and over again
> and you to have to push them back :) Let me know what do you think, in case I am
> happy to change my patch accordingly.

We have discussed __maybe_unused in the email thread as well. I am not a
great fan of that as mentioed there.
Vincenzo Frascino March 5, 2020, 10:46 a.m. UTC | #4
Hi Michal,

On 3/5/20 10:00 AM, Michal Hocko wrote:
> On Thu 05-03-20 09:49:23, Vincenzo Frascino wrote:
>> Hi Michal,
>>
>> On 3/4/20 4:53 PM, Michal Hocko wrote:
>>> On Wed 04-03-20 14:23:48, Vincenzo Frascino wrote:
>>>> mem_cgroup_id_get_many() is currently used only when MMU or MEMCG_SWAP
>>>> configuration options are enabled. Having them disabled triggers the
>>>> following warning at compile time:
>>>>
>>>> linux/mm/memcontrol.c:4797:13: warning: ‘mem_cgroup_id_get_many’ defined
>>>> but not used [-Wunused-function]
>>>>  static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned
>>>>  int n)
>>>>
>>>> Make mem_cgroup_id_get_many() dependent on MMU and MEMCG_SWAP to address
>>>> the issue.
>>>
>>> A similar patch has been proposed recently
>>> http://lkml.kernel.org/r/87fthjh2ib.wl-kuninori.morimoto.gx@renesas.com.
>>> The conclusion was that the warning is not really worth adding code.
>>>
>>
>> Thank you for pointing this out, I was not aware of it. I understand that you
>> are against "#ifdeffery" in this case, but isn't it the case of adding at least
>> __maybe_unused? This would prevent people from reporting it over and over again
>> and you to have to push them back :) Let me know what do you think, in case I am
>> happy to change my patch accordingly.
> 
> We have discussed __maybe_unused in the email thread as well. I am not a
> great fan of that as mentioed there.
> 

I am aware of this. I was just exploring if there was a possibility of
addressing the warning, since if we leave all the warnings in scenarios like
randconfig can cause confusion in between real and non real issues.
Is there anything we can do?
Michal Hocko March 5, 2020, 2:18 p.m. UTC | #5
On Thu 05-03-20 10:46:21, Vincenzo Frascino wrote:
[...]
> I am aware of this. I was just exploring if there was a possibility of
> addressing the warning, since if we leave all the warnings in scenarios like
> randconfig can cause confusion in between real and non real issues.

I would very much like to address _real_ warnings. This one is just
bugus. I do not see a fix that would be sensible. Wrapping the helper
by ifdefs is just going to make the resulting code worse because there
is nothing really specific to swap there. Marking it __maybe_unused will
just paper over the report and allow the function to bitrot when it is
not used anymore.

So for now I would just live with the warning unless it is really
causing any real problems.
Johannes Weiner March 5, 2020, 4:09 p.m. UTC | #6
On Thu, Mar 05, 2020 at 09:49:23AM +0000, Vincenzo Frascino wrote:
> Hi Michal,
> 
> On 3/4/20 4:53 PM, Michal Hocko wrote:
> > On Wed 04-03-20 14:23:48, Vincenzo Frascino wrote:
> >> mem_cgroup_id_get_many() is currently used only when MMU or MEMCG_SWAP
> >> configuration options are enabled. Having them disabled triggers the
> >> following warning at compile time:
> >>
> >> linux/mm/memcontrol.c:4797:13: warning: ‘mem_cgroup_id_get_many’ defined
> >> but not used [-Wunused-function]
> >>  static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned
> >>  int n)
> >>
> >> Make mem_cgroup_id_get_many() dependent on MMU and MEMCG_SWAP to address
> >> the issue.
> > 
> > A similar patch has been proposed recently
> > http://lkml.kernel.org/r/87fthjh2ib.wl-kuninori.morimoto.gx@renesas.com.
> > The conclusion was that the warning is not really worth adding code.
> > 
> 
> Thank you for pointing this out, I was not aware of it. I understand that you
> are against "#ifdeffery" in this case, but isn't it the case of adding at least
> __maybe_unused? This would prevent people from reporting it over and over again
> and you to have to push them back :) Let me know what do you think, in case I am
> happy to change my patch accordingly.

I would ack a patch that adds __maybe_unused.

This is a tiny function. If we keep it around a few releases after
removing the last user, it costs us absolutely nothing. Eventually
somebody will notice and send a patch to remove it. No big deal.

There is, however, real cost in keeping bogus warnings around and
telling people to ignore them. It's actively lowering the
signal-to-noise ratio and normalizing warnings to developers. That's
the kind of thing that will actually hide problems in the kernel.

We know that the function can be unused in certain scenarios. It's
silly to let the compiler continue to warn about it. That's exactly
what __maybe_unused is for, so let's use it here.
Vincenzo Frascino March 5, 2020, 4:21 p.m. UTC | #7
Hi Johannes,

On 3/5/20 4:09 PM, Johannes Weiner wrote:
> On Thu, Mar 05, 2020 at 09:49:23AM +0000, Vincenzo Frascino wrote:
>> Hi Michal,
>>
>> On 3/4/20 4:53 PM, Michal Hocko wrote:
>>> On Wed 04-03-20 14:23:48, Vincenzo Frascino wrote:
>>>> mem_cgroup_id_get_many() is currently used only when MMU or MEMCG_SWAP
>>>> configuration options are enabled. Having them disabled triggers the
>>>> following warning at compile time:
>>>>
>>>> linux/mm/memcontrol.c:4797:13: warning: ‘mem_cgroup_id_get_many’ defined
>>>> but not used [-Wunused-function]
>>>>  static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned
>>>>  int n)
>>>>
>>>> Make mem_cgroup_id_get_many() dependent on MMU and MEMCG_SWAP to address
>>>> the issue.
>>>
>>> A similar patch has been proposed recently
>>> http://lkml.kernel.org/r/87fthjh2ib.wl-kuninori.morimoto.gx@renesas.com.
>>> The conclusion was that the warning is not really worth adding code.
>>>
>>
>> Thank you for pointing this out, I was not aware of it. I understand that you
>> are against "#ifdeffery" in this case, but isn't it the case of adding at least
>> __maybe_unused? This would prevent people from reporting it over and over again
>> and you to have to push them back :) Let me know what do you think, in case I am
>> happy to change my patch accordingly.
> 
> I would ack a patch that adds __maybe_unused.
> 
> This is a tiny function. If we keep it around a few releases after
> removing the last user, it costs us absolutely nothing. Eventually
> somebody will notice and send a patch to remove it. No big deal.
> 
> There is, however, real cost in keeping bogus warnings around and
> telling people to ignore them. It's actively lowering the
> signal-to-noise ratio and normalizing warnings to developers. That's
> the kind of thing that will actually hide problems in the kernel.
> 
> We know that the function can be unused in certain scenarios. It's
> silly to let the compiler continue to warn about it. That's exactly
> what __maybe_unused is for, so let's use it here.
> 

I agree with what you are saying. I am going to change my patch accordingly.

Thank you.
Chris Down March 5, 2020, 6:34 p.m. UTC | #8
Johannes Weiner writes:
>I would ack a patch that adds __maybe_unused.
>
>This is a tiny function. If we keep it around a few releases after
>removing the last user, it costs us absolutely nothing. Eventually
>somebody will notice and send a patch to remove it. No big deal.
>
>There is, however, real cost in keeping bogus warnings around and
>telling people to ignore them. It's actively lowering the
>signal-to-noise ratio and normalizing warnings to developers. That's
>the kind of thing that will actually hide problems in the kernel.
>
>We know that the function can be unused in certain scenarios. It's
>silly to let the compiler continue to warn about it. That's exactly
>what __maybe_unused is for, so let's use it here.

Yeah, this is exactly what I was trying to express in the first one[0]. The 
fact that this patch came around a second time, as expected, just solidifies my 
concern around the waste to human time.

I would also ack a patch that adds __maybe_unused.

0: https://lore.kernel.org/linux-mm/20191217143720.GB131030@chrisdown.name/
diff mbox series

Patch

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d09776cd6e10..628cebeb4bdd 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4794,10 +4794,12 @@  static void mem_cgroup_id_remove(struct mem_cgroup *memcg)
 	}
 }
 
+#if defined(CONFIG_MEMCG_SWAP) || defined(CONFIG_MMU)
 static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n)
 {
 	refcount_add(n, &memcg->id.ref);
 }
+#endif
 
 static void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n)
 {