• Thomas Hellstrom (VMware)'s avatar
    mm: Split huge pages on write-notify or COW · 327e9fd4
    Thomas Hellstrom (VMware) authored
    The functions wp_huge_pmd() and wp_huge_pud() currently relies on the
    huge_fault() callback to split huge page table entries if needed.
    However for module users that requires export of the split_huge_xxx()
    functionality which may be undesired. Instead split pre-existing huge
    page-table entries on VM_FAULT_FALLBACK return.
    
    We currently only do COW and write-notify on the PTE level, so if the
    huge_fault() handler returns VM_FAULT_FALLBACK on wp faults,
    split the huge pages and page-table entries. Also do this for huge PUDs
    if there is no huge_fault() handler and the vma is not anonymous, similar
    to how it's done for PMDs.
    
    Note that fs/dax.c still does the splitting in the huge_fault() handler,
    but as huge_fault() A follow-up patch can remove the dax.c split_huge_pmd()
    if needed.
    
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
    Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
    Cc: Ralph Campbell <rcampbell@nvidia.com>
    Cc: "Jérôme Glisse" <jglisse@redhat.com>
    Cc: "Christian König" <christian.koenig@amd.com>
    Cc: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: default avatarThomas Hellstrom (VMware) <thomas_os@shipmail.org>
    Acked-by: default avatarChristian König <christian.koenig@amd.com>
    Acked-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    327e9fd4
memory.c 131 KB