[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20211206145516.23760-1-xiaofeng5@xiaomi.com>
Date: Mon, 6 Dec 2021 22:55:16 +0800
From: xf2017140389@...il.com
To: akpm@...ux-foundation.org, christian@...uner.io
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
zhangcang@...omi.com, wangju@...omi.com, fangzhirong@...omi.com,
xiaofeng <xiaofeng5@...omi.com>
Subject: [PATCH] mm/madvise: break reclaim when lock race
From: xiaofeng <xiaofeng5@...omi.com>
In Android phones, the recycling thread is likely to hold the mmap_lock to reclaim the memory of the application When the top-App is switched to the background. Once the user switches the application to the top during the recycling process, there is a high possibility that the memory will be allocated due to the inability to obtain the lock, which may cause lag or other problem.
Signed-off-by: xiaofeng <xiaofeng5@...omi.com>
---
mm/madvise.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/madvise.c b/mm/madvise.c
index 8c927202bbe6..8f1e325873e0 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -322,6 +322,9 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
if (fatal_signal_pending(current))
return -EINTR;
+ if (mmap_lock_is_contended(mm))
+ return -EINTR;
+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
if (pmd_trans_huge(*pmd)) {
pmd_t orig_pmd;
--
2.17.1
Powered by blists - more mailing lists