From: "Zach O'Keefe" <zokeefe@google.com>
To: Andrew Morton <akpm@linux-foundation.org>, linux-mm@kvack.org
Cc: Hugh Dickins <hughd@google.com>, Yang Shi <shy828301@gmail.com>,
"Zach O'Keefe" <zokeefe@google.com>
Subject: [PATCH mm-unstable] Revert "mm/khugepaged: remove redundant transhuge_vma_suitable() check"
Date: Wed, 20 Jul 2022 04:13:18 -0700 [thread overview]
Message-ID: <20220720111318.1831708-1-zokeefe@google.com> (raw)
A pmd should not cross a VMA boundary, which is normally enforced by
vma_adjust_trans_huge(), and assumed by e.g. __split_huge_pmd_locked().
In this regard, the transhuge_vma_suitable() check in
hugepage_vma_check() is not redundant with the transhuge_vma_suitable()
check previously in hugepage_vma_revalidate().
The former validates the VMA itself, and checks that *some* memory
in the VMA is suitable to collapse while the latter validates if
collapsing at a specific address is suitable. By removing the check on
the faulting address, we've inadvertently allowed collapse of a pmd that
can cross vma->vm_end. Revert this change.
Fixes: 143776e7512e ("mm/khugepaged: remove redundant transhuge_vma_suitable() check")
Signed-off-by: Zach O'Keefe <zokeefe@google.com>
---
Apologies, Andrew. I think you've put the series description into this
first patch (thank you). Do you mind moving it into the next patch in the
series,
"mm: khugepaged: don't carry huge page to the next loop for !CONFIG_NUMA"?
Note that the "mm: userspace hugepage collapse, v7" series doesn't actually
depend on this patch, it was just a cleanup (and thus perhaps I shouldn't have
included it in the series in the first place).
---
mm/khugepaged.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 2db6d0dd2981..69990dacde14 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -855,6 +855,8 @@ static int hugepage_vma_revalidate(struct mm_struct *mm, unsigned long address,
if (!vma)
return SCAN_VMA_NULL;
+ if (!transhuge_vma_suitable(vma, address))
+ return SCAN_ADDRESS_RANGE;
if (!hugepage_vma_check(vma, vma->vm_flags, false, false,
cc->is_khugepaged))
return SCAN_VMA_CHECK;
--
2.37.0.170.g444d1eabd0-goog
next reply other threads:[~2022-07-20 11:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-20 11:13 Zach O'Keefe [this message]
2022-07-20 17:22 ` [PATCH mm-unstable] Revert "mm/khugepaged: remove redundant transhuge_vma_suitable() check" Yang Shi
2022-07-20 18:42 ` Zach O'Keefe
2022-07-20 20:28 ` Hugh Dickins
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=20220720111318.1831708-1-zokeefe@google.com \
--to=zokeefe@google.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=linux-mm@kvack.org \
--cc=shy828301@gmail.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).