From 271ccd30184c3e0c831b57fc3f204a45f3feeb32 Mon Sep 17 00:00:00 2001 From: Chris Goldsworthy Date: Sat, 25 Jan 2020 16:37:26 -0800 Subject: [PATCH 1/4] defconfig: Enable userspace low memory killer for Lahaina Enable support for a userspace low memory killer and associated debug options. Change-Id: If730f1634e39b516e00b29f86260b720c33706d4 Signed-off-by: Chris Goldsworthy --- arch/arm64/configs/vendor/lahaina_QGKI.config | 1 + arch/arm64/configs/vendor/lahaina_debug.config | 2 ++ 2 files changed, 3 insertions(+) diff --git a/arch/arm64/configs/vendor/lahaina_QGKI.config b/arch/arm64/configs/vendor/lahaina_QGKI.config index c100ff72d0b9..8a6891eb3678 100644 --- a/arch/arm64/configs/vendor/lahaina_QGKI.config +++ b/arch/arm64/configs/vendor/lahaina_QGKI.config @@ -114,3 +114,4 @@ CONFIG_CRYPTO_DEV_QCRYPTO=y CONFIG_CRYPTO_DEV_QCEDEV=y CONFIG_THERMAL_TSENS=y CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y +CONFIG_HAVE_USERSPACE_LOW_MEMORY_KILLER=y diff --git a/arch/arm64/configs/vendor/lahaina_debug.config b/arch/arm64/configs/vendor/lahaina_debug.config index f55e0ffeb231..2a86ea9e3851 100644 --- a/arch/arm64/configs/vendor/lahaina_debug.config +++ b/arch/arm64/configs/vendor/lahaina_debug.config @@ -55,3 +55,5 @@ CONFIG_SLIMBUS_MSM_NGD=y CONFIG_QCOM_SMCINVOKE=y CONFIG_MSM_DEBUGCC_LAHAINA=y CONFIG_QRTR_MHI=y +CONFIG_DEBUG_PANIC_ON_OOM=y +# CONFIG_USB_F_FS_IPC_LOGGING is not set From 44783e7f43b1190ccf6656f7de9456aec0dd6c2c Mon Sep 17 00:00:00 2001 From: Charan Teja Reddy Date: Fri, 9 Aug 2019 19:26:04 +0530 Subject: [PATCH 2/4] mm: oom: enable the sysctl_reap_mem_on_sigkill by default Enable the reaping of memory on a sigkill by default. This helps in faster releasing of memory pages to buddy. Change-Id: I90a508e6d16099527991674f6b4efdc55f415c59 Signed-off-by: Charan Teja Reddy Signed-off-by: Chris Goldsworthy --- mm/oom_kill.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 1b076aa6a1e6..3b522b9b2aca 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -56,7 +56,7 @@ int sysctl_panic_on_oom = IS_ENABLED(CONFIG_DEBUG_PANIC_ON_OOM) ? 2 : 0; int sysctl_oom_kill_allocating_task; int sysctl_oom_dump_tasks = 1; -int sysctl_reap_mem_on_sigkill; +int sysctl_reap_mem_on_sigkill = 1; /* * Serializes oom killer invocations (out_of_memory()) from all contexts to From ed69314eaf21fd6f6f83f8e987914a12c386716d Mon Sep 17 00:00:00 2001 From: Prakash Gupta Date: Wed, 6 Mar 2019 14:08:08 +0530 Subject: [PATCH 3/4] mm, oom: check LMK enabled for pagefault_out_of_memory() Rely on LMK to reclaim memory and avoid OOM, when out of memory condition is detected in a pagefault. pagefault_out_of_memory() may be called due to commit d1b75390beb8 ("mm: reduce the time spend by killed tasks in alloc path"), which bails out from alloc_pages_slowpath() if the current task has been killed. Change-Id: Icfdaa51d7cfb0dfe9a665bcff23357101b15f421 Signed-off-by: Prakash Gupta Signed-off-by: Chris Goldsworthy --- mm/oom_kill.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 3b522b9b2aca..b6783179e9b2 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -1177,6 +1177,10 @@ void pagefault_out_of_memory(void) .order = 0, }; + if (IS_ENABLED(CONFIG_HAVE_LOW_MEMORY_KILLER) || + IS_ENABLED(CONFIG_HAVE_USERSPACE_LOW_MEMORY_KILLER)) + return; + if (mem_cgroup_oom_synchronize(true)) return; From c0580dc24cf0c04c586062069580d8498e24c427 Mon Sep 17 00:00:00 2001 From: Charan Teja Reddy Date: Mon, 30 Sep 2019 16:57:29 +0530 Subject: [PATCH 4/4] mm: set the watermark_boost before updating the low and high wmarks Updating the zone watermarks by any means, like extra_free_kbytes, min_free_kbytes, water_mark_scale_factor, when boost_watermark(zone) is set can result into the higher water_mark_low|min as the macro min_wmark_pages returns by adding the zone->watermark_boost. Set this to Zero early. Change-Id: I5e3edd1798e46974f3df34ef750f9d08b8ff35f4 Signed-off-by: Charan Teja Reddy Signed-off-by: Chris Goldsworthy --- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3f62feb6dad5..4abaae89ad8c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7896,11 +7896,11 @@ static void __setup_per_zone_wmarks(void) mult_frac(zone_managed_pages(zone), watermark_scale_factor, 10000)); + zone->watermark_boost = 0; zone->_watermark[WMARK_LOW] = min_wmark_pages(zone) + low + tmp; zone->_watermark[WMARK_HIGH] = min_wmark_pages(zone) + low + tmp * 2; - zone->watermark_boost = 0; spin_unlock_irqrestore(&zone->lock, flags); }