linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -mm] mm: hugetlbfs: Correctly populate shared pmd
@ 2012-08-02 14:16 Michal Hocko
  2012-08-02 14:40 ` Rik van Riel
  2012-08-03 14:16 ` Hillf Danton
  0 siblings, 2 replies; 4+ messages in thread
From: Michal Hocko @ 2012-08-02 14:16 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Mel Gorman, Rik van Riel, Hugh Dickins, Linux-MM, David Gibson,
	Ken Chen, Cong Wang, LKML

Hi Andrew,
the following patch fixes yet-another race in the hugetlb pte sharing
code reported by Larry. It is based on top of the current -mm tree but
it cleanly applies to linus tree as well. It should go to stable as
well. The bug is there for ages but this fix is possible only since 3.0
because i_mmap_lock used to be a spinlock until 3d48ae45 which turned it
into mutex and so we can call pmd_alloc.
There was another candidate for the same issue by Mel
(https://lkml.org/lkml/2012/7/31/275) but we considered this one to be
better because it is more focused on the arch specific code and it also
highers chances for sharing.
---

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -mm] mm: hugetlbfs: Correctly populate shared pmd
  2012-08-02 14:16 [PATCH -mm] mm: hugetlbfs: Correctly populate shared pmd Michal Hocko
@ 2012-08-02 14:40 ` Rik van Riel
  2012-08-03 14:16 ` Hillf Danton
  1 sibling, 0 replies; 4+ messages in thread
From: Rik van Riel @ 2012-08-02 14:40 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Andrew Morton, Mel Gorman, Hugh Dickins, Linux-MM, David Gibson,
	Ken Chen, Cong Wang, LKML, Larry Woodman

On 08/02/2012 10:16 AM, Michal Hocko wrote:
> Hi Andrew,
> the following patch fixes yet-another race in the hugetlb pte sharing
> code reported by Larry. It is based on top of the current -mm tree but
> it cleanly applies to linus tree as well. It should go to stable as
> well. The bug is there for ages but this fix is possible only since 3.0
> because i_mmap_lock used to be a spinlock until 3d48ae45 which turned it
> into mutex and so we can call pmd_alloc.

> This patch addresses the issue by moving pmd_alloc into huge_pmd_share
> which guarantees that the shared pud is populated in the same
> critical section as pmd. This also means that huge_pte_offset test in
> huge_pmd_share is serialized correctly now which in turn means that
> the success of the sharing will be higher as the racing tasks see the
> pud and pmd populated together.
>
> Race identified and changelog written mostly by Mel Gorman
> Reported-and-tested-by: Larry Woodman <lwoodman@redhat.com>
> Reviewed-by: Mel Gorman <mgorman@suse.de>
> Signed-off-by: Michal Hocko <mhocko@suse.cz>

Reviewed-by: Rik van Riel <riel@redhat.com>


--
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -mm] mm: hugetlbfs: Correctly populate shared pmd
  2012-08-02 14:16 [PATCH -mm] mm: hugetlbfs: Correctly populate shared pmd Michal Hocko
  2012-08-02 14:40 ` Rik van Riel
@ 2012-08-03 14:16 ` Hillf Danton
  2012-08-03 14:37   ` Michal Hocko
  1 sibling, 1 reply; 4+ messages in thread
From: Hillf Danton @ 2012-08-03 14:16 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Andrew Morton, Mel Gorman, Rik van Riel, Hugh Dickins, Linux-MM,
	David Gibson, Ken Chen, Cong Wang

On Thu, Aug 2, 2012 at 10:16 PM, Michal Hocko <mhocko@suse.cz> wrote:
> This patch addresses the issue by moving pmd_alloc into huge_pmd_share
> which guarantees that the shared pud is populated in the same
> critical section as pmd.

Is i_mmap_mutex for guarding new pmd allocation?
Is regression introduced if sharing is unavailable?

--
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -mm] mm: hugetlbfs: Correctly populate shared pmd
  2012-08-03 14:16 ` Hillf Danton
@ 2012-08-03 14:37   ` Michal Hocko
  0 siblings, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2012-08-03 14:37 UTC (permalink / raw)
  To: Hillf Danton
  Cc: Andrew Morton, Mel Gorman, Rik van Riel, Hugh Dickins, Linux-MM,
	David Gibson, Ken Chen, Cong Wang

On Fri 03-08-12 22:16:52, Hillf Danton wrote:
> On Thu, Aug 2, 2012 at 10:16 PM, Michal Hocko <mhocko@suse.cz> wrote:
> > This patch addresses the issue by moving pmd_alloc into huge_pmd_share
> > which guarantees that the shared pud is populated in the same
> > critical section as pmd.
> 
> Is i_mmap_mutex for guarding new pmd allocation?

It doesn't guard the pmd allocation itself it just makes sure that pud
population and pmd_allocation are done atomicaly wrt. other processes to
share the same pmd because sharing is synchronized by i_mmap_mutex.

> Is regression introduced if sharing is unavailable?

No. The bug is about the sharing as the changelog describes.

-- 
Michal Hocko
SUSE Labs

--
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-08-03 14:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-02 14:16 [PATCH -mm] mm: hugetlbfs: Correctly populate shared pmd Michal Hocko
2012-08-02 14:40 ` Rik van Riel
2012-08-03 14:16 ` Hillf Danton
2012-08-03 14:37   ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).