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

From: Michal Hocko
Date: Wed Mar 04 2020 - 11:53:46 EST


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@xxxxxxxxxxxx
The conclusion was that the warning is not really worth adding code.

> Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
> Cc: Michal Hocko <mhocko@xxxxxxxxxx>
> Cc: Vladimir Davydov <vdavydov.dev@xxxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@xxxxxxx>
> ---
> 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