Re: [PATCH V2 1/2] mm: Update generic gup implementation to handle hugepage directory

From: Andrea Arcangeli
Date: Mon Oct 27 2014 - 14:41:49 EST


Hi Aneesh,

On Mon, Oct 27, 2014 at 11:28:41PM +0530, Aneesh Kumar K.V wrote:
> VM_BUG_ON(address & ~HPAGE_PMD_MASK);
> if (pmd_trans_huge(*pmdp)) {
> pmd = pmdp_get_and_clear(vma->vm_mm, address, pmdp);
> } else {

The only problematic path that needs IPI is the below one yes.

> /*
> * khugepaged calls this for normal pmd
> */
> pmd = *pmdp;
> pmd_clear(pmdp);
> /*
> * Wait for all pending hash_page to finish. This is needed
> * in case of subpage collapse. When we collapse normal pages
> * to hugepage, we first clear the pmd, then invalidate all
> * the PTE entries. The assumption here is that any low level
> * page fault will see a none pmd and take the slow path that
> * will wait on mmap_sem. But we could very well be in a
> * hash_page with local ptep pointer value. Such a hash page
> * can result in adding new HPTE entries for normal subpages.
> * That means we could be modifying the page content as we
> * copy them to a huge page. So wait for parallel hash_page
> * to finish before invalidating HPTE entries. We can do this
> * by sending an IPI to all the cpus and executing a dummy
> * function there.
> */
> kick_all_cpus_sync();
>
> We already do an IPI for ppc64.

Agreed, ppc64 is already covered.

sparc/arm seem to be using the generic pmdp_clear_flush implementation
instead, which just calls flush_tlb_range, so perhaps they aren't.

As above, the IPIs are only needed if the *pmd is not transhuge.

Thanks,
Andrea
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/