From: Andrea Arcangeli <aarcange@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, Rik van Riel <riel@redhat.com>,
Johannes Weiner <jweiner@redhat.com>,
Hugh Dickins <hughd@google.com>, Mel Gorman <mgorman@suse.de>,
Petr Holasek <pholasek@redhat.com>
Subject: [PATCH] thp: avoid VM_BUG_ON page_count(page) false positives in __collapse_huge_page_copy
Date: Tue, 25 Sep 2012 20:11:18 +0200 [thread overview]
Message-ID: <1348596678-2768-2-git-send-email-aarcange@redhat.com> (raw)
In-Reply-To: <1348596678-2768-1-git-send-email-aarcange@redhat.com>
Use page_freeze_refs to prevent speculative pagecache lookups to
trigger the false positives, so we're still able to check the
page_count to be exact.
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
---
mm/huge_memory.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 1598708..7eca652 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1704,6 +1704,9 @@ void __khugepaged_exit(struct mm_struct *mm)
static void release_pte_page(struct page *page)
{
+#ifdef CONFIG_DEBUG_VM
+ page_unfreeze_refs(page, 2);
+#endif
/* 0 stands for page_is_file_cache(page) == false */
dec_zone_page_state(page, NR_ISOLATED_ANON + 0);
unlock_page(page);
@@ -1784,6 +1787,20 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
VM_BUG_ON(!PageLocked(page));
VM_BUG_ON(PageLRU(page));
+#ifdef CONFIG_DEBUG_VM
+ /*
+ * For the VM_BUG_ON check on page_count(page) in
+ * __collapse_huge_page_copy not to trigger false
+ * positives we've to prevent the speculative
+ * pagecache lookups too with page_freeze_refs. We
+ * could check for >= 2 instead but this provides for
+ * a more strict debugging behavior.
+ */
+ if (!page_freeze_refs(page, 2)) {
+ release_pte_pages(pte, _pte+1);
+ goto out;
+ }
+#endif
/* If there is no mapped pte young don't collapse the page */
if (pte_young(pteval) || PageReferenced(page) ||
mmu_notifier_test_young(vma->vm_mm, address))
@@ -1814,7 +1831,7 @@ static void __collapse_huge_page_copy(pte_t *pte, struct page *page,
src_page = pte_page(pteval);
copy_user_highpage(page, src_page, address, vma);
VM_BUG_ON(page_mapcount(src_page) != 1);
- VM_BUG_ON(page_count(src_page) != 2);
+ VM_BUG_ON(page_count(src_page) != 0);
release_pte_page(src_page);
/*
* ptl mostly unnecessary, but preempt has to
--
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>
next prev parent reply other threads:[~2012-09-25 18:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-25 18:11 [PATCH] thp: avoid VM_BUG_ON page_count(page) false positives in __collapse_huge_page_copy Andrea Arcangeli
2012-09-25 18:11 ` Andrea Arcangeli [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-09-28 12:35 Andrea Arcangeli
2012-09-28 15:14 ` Rik van Riel
2012-09-28 15:31 ` Johannes Weiner
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=1348596678-2768-2-git-send-email-aarcange@redhat.com \
--to=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=jweiner@redhat.com \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=pholasek@redhat.com \
--cc=riel@redhat.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;
as well as URLs for NNTP newsgroup(s).