提交 fceda1bf 编写于 作者: M Michal Hocko 提交者: Linus Torvalds

memsw: handle swapaccount kernel parameter correctly

__setup based kernel command line parameters handlers which are handled in
obsolete_checksetup are provided with the parameter value including =
(more precisely everything right after the parameter name).

This means that the current implementation of swapaccount[=1|0] doesn't
work at all because if there is a value for the parameter then we are
testing for "0" resp.  "1" but we are getting "=0" resp.  "=1" and if
there is no parameter value we are getting an empty string rather than
NULL.

The original noswapccount parameter, which doesn't care about the value,
works correctly.
Signed-off-by: NMichal Hocko <mhocko@suse.cz>
Acked-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: <stable@kernel.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 afe8a887
...@@ -5024,9 +5024,9 @@ struct cgroup_subsys mem_cgroup_subsys = { ...@@ -5024,9 +5024,9 @@ struct cgroup_subsys mem_cgroup_subsys = {
static int __init enable_swap_account(char *s) static int __init enable_swap_account(char *s)
{ {
/* consider enabled if no parameter or 1 is given */ /* consider enabled if no parameter or 1 is given */
if (!s || !strcmp(s, "1")) if (!(*s) || !strcmp(s, "=1"))
really_do_swap_account = 1; really_do_swap_account = 1;
else if (!strcmp(s, "0")) else if (!strcmp(s, "=0"))
really_do_swap_account = 0; really_do_swap_account = 0;
return 1; return 1;
} }
...@@ -5034,7 +5034,7 @@ __setup("swapaccount", enable_swap_account); ...@@ -5034,7 +5034,7 @@ __setup("swapaccount", enable_swap_account);
static int __init disable_swap_account(char *s) static int __init disable_swap_account(char *s)
{ {
enable_swap_account("0"); enable_swap_account("=0");
return 1; return 1;
} }
__setup("noswapaccount", disable_swap_account); __setup("noswapaccount", disable_swap_account);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册