> > From: Mike Kravetz <mike.kravetz@xxxxxxxxxx> > > When processing a hugetlb fault for no page present, check the vma to > determine if faults are to be handled via userfaultfd. If so, drop the > hugetlb_fault_mutex and call handle_userfault(). > > Signed-off-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx> > Signed-off-by: Andrea Arcangeli <aarcange@xxxxxxxxxx> > --- Acked-by: Hillf Danton <hillf.zj@xxxxxxxxxxxxxxx> > mm/hugetlb.c | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index baf7fd4..7247f8c 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -32,6 +32,7 @@ > #include <linux/hugetlb.h> > #include <linux/hugetlb_cgroup.h> > #include <linux/node.h> > +#include <linux/userfaultfd_k.h> > #include "internal.h" > > int hugepages_treat_as_movable; > @@ -3589,6 +3590,38 @@ static int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma, > size = i_size_read(mapping->host) >> huge_page_shift(h); > if (idx >= size) > goto out; > + > + /* > + * Check for page in userfault range > + */ > + if (userfaultfd_missing(vma)) { > + u32 hash; > + struct fault_env fe = { > + .vma = vma, > + .address = address, > + .flags = flags, > + /* > + * Hard to debug if it ends up being > + * used by a callee that assumes > + * something about the other > + * uninitialized fields... same as in > + * memory.c > + */ > + }; > + > + /* > + * hugetlb_fault_mutex must be dropped before > + * handling userfault. Reacquire after handling > + * fault to make calling code simpler. > + */ > + hash = hugetlb_fault_mutex_hash(h, mm, vma, mapping, > + idx, address); > + mutex_unlock(&hugetlb_fault_mutex_table[hash]); > + ret = handle_userfault(&fe, VM_UFFD_MISSING); > + mutex_lock(&hugetlb_fault_mutex_table[hash]); > + goto out; > + } > + > page = alloc_huge_page(vma, address, 0); > if (IS_ERR(page)) { > ret = PTR_ERR(page); > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>