Skip to contentSkip to conversation

mm: replace hardcoded 3% with admin_reserve_pages knob

PATCH Superseded Andrew Shewmaker 1 participant 1 message Mar 1, 2013

Subsystems (5)

v3 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 2/2 mm: replace hardcoded 3% with admin_reserve_pages knob

Add an admin_reserve_pages knob to allow admins of large memory systems running with overcommit disabled to change the hardcoded memory reserve to something other than 3%.

admin_reserve_pages is initialized to min(3%, k) as Alan suggested. k=2000 pages should allow the admin to spawn new sshd, bash, and top to recover if necessary.

This affects OVERCOMMIT_GUESS and OVERCOMMIT_NEVER modes.

---

I changed the name of the knob from "rootuser" to "admin" because it better matches the cap_sys_admin conditional.

 Documentation/sysctl/vm.txt | 16 +++++++++++++++
 include/linux/mm.h          |  2 ++
 kernel/sysctl.c             |  8 ++++++++
 mm/mmap.c                   | 50 +++++++++++++++++++++++++++++++++++++++++----
 4 files changed, 72 insertions(+), 4 deletions(-)
Documentation/sysctl/vm.txt +16 -0
index 078701f..2827800 100644
@@ -18,6 +18,7 @@ files can be found in mm/swap.c.
 
 Currently, these files are in /proc/sys/vm:
 
+- admin_reserve_pages
 - block_dump
 - compact_memory
 - dirty_background_bytes
@@ -628,6 +629,21 @@ the high water marks for each per cpu page list.
 
 ==============================================================
 
+admin_reserve_pages
+
+The number of free pages in the system that should be reserved for users
+with the capability cap_sys_admin. The default value is the smaller of 3% 
+of free pages or 2000 pages (8MB with 4k pages). 8MB should provide 
+enough for the admin to log in and kill a process if necessary. 
+
+Systems running with overcommit disabled should consider increasing this 
+to account for the full Virtual Memory Size of programs used to recover 
+a system.
+
+Changing this takes effect whenever an application requests memory.
+
+==============================================================
+
 stat_interval
 
 The time interval between which vm statistics are updated.  The default
include/linux/mm.h +2 -0
index 66e2f7c..fba5f9a 100644
@@ -1677,6 +1677,8 @@ int in_gate_area_no_mm(unsigned long addr);
 
 int drop_caches_sysctl_handler(struct ctl_table *, int,
 					void __user *, size_t *, loff_t *);
+int admin_reserve_pages_sysctl_handler(struct ctl_table *, int,
+					void __user *, size_t *, loff_t *);
 unsigned long shrink_slab(struct shrink_control *shrink,
 			  unsigned long nr_pages_scanned,
 			  unsigned long lru_pages);
kernel/sysctl.c +8 -0
index c88878d..33f99f6 100644
@@ -96,6 +96,7 @@
 /* External variables not in a header file. */
 extern int sysctl_overcommit_memory;
 extern int sysctl_overcommit_ratio;
+extern int sysctl_admin_reserve_pages;
 extern int max_threads;
 extern int suid_dumpable;
 #ifdef CONFIG_COREDUMP
@@ -1413,6 +1414,13 @@ static struct ctl_table vm_table[] = {
 		.extra2		= &one,
 	},
 #endif
+	{
+		.procname	= "admin_reserve_pages",
+		.data		= &sysctl_admin_reserve_pages,
+		.maxlen		= sizeof(sysctl_admin_reserve_pages),
+		.mode		= 0644,
+		.proc_handler	= admin_reserve_pages_sysctl_handler,
+	},
 	{ }
 };
 
mm/mmap.c +46 -4

81 lines not on this page · raw message

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>