]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm/huge_memory: comment the subtly logic in __split_huge_pmd
authorMiaohe Lin <linmiaohe@huawei.com>
Mon, 4 Jul 2022 13:22:00 +0000 (21:22 +0800)
committerakpm <akpm@linux-foundation.org>
Mon, 18 Jul 2022 00:14:46 +0000 (17:14 -0700)
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>
mm/huge_memory.c

index f3f3e4b5a3ab31bfa50eded14b8880b71121f66b..17e392ec9eb3ba3aa2471a792c1595c3c6c7e3cd 100644 (file)
@@ -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);