summaryrefslogtreecommitdiffstats
path: root/mm/huge_memory.c
diff options
context:
space:
mode:
authorMiaohe Lin <linmiaohe@huawei.com>2022-07-04 21:22:00 +0800
committerakpm <akpm@linux-foundation.org>2022-07-17 17:14:46 -0700
commitcea3332808f92c0120fb0b157c56d48639e0c713 (patch)
tree52a10515ade5a20f50b347bd26ea2d842d472147 /mm/huge_memory.c
parentd764afedfb04e4eaf04b175c5ac54ffa4a423070 (diff)
downloadlinux-cea3332808f92c0120fb0b157c56d48639e0c713.tar.bz2
mm/huge_memory: comment the subtly logic in __split_huge_pmd
It's dangerous and wrong to call page_folio(pmd_page(*pmd)) when pmd isn't present. But the caller guarantees pmd is present when folio is set. So we should be safe here. Add comment to make it clear. Link: https://lkml.kernel.org/r/20220704132201.14611-16-linmiaohe@huawei.com Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Muchun Song <songmuchun@bytedance.com> Cc: Yang Shi <shy828301@gmail.com> Cc: Zach O'Keefe <zokeefe@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/huge_memory.c')
-rw-r--r--mm/huge_memory.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index f3f3e4b5a3ab..17e392ec9eb3 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2235,6 +2235,10 @@ void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
if (pmd_trans_huge(*pmd) || pmd_devmap(*pmd) ||
is_pmd_migration_entry(*pmd)) {
+ /*
+ * It's safe to call pmd_page when folio is set because it's
+ * guaranteed that pmd is present.
+ */
if (folio && folio != page_folio(pmd_page(*pmd)))
goto out;
__split_huge_pmd_locked(vma, pmd, range.start, freeze);