Skip to content

Commit fceda1b

Browse files
Michal Hockotorvalds
authored andcommitted
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: Michal Hocko <mhocko@suse.cz> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent afe8a88 commit fceda1b

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎mm/memcontrol.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5024,17 +5024,17 @@ struct cgroup_subsys mem_cgroup_subsys = {
50245024
static int __init enable_swap_account(char *s)
50255025
{
50265026
/* consider enabled if no parameter or 1 is given */
5027-
if (!s || !strcmp(s, "1"))
5027+
if (!(*s) || !strcmp(s, "=1"))
50285028
really_do_swap_account = 1;
5029-
else if (!strcmp(s, "0"))
5029+
else if (!strcmp(s, "=0"))
50305030
really_do_swap_account = 0;
50315031
return 1;
50325032
}
50335033
__setup("swapaccount", enable_swap_account);
50345034

50355035
static int __init disable_swap_account(char *s)
50365036
{
5037-
enable_swap_account("0");
5037+
enable_swap_account("=0");
50385038
return 1;
50395039
}
50405040
__setup("noswapaccount", disable_swap_account);

0 commit comments

Comments
 (0)