public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] mm/memcontrol: return 1 from cgroup.memory __setup() handler
@ 2022-02-22  0:58 Randy Dunlap
       [not found] ` <20220222005811.10672-1-rdunlap-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Randy Dunlap @ 2022-02-22  0:58 UTC (permalink / raw)
  To: linux-mm-Bw31MaZKKs3YtjvyW6yDsg
  Cc: Randy Dunlap, Igor Zhbanov, Andrew Morton, Johannes Weiner,
	Michal Hocko, Vladimir Davydov, cgroups-u79uwXL29TY76Z2rM5mHXA

__setup() handlers should return 1 if the command line option is handled
and 0 if not (or maybe never return 0; it just pollutes init's environment).

The only reason that this particular __setup handler does not pollute
init's environment is that the setup string contains a '.', as in
"cgroup.memory". This causes init/main.c::unknown_boottoption() to
consider it to be an "Unused module parameter" and ignore it. (This is
for parsing of loadable module parameters any time after kernel init.)
Otherwise the string "cgroup.memory=whatever" would be added to init's
environment strings.

Instead of relying on this '.' quirk, just return 1 to indicate that
the boot option has been handled.

Note that there is no warning message if someone enters:
	cgroup.memory=anything_invalid

Fixes: f7e1cb6ec51b0 ("mm: memcontrol: account socket memory in unified hierarchy memory controller")
Signed-off-by: Randy Dunlap <rdunlap-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
Reported-by: Igor Zhbanov <i.zhbanov-4G3FwjhnV40EXkLx5dDeUA@public.gmane.org>
Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3-4G3FwjhnV40EXkLx5dDeUA@public.gmane.org
Cc: Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Cc: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
Cc: Michal Hocko <mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Vladimir Davydov <vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
 mm/memcontrol.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-next-20220217.orig/mm/memcontrol.c
+++ linux-next-20220217/mm/memcontrol.c
@@ -7044,7 +7044,7 @@ static int __init cgroup_memory(char *s)
 		if (!strcmp(token, "nokmem"))
 			cgroup_memory_nokmem = true;
 	}
-	return 0;
+	return 1;
 }
 __setup("cgroup.memory=", cgroup_memory);
 

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

end of thread, other threads:[~2022-03-03 22:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-22  0:58 [PATCH 1/2] mm/memcontrol: return 1 from cgroup.memory __setup() handler Randy Dunlap
     [not found] ` <20220222005811.10672-1-rdunlap-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2022-03-02 18:53   ` Michal Koutný
     [not found]     ` <20220302185300.GA19699-9OudH3eul5jcvrawFnH+a6VXKuFTiq87@public.gmane.org>
2022-03-03  0:53       ` Randy Dunlap
     [not found]         ` <9f8d4ddb-81ce-738a-d1f7-346ff9bf8ebd-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2022-03-03 10:14           ` Michal Koutný
     [not found]             ` <20220303101406.GE10867-9OudH3eul5jcvrawFnH+a6VXKuFTiq87@public.gmane.org>
2022-03-03 21:53               ` Randy Dunlap
     [not found]                 ` <5130da56-0f22-8212-0ea3-6ddb8a8f5455-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2022-03-03 22:32                   ` Michal Koutný
2022-03-03 22:53                     ` Randy Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox