mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
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. [[email protected]: coding-style fixes] [[email protected]: fix nommu build] Signed-off-by: Jerome Marchand <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Alan Cox <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
aec6a8889a
commit
49f0ce5f92
8 changed files with 70 additions and 8 deletions
36
mm/util.c
36
mm/util.c
|
|
@ -404,13 +404,45 @@ struct address_space *page_mapping(struct page *page)
|
|||
return mapping;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* Committed memory limit enforced when OVERCOMMIT_NEVER policy is used
|
||||
*/
|
||||
unsigned long vm_commit_limit(void)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue