Skip to contentSkip to conversation

mm: factor commit limit calculation

PATCH Superseded Jerome Marchand 3 participants 13 messages Aug 19, 2013 – Sep 6, 2013

Subsystems (6)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mm: factor commit limit calculation

The same calculation is currently done in three different places. Factor that code so future changes has to be made at only one place.

---
 fs/proc/meminfo.c    |    5 +----
 include/linux/mman.h |   12 ++++++++++++
 mm/mmap.c            |    4 +---
 mm/nommu.c           |    3 +--
 4 files changed, 15 insertions(+), 9 deletions(-)
fs/proc/meminfo.c +1 -4
index 5aa847a..6f7767d 100644
@@ -24,7 +24,6 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
 {
 	struct sysinfo i;
 	unsigned long committed;
-	unsigned long allowed;
 	struct vmalloc_info vmi;
 	long cached;
 	unsigned long pages[NR_LRU_LISTS];
@@ -37,8 +36,6 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
 	si_meminfo(&i);
 	si_swapinfo(&i);
 	committed = percpu_counter_read_positive(&vm_committed_as);
-	allowed = ((totalram_pages - hugetlb_total_pages())
-		* sysctl_overcommit_ratio / 100) + total_swap_pages;
 
 	cached = global_page_state(NR_FILE_PAGES) -
 			total_swapcache_pages() - i.bufferram;
@@ -153,7 +150,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
 		K(global_page_state(NR_UNSTABLE_NFS)),
 		K(global_page_state(NR_BOUNCE)),
 		K(global_page_state(NR_WRITEBACK_TEMP)),
-		K(allowed),
+		K(vm_commit_limit()),
 		K(committed),
 		(unsigned long)VMALLOC_TOTAL >> 10,
 		vmi.used >> 10,
include/linux/mman.h +12 -0
index 92dc257..d622d34 100644
@@ -7,6 +7,9 @@
 #include <linux/atomic.h>
 #include <uapi/linux/mman.h>
 
+#include <linux/hugetlb.h>
+#include <linux/swap.h>
+
 extern int sysctl_overcommit_memory;
 extern int sysctl_overcommit_ratio;
 extern struct percpu_counter vm_committed_as;
@@ -87,4 +90,13 @@ calc_vm_flag_bits(unsigned long flags)
 	       _calc_vm_trans(flags, MAP_DENYWRITE,  VM_DENYWRITE ) |
 	       _calc_vm_trans(flags, MAP_LOCKED,     VM_LOCKED    );
 }
+
+/*
+ * Commited memory limit enforced when OVERCOMMIT_NEVER policy is used
+ */
+static inline unsigned long vm_commit_limit()
+{
+	return ((totalram_pages - hugetlb_total_pages())
+		* sysctl_overcommit_ratio / 100) + total_swap_pages;
+}
 #endif /* _LINUX_MMAN_H */
mm/mmap.c +1 -3
index 1edbaa3..06c98f8 100644
@@ -179,14 +179,12 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)
 		goto error;
 	}
 
-	allowed = (totalram_pages - hugetlb_total_pages())
-	       	* sysctl_overcommit_ratio / 100;
+	allowed = vm_commit_limit();
 	/*
 	 * Reserve some for root
 	 */
 	if (!cap_sys_admin)
 		allowed -= sysctl_admin_reserve_kbytes >> (PAGE_SHIFT - 10);
-	allowed += total_swap_pages;
 
 	/*
 	 * Don't let a single process grow so big a user can't recover
mm/nommu.c +1 -2
index ecd1f15..d8a957b 100644
@@ -1948,13 +1948,12 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)
 		goto error;
 	}
 
-	allowed = totalram_pages * sysctl_overcommit_ratio / 100;
+	allowed = vm_commit_limit();
 	/*
 	 * Reserve some 3% for root
 	 */
 	if (!cap_sys_admin)
 		allowed -= sysctl_admin_reserve_kbytes >> (PAGE_SHIFT - 10);
-	allowed += total_swap_pages;
 
 	/*
 	 * Don't let a single process grow so big a user can't recover
Signature · 7 lines
1.7.7.6

--
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>
#1 lore raw

PATCH 2/2 mm: add overcommit_kbytes sysctl variable

Some applications that run on HPC clusters are designed around the availability of RAM and the overcommit ratio is fine tuned to get the maximum usage of memory without swapping. With growing memory, the 1%-of-all-RAM grain provided by overcommit_ratio has become too coarse for these workload (on a 2TB machine it represents no less than 20GB).

This patch adds the new overcommit_kbytes sysctl variable that allow a much finer grain.

---
 Documentation/sysctl/vm.txt            |   12 ++++++++++++
 Documentation/vm/overcommit-accounting |    7 ++++---
 include/linux/mm.h                     |    5 +++++
 include/linux/mman.h                   |   13 +++++++++++--
 kernel/sysctl.c                        |   10 +++++++++-
 mm/mmap.c                              |   25 +++++++++++++++++++++++++
 mm/nommu.c                             |    1 +
 7 files changed, 67 insertions(+), 6 deletions(-)
Documentation/sysctl/vm.txt +12 -0
index 36ecc26..a23aea1 100644
@@ -47,6 +47,7 @@ Currently, these files are in /proc/sys/vm:
 - numa_zonelist_order
 - oom_dump_tasks
 - oom_kill_allocating_task
+- overcommit_kbytes
 - overcommit_memory
 - overcommit_ratio
 - page-cluster
@@ -561,6 +562,17 @@ The default value is 0.
 
 ==============================================================
 
+overcommit_kbytes:
+
+When overcommit_memory is set to 2, the committed address space is not
+permitted to exceed swap plus this amount of physical RAM. See below.
+
+Note: overcommit_kbytes is the counterpart of overcommit_ratio. Only one
+of them may be specified at a time. Setting one disable the other (which
+then appears as 0 when read).
+
+==============================================================
+
 overcommit_memory:
 
 This value contains a flag that enables memory overcommitment.
Documentation/vm/overcommit-accounting +4 -3
index 8eaa2fc..cbfaaa6 100644
@@ -14,8 +14,8 @@ The Linux kernel supports the following overcommit handling modes
 
 2	-	Don't overcommit. The total address space commit
 		for the system is not permitted to exceed swap + a
-		configurable percentage (default is 50) of physical RAM.
-		Depending on the percentage you use, in most situations
+		configurable amount (default is 50%) of physical RAM.
+		Depending on the amount you use, in most situations
 		this means a process will not be killed while accessing
 		pages but will receive errors on memory allocation as
 		appropriate.
@@ -26,7 +26,8 @@ The Linux kernel supports the following overcommit handling modes
 
 The overcommit policy is set via the sysctl `vm.overcommit_memory'.
 
-The overcommit percentage is set via `vm.overcommit_ratio'.
+The overcommit amount can be set via `vm.overcommit_ratio' (percentage)
+or `vm.overcommit_kbytes' (absolute value).
 
 The current overcommit limit and amount committed are viewable in
 /proc/meminfo as CommitLimit and Committed_AS respectively.
include/linux/mm.h +5 -0
index f022460..15f2b0c 100644
@@ -53,6 +53,11 @@ extern int sysctl_legacy_va_layout;
 extern unsigned long sysctl_user_reserve_kbytes;
 extern unsigned long sysctl_admin_reserve_kbytes;
 
+extern int overcommit_ratio_handler(struct ctl_table *, int, void __user *,
+				    size_t *, loff_t *);
+extern int overcommit_kbytes_handler(struct ctl_table *, int, void __user *,
+				    size_t *, loff_t *);
+
 #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
 
 /* to align the pointer to the (next) page boundary */
include/linux/mman.h +11 -2
index d622d34..debd0f9 100644
@@ -12,6 +12,7 @@
 
 extern int sysctl_overcommit_memory;
 extern int sysctl_overcommit_ratio;
+extern unsigned long sysctl_overcommit_kbytes;
 extern struct percpu_counter vm_committed_as;
 
 #ifdef CONFIG_SMP
@@ -96,7 +97,15 @@ calc_vm_flag_bits(unsigned long flags)
  */
 static inline unsigned long vm_commit_limit()
 {
-	return ((totalram_pages - hugetlb_total_pages())
-		* sysctl_overcommit_ratio / 100) + total_swap_pages;
+	unsigned long allowed;
+
+	if (sysctl_overcommit_kbytes)
+		allowed = sysctl_overcommit_kbytes >> (PAGE_SHIFT - 10);
+	else
+		allowed = ((totalram_pages - hugetlb_total_pages())
+			   * sysctl_overcommit_ratio / 100);
+	allowed += total_swap_pages;
+
+	return allowed;
 }
 #endif /* _LINUX_MMAN_H */
kernel/sysctl.c +9 -1
index 07f6fc4..e1968a4 100644
@@ -97,6 +97,7 @@
 /* External variables not in a header file. */
 extern int sysctl_overcommit_memory;
 extern int sysctl_overcommit_ratio;
+extern unsigned long sysctl_overcommit_kbytes;
 extern int max_threads;
 extern int suid_dumpable;
 #ifdef CONFIG_COREDUMP
@@ -1119,7 +1120,14 @@ static struct ctl_table vm_table[] = {
 		.data		= &sysctl_overcommit_ratio,
 		.maxlen		= sizeof(sysctl_overcommit_ratio),
 		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
+		.proc_handler	= overcommit_ratio_handler,
+	},
+	{
+		.procname	= "overcommit_kbytes",
+		.data		= &sysctl_overcommit_kbytes,
+		.maxlen		= sizeof(sysctl_overcommit_kbytes),
+		.mode		= 0644,
+		.proc_handler	= overcommit_kbytes_handler,
 	},
 	{
 		.procname	= "page-cluster", 
mm/mmap.c +25 -0
index 06c98f8..c4a09a5 100644
@@ -86,6 +86,7 @@ EXPORT_SYMBOL(vm_get_page_prot);
 
 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS;  /* heuristic overcommit */
 int sysctl_overcommit_ratio __read_mostly = 50;	/* default is 50% */
+unsigned long sysctl_overcommit_kbytes __read_mostly = 0;
 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
@@ -95,6 +96,30 @@ unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
  */
 struct percpu_counter vm_committed_as ____cacheline_aligned_in_smp;
 
+int overcommit_ratio_handler(struct ctl_table *table, int write,
+			     void __user *buffer, size_t *lenp,
+			     loff_t *ppos)
+{
+	int ret;
+
+	ret = proc_dointvec(table, write, buffer, lenp, ppos);
+	if (ret == 0 && write)
+		sysctl_overcommit_kbytes = 0;
+	return ret;
+}
+
+int overcommit_kbytes_handler(struct ctl_table *table, int write,
+			     void __user *buffer, size_t *lenp,
+			     loff_t *ppos)
+{
+	int ret;
+
+	ret = proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
+	if (ret == 0 && write)
+		sysctl_overcommit_ratio = 0;
+	return ret;
+}
+
 /*
  * The global memory commitment made in the system can be a metric
  * that can be used to drive ballooning decisions when Linux is hosted
mm/nommu.c +1 -0
index d8a957b..3c4216a 100644
@@ -60,6 +60,7 @@ unsigned long highest_memmap_pfn;
 struct percpu_counter vm_committed_as;
 int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
 int sysctl_overcommit_ratio = 50; /* default is 50% */
+unsigned long sysctl_overcommit_kbytes __read_mostly = 0;
 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
Signature · 7 lines
1.7.7.6

--
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>
#2 lore raw

Re: [PATCH 2/2] mm: add overcommit_kbytes sysctl variable

Quoted 9 lines · Jerome Marchand

Some applications that run on HPC clusters are designed around the availability of RAM and the overcommit ratio is fine tuned to get the maximum usage of memory without swapping. With growing memory, the 1%-of-all-RAM grain provided by overcommit_ratio has become too coarse for these workload (on a 2TB machine it represents no less than 20GB).

This patch adds the new overcommit_kbytes sysctl variable that allow a much finer grain.

Instead of introducing yet another tunable, why don't we just make the ratio that comes in from the user more fine-grained?

sysctl overcommit_ratio=0.2

We change the internal 'sysctl_overcommit_ratio' to store tenths or hundreths of a percent (or whatever), then parse the input as two integers. I don't think we need fully correct floating point parsing and rounding here, so it shouldn't be too much of a chore. It'd probably end up being less code than you have as it stands.

--
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>

#3 lore raw

Re: [PATCH 2/2] mm: add overcommit_kbytes sysctl variable

Quoted 14 lines · Dave Hansen
Quoted 9 lines · Jerome Marchand

Some applications that run on HPC clusters are designed around the availability of RAM and the overcommit ratio is fine tuned to get the maximum usage of memory without swapping. With growing memory, the 1%-of-all-RAM grain provided by overcommit_ratio has become too coarse for these workload (on a 2TB machine it represents no less than 20GB).

This patch adds the new overcommit_kbytes sysctl variable that allow a much finer grain.

Instead of introducing yet another tunable, why don't we just make the ratio that comes in from the user more fine-grained?

Quoted 8 lines

sysctl overcommit_ratio=0.2

We change the internal 'sysctl_overcommit_ratio' to store tenths or hundreths of a percent (or whatever), then parse the input as two integers. I don't think we need fully correct floating point parsing and rounding here, so it shouldn't be too much of a chore. It'd probably end up being less code than you have as it stands.

Whatever works for me. I did it in that way to be more consistent with what has already been done for dirty*_ratio/bytes.

Thanks,
Jerome

--
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>

#4 lore raw

Re: [PATCH 2/2] mm: add overcommit_kbytes sysctl variable

In reply to Dave Hansen
Quoted 14 lines · Dave Hansen
Quoted 9 lines · Jerome Marchand

Some applications that run on HPC clusters are designed around the availability of RAM and the overcommit ratio is fine tuned to get the maximum usage of memory without swapping. With growing memory, the 1%-of-all-RAM grain provided by overcommit_ratio has become too coarse for these workload (on a 2TB machine it represents no less than 20GB).

This patch adds the new overcommit_kbytes sysctl variable that allow a much finer grain.

Instead of introducing yet another tunable, why don't we just make the ratio that comes in from the user more fine-grained?

Quoted 8 lines

sysctl overcommit_ratio=0.2

We change the internal 'sysctl_overcommit_ratio' to store tenths or hundreths of a percent (or whatever), then parse the input as two integers. I don't think we need fully correct floating point parsing and rounding here, so it shouldn't be too much of a chore. It'd probably end up being less code than you have as it stands.

Now that I think about it, that could break user space. Sure write access wouldn't be a problem (one can still write a plain integer), but a script that reads a fractional value when it expects an integer might not be able to cope with it.

--
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>

#5 lore raw

Re: [PATCH 2/2] mm: add overcommit_kbytes sysctl variable

Quoted 11 lines · Jerome Marchand
Quoted 11 lines
Quoted 11 lines

Instead of introducing yet another tunable, why don't we just make the ratio that comes in from the user more fine-grained?

sysctl overcommit_ratio=0.2

We change the internal 'sysctl_overcommit_ratio' to store tenths or hundreths of a percent (or whatever), then parse the input as two integers. I don't think we need fully correct floating point parsing and rounding here, so it shouldn't be too much of a chore. It'd probably end up being less code than you have as it stands.

Quoted 4 lines

Now that I think about it, that could break user space. Sure write access wouldn't be a problem (one can still write a plain integer), but a script that reads a fractional value when it expects an integer might not be able to cope with it.

You're right. Something doing FOO=$(cat overcommit_ratio) and then trying do do arithmetic would just fail loudly. But, it would probably fail silently if we create another tunable that all of a sudden returns 0 (when the kernel is not _behaving_ like it is set to 0).

I'm not sure there's a good way out of this without breakage (or at least confusing) of _some_ old scripts/programs. Either way has ups and downs.

The existing dirty_ratio/bytes stuff just annoys me because I end up having to check two places whenever I go looking for it.

--
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>

#6 lore raw

Re: [PATCH 2/2] mm: add overcommit_kbytes sysctl variable

Quoted 22 lines · Dave Hansen
Quoted 11 lines · Jerome Marchand
Quoted 11 lines
Quoted 11 lines

Instead of introducing yet another tunable, why don't we just make the ratio that comes in from the user more fine-grained?

sysctl overcommit_ratio=0.2

We change the internal 'sysctl_overcommit_ratio' to store tenths or hundreths of a percent (or whatever), then parse the input as two integers. I don't think we need fully correct floating point parsing and rounding here, so it shouldn't be too much of a chore. It'd probably end up being less code than you have as it stands.

Quoted 4 lines

Now that I think about it, that could break user space. Sure write access wouldn't be a problem (one can still write a plain integer), but a script that reads a fractional value when it expects an integer might not be able to cope with it.

You're right. Something doing FOO=$(cat overcommit_ratio) and then trying do do arithmetic would just fail loudly. But, it would probably fail silently if we create another tunable that all of a sudden returns 0 (when the kernel is not _behaving_ like it is set to 0).

Quoted 7 lines

I'm not sure there's a good way out of this without breakage (or at least confusing) of _some_ old scripts/programs. Either way has ups and downs.

The existing dirty_ratio/bytes stuff just annoys me because I end up having to check two places whenever I go looking for it.

Right. Then we could just use some overcommit_fine_ratio internally and overcommit_ratio would show and set a rounded value. I doubt that a script that reads 80% would notice the difference if it is actually 79.5%.

We could also use overcommit_kbytes internally, but then overcommit_ratio would fluctuate if RAM ram is added/removed (e.g. memory hotplug or baloon driver). That might be a problem.

--
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>

#7 lore raw

PATCH v2 2/2 mm: allow to set overcommit ratio more precisely

In reply to Jerome Marchand

Changes since v1:
- use overcommit_ratio_ppm instead of overcommit_kbytes
- keep both variables in sync

Some applications that run on HPC clusters are designed around the availability of RAM and the overcommit ratio is fine tuned to get the maximum usage of memory without swapping. With growing memory, the 1% of all RAM grain provided by overcommit_ratio has become too coarse for these workload (on a 2TB machine it represents no less than 20GB).

This patch adds the new overcommit_ratio_ppm sysctl variable that allow to set overcommit ratio with a part per million precision. The old overcommit_ratio variable can still be used to set and read the ratio with a 1% precision. That way, overcommit_ratio interface isn't broken in any way that I can imagine.

---
 include/linux/mman.h   |    6 ++--
 include/linux/sysctl.h |    2 +
 kernel/sysctl.c        |   63 +++++++++++++++++++++++++++++++++++++++++++++--
 mm/mmap.c              |    2 +-
 mm/nommu.c             |    2 +-
 5 files changed, 67 insertions(+), 8 deletions(-)
include/linux/mman.h +3 -3
index d622d34..24f9c12 100644
@@ -11,7 +11,7 @@
 #include <linux/swap.h>
 
 extern int sysctl_overcommit_memory;
-extern int sysctl_overcommit_ratio;
+extern int sysctl_overcommit_ratio_ppm;
 extern struct percpu_counter vm_committed_as;
 
 #ifdef CONFIG_SMP
@@ -96,7 +96,7 @@ calc_vm_flag_bits(unsigned long flags)
  */
 static inline unsigned long vm_commit_limit()
 {
-	return ((totalram_pages - hugetlb_total_pages())
-		* sysctl_overcommit_ratio / 100) + total_swap_pages;
+	return ((u64) (totalram_pages - hugetlb_total_pages())
+		* sysctl_overcommit_ratio_ppm / 100000) + total_swap_pages;
 }
 #endif /* _LINUX_MMAN_H */
include/linux/sysctl.h +2 -0
index 14a8ff2..2e2389c 100644
@@ -51,6 +51,8 @@ extern int proc_dointvec_userhz_jiffies(struct ctl_table *, int,
 					void __user *, size_t *, loff_t *);
 extern int proc_dointvec_ms_jiffies(struct ctl_table *, int,
 				    void __user *, size_t *, loff_t *);
+extern int proc_dointvec_percent_ppm(struct ctl_table *, int,
+				     void __user *, size_t *, loff_t *);
 extern int proc_doulongvec_minmax(struct ctl_table *, int,
 				  void __user *, size_t *, loff_t *);
 extern int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int,
kernel/sysctl.c +60 -3

81 lines not on this page · raw message

mm/mmap.c +1 -1
index 06c98f8..bdec0e1 100644
@@ -85,7 +85,7 @@ pgprot_t vm_get_page_prot(unsigned long vm_flags)
 EXPORT_SYMBOL(vm_get_page_prot);
 
 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS;  /* heuristic overcommit */
-int sysctl_overcommit_ratio __read_mostly = 50;	/* default is 50% */
+int sysctl_overcommit_ratio_ppm __read_mostly = 500000;	/* default is 50% */
 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
mm/nommu.c +1 -1
index d8a957b..cf10a9b 100644
@@ -59,7 +59,7 @@ unsigned long max_mapnr;
 unsigned long highest_memmap_pfn;
 struct percpu_counter vm_committed_as;
 int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
-int sysctl_overcommit_ratio = 50; /* default is 50% */
+int sysctl_overcommit_ratio_ppm = 500000; /* default is 50% */
 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
Signature · 7 lines
1.7.7.6

--
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>
#8 lore raw

Re: [PATCH 2/2 v2] mm: allow to set overcommit ratio more precisely

Quoted 5 lines · Jerome Marchand

This patch adds the new overcommit_ratio_ppm sysctl variable that allow to set overcommit ratio with a part per million precision. The old overcommit_ratio variable can still be used to set and read the ratio with a 1% precision. That way, overcommit_ratio interface isn't broken in any way that I can imagine.

Looks like a pretty sane solution. Could you also make a Documentation/ update, please?

--
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>

#9 lore raw

Re: [PATCH 2/2 v2] mm: allow to set overcommit ratio more precisely

Quoted 9 lines · Dave Hansen
Quoted 5 lines · Jerome Marchand

This patch adds the new overcommit_ratio_ppm sysctl variable that allow to set overcommit ratio with a part per million precision. The old overcommit_ratio variable can still be used to set and read the ratio with a 1% precision. That way, overcommit_ratio interface isn't broken in any way that I can imagine.

Looks like a pretty sane solution. Could you also make a Documentation/ update, please?

Damn! I forgot. Will do.

Thanks

Quoted 7 lines

--
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>

--
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>

#10 lore raw

Re: [PATCH 2/2 v2] mm: allow to set overcommit ratio more precisely

hi!

Quoted 10 lines
Quoted 8 lines
Quoted 5 lines

This patch adds the new overcommit_ratio_ppm sysctl variable that allow to set overcommit ratio with a part per million precision. The old overcommit_ratio variable can still be used to set and read the ratio with a 1% precision. That way, overcommit_ratio interface isn't broken in any way that I can imagine.

Looks like a pretty sane solution. Could you also make a Documentation/ update, please?

Damn! I forgot. Will do.

Actually... would something like overcommit_bytes be better interface? overcommit_pages?

If system would normally allow allocating "n" pages, with overcommit it would allow allocating "n + overcommit_pages" pages. That seems like right granularity...

Signature · 8 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

--
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>
#11 lore raw

Re: [PATCH 2/2 v2] mm: allow to set overcommit ratio more precisely

Quoted 11 lines · Pavel Machek

hi!

Quoted 9 lines
Quoted 8 lines
Quoted 5 lines

This patch adds the new overcommit_ratio_ppm sysctl variable that allow to set overcommit ratio with a part per million precision. The old overcommit_ratio variable can still be used to set and read the ratio with a 1% precision. That way, overcommit_ratio interface isn't broken in any way that I can imagine.

Looks like a pretty sane solution. Could you also make a Documentation/ update, please?

Quoted 8 lines
Quoted 1 line

Damn! I forgot. Will do.

Actually... would something like overcommit_bytes be better interface? overcommit_pages?

If system would normally allow allocating "n" pages, with overcommit it would allow allocating "n + overcommit_pages" pages. That seems like right granularity...

I don't know what do you mean by "normally".
Anyway, I've considered that option: my concern about mixing absolute and proportional values is that they would diverge if the amount of ram varies (e.g. memory hotplug or virt baloon driver).

--
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>

#12 lore raw

PATCH v3 2/2 mm: allow to set overcommit ratio more precisely

In reply to Dave Hansen

Changes since v2:
- update documentation
Changes since v1:
- use overcommit_ratio_ppm instead of overcommit_kbytes
- keep both variables in sync

Some applications that run on HPC clusters are designed around the availability of RAM and the overcommit ratio is fine tuned to get the maximum usage of memory without swapping. With growing memory, the 1% of all RAM grain provided by overcommit_ratio has become too coarse for these workload (on a 2TB machine it represents no less than 20GB).

This patch adds the new overcommit_ratio_ppm sysctl variable that allow to set overcommit ratio with a part per million precision. The old overcommit_ratio variable can still be used to set and read the ratio with a 1% precision. That way, overcommit_ratio interface isn't broken in any way that I can imagine.

---
 Documentation/sysctl/vm.txt            |   10 +++++
 Documentation/vm/overcommit-accounting |    7 ++--
 include/linux/mman.h                   |    6 ++--
 include/linux/sysctl.h                 |    2 +
 kernel/sysctl.c                        |   63 ++++++++++++++++++++++++++++++--
 mm/mmap.c                              |    2 +-
 mm/nommu.c                             |    2 +-
 7 files changed, 81 insertions(+), 11 deletions(-)
Documentation/sysctl/vm.txt +10 -0
index 36ecc26..5cd5c53 100644
@@ -49,6 +49,7 @@ Currently, these files are in /proc/sys/vm:
 - oom_kill_allocating_task
 - overcommit_memory
 - overcommit_ratio
+- overcommit_ratio_ppm
 - page-cluster
 - panic_on_oom
 - percpu_pagelist_fraction
@@ -591,6 +592,15 @@ overcommit_ratio:
 When overcommit_memory is set to 2, the committed address
 space is not permitted to exceed swap plus this percentage
 of physical RAM.  See above.
+If overcommit_ratio_ppm has been set, overcommit_ratio shows a
+rounded value.
+
+==============================================================
+
+overcommit_ratio_ppm:
+
+Same as overcommit_ratio, but allows to set the ratio with a finer
+grain (part per million).
 
 ==============================================================
 
Documentation/vm/overcommit-accounting +4 -3
index 8eaa2fc..15b5ecb 100644
@@ -14,8 +14,8 @@ The Linux kernel supports the following overcommit handling modes
 
 2	-	Don't overcommit. The total address space commit
 		for the system is not permitted to exceed swap + a
-		configurable percentage (default is 50) of physical RAM.
-		Depending on the percentage you use, in most situations
+		configurable ratio (default is 50%) of physical RAM.
+		Depending on the ratio you use, in most situations
 		this means a process will not be killed while accessing
 		pages but will receive errors on memory allocation as
 		appropriate.
@@ -26,7 +26,8 @@ The Linux kernel supports the following overcommit handling modes
 
 The overcommit policy is set via the sysctl `vm.overcommit_memory'.
 
-The overcommit percentage is set via `vm.overcommit_ratio'.
+The overcommit percentage is set via `vm.overcommit_ratio' or
+`vm.overcommit_ratio_ppm'.
 
 The current overcommit limit and amount committed are viewable in
 /proc/meminfo as CommitLimit and Committed_AS respectively.
include/linux/mman.h +3 -3
index d622d34..24f9c12 100644
@@ -11,7 +11,7 @@
 #include <linux/swap.h>
 
 extern int sysctl_overcommit_memory;
-extern int sysctl_overcommit_ratio;
+extern int sysctl_overcommit_ratio_ppm;
 extern struct percpu_counter vm_committed_as;
 
 #ifdef CONFIG_SMP
@@ -96,7 +96,7 @@ calc_vm_flag_bits(unsigned long flags)
  */
 static inline unsigned long vm_commit_limit()
 {
-	return ((totalram_pages - hugetlb_total_pages())
-		* sysctl_overcommit_ratio / 100) + total_swap_pages;
+	return ((u64) (totalram_pages - hugetlb_total_pages())
+		* sysctl_overcommit_ratio_ppm / 100000) + total_swap_pages;
 }
 #endif /* _LINUX_MMAN_H */
include/linux/sysctl.h +2 -0
index 14a8ff2..2e2389c 100644
@@ -51,6 +51,8 @@ extern int proc_dointvec_userhz_jiffies(struct ctl_table *, int,
 					void __user *, size_t *, loff_t *);
 extern int proc_dointvec_ms_jiffies(struct ctl_table *, int,
 				    void __user *, size_t *, loff_t *);
+extern int proc_dointvec_percent_ppm(struct ctl_table *, int,
+				     void __user *, size_t *, loff_t *);
 extern int proc_doulongvec_minmax(struct ctl_table *, int,
 				  void __user *, size_t *, loff_t *);
 extern int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int,
kernel/sysctl.c +60 -3

81 lines not on this page · raw message

mm/mmap.c +1 -1
index 3a1bd2c..b996483 100644
@@ -85,7 +85,7 @@ pgprot_t vm_get_page_prot(unsigned long vm_flags)
 EXPORT_SYMBOL(vm_get_page_prot);
 
 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS;  /* heuristic overcommit */
-int sysctl_overcommit_ratio __read_mostly = 50;	/* default is 50% */
+int sysctl_overcommit_ratio_ppm __read_mostly = 500000;	/* default is 50% */
 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
mm/nommu.c +1 -1
index d8a957b..cf10a9b 100644
@@ -59,7 +59,7 @@ unsigned long max_mapnr;
 unsigned long highest_memmap_pfn;
 struct percpu_counter vm_committed_as;
 int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
-int sysctl_overcommit_ratio = 50; /* default is 50% */
+int sysctl_overcommit_ratio_ppm = 500000; /* default is 50% */
 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
Signature · 7 lines
1.7.7.6

--
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>