linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: xf2017140389@gmail.com
To: akpm@linux-foundation.org, christian@brauner.io
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	zhangcang@xiaomi.com, wangju@xiaomi.com, surenb@google.com,
	fangzhirong@xiaomi.com, xiaofeng <xiaofeng5@xiaomi.com>
Subject: [PATCH] mm/madvise: break reclaim when lock race
Date: Tue,  7 Dec 2021 11:22:02 +0800	[thread overview]
Message-ID: <20211207032202.6022-1-xiaofeng5@xiaomi.com> (raw)

From: xiaofeng <xiaofeng5@xiaomi.com>

When the process_madvise() system call is being used, it takes mmap_lock and blocks the application from allocating memory, leading to unreasonable delays. This patchset aims to fix it.

Signed-off-by: xiaofeng <xiaofeng5@xiaomi.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



             reply	other threads:[~2021-12-07  3:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-07  3:22 xf2017140389 [this message]
2021-12-07 17:04 ` Suren Baghdasaryan
2021-12-07 17:20 ` Matthew Wilcox
  -- strict thread matches above, loose matches on Subject: below --
2021-12-06 14:55 xf2017140389

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211207032202.6022-1-xiaofeng5@xiaomi.com \
    --to=xf2017140389@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=christian@brauner.io \
    --cc=fangzhirong@xiaomi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=surenb@google.com \
    --cc=wangju@xiaomi.com \
    --cc=xiaofeng5@xiaomi.com \
    --cc=zhangcang@xiaomi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox