diff options
author | Jerome Marchand <jmarchan@redhat.com> | 2014-01-21 18:49:14 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-21 19:19:44 -0500 |
commit | 49f0ce5f92321cdcf741e35f385669a421013cb7 (patch) | |
tree | d41c5a2283b32be69840cb8722ffd8cd8c38a1b0 /mm | |
parent | aec6a8889a98a0cd58357cd0937a25189908f191 (diff) |
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.
[akpm@linux-foundation.org: coding-style fixes]
[akpm@linux-foundation.org: fix nommu build]
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/mmap.c | 1 | ||||
-rw-r--r-- | mm/nommu.c | 1 | ||||
-rw-r--r-- | mm/util.c | 36 |
3 files changed, 36 insertions, 2 deletions
@@ -86,6 +86,7 @@ EXPORT_SYMBOL(vm_get_page_prot); | |||
86 | 86 | ||
87 | int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */ | 87 | int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */ |
88 | int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */ | 88 | int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */ |
89 | unsigned long sysctl_overcommit_kbytes __read_mostly; | ||
89 | int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT; | 90 | int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT; |
90 | unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */ | 91 | unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */ |
91 | unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */ | 92 | unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */ |
diff --git a/mm/nommu.c b/mm/nommu.c index fec093adad9c..8740213b1647 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -60,6 +60,7 @@ unsigned long highest_memmap_pfn; | |||
60 | struct percpu_counter vm_committed_as; | 60 | struct percpu_counter vm_committed_as; |
61 | int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */ | 61 | int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */ |
62 | int sysctl_overcommit_ratio = 50; /* default is 50% */ | 62 | int sysctl_overcommit_ratio = 50; /* default is 50% */ |
63 | unsigned long sysctl_overcommit_kbytes __read_mostly; | ||
63 | int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT; | 64 | int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT; |
64 | int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS; | 65 | int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS; |
65 | unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */ | 66 | unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */ |
@@ -404,13 +404,45 @@ struct address_space *page_mapping(struct page *page) | |||
404 | return mapping; | 404 | return mapping; |
405 | } | 405 | } |
406 | 406 | ||
407 | int overcommit_ratio_handler(struct ctl_table *table, int write, | ||
408 | void __user *buffer, size_t *lenp, | ||
409 | loff_t *ppos) | ||
410 | { | ||
411 | int ret; | ||
412 | |||
413 | ret = proc_dointvec(table, write, buffer, lenp, ppos); | ||
414 | if (ret == 0 && write) | ||
415 | sysctl_overcommit_kbytes = 0; | ||
416 | return ret; | ||
417 | } | ||
418 | |||
419 | int overcommit_kbytes_handler(struct ctl_table *table, int write, | ||
420 | void __user *buffer, size_t *lenp, | ||
421 | loff_t *ppos) | ||
422 | { | ||
423 | int ret; | ||
424 | |||
425 | ret = proc_doulongvec_minmax(table, write, buffer, lenp, ppos); | ||
426 | if (ret == 0 && write) | ||
427 | sysctl_overcommit_ratio = 0; | ||
428 | return ret; | ||
429 | } | ||
430 | |||
407 | /* | 431 | /* |
408 | * Committed memory limit enforced when OVERCOMMIT_NEVER policy is used | 432 | * Committed memory limit enforced when OVERCOMMIT_NEVER policy is used |
409 | */ | 433 | */ |
410 | unsigned long vm_commit_limit(void) | 434 | unsigned long vm_commit_limit(void) |
411 | { | 435 | { |
412 | return ((totalram_pages - hugetlb_total_pages()) | 436 | unsigned long allowed; |
413 | * sysctl_overcommit_ratio / 100) + total_swap_pages; | 437 | |
438 | if (sysctl_overcommit_kbytes) | ||
439 | allowed = sysctl_overcommit_kbytes >> (PAGE_SHIFT - 10); | ||
440 | else | ||
441 | allowed = ((totalram_pages - hugetlb_total_pages()) | ||
442 | * sysctl_overcommit_ratio / 100); | ||
443 | allowed += total_swap_pages; | ||
444 | |||
445 | return allowed; | ||
414 | } | 446 | } |
415 | 447 | ||
416 | 448 | ||