Commit a42c390cfa0c2612459d7226ba11612847ca3a64
Committed by
Linus Torvalds
1 parent
b1dd693e5b
Exists in
master
and in
20 other branches
cgroups: make swap accounting default behavior configurable
Swap accounting can be configured by CONFIG_CGROUP_MEM_RES_CTLR_SWAP configuration option and then it is turned on by default. There is a boot option (noswapaccount) which can disable this feature. This makes it hard for distributors to enable the configuration option as this feature leads to a bigger memory consumption and this is a no-go for general purpose distribution kernel. On the other hand swap accounting may be very usuful for some workloads. This patch adds a new configuration option which controls the default behavior (CGROUP_MEM_RES_CTLR_SWAP_ENABLED). If the option is selected then the feature is turned on by default. It also adds a new boot parameter swapaccount[=1|0] which enhances the original noswapaccount parameter semantic by means of enable/disable logic (defaults to 1 if no value is provided to be still consistent with noswapaccount). The default behavior is unchanged (if CONFIG_CGROUP_MEM_RES_CTLR_SWAP is enabled then CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED is enabled as well) Signed-off-by: Michal Hocko <mhocko@suse.cz> Acked-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Cc: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 3 changed files with 37 additions and 2 deletions Side-by-side Diff
Documentation/kernel-parameters.txt
... | ... | @@ -2385,6 +2385,11 @@ |
2385 | 2385 | improve throughput, but will also increase the |
2386 | 2386 | amount of memory reserved for use by the client. |
2387 | 2387 | |
2388 | + swapaccount[=0|1] | |
2389 | + [KNL] Enable accounting of swap in memory resource | |
2390 | + controller if no parameter or 1 is given or disable | |
2391 | + it if 0 is given (See Documentation/cgroups/memory.txt) | |
2392 | + | |
2388 | 2393 | swiotlb= [IA-64] Number of I/O TLB slabs |
2389 | 2394 | |
2390 | 2395 | switches= [HW,M68k] |
init/Kconfig
... | ... | @@ -613,6 +613,19 @@ |
613 | 613 | if boot option "noswapaccount" is set, swap will not be accounted. |
614 | 614 | Now, memory usage of swap_cgroup is 2 bytes per entry. If swap page |
615 | 615 | size is 4096bytes, 512k per 1Gbytes of swap. |
616 | +config CGROUP_MEM_RES_CTLR_SWAP_ENABLED | |
617 | + bool "Memory Resource Controller Swap Extension enabled by default" | |
618 | + depends on CGROUP_MEM_RES_CTLR_SWAP | |
619 | + default y | |
620 | + help | |
621 | + Memory Resource Controller Swap Extension comes with its price in | |
622 | + a bigger memory consumption. General purpose distribution kernels | |
623 | + which want to enable the feautre but keep it disabled by default | |
624 | + and let the user enable it by swapaccount boot command line | |
625 | + parameter should have this option unselected. | |
626 | + For those who want to have the feature enabled by default should | |
627 | + select this option (if, for some reason, they need to disable it | |
628 | + then noswapaccount does the trick). | |
616 | 629 | |
617 | 630 | menuconfig CGROUP_SCHED |
618 | 631 | bool "Group CPU scheduler" |
mm/memcontrol.c
... | ... | @@ -61,8 +61,15 @@ |
61 | 61 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP |
62 | 62 | /* Turned on only when memory cgroup is enabled && really_do_swap_account = 1 */ |
63 | 63 | int do_swap_account __read_mostly; |
64 | -static int really_do_swap_account __initdata = 1; /* for remember boot option*/ | |
64 | + | |
65 | +/* for remember boot option*/ | |
66 | +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED | |
67 | +static int really_do_swap_account __initdata = 1; | |
65 | 68 | #else |
69 | +static int really_do_swap_account __initdata = 0; | |
70 | +#endif | |
71 | + | |
72 | +#else | |
66 | 73 | #define do_swap_account (0) |
67 | 74 | #endif |
68 | 75 | |
69 | 76 | |
... | ... | @@ -4920,10 +4927,20 @@ |
4920 | 4927 | }; |
4921 | 4928 | |
4922 | 4929 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP |
4930 | +static int __init enable_swap_account(char *s) | |
4931 | +{ | |
4932 | + /* consider enabled if no parameter or 1 is given */ | |
4933 | + if (!s || !strcmp(s, "1")) | |
4934 | + really_do_swap_account = 1; | |
4935 | + else if (!strcmp(s, "0")) | |
4936 | + really_do_swap_account = 0; | |
4937 | + return 1; | |
4938 | +} | |
4939 | +__setup("swapaccount", enable_swap_account); | |
4923 | 4940 | |
4924 | 4941 | static int __init disable_swap_account(char *s) |
4925 | 4942 | { |
4926 | - really_do_swap_account = 0; | |
4943 | + enable_swap_account("0"); | |
4927 | 4944 | return 1; |
4928 | 4945 | } |
4929 | 4946 | __setup("noswapaccount", disable_swap_account); |