On Tue, May 19, 2015 at 10:25:30AM +0200, Vlastimil Babka wrote: > On 04/23/2015 11:03 PM, Kirill A. Shutemov wrote: > >Original split_huge_page() combined two operations: splitting PMDs into > >tables of PTEs and splitting underlying compound page. This patch > >implements split_huge_pmd() which split given PMD without splitting > >other PMDs this page mapped with or underlying compound page. > > > >Without tail page refcounting, implementation of split_huge_pmd() is > >pretty straight-forward. > > > >Signed-off-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> > >Tested-by: Sasha Levin <sasha.levin@xxxxxxxxxx> > >--- > > include/linux/huge_mm.h | 11 ++++- > > mm/huge_memory.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++ > > 2 files changed, 118 insertions(+), 1 deletion(-) > > > >diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h > >index 0382230b490f..b7844c73b7db 100644 > >--- a/include/linux/huge_mm.h > >+++ b/include/linux/huge_mm.h > >@@ -94,7 +94,16 @@ extern unsigned long transparent_hugepage_flags; > > > > #define split_huge_page_to_list(page, list) BUILD_BUG() > > #define split_huge_page(page) BUILD_BUG() > >-#define split_huge_pmd(__vma, __pmd, __address) BUILD_BUG() > >+ > >+void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, > >+ unsigned long address); > >+ > >+#define split_huge_pmd(__vma, __pmd, __address) \ > >+ do { \ > >+ pmd_t *____pmd = (__pmd); \ > >+ if (unlikely(pmd_trans_huge(*____pmd))) \ > > Given that most of calls to split_huge_pmd() appear to be in > if (pmd_trans_huge(...)) branches, this unlikely() seems counter-productive. Fair enough. > >+void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, > >+ unsigned long address) > >+{ > >+ spinlock_t *ptl; > >+ struct mm_struct *mm = vma->vm_mm; > >+ unsigned long haddr = address & HPAGE_PMD_MASK; > >+ > >+ mmu_notifier_invalidate_range_start(mm, haddr, haddr + HPAGE_PMD_SIZE); > >+ ptl = pmd_lock(mm, pmd); > >+ if (likely(pmd_trans_huge(*pmd))) > > This likely is likely useless :) No, it's not. We check the pmd with pmd_trans_huge() under ptl for the first time. And __split_huge_pmd_locked() assumes pmd is huge. > >+ __split_huge_pmd_locked(vma, pmd, haddr); > >+ spin_unlock(ptl); > >+ mmu_notifier_invalidate_range_end(mm, haddr, haddr + HPAGE_PMD_SIZE); > >+} > >+ -- Kirill A. Shutemov -- 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>