LKML Archive mirror
 help / color / mirror / Atom feed
From: yanfei.xu@windriver.com
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] mm: khugepaged: check MMF_DISABLE_THP ahead of iterating over vmas
Date: Sun,  4 Apr 2021 23:33:11 +0800	[thread overview]
Message-ID: <20210404153311.1460106-3-yanfei.xu@windriver.com> (raw)
In-Reply-To: <20210404153311.1460106-1-yanfei.xu@windriver.com>

From: Yanfei Xu <yanfei.xu@windriver.com>

We could check MMF_DISABLE_THP ahead of iterating over all of vma.
Otherwise if some mm_struct contain a large number of vma, there will
be amounts meaningless cpu cycles cost.

BTW, drop an unnecessary cond_resched(), because there is a another
cond_resched() followed it and no consumed invocation between them.

Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
---
 mm/khugepaged.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 2efe1d0c92ed..c293ec4a94ea 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2094,6 +2094,8 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages,
 	 */
 	if (unlikely(!mmap_read_trylock(mm)))
 		goto breakouterloop_mmap_lock;
+	if (test_bit(MMF_DISABLE_THP, &mm->flags))
+		goto breakouterloop_mmap_lock;
 	if (likely(!khugepaged_test_exit(mm)))
 		vma = find_vma(mm, khugepaged_scan.address);
 
@@ -2101,7 +2103,6 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages,
 	for (; vma; vma = vma->vm_next) {
 		unsigned long hstart, hend;
 
-		cond_resched();
 		if (unlikely(khugepaged_test_exit(mm))) {
 			progress++;
 			break;
-- 
2.27.0


  parent reply	other threads:[~2021-04-04 15:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-04 15:33 [PATCH 0/2] mm: khugepaged: cleanup and a minor tuning in THP yanfei.xu
2021-04-04 15:33 ` [PATCH 1/2] mm: khugepaged: use macro to align addresses yanfei.xu
2021-04-04 15:33 ` yanfei.xu [this message]
2021-04-05 18:20   ` [PATCH 2/2] mm: khugepaged: check MMF_DISABLE_THP ahead of iterating over vmas Yang Shi
2021-04-06  2:51     ` Xu, Yanfei
2021-04-06  3:04       ` Xu, Yanfei
2021-04-06 21:04         ` Yang Shi

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=20210404153311.1460106-3-yanfei.xu@windriver.com \
    --to=yanfei.xu@windriver.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).