2020-03-04 14:25:00

by Vincenzo Frascino

[permalink] [raw]
Subject: [PATCH] mm: Make mem_cgroup_id_get_many dependent on MMU and MEMCG_SWAP

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 <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Vladimir Davydov <[email protected]>
Cc: Andrew Morton <[email protected]>
Signed-off-by: Vincenzo Frascino <[email protected]>
---
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


2020-03-04 16:54:31

by Michal Hocko

[permalink] [raw]
Subject: Re: [PATCH] mm: Make mem_cgroup_id_get_many dependent on MMU and MEMCG_SWAP

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/[email protected].
The conclusion was that the warning is not really worth adding code.

> Cc: Johannes Weiner <[email protected]>
> Cc: Michal Hocko <[email protected]>
> Cc: Vladimir Davydov <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Signed-off-by: Vincenzo Frascino <[email protected]>
> ---
> 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

--
Michal Hocko
SUSE Labs

2020-03-05 09:49:38

by Vincenzo Frascino

[permalink] [raw]
Subject: Re: [PATCH] mm: Make mem_cgroup_id_get_many dependent on MMU and MEMCG_SWAP

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/[email protected].
> 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.

[...]

--
Regards,
Vincenzo

2020-03-05 10:02:46

by Michal Hocko

[permalink] [raw]
Subject: Re: [PATCH] mm: Make mem_cgroup_id_get_many dependent on MMU and MEMCG_SWAP

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/[email protected].
> > 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.
--
Michal Hocko
SUSE Labs

2020-03-05 10:48:05

by Vincenzo Frascino

[permalink] [raw]
Subject: Re: [PATCH] mm: Make mem_cgroup_id_get_many dependent on MMU and MEMCG_SWAP

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/[email protected].
>>> 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?

--
Regards,
Vincenzo

2020-03-05 14:20:52

by Michal Hocko

[permalink] [raw]
Subject: Re: [PATCH] mm: Make mem_cgroup_id_get_many dependent on MMU and MEMCG_SWAP

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.

--
Michal Hocko
SUSE Labs

2020-03-05 16:11:33

by Johannes Weiner

[permalink] [raw]
Subject: Re: [PATCH] mm: Make mem_cgroup_id_get_many dependent on MMU and MEMCG_SWAP

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/[email protected].
> > 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.

2020-03-05 16:22:35

by Vincenzo Frascino

[permalink] [raw]
Subject: Re: [PATCH] mm: Make mem_cgroup_id_get_many dependent on MMU and MEMCG_SWAP

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/[email protected].
>>> 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.

--
Regards,
Vincenzo

2020-03-05 18:35:05

by Chris Down

[permalink] [raw]
Subject: Re: [PATCH] mm: Make mem_cgroup_id_get_many dependent on MMU and MEMCG_SWAP

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/[email protected]/