Skip to content

Commit

Permalink
memsw: handle swapaccount kernel parameter correctly
Browse files Browse the repository at this point in the history
__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 <[email protected]>
Acked-by: KAMEZAWA Hiroyuki <[email protected]>
Cc: Daisuke Nishimura <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Michal Hocko authored and torvalds committed Feb 3, 2011
1 parent afe8a88 commit fceda1b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -5024,17 +5024,17 @@ struct cgroup_subsys mem_cgroup_subsys = {
static int __init enable_swap_account(char *s)
{
/* consider enabled if no parameter or 1 is given */
if (!s || !strcmp(s, "1"))
if (!(*s) || !strcmp(s, "=1"))
really_do_swap_account = 1;
else if (!strcmp(s, "0"))
else if (!strcmp(s, "=0"))
really_do_swap_account = 0;
return 1;
}
__setup("swapaccount", enable_swap_account);

static int __init disable_swap_account(char *s)
{
enable_swap_account("0");
enable_swap_account("=0");
return 1;
}
__setup("noswapaccount", disable_swap_account);
Expand Down

0 comments on commit fceda1b

Please sign in to comment.