From d97c09c1531f4a6c427a33f6d6bf83d1cc1f8098 Mon Sep 17 00:00:00 2001 From: Vijayanand Jitta Date: Tue, 10 Apr 2018 16:27:47 -0700 Subject: [PATCH] mm: treat indirectly reclaimable memory as free in overcommit logic Indirectly reclaimable memory can consume a significant part of total memory and it's actually reclaimable (it will be released under actual memory pressure).This patch considers it as free in overcommit logic. This patch is referenced from commit d79f7aa496fc ("mm: treat indirectly reclaimable memory as free in overcommit logic") on upstream, as node based vmstat global_node_page_state is not present zone based vmstat global_page_state is used instead. Change-Id: I9af71c566c83e24cd12e7653782b1898ccc7d680 Signed-off-by: Vijayanand Jitta --- mm/mmap.c | 7 +++++++ mm/nommu.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/mm/mmap.c b/mm/mmap.c index 2339b533f4b2..5457c5f4935b 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -205,6 +205,13 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin) */ free += global_page_state(NR_SLAB_RECLAIMABLE); + /* + * Part of the kernel memory, which can be released + * under memory pressure. + */ + free += global_page_state( + NR_INDIRECTLY_RECLAIMABLE_BYTES) >> PAGE_SHIFT; + /* * Leave reserved pages. The pages are not for anonymous pages. */ diff --git a/mm/nommu.c b/mm/nommu.c index 92be862c859b..8d75e425c21c 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -1879,6 +1879,13 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin) */ free += global_page_state(NR_SLAB_RECLAIMABLE); + /* + * Part of the kernel memory, which can be released + * under memory pressure. + */ + free += global_page_state( + NR_INDIRECTLY_RECLAIMABLE_BYTES) >> PAGE_SHIFT; + /* * Leave reserved pages. The pages are not for anonymous pages. */