Re: RFC: Cleanup / small fixes to hugetlb fault handling

'David Gibson'
2005-10-27T00:05:04Z

On Wed, Oct 26, 2005 at 11:44:52AM -0700, Chen, Kenneth W wrote:
> David Gibson wrote on Tuesday, October 25, 2005 7:49 PM
> > +int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
> > + unsigned long address, int write_access)
> > +{
> > + pte_t *ptep;
> > + pte_t entry;
> > +
> > + ptep = huge_pte_alloc(mm, address);
> > + if (! ptep)
> > + /* OOM */
> > + return VM_FAULT_SIGBUS;
> > +
> > + entry = *ptep;
> > +
> > + if (pte_none(entry))
> > + return hugetlb_no_page(mm, vma, address, ptep);
> > +
> > + /* we could get here if another thread instantiated the pte
> > + * before the test above */
> > +
> > + return VM_FAULT_SIGBUS;
> > }
>
> Are you sure about the last return? Looks like a typo to me, if *ptep
> is present, it should return VM_FAULT_MINOR.

Oops, yes, thinko. Corrected patch shortly.

> But the bigger question is: don't you need some lock when checking *ptep?

No, I'm pretty sure that's ok. In a sense, the test here is only an
optimization: we recheck the pte with lock held in hugetlb_no_page()
before attempting the set_pte_at().