Currently the implementation will split the PUD when a fallback is taken inside the create_huge_pud function. This isn't where it should be done: the splitting should be done in wp_huge_pud, just like it's done for PMDs. Reason being that if a callback is taken during create, there is no PUD yet so nothing to split, whereas if a fallback is taken when encountering a write protection fault there is something to split. It looks like this was the original intention with the commit where the splitting was introduced, but somehow it got moved to the wrong place between v1 and v2 of the patch series. Rebase mistake perhaps.
Unified · Split
| @@ -4798,6 +4798,19 @@ static inline vm_fault_t wp_huge_pmd(struct vm_fault *vmf) · 4797 unmodified lines | ||
| 4798 | 4798 | |
| 4799 | 4799 | static vm_fault_t create_huge_pud(struct vm_fault *vmf) |
| 4800 | 4800 | { |
| 4801 | +#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && \ | |
| 4802 | + defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) | |
| 4803 | + /* No support for anonymous transparent PUD pages yet */ | |
| 4804 | + if (vma_is_anonymous(vmf->vma)) | |
| 4805 | + return VM_FAULT_FALLBACK; | |
| 4806 | + if (vmf->vma->vm_ops->huge_fault) | |
| 4807 | + return vmf->vma->vm_ops->huge_fault(vmf, PE_SIZE_PUD); | |
| 4808 | +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ | |
| 4809 | + return VM_FAULT_FALLBACK; | |
| 4810 | +} | |
| 4811 | + | |
| 4812 | +static vm_fault_t wp_huge_pud(struct vm_fault *vmf, pud_t orig_pud) | |
| 4813 | +{ | |
| 4801 | 4814 | #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && \ |
| 4802 | 4815 | defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) |
| 4803 | 4816 | /* No support for anonymous transparent PUD pages yet */ |
| @@ -4812,19 +4825,7 @@ static vm_fault_t create_huge_pud(struct vm_fault *vmf) · 8 unmodified lines | ||
| 4812 | 4825 | split: |
| 4813 | 4826 | /* COW or write-notify not handled on PUD level: split pud.*/ |
| 4814 | 4827 | __split_huge_pud(vmf->vma, vmf->pud, vmf->address); |
| 4815 | −#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ | |
| 4816 | − return VM_FAULT_FALLBACK; | |
| 4817 | −} | |
| 4818 | − | |
| 4819 | −static vm_fault_t wp_huge_pud(struct vm_fault *vmf, pud_t orig_pud) | |
| 4820 | −{ | |
| 4821 | −#ifdef CONFIG_TRANSPARENT_HUGEPAGE | |
| 4822 | − /* No support for anonymous transparent PUD pages yet */ | |
| 4823 | − if (vma_is_anonymous(vmf->vma)) | |
| 4824 | − return VM_FAULT_FALLBACK; | |
| 4825 | − if (vmf->vma->vm_ops->huge_fault) | |
| 4826 | − return vmf->vma->vm_ops->huge_fault(vmf, PE_SIZE_PUD); | |
| 4827 | −#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ | |
| 4828 | +#endif /* CONFIG_TRANSPARENT_HUGEPAGE && CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */ | |
| 4828 | 4829 | return VM_FAULT_FALLBACK; |
| 4829 | 4830 | } |
| 4830 | 4831 | |