Skip to content

Commit cea3332

Browse files
MiaoheLinakpm00
authored andcommitted
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/[email protected] Signed-off-by: Miaohe Lin <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Muchun Song <[email protected]> Cc: Yang Shi <[email protected]> Cc: Zach O'Keefe <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent d764afe commit cea3332

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

mm/huge_memory.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,6 +2235,10 @@ void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
22352235

22362236
if (pmd_trans_huge(*pmd) || pmd_devmap(*pmd) ||
22372237
is_pmd_migration_entry(*pmd)) {
2238+
/*
2239+
* It's safe to call pmd_page when folio is set because it's
2240+
* guaranteed that pmd is present.
2241+
*/
22382242
if (folio && folio != page_folio(pmd_page(*pmd)))
22392243
goto out;
22402244
__split_huge_pmd_locked(vma, pmd, range.start, freeze);

0 commit comments

Comments
 (0)