Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932103Ab3IMPqe (ORCPT ); Fri, 13 Sep 2013 11:46:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12605 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755983Ab3IMPqc (ORCPT ); Fri, 13 Sep 2013 11:46:32 -0400 Date: Fri, 13 Sep 2013 11:45:36 -0400 From: Naoya Horiguchi To: "Kirill A. Shutemov" Cc: Alex Thorlton , Ingo Molnar , Andrew Morton , "Eric W . Biederman" , "Paul E . McKenney" , Al Viro , Andi Kleen , Andrea Arcangeli , Dave Hansen , Dave Jones , David Howells , Frederic Weisbecker , Johannes Weiner , Kees Cook , Mel Gorman , Michael Kerrisk , Oleg Nesterov , Peter Zijlstra , Rik van Riel , Robin Holt , Sedat Dilek , Srikar Dronamraju , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-mm@kvack.org Message-ID: <1379087136-kk1xxduo-mutt-n-horiguchi@ah.jp.nec.com> In-Reply-To: <1379077576-2472-9-git-send-email-kirill.shutemov@linux.intel.com> References: <20130910074748.GA2971@gmail.com> <1379077576-2472-1-git-send-email-kirill.shutemov@linux.intel.com> <1379077576-2472-9-git-send-email-kirill.shutemov@linux.intel.com> Subject: Re: [PATCH 8/9] mm: implement split page table lock for PMD level Mime-Version: 1.0 Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Mutt-Fcc: ~/Maildir/sent/ User-Agent: Mutt 1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3632 Lines: 111 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 > Signed-off-by: Kirill A. Shutemov > --- > 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 from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/