powerpc: mm: fixup preempt undefflow with huge pages
PATCH 1/1 powerpc: mm: fixup preempt undefflow with huge pages
hugepd_free() used __get_cpu_var() once. Nothing ensured that the code accessing the variable did not migrate from one CPU to another and soon this was noticed by Tiejun Chen in 94b09d755462 ("powerpc/hugetlb:
Replace __get_cpu_var with get_cpu_var"). So we had it fixed.
Christoph Lameter was doing his __get_cpu_var() replaces and forgot PowerPC. Then he noticed this and sent his fixed up batch again which got applied as 69111bac42f5 ("powerpc: Replace __get_cpu_var uses").
The careful reader will noticed one little detail: get_cpu_var() got replaced with this_cpu_ptr(). So now we have a put_cpu_var() which does a preempt_enable() and nothing that does preempt_disable() so we underflow the preempt counter.
--- arch/powerpc/mm/hugetlbpage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/mm/hugetlbpage.c +1 -1
@@ -414,7 +414,7 @@ static void hugepd_free(struct mmu_gather *tlb, void *hugepte) { struct hugepd_freelist **batchp; - batchp = this_cpu_ptr(&hugepd_freelist_cur); + batchp = get_cpu_ptr(&hugepd_freelist_cur); if (atomic_read(&tlb->mm->mm_users) < 2 || cpumask_equal(mm_cpumask(tlb->mm),
Signature · 1 line
2.7.0
Quoted 30 lines · Sebastian Andrzej Siewior
[ text/plain ]
hugepd_free()used__get_cpu_var()once. Nothing ensured that the code accessing the variable did not migrate from one CPU to another and soon this was noticed by Tiejun Chen in94b09d755462("powerpc/hugetlb:
Replace__get_cpu_varwithget_cpu_var"). So we had it fixed.Christoph Lameter was doing his
__get_cpu_var()replaces and forgot PowerPC. Then he noticed this and sent his fixed up batch again which got applied as69111bac42f5("powerpc: Replace__get_cpu_varuses").The careful reader will noticed one little detail:
get_cpu_var()got replaced withthis_cpu_ptr(). So now we have aput_cpu_var()which does apreempt_enable()and nothing that doespreempt_disable()so we underflow the preempt counter.Cc Benjamin Herrenschmidt <[email protected]>Cc Christoph Lameter <[email protected]>Cc Michael Ellerman <[email protected]>Cc Tiejun Chen <[email protected]>Cc <[email protected]>Signed-off-by Sebastian Andrzej Siewior <[email protected]>--- arch/powerpc/mm/hugetlbpage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/mm/hugetlbpage.c +0
-0
arch/powerpc/mm/hugetlbpage.c static void hugepd_free(struct mmu_gather *tlb, void *hugepte) · line 420
Quoted 8 lines
arch/powerpc/mm/hugetlbpage.c +1
-1@@ -414,7 +414,7 @@ static void hugepd_free(struct mmu_gather *tlb, void *hugepte) { struct hugepd_freelist **batchp; - batchp = this_cpu_ptr(&hugepd_freelist_cur); + batchp = get_cpu_ptr(&hugepd_freelist_cur); if (atomic_read(&tlb->mm->mm_users) < 2 || cpumask_equal(mm_cpumask(tlb->mm),
IMHO it would better if we do
batchp = get_cpu_var(hugepd_freelist_cpu);
so that it match the existing
put_cpu_var(hugepd_freelist_cur);
While you are there, can you also fix the wrong indentation on line 423 ?
-aneesh
Quoted 5 lines · Aneesh Kumar K.V
Sebastian Andrzej Siewior <[email protected]> writes:
While you are there, can you also fix the wrong indentation on line 423
?
.../...
Also this looks like stable material no ?
Cheers,
Ben.
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 5 lines · Aneesh Kumar K.V
Sebastian Andrzej Siewior <[email protected]> writes:
While you are there, can you also fix the wrong indentation on line 423
?.../...
Also this looks like stable material no ?
Yes, I had a stable tag attached. I am going to resend it with the additional changes Aneesh asked for.
Quoted 3 lines
Cheers,
Ben.
Sebastian
PATCH v2 1/1 powerpc: mm: fixup preempt undefflow with huge pages
In reply to Benjamin Herrenschmidthugepd_free() used __get_cpu_var() once. Nothing ensured that the code accessing the variable did not migrate from one CPU to another and soon this was noticed by Tiejun Chen in 94b09d755462 ("powerpc/hugetlb:
Replace __get_cpu_var with get_cpu_var"). So we had it fixed.
Christoph Lameter was doing his __get_cpu_var() replaces and forgot PowerPC. Then he noticed this and sent his fixed up batch again which got applied as 69111bac42f5 ("powerpc: Replace __get_cpu_var uses").
The careful reader will noticed one little detail: get_cpu_var() got replaced with this_cpu_ptr(). So now we have a put_cpu_var() which does a preempt_enable() and nothing that does preempt_disable() so we underflow the preempt counter.
---
v1=E2=80=A6v2: - use get_cpu_var() instead of get_cpu_ptr()
- correct indentation of put_cpu_var()
arch/powerpc/mm/hugetlbpage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/hugetlbpage.c +0 -0
@@ -414,13 +414,13 @@ static void hugepd_free(struct mmu_gather *tlb, void =
*hugepte)
{
struct hugepd_freelist **batchp;
=20
- batchp =3D this_cpu_ptr(&hugepd_freelist_cur);
+ batchp =3D &get_cpu_var(hugepd_freelist_cur);
=20
if (atomic_read(&tlb->mm->mm_users) < 2 ||
cpumask_equal(mm_cpumask(tlb->mm),
cpumask_of(smp_processor_id()))) {
kmem_cache_free(hugepte_cache, hugepte);
- put_cpu_var(hugepd_freelist_cur);
+ put_cpu_var(hugepd_freelist_cur);
return;
}
=20
--=20
2.7.0
Quoted 6 lines · Sebastian Andrzej Siewior
[ text/plain ]
hugepd_free()used__get_cpu_var()once. Nothing ensured that the code accessing the variable did not migrate from one CPU to another and soon this was noticed by Tiejun Chen in94b09d755462("powerpc/hugetlb:
Replace__get_cpu_varwithget_cpu_var"). So we had it fixed.
Quoted 9 lines
Christoph Lameter was doing his
__get_cpu_var()replaces and forgot PowerPC. Then he noticed this and sent his fixed up batch again which got applied as69111bac42f5("powerpc: Replace__get_cpu_varuses").The careful reader will noticed one little detail:
get_cpu_var()got replaced withthis_cpu_ptr(). So now we have aput_cpu_var()which does apreempt_enable()and nothing that doespreempt_disable()so we underflow the preempt counter.
arch/powerpc/mm/hugetlbpage.c static void hugepd_free(struct mmu_gather *tlb, voi=
Quoted 17 lines
Cc Benjamin Herrenschmidt <[email protected]>Cc Christoph Lameter <[email protected]>Cc Michael Ellerman <[email protected]>Cc <[email protected]>Signed-off-by Sebastian Andrzej Siewior <[email protected]>---
v1=E2=80=A6v2: - useget_cpu_var()instead ofget_cpu_ptr()
- correct indentation ofput_cpu_var()arch/powerpc/mm/hugetlbpage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/powerpc/mm/hugetlbpage.c +0
-0@@ -414,13 +414,13 @@ static void hugepd_free(struct mmu_gather *tlb, voi=
d *hugepte)
Quoted 17 lines
arch/powerpc/mm/hugetlbpage.c +0
-0{struct hugepd_freelist **batchp;=20=20
arch/powerpc/mm/hugetlbpage.c +1
-1- batchp =3D this_cpu_ptr(&hugepd_freelist_cur); + batchp =3D &get_cpu_var (hugepd_freelist_cur);=20=20
arch/powerpc/mm/hugetlbpage.c +1
-1if (atomic_read (&tlb->mm->mm_users) <2 ||cpumask_equal (mm_cpumask (tlb->mm),cpumask_of (smp_processor_id ()))) {kmem_cache_free (hugepte_cache, hugepte); -put_cpu_var (hugepd_freelist_cur); +put_cpu_var (hugepd_freelist_cur);return ; }=20=20
--=20
2.7.0
Quoted 1 line · Aneesh Kumar K.V
Sebastian Andrzej Siewior <[email protected]> writes:
*ping*
http://patchwork.ozlabs.org/patch/593943/
Quoted 27 lines
Quoted 6 lines
[ text/plain ]
hugepd_free()used__get_cpu_var()once. Nothing ensured that the code accessing the variable did not migrate from one CPU to another and soon this was noticed by Tiejun Chen in94b09d755462("powerpc/hugetlb:
Replace__get_cpu_varwithget_cpu_var"). So we had it fixed.Quoted 9 lines
Christoph Lameter was doing his
__get_cpu_var()replaces and forgot PowerPC. Then he noticed this and sent his fixed up batch again which got applied as69111bac42f5("powerpc: Replace__get_cpu_varuses").The careful reader will noticed one little detail:
get_cpu_var()got replaced withthis_cpu_ptr(). So now we have aput_cpu_var()which does apreempt_enable()and nothing that doespreempt_disable()so we underflow the preempt counter.=20
Reviewed-by Aneesh Kumar K.V <[email protected]>=20
Quoted 9 lines
Cc Benjamin Herrenschmidt <[email protected]>Cc Christoph Lameter <[email protected]>Cc Michael Ellerman <[email protected]>Cc <[email protected]>Signed-off-by Sebastian Andrzej Siewior <[email protected]>---
v1=E2=80=A6v2: - useget_cpu_var()instead ofget_cpu_ptr()
- correct indentation ofput_cpu_var()
Quoted 4 lines
arch/powerpc/mm/hugetlbpag=
Quoted 4 lines
arch/powerpc/mm/hugetlbpage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/powerpc/mm/hugetlbpag= renamed from arch/powerpc/mm/hugetlbpage.c +0
-0
e.c
Quoted 4 lines
arch/powerpc/mm/hugetlbpage.c static void hugepd_free(struct mmu_gather *tlb, v=
Quoted 4 lines
index
744e24bcb85c..4a811ca7ac9d100644arch/powerpc/mm/hugetlbpage.c +0
-0@@ -414,13 +414,13 @@ static void hugepd_free(struct mmu_gather *tlb, v=
oid *hugepte)
Quoted 7 lines
Quoted 7 lines
arch/powerpc/mm/hugetlbpage.c +0
-0{struct hugepd_freelist **batchp;=20
arch/powerpc/mm/hugetlbpage.c +1
-1- batchp =3D this_cpu_ptr(&hugepd_freelist_cur); + batchp =3D &get_cpu_var (hugepd_freelist_cur);=20
if (atomic_read(&tlb->mm->mm_users)< 2 ||
Quoted 8 lines
Quoted 8 lines
arch/powerpc/mm/hugetlbpage.c +1
-1cpumask_equal(mm_cpumask(tlb->mm), cpumask_of(smp_processor_id()))) {kmem_cache_free (hugepte_cache, hugepte); -put_cpu_var (hugepd_freelist_cur); +put_cpu_var (hugepd_freelist_cur);return ; }=20
Sebastian
Michael Ellerman
reviewerQuoted 6 lines · Sebastian Andrzej Siewior
Quoted 1 line · Aneesh Kumar K.V
Sebastian Andrzej Siewior <[email protected]> writes:
*pong*
The merge window just closed, I'm still recovering.
I've got it in my fixes branch locally, I'll probably push that today to linux-next.
cheers
Quoted 4 lines · Michael Ellerman
The merge window just closed, I'm still recovering.
I've got it in my fixes branch locally, I'll probably push that today to linux-next.
Thank you.
Quoted 3 lines
cheers
Sebastian
Quoted 14 lines · Sebastian Siewior
hugepd_free()used__get_cpu_var()once. Nothing ensured that the code accessing the variable did not migrate from one CPU to another and soon this was noticed by Tiejun Chen in94b09d755462("powerpc/hugetlb:
Replace__get_cpu_varwithget_cpu_var"). So we had it fixed.Christoph Lameter was doing his
__get_cpu_var()replaces and forgot PowerPC. Then he noticed this and sent his fixed up batch again which got applied as69111bac42f5("powerpc: Replace__get_cpu_varuses").The careful reader will noticed one little detail:
get_cpu_var()got replaced withthis_cpu_ptr(). So now we have aput_cpu_var()which does apreempt_enable()and nothing that doespreempt_disable()so we underflow the preempt counter.
Quoted 6 lines
Cc Benjamin Herrenschmidt <[email protected]>Cc Christoph Lameter <[email protected]>Cc Michael Ellerman <[email protected]>Cc <[email protected]>Signed-off-by Sebastian Andrzej Siewior <[email protected]>Reviewed-by Aneesh Kumar K.V <[email protected]>
Applied to powerpc fixes, thanks.
https://git.kernel.org/powerpc/c/08a5bb2921e490939f78f38fd0
cheers