powerpc/mm: Add memory barrier in __hugepte_alloc()
Subsystems (2)
PATCH 1/1 powerpc/mm: Add memory barrier in __hugepte_alloc()
Quoted 1 line
From
f7b73c6b4508fe9b141a43d92be2f9dd7d3c4a58Mon Sep 17 00:00:00 2001
From: Sukadev Bhattiprolu <[email protected]>
Date: Thu, 24 Mar 2016 02:07:57 -0400
Subject: [PATCH 1/1] powerpc/mm: Add memory barrier in __hugepte_alloc()
__hugepte_alloc() uses kmem_cache_zalloc() to allocate a zeroed PTE and proceeds to use the newly allocated PTE. Add a memory barrier to make sure that the other CPUs see a properly initialized PTE.
Based on a fix suggested by James Dykman.
---
Note:
The bug was encountered and fix tested on an older version of the kernel. Forward porting to mainline.
--- arch/powerpc/mm/hugetlbpage.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/powerpc/mm/hugetlbpage.c +7 -0
@@ -81,6 +81,13 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,if (! new)return -ENOMEM ; +/* +* Make sure other cpus find the hugepd set only after a +* properly initialized page table is visible to them. +* For more details look for comment in __pte_alloc(). +*/ +smp_wmb (); +spin_lock (&mm->page_table_lock);#ifdef CONFIG_PPC_FSL_BOOK3E /*
Signature · 1 line
1.8.3.1
On Tue 05-04-16 12:05:47, Sukadev Bhattiprolu wrote:
[...]
Quoted 5 lines
arch/powerpc/mm/hugetlbpage.c +0
-0
arch/powerpc/mm/hugetlbpage.c static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, · line 90
Quoted 10 lines
arch/powerpc/mm/hugetlbpage.c +7
-0@@ -81,6 +81,13 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,if (! new)return -ENOMEM ; +/* +* Make sure other cpus find the hugepd set only after a +* properly initialized page table is visible to them. +* For more details look for comment in __pte_alloc(). +*/ +smp_wmb (); +
what is the pairing memory barrier?
Quoted 5 lines
arch/powerpc/mm/hugetlbpage.c +0
-0spin_lock (&mm->page_table_lock);#ifdef CONFIG_PPC_FSL_BOOK3E /* Signature · 1 line
1.8.3.1
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 11 lines · Michal Hocko
[ text/plain ]
On Tue 05-04-16 12:05:47, Sukadev Bhattiprolu wrote:
[...]Quoted 8 lines
arch/powerpc/mm/hugetlbpage.c +0
-0@@ -81,6 +81,13 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,if (! new)return -ENOMEM ;
Quoted 13 lines
arch/powerpc/mm/hugetlbpage.c static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, · line 90
Quoted 7 lines
arch/powerpc/mm/hugetlbpage.c +7
-0+/* +* Make sure other cpus find the hugepd set only after a +* properly initialized page table is visible to them. +* For more details look for comment in __pte_alloc(). +*/ +smp_wmb (); +what is the pairing memory barrier?
Quoted 3 lines
arch/powerpc/mm/hugetlbpage.c +0
-0spin_lock (&mm->page_table_lock);#ifdef CONFIG_PPC_FSL_BOOK3E /*
This is documented in __pte_alloc(). I didn't want to repeat the same here.
/*
* Ensure all pte setup (eg. pte page lock and page clearing) are
* visible before the pte is made visible to other CPUs by being
* put into page tables.
*
* The other side of the story is the pointer chasing in the page
* table walking code (when walking the page table without locking;
* ie. most of the time). Fortunately, these data accesses consist
* of a chain of data-dependent loads, meaning most CPUs (alpha
* being the notable exception) will already guarantee loads are
* seen in-order. See the alpha page table accessors for the
* smp_read_barrier_depends() barriers in page table walking code. */
smp_wmb(); /* Could be smp_wmb__xxx(before|after)_spin_lock */
-aneesh
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 30 lines · Aneesh Kumar K.V
Quoted 11 lines · Michal Hocko
[ text/plain ]
On Tue 05-04-16 12:05:47, Sukadev Bhattiprolu wrote:
[...]Quoted 8 lines
arch/powerpc/mm/hugetlbpage.c +0
-0@@ -81,6 +81,13 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,if (! new)return -ENOMEM ;Quoted 13 lines
arch/powerpc/mm/hugetlbpage.c static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, · line 90
Quoted 7 lines
arch/powerpc/mm/hugetlbpage.c +7
-0+/* +* Make sure other cpus find the hugepd set only after a +* properly initialized page table is visible to them. +* For more details look for comment in __pte_alloc(). +*/ +smp_wmb (); +what is the pairing memory barrier?
Quoted 3 lines
arch/powerpc/mm/hugetlbpage.c +0
-0spin_lock (&mm->page_table_lock);#ifdef CONFIG_PPC_FSL_BOOK3E /* This is documented in
__pte_alloc(). I didn't want to repeat the same here.
Quoted 14 lines
/*
* Ensure all pte setup (eg. pte page lock and page clearing) are
* visible before the pte is made visible to other CPUs by being
* put into page tables.
*
* The other side of the story is the pointer chasing in the page
* table walking code (when walking the page table without locking;
* ie. most of the time). Fortunately, these data accesses consist
* of a chain of data-dependent loads, meaning most CPUs (alpha
* being the notable exception) will already guarantee loads are
* seen in-order. See the alpha page table accessors for the
*smp_read_barrier_depends()barriers in page table walking code. */
smp_wmb(); /* Could be smp_wmb__xxx(before|after)_spin_lock */
OK, I have missed the reference to __pte_alloc. My bad!
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Michael Ellerman
AppliedQuoted 9 lines · Sukadev Bhattiprolu
Quoted 1 line
From
f7b73c6b4508fe9b141a43d92be2f9dd7d3c4a58Mon Sep 17 00:00:00 2001From: Sukadev Bhattiprolu <[email protected]>
Date: Thu, 24 Mar 2016 02:07:57 -0400
Subject: [PATCH 1/1] powerpc/mm: Add memory barrier in__hugepte_alloc()
__hugepte_alloc()useskmem_cache_zalloc()to allocate a zeroed PTE and proceeds to use the newly allocated PTE. Add a memory barrier to make sure that the other CPUs see a properly initialized PTE.
Quoted 6 lines
Based on a fix suggested by James Dykman.
Reported-by James Dykman <[email protected]>Signed-off-by Aneesh Kumar K.V <[email protected]>Signed-off-by Sukadev Bhattiprolu <[email protected]>Tested-by James Dykman <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/0eab46be21449f1612791201aa
cheers