Re: [PATCH] mm: memcontrol.c: move mem_cgroup_id_get_many under CONFIG_MMU

From: Chris Down
Date: Tue Dec 17 2019 - 08:54:46 EST


Hi Kuninori,

Michal Hocko writes:
On Tue 17-12-19 15:47:40, Kuninori Morimoto wrote:
From: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>

mem_cgroup_id_get_many() is used under CONFIG_MMU.

Not really. It is used when SWAP is enabled currently. But it is not
really bound to the swap functionality by any means. It just happens
that we do not have other users currently. We might put it under
CONFIG_SWAP but I do not really think it is a big improvement.

Agreed, I think we shouldn't wrap this in preprocessor conditionals it since it's entirely possible it will end up used elsewhere and we'll end up with a mess of #ifdefs.

This patch moves it to under CONFIG_MMU.
We will get below warning without this patch
if .config doesn't have CONFIG_MMU.

LINUX/mm/memcontrol.c:4814: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)
^~~~~~~~~~~~~~~~~~~~~~

Is this warning really a big deal? The function is not used, alright,
and the compiler will likely just drop it.

Let's just add __maybe_unused, since it seems like what we want in this scenario -- it avoids new users having to enter preprocessor madness, while also not polluting the build output.

Once you've done that, I'll send over my ack. :-)

Thanks.