linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: add config option to select the initial overcommit mode
@ 2016-05-10 11:56 Sebastian Frias
  2016-05-10 12:00 ` Fwd: " Sebastian Frias
                   ` (2 more replies)
  0 siblings, 3 replies; 52+ messages in thread
From: Sebastian Frias @ 2016-05-10 11:56 UTC (permalink / raw)
  To: linux-mm, Andrew Morton, Michal Hocko, Linus Torvalds; +Cc: LKML, mason

Currently the initial value of the overcommit mode is OVERCOMMIT_GUESS.
However, on embedded systems it is usually better to disable overcommit
to avoid waking up the OOM-killer and its well known undesirable
side-effects.

This config option allows to setup the initial overcommit mode to any of
the 3 available values, OVERCOMMIT_GUESS (which remains as default),
OVERCOMMIT_ALWAYS and OVERCOMMIT_NEVER.
The overcommit mode can still be changed thru sysctl after the system
boots up.

This config option depends on CONFIG_EXPERT.
This patch does not introduces functional changes.

Signed-off-by: Sebastian Frias <sf84@laposte.net>
---

NOTE: I understand that the overcommit mode can be changed dynamically thru
sysctl, but on embedded systems, where we know in advance that overcommit
will be disabled, there's no reason to postpone such setting.

I would also be interested in knowing if you guys think this option should
disable sysctl access for overcommit mode, essentially hardcoding the
overcommit mode when this option is used.

NOTE2: I tried to track down the history of overcommit but back then there
were no single patches apparently and the patch that appears to have
introduced the first overcommit mode (OVERCOMMIT_ALWAYS) is commit
9334eab8a36f ("Import 2.1.27"). OVERCOMMIT_NEVER was introduced with commit
502bff0685b2 ("[PATCH] strict overcommit").
My understanding is that prior to commit 9334eab8a36f ("Import 2.1.27")
there was no overcommit, is that correct?

NOTE3: checkpatch.pl is warning about missing description for the config
symbols ("please write a paragraph that describes the config symbol fully")
but my understanding is that that is a false positive (or the warning message
not clear enough for me to understand it) considering that I have added
'help' sections for each 'config' section.
---
 mm/Kconfig | 32 ++++++++++++++++++++++++++++++++
 mm/util.c  |  8 +++++++-
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/mm/Kconfig b/mm/Kconfig
index abb7dcf..6dad57d 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -439,6 +439,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 917e0e3..fd098bb 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -418,7 +418,13 @@ int __page_mapcount(struct page *page)
 }
 EXPORT_SYMBOL_GPL(__page_mapcount);
 
-int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS;
+#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;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2016-05-23 13:11 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-10 11:56 [PATCH] mm: add config option to select the initial overcommit mode Sebastian Frias
2016-05-10 12:00 ` Fwd: " Sebastian Frias
2016-05-10 12:39   ` Andy Whitcroft
2016-05-10 13:02     ` Sebastian Frias
2016-05-13  8:04 ` Michal Hocko
2016-05-13  8:44   ` Mason
2016-05-13  9:52     ` Michal Hocko
2016-05-13 10:18       ` Mason
2016-05-13 10:42         ` Sebastian Frias
2016-05-13 11:44         ` Michal Hocko
2016-05-13 12:15           ` Mason
2016-05-13 14:01             ` Michal Hocko
2016-05-13 14:15               ` Sebastian Frias
2016-05-13 15:04               ` One Thousand Gnomes
2016-05-13 15:37                 ` Sebastian Frias
2016-05-13 15:43                   ` One Thousand Gnomes
2016-05-17  8:24                     ` Sebastian Frias
2016-05-17  8:57                       ` Michal Hocko
2016-05-17 16:16                         ` Sebastian Frias
2016-05-17 17:29                           ` Austin S. Hemmelgarn
2016-05-18 15:19                             ` Sebastian Frias
2016-05-18 16:28                               ` Austin S. Hemmelgarn
2016-05-17 20:16                           ` Michal Hocko
2016-05-18 15:18                             ` Sebastian Frias
2016-05-19  7:14                               ` Michal Hocko
2016-05-13 17:01                   ` Austin S. Hemmelgarn
2016-05-13 13:27         ` Austin S. Hemmelgarn
2016-05-13  9:52     ` Sebastian Frias
2016-05-13 12:00       ` Michal Hocko
2016-05-13 12:39         ` Sebastian Frias
2016-05-13 13:11           ` Austin S. Hemmelgarn
2016-05-13 13:32             ` Sebastian Frias
2016-05-13 13:51               ` Austin S. Hemmelgarn
2016-05-13 14:35                 ` Sebastian Frias
2016-05-13 14:54                   ` Michal Hocko
2016-05-13 15:15                   ` Austin S. Hemmelgarn
2016-05-13 13:34             ` Sebastian Frias
2016-05-13 14:14               ` Austin S. Hemmelgarn
2016-05-13 14:23                 ` Sebastian Frias
2016-05-13 15:02                   ` Austin S. Hemmelgarn
2016-05-13 15:01               ` One Thousand Gnomes
2016-05-13 15:15                 ` Sebastian Frias
2016-05-13 15:25                   ` Michal Hocko
2016-05-13 14:51           ` Michal Hocko
2016-05-13 14:59             ` Mason
2016-05-13 15:11               ` One Thousand Gnomes
2016-05-13 15:26                 ` Michal Hocko
2016-05-13 15:32                 ` Sebastian Frias
2016-05-13 15:10             ` Sebastian Frias
2016-05-13 15:41               ` One Thousand Gnomes
2016-05-23 13:11                 ` Sebastian Frias
2016-05-17  9:03 ` Mason

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).