diff --git a/mm/Kconfig b/mm/Kconfig index 989f8f3d77e0d7..32945d07aeaa7d 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -427,6 +427,38 @@ choice benefit. endchoice +choice + prompt "Overcommit Mode" + default OVERCOMMIT_GUESS + depends on EXPERT + help + Selects the initial value for Overcommit mode. + + NOTE: The overcommit mode can be changed dynamically through sysctl. + + config OVERCOMMIT_GUESS + bool "Guess" + help + Selecting this option forces the initial value of overcommit mode to + "Guess" overcommits. This is the default value. + See Documentation/vm/overcommit-accounting for more information. + + config OVERCOMMIT_ALWAYS + bool "Always" + help + Selecting this option forces the initial value of overcommit mode to + "Always" overcommit. + See Documentation/vm/overcommit-accounting for more information. + + config OVERCOMMIT_NEVER + bool "Never" + help + Selecting this option forces the initial value of overcommit mode to + "Never" overcommit. + See Documentation/vm/overcommit-accounting for more information. + +endchoice + # # UP and nommu archs use km based percpu allocator # diff --git a/mm/util.c b/mm/util.c index 6cc81e7b870523..1720bd82615d09 100644 --- a/mm/util.c +++ b/mm/util.c @@ -394,7 +394,13 @@ int __page_mapcount(struct page *page) } EXPORT_SYMBOL_GPL(__page_mapcount); +#if defined(CONFIG_OVERCOMMIT_NEVER) +int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_NEVER; +#elif defined(CONFIG_OVERCOMMIT_ALWAYS) +int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_ALWAYS; +#else int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; +#endif int sysctl_overcommit_ratio __read_mostly = 50; unsigned long sysctl_overcommit_kbytes __read_mostly; int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;