Skip to content

Commit 14c99d6

Browse files
jgowansakpm00
authored andcommitted
mm: split huge PUD on wp_huge_pud fallback
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. Link: https://lkml.kernel.org/r/[email protected] Fixes: 327e9fd ("mm: Split huge pages on write-notify or COW") Signed-off-by: James Gowans <[email protected]> Reviewed-by: Thomas Hellström <[email protected]> Cc: Christian König <[email protected]> Cc: Jan H. Schönherr <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 5924e6e commit 14c99d6

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

mm/memory.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4798,6 +4798,19 @@ static inline vm_fault_t wp_huge_pmd(struct vm_fault *vmf)
47984798

47994799
static vm_fault_t create_huge_pud(struct vm_fault *vmf)
48004800
{
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+
{
48014814
#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && \
48024815
defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD)
48034816
/* No support for anonymous transparent PUD pages yet */
@@ -4812,19 +4825,7 @@ static vm_fault_t create_huge_pud(struct vm_fault *vmf)
48124825
split:
48134826
/* COW or write-notify not handled on PUD level: split pud.*/
48144827
__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 */
48284829
return VM_FAULT_FALLBACK;
48294830
}
48304831

0 commit comments

Comments
 (0)