mm: stricter check on THP migration entry
Subsystems (2)
PATCH 1/1 mm: stricter check on THP migration entry
When VM_BUG_ON check for THP migration entry, the existing code only check thp_migration_supported case, but not for !thp_migration_supported case. If !thp_migration_supported() and !pmd_present(), the original code may dead loop in theory. To make the VM_BUG_ON check more consistent, we need to catch both cases.
--- mm/memory.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
mm/memory.c +3 -4
@@ -5043,10 +5043,9 @@ static vm_fault_t __handle_mm_fault(struct vm_area_struct *vma,barrier ();if (unlikely (is_swap_pmd (vmf.orig_pmd))) { -VM_BUG_ON (thp_migration_supported () && - !is_pmd_migration_entry (vmf.orig_pmd)); -if (is_pmd_migration_entry (vmf.orig_pmd)) -pmd_migration_entry_wait (mm, vmf.pmd); +VM_BUG_ON (!thp_migration_supported () || + !is_pmd_migration_entry (vmf.orig_pmd)); +pmd_migration_entry_wait (mm, vmf.pmd);return 0 ; }if (pmd_trans_huge (vmf.orig_pmd) ||pmd_devmap (vmf.orig_pmd)) {
Signature · 1 line
2.23.0
Quoted 5 lines · Miaohe Lin
When
VM_BUG_ONcheck for THP migration entry, the existing code only checkthp_migration_supportedcase, but not for !thp_migration_supported case. If !thp_migration_supported() and !pmd_present(), the original code may dead loop in theory. To make theVM_BUG_ONcheck more consistent, we need to catch both cases.
This patch makes no sense to me.
Quoted 27 lines
Signed-off-by Miaohe Lin <[email protected]>--- mm/memory.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)mm/memory.c +3
-4@@ -5043,10 +5043,9 @@ static vm_fault_t __handle_mm_fault(struct vm_area_struct *vma,barrier ();if (unlikely (is_swap_pmd (vmf.orig_pmd))) { -VM_BUG_ON (thp_migration_supported () && - !is_pmd_migration_entry (vmf.orig_pmd)); -if (is_pmd_migration_entry (vmf.orig_pmd)) -pmd_migration_entry_wait (mm, vmf.pmd); +VM_BUG_ON (!thp_migration_supported () || + !is_pmd_migration_entry (vmf.orig_pmd)); +pmd_migration_entry_wait (mm, vmf.pmd);return 0 ; }if (pmd_trans_huge (vmf.orig_pmd) ||pmd_devmap (vmf.orig_pmd)) {Signature · 1 line
2.23.0
Quoted 8 lines · Matthew Wilcox
Quoted 5 lines · Miaohe Lin
When
VM_BUG_ONcheck for THP migration entry, the existing code only checkthp_migration_supportedcase, but not for !thp_migration_supported case. If !thp_migration_supported() and !pmd_present(), the original code may dead loop in theory. To make theVM_BUG_ONcheck more consistent, we need to catch both cases.This patch makes no sense to me.
Could you please explain it more? This patch is inspired by below commit indeed:28b0ee3fb350 ("mm/gup.c: stricter check on THP migration entry during follow_pmd_mask").
Thanks.
Quoted 31 lines
Quoted 28 lines
Signed-off-by Miaohe Lin <[email protected]>--- mm/memory.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)mm/memory.c +3
-4@@ -5043,10 +5043,9 @@ static vm_fault_t __handle_mm_fault(struct vm_area_struct *vma,barrier ();if (unlikely (is_swap_pmd (vmf.orig_pmd))) { -VM_BUG_ON (thp_migration_supported () && - !is_pmd_migration_entry (vmf.orig_pmd)); -if (is_pmd_migration_entry (vmf.orig_pmd)) -pmd_migration_entry_wait (mm, vmf.pmd); +VM_BUG_ON (!thp_migration_supported () || + !is_pmd_migration_entry (vmf.orig_pmd)); +pmd_migration_entry_wait (mm, vmf.pmd);return 0 ; }if (pmd_trans_huge (vmf.orig_pmd) ||pmd_devmap (vmf.orig_pmd)) {Signature · 1 line
2.23.0.