diff options
Diffstat (limited to 'mm/memory.c')
-rw-r--r-- | mm/memory.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/mm/memory.c b/mm/memory.c index 2bf9e110437c..1b7dc662bf9f 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -3486,6 +3486,7 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma, | |||
3486 | if (unlikely(is_vm_hugetlb_page(vma))) | 3486 | if (unlikely(is_vm_hugetlb_page(vma))) |
3487 | return hugetlb_fault(mm, vma, address, flags); | 3487 | return hugetlb_fault(mm, vma, address, flags); |
3488 | 3488 | ||
3489 | retry: | ||
3489 | pgd = pgd_offset(mm, address); | 3490 | pgd = pgd_offset(mm, address); |
3490 | pud = pud_alloc(mm, pgd, address); | 3491 | pud = pud_alloc(mm, pgd, address); |
3491 | if (!pud) | 3492 | if (!pud) |
@@ -3499,13 +3500,24 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma, | |||
3499 | pmd, flags); | 3500 | pmd, flags); |
3500 | } else { | 3501 | } else { |
3501 | pmd_t orig_pmd = *pmd; | 3502 | pmd_t orig_pmd = *pmd; |
3503 | int ret; | ||
3504 | |||
3502 | barrier(); | 3505 | barrier(); |
3503 | if (pmd_trans_huge(orig_pmd)) { | 3506 | if (pmd_trans_huge(orig_pmd)) { |
3504 | if (flags & FAULT_FLAG_WRITE && | 3507 | if (flags & FAULT_FLAG_WRITE && |
3505 | !pmd_write(orig_pmd) && | 3508 | !pmd_write(orig_pmd) && |
3506 | !pmd_trans_splitting(orig_pmd)) | 3509 | !pmd_trans_splitting(orig_pmd)) { |
3507 | return do_huge_pmd_wp_page(mm, vma, address, | 3510 | ret = do_huge_pmd_wp_page(mm, vma, address, pmd, |
3508 | pmd, orig_pmd); | 3511 | orig_pmd); |
3512 | /* | ||
3513 | * If COW results in an oom, the huge pmd will | ||
3514 | * have been split, so retry the fault on the | ||
3515 | * pte for a smaller charge. | ||
3516 | */ | ||
3517 | if (unlikely(ret & VM_FAULT_OOM)) | ||
3518 | goto retry; | ||
3519 | return ret; | ||
3520 | } | ||
3509 | return 0; | 3521 | return 0; |
3510 | } | 3522 | } |
3511 | } | 3523 | } |