Re: [PATCHv9-rebased2 11/37] mm: introduce do_set_pmd()

From: Kirill A. Shutemov
Date: Thu Jun 16 2016 - 06:17:53 EST


On Thu, Jun 16, 2016 at 05:15:22PM +0800, Hillf Danton wrote:
> > +
> > +static int do_set_pmd(struct fault_env *fe, struct page *page)
> > +{
> > + struct vm_area_struct *vma = fe->vma;
> > + bool write = fe->flags & FAULT_FLAG_WRITE;
> > + unsigned long haddr = fe->address & HPAGE_PMD_MASK;
> > + pmd_t entry;
> > + int i, ret;
> > +
> > + if (!transhuge_vma_suitable(vma, haddr))
> > + return VM_FAULT_FALLBACK;
> > +
> > + ret = VM_FAULT_FALLBACK;
> > + page = compound_head(page);
> > +
> > + fe->ptl = pmd_lock(vma->vm_mm, fe->pmd);
> > + if (unlikely(!pmd_none(*fe->pmd)))
> > + goto out;
>
> Can we reply to the caller that fault is handled correctly(by
> resetting ret to zero before jump)?

It's non necessary handled. It's handled only if the pmd if huge. If it
points to pte table, we need to check relevant pte entry.

If pmd is huge it will caught by pte_alloc_one_map() later.

--
Kirill A. Shutemov