mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
mm: factor commit limit calculation
The same calculation is currently done in three differents places. Factor that code so future changes has to be made at only one place. [[email protected]: uninline vm_commit_limit()] Signed-off-by: Jerome Marchand <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Michal Hocko <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
715ea41e60
commit
00619bcc44
5 changed files with 18 additions and 9 deletions
13
mm/util.c
13
mm/util.c
|
|
@ -7,6 +7,9 @@
|
|||
#include <linux/security.h>
|
||||
#include <linux/swap.h>
|
||||
#include <linux/swapops.h>
|
||||
#include <linux/mman.h>
|
||||
#include <linux/hugetlb.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
|
@ -398,6 +401,16 @@ struct address_space *page_mapping(struct page *page)
|
|||
return mapping;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
/* Tracepoints definitions. */
|
||||
EXPORT_TRACEPOINT_SYMBOL(kmalloc);
|
||||
EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc);
|
||||
|
|
|
|||
Loading…
Reference in a new issue