On Fri, Sep 13, 2013 at 04:06:15PM +0300, Kirill A. Shutemov wrote: > The basic idea is the same as with PTE level: the lock is embedded into > struct page of table's page. > > Split pmd page table lock only makes sense on big machines. > Let's say >= 32 CPUs for now. > > We can't use mm->pmd_huge_pte to store pgtables for THP, since we don't > take mm->page_table_lock anymore. Let's reuse page->lru of table's page > for that. Looks nice. > hugetlbfs hasn't converted to split locking: disable split locking if > hugetlbfs enabled. I don't think that we have to disable when hugetlbfs is enabled, because hugetlbfs code doesn't use huge_pmd_lockptr() or huge_pmd_lock(). > Signed-off-by: Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx> > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> > --- > include/linux/mm.h | 31 +++++++++++++++++++++++++++++++ > include/linux/mm_types.h | 5 +++++ > kernel/fork.c | 4 ++-- > mm/Kconfig | 10 ++++++++++ > 4 files changed, 48 insertions(+), 2 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index d2f8a50..5b3922d 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1294,13 +1294,44 @@ static inline void pgtable_page_dtor(struct page *page) > ((unlikely(pmd_none(*(pmd))) && __pte_alloc_kernel(pmd, address))? \ > NULL: pte_offset_kernel(pmd, address)) > > +#if USE_SPLIT_PMD_PTLOCKS > + > +static inline spinlock_t *huge_pmd_lockptr(struct mm_struct *mm, pmd_t *pmd) > +{ > + return &virt_to_page(pmd)->ptl; > +} > + > +static inline void pgtable_pmd_page_ctor(struct page *page) > +{ > + spin_lock_init(&page->ptl); > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE > + page->pmd_huge_pte = NULL; > +#endif > +} > + > +static inline void pgtable_pmd_page_dtor(struct page *page) > +{ > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE > + VM_BUG_ON(page->pmd_huge_pte); > +#endif > +} > + > +#define pmd_huge_pte(mm, pmd) (virt_to_page(pmd)->pmd_huge_pte) > > + > +#else > + > static inline spinlock_t *huge_pmd_lockptr(struct mm_struct *mm, pmd_t *pmd) > { > return &mm->page_table_lock; > } > > +static inline void pgtable_pmd_page_ctor(struct page *page) {} > +static inline void pgtable_pmd_page_dtor(struct page *page) {} > + > #define pmd_huge_pte(mm, pmd) ((mm)->pmd_huge_pte) > > +#endif > + > static inline spinlock_t *huge_pmd_lock(struct mm_struct *mm, pmd_t *pmd) > { > spinlock_t *ptl = huge_pmd_lockptr(mm, pmd); > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > index 1c64730..5706ddf 100644 > --- a/include/linux/mm_types.h > +++ b/include/linux/mm_types.h > @@ -24,6 +24,8 @@ > struct address_space; > > #define USE_SPLIT_PTE_PTLOCKS (NR_CPUS >= CONFIG_SPLIT_PTE_PTLOCK_CPUS) > +#define USE_SPLIT_PMD_PTLOCKS (USE_SPLIT_PTE_PTLOCKS && \ > + NR_CPUS >= CONFIG_SPLIT_PMD_PTLOCK_CPUS) > > /* > * Each physical page in the system has a struct page associated with > @@ -130,6 +132,9 @@ struct page { > > struct list_head list; /* slobs list of pages */ > struct slab *slab_page; /* slab fields */ > +#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && USE_SPLIT_PMD_PTLOCKS > + pgtable_t pmd_huge_pte; /* protected by page->ptl */ > +#endif > }; > > /* Remainder is not double word aligned */ Can we remove pmd_huge_pte from mm_struct when USE_SPLIT_PMD_PTLOCKS is true? Thanks, Naoya Horiguchi -- 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>