From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
Mel Gorman <mgorman@suse.de>, Andi Kleen <andi@firstfloor.org>,
Michal Hocko <mhocko@suse.cz>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Rik van Riel <riel@redhat.com>,
Andrea Arcangeli <aarcange@redhat.com>,
kirill.shutemov@linux.intel.com,
Alex Thorlton <athorlton@sgi.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] hugetlbfs: support split page table lock
Date: Thu, 05 Sep 2013 14:48:18 +0530 [thread overview]
Message-ID: <87d2onwrs5.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <1378312330-afoa3r2y-mutt-n-horiguchi@ah.jp.nec.com>
Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> writes:
> Hi Aneesh,
>
> On Wed, Sep 04, 2013 at 12:43:19PM +0530, Aneesh Kumar K.V wrote:
>> Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> writes:
>>
>> > Currently all of page table handling by hugetlbfs code are done under
>> > mm->page_table_lock. So when a process have many threads and they heavily
>> > access to the memory, lock contention happens and impacts the performance.
>> >
>> > This patch makes hugepage support split page table lock so that we use
>> > page->ptl of the leaf node of page table tree which is pte for normal pages
>> > but can be pmd and/or pud for hugepages of some architectures.
>> >
>> > ChangeLog v2:
>> > - add split ptl on other archs missed in v1
>> >
>> > Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
>> > ---
>> > arch/powerpc/mm/hugetlbpage.c | 6 ++-
>> > arch/tile/mm/hugetlbpage.c | 6 ++-
>> > include/linux/hugetlb.h | 20 ++++++++++
>> > mm/hugetlb.c | 92 ++++++++++++++++++++++++++-----------------
>> > mm/mempolicy.c | 5 ++-
>> > mm/migrate.c | 4 +-
>> > mm/rmap.c | 2 +-
>> > 7 files changed, 90 insertions(+), 45 deletions(-)
>> >
>> > diff --git v3.11-rc3.orig/arch/powerpc/mm/hugetlbpage.c v3.11-rc3/arch/powerpc/mm/hugetlbpage.c
>> > index d67db4b..7e56cb7 100644
>> > --- v3.11-rc3.orig/arch/powerpc/mm/hugetlbpage.c
>> > +++ v3.11-rc3/arch/powerpc/mm/hugetlbpage.c
>> > @@ -124,6 +124,7 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
>> > {
>> > struct kmem_cache *cachep;
>> > pte_t *new;
>> > + spinlock_t *ptl;
>> >
>> > #ifdef CONFIG_PPC_FSL_BOOK3E
>> > int i;
>> > @@ -141,7 +142,8 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
>> > if (! new)
>> > return -ENOMEM;
>> >
>> > - spin_lock(&mm->page_table_lock);
>> > + ptl = huge_pte_lockptr(mm, new);
>> > + spin_lock(ptl);
>>
>>
>> Are you sure we can do that for ppc ?
>> new = kmem_cache_zalloc(cachep, GFP_KERNEL|__GFP_REPEAT);
>
> Ah, thanks. new is not a pointer to one full page occupied by page
> table entries, so trying to use struct page of it is totally wrong.
>
>> The page for new(pte_t) could be shared right ? which mean a deadlock ?
>
> Yes, that's disastrous.
>
>> May be you should do it at the pmd level itself for ppc
The pgd page also cannot be used because pgd also comes from kmem
cache.
>
> Yes, that's possible, but I simply drop the changes in __hugepte_alloc()
> for now because this lock seems to protect us from the race between concurrent
> calls of __hugepte_alloc(), not between allocation and read/write access.
> Split ptl is used to avoid race between read/write accesses, so I think
> that using different types of locks here is not dangerous.
> # I guess that that's why we now use mm->page_table_lock for __pte_alloc()
> # and its family even if USE_SPLIT_PTLOCKS is true.
A simpler approach could be to make huge_pte_lockptr arch
specific and leave it as mm->page_table_lock for ppc
-aneesh
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
Mel Gorman <mgorman@suse.de>, Andi Kleen <andi@firstfloor.org>,
Michal Hocko <mhocko@suse.cz>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Rik van Riel <riel@redhat.com>,
Andrea Arcangeli <aarcange@redhat.com>,
kirill.shutemov@linux.intel.com,
Alex Thorlton <athorlton@sgi.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] hugetlbfs: support split page table lock
Date: Thu, 05 Sep 2013 14:48:18 +0530 [thread overview]
Message-ID: <87d2onwrs5.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <1378312330-afoa3r2y-mutt-n-horiguchi@ah.jp.nec.com>
Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> writes:
> Hi Aneesh,
>
> On Wed, Sep 04, 2013 at 12:43:19PM +0530, Aneesh Kumar K.V wrote:
>> Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> writes:
>>
>> > Currently all of page table handling by hugetlbfs code are done under
>> > mm->page_table_lock. So when a process have many threads and they heavily
>> > access to the memory, lock contention happens and impacts the performance.
>> >
>> > This patch makes hugepage support split page table lock so that we use
>> > page->ptl of the leaf node of page table tree which is pte for normal pages
>> > but can be pmd and/or pud for hugepages of some architectures.
>> >
>> > ChangeLog v2:
>> > - add split ptl on other archs missed in v1
>> >
>> > Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
>> > ---
>> > arch/powerpc/mm/hugetlbpage.c | 6 ++-
>> > arch/tile/mm/hugetlbpage.c | 6 ++-
>> > include/linux/hugetlb.h | 20 ++++++++++
>> > mm/hugetlb.c | 92 ++++++++++++++++++++++++++-----------------
>> > mm/mempolicy.c | 5 ++-
>> > mm/migrate.c | 4 +-
>> > mm/rmap.c | 2 +-
>> > 7 files changed, 90 insertions(+), 45 deletions(-)
>> >
>> > diff --git v3.11-rc3.orig/arch/powerpc/mm/hugetlbpage.c v3.11-rc3/arch/powerpc/mm/hugetlbpage.c
>> > index d67db4b..7e56cb7 100644
>> > --- v3.11-rc3.orig/arch/powerpc/mm/hugetlbpage.c
>> > +++ v3.11-rc3/arch/powerpc/mm/hugetlbpage.c
>> > @@ -124,6 +124,7 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
>> > {
>> > struct kmem_cache *cachep;
>> > pte_t *new;
>> > + spinlock_t *ptl;
>> >
>> > #ifdef CONFIG_PPC_FSL_BOOK3E
>> > int i;
>> > @@ -141,7 +142,8 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
>> > if (! new)
>> > return -ENOMEM;
>> >
>> > - spin_lock(&mm->page_table_lock);
>> > + ptl = huge_pte_lockptr(mm, new);
>> > + spin_lock(ptl);
>>
>>
>> Are you sure we can do that for ppc ?
>> new = kmem_cache_zalloc(cachep, GFP_KERNEL|__GFP_REPEAT);
>
> Ah, thanks. new is not a pointer to one full page occupied by page
> table entries, so trying to use struct page of it is totally wrong.
>
>> The page for new(pte_t) could be shared right ? which mean a deadlock ?
>
> Yes, that's disastrous.
>
>> May be you should do it at the pmd level itself for ppc
The pgd page also cannot be used because pgd also comes from kmem
cache.
>
> Yes, that's possible, but I simply drop the changes in __hugepte_alloc()
> for now because this lock seems to protect us from the race between concurrent
> calls of __hugepte_alloc(), not between allocation and read/write access.
> Split ptl is used to avoid race between read/write accesses, so I think
> that using different types of locks here is not dangerous.
> # I guess that that's why we now use mm->page_table_lock for __pte_alloc()
> # and its family even if USE_SPLIT_PTLOCKS is true.
A simpler approach could be to make huge_pte_lockptr arch
specific and leave it as mm->page_table_lock for ppc
-aneesh
next prev parent reply other threads:[~2013-09-05 9:18 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-30 17:18 [PATCH 0/2 v2] split page table lock for hugepage Naoya Horiguchi
2013-08-30 17:18 ` Naoya Horiguchi
2013-08-30 17:18 ` [PATCH 1/2] hugetlbfs: support split page table lock Naoya Horiguchi
2013-08-30 17:18 ` Naoya Horiguchi
2013-09-04 7:13 ` Aneesh Kumar K.V
2013-09-04 7:13 ` Aneesh Kumar K.V
2013-09-04 16:32 ` Naoya Horiguchi
2013-09-04 16:32 ` Naoya Horiguchi
2013-09-05 9:18 ` Aneesh Kumar K.V [this message]
2013-09-05 9:18 ` Aneesh Kumar K.V
2013-09-05 15:23 ` Naoya Horiguchi
2013-09-05 15:23 ` Naoya Horiguchi
2013-08-30 17:18 ` [PATCH 2/2] thp: " Naoya Horiguchi
2013-08-30 17:18 ` Naoya Horiguchi
2013-09-02 10:53 ` Kirill A. Shutemov
2013-09-02 10:53 ` Kirill A. Shutemov
2013-09-02 16:37 ` Naoya Horiguchi
2013-09-02 16:37 ` Naoya Horiguchi
2013-09-03 20:52 ` Naoya Horiguchi
2013-09-03 20:52 ` Naoya Horiguchi
-- strict thread matches above, loose matches on Subject: below --
2013-09-05 21:27 [PATCH 0/2 v3] split page table lock for hugepage Naoya Horiguchi
2013-09-05 21:27 ` [PATCH 1/2] hugetlbfs: support split page table lock Naoya Horiguchi
2013-09-05 21:27 ` Naoya Horiguchi
2013-09-08 16:53 ` Aneesh Kumar K.V
2013-09-08 16:53 ` Aneesh Kumar K.V
2013-09-09 16:26 ` Naoya Horiguchi
2013-09-09 16:26 ` Naoya Horiguchi
2013-05-28 19:52 [PATCH 0/2] " Naoya Horiguchi
2013-05-28 19:52 ` [PATCH 1/2] " Naoya Horiguchi
2013-05-28 19:52 ` Naoya Horiguchi
2013-05-29 1:09 ` Wanpeng Li
2013-05-29 1:09 ` Wanpeng Li
2013-06-03 13:19 ` Michal Hocko
2013-06-03 13:19 ` Michal Hocko
2013-06-03 14:34 ` Naoya Horiguchi
2013-06-03 14:34 ` Naoya Horiguchi
2013-06-03 15:42 ` Michal Hocko
2013-06-03 15:42 ` Michal Hocko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d2onwrs5.fsf@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=athorlton@sgi.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.cz \
--cc=n-horiguchi@ah.jp.nec.com \
--cc=riel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.