linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: linux-mm@kvack.org
Subject: Consolidate calls to unmap_mapping_range in collapse_shmem
Date: Tue, 28 Mar 2017 19:15:03 -0700	[thread overview]
Message-ID: <20170329021503.GA7760@bombadil.infradead.org> (raw)


Is there a reason we call unmap_mapping_range() for a single page at a
time instead of the entire hugepage?  This is surely more efficient ...
but does it do something like increase the refcount on the page?

I suppose we might be able to skip all the calls to unmap_mapping_range()
if none of the pages are mapped, but surely anonymous pages are usually
mapped?

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 34bce5c308e3..2c686ba6a32b 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1396,17 +1396,11 @@ static void collapse_shmem(struct mm_struct *mm,
 			goto out_isolate_failed;
 		}
 
-		if (page_mapped(page))
-			unmap_mapping_range(mapping, index << PAGE_SHIFT,
-					PAGE_SIZE, 0);
-
 		spin_lock_irq(&mapping->tree_lock);
 
 		slot = radix_tree_lookup_slot(&mapping->page_tree, index);
 		VM_BUG_ON_PAGE(page != radix_tree_deref_slot_protected(slot,
 					&mapping->tree_lock), page);
-		VM_BUG_ON_PAGE(page_mapped(page), page);
-
 		/*
 		 * The page is expected to have page_count() == 3:
 		 *  - we hold a pin on it;
@@ -1472,6 +1466,9 @@ static void collapse_shmem(struct mm_struct *mm,
 		unsigned long flags;
 		struct zone *zone = page_zone(new_page);
 
+		unmap_mapping_range(mapping, start << PAGE_SHIFT,
+					HPAGE_PMD_SIZE, 0);
+
 		/*
 		 * Replacing old pages with new one has succeed, now we need to
 		 * copy the content and free old pages.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2017-03-29  2:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-29  2:15 Matthew Wilcox [this message]
2017-03-29 11:06 ` Kirill A. Shutemov

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=20170329021503.GA7760@bombadil.infradead.org \
    --to=willy@infradead.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