Skip to contentSkip to conversation

powerpc/64s/radix: fix preempt imbalance in TLB flush

PATCH Superseded Nicholas Piggin 3 participants 5 messages Oct 10, 2017 PowerPC

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Nicholas Piggin

author reviewer
#0 lore raw

PATCH 1/1 powerpc/64s/radix: fix preempt imbalance in TLB flush

---
 arch/powerpc/mm/tlb-radix.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/mm/tlb-radix.c +2 -1
index b3e849c4886e..de414460287a 100644
@@ -358,7 +358,7 @@ void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr)
 	unsigned long ap = mmu_get_ap(mmu_virtual_psize);
 	unsigned long pid, end;
 
-
+	preempt_disable();
 	pid = mm ? mm->context.id : 0;
 	if (unlikely(pid == MMU_NO_CONTEXT))
 		goto no_context;
@@ -366,6 +366,7 @@ void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr)
 	/* 4k page size, just blow the world */
 	if (PAGE_SIZE == 0x1000) {
 		radix__flush_all_mm(mm);
+		preempt_enable();
 		return;
 	}
 
Signature · 1 line
2.13.3
#1 lore raw
Quoted 19 lines · Nicholas Piggin
---
  arch/powerpc/mm/tlb-radix.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/mm/tlb-radix.c +1 -1
index b3e849c4886e..de414460287a 100644
@@ -358,7 +358,7 @@ void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr)
  	unsigned long ap = mmu_get_ap(mmu_virtual_psize);
  	unsigned long pid, end;
 
-
+	preempt_disable();
  	pid = mm ? mm->context.id : 0;
  	if (unlikely(pid == MMU_NO_CONTEXT))
  		goto no_context;

arch/powerpc/mm/tlb-radix.c void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr) · line 372

Quoted 7 lines
arch/powerpc/mm/tlb-radix.c +1 -0
@@ -366,6 +366,7 @@ void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr)
  	/* 4k page size, just blow the world */
  	if (PAGE_SIZE == 0x1000) {
  		radix__flush_all_mm(mm);
+		preempt_enable();
  		return;
  	}
 

Can't we do a preempt_disable before the if (local) check?. That way we don't need that prempt_enable in that PAGE_SIZE==0x1000 path.We already do disable/enable correctly in radix__flush_all_mm(mm)

-aneesh

author reviewer
#2 lore raw
Quoted 23 lines · On Tue, 10 Oct 2017 15:52:02 +0530 "Aneesh Kumar K.V"…
Quoted 22 lines · Nicholas Piggin
---
  arch/powerpc/mm/tlb-radix.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/mm/tlb-radix.c +1 -1
index b3e849c4886e..de414460287a 100644
@@ -358,7 +358,7 @@ void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr)
  	unsigned long ap = mmu_get_ap(mmu_virtual_psize);
  	unsigned long pid, end;
 
-
+	preempt_disable();
  	pid = mm ? mm->context.id : 0;
  	if (unlikely(pid == MMU_NO_CONTEXT))
  		goto no_context;
@@ -366,6 +366,7 @@ void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr)
  	/* 4k page size, just blow the world */
  	if (PAGE_SIZE == 0x1000) {
  		radix__flush_all_mm(mm);
Quoted 8 lines

arch/powerpc/mm/tlb-radix.c void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr) · line 372

Quoted 4 lines
arch/powerpc/mm/tlb-radix.c +1 -0
+		preempt_enable();
  		return;
  	}
 

Can't we do a preempt_disable before the if (local) check?. That way we don't need that prempt_enable in that PAGE_SIZE==0x1000 path.We already do disable/enable correctly in radix__flush_all_mm(mm)

Well this is just to fix the imbalance. Nested preempt doesn't matter much, and these are all no-ops for !preempt kernel, unless you turn on debugging.

I already proposed another patch to bring those local tests under preempt disable but no response yet

https://patchwork.ozlabs.org/patch/811061/

Thanks,
Nick

#3 lore raw
Quoted 33 lines · Nicholas Piggin
Quoted 14 lines · On Tue, 10 Oct 2017 15:52:02 +0530 "Aneesh Kumar K.V"…
Quoted 13 lines · Nicholas Piggin
---
   arch/powerpc/mm/tlb-radix.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/mm/tlb-radix.c +0 -0
index b3e849c4886e..de414460287a 100644
@@ -358,7 +358,7 @@ void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr)
   	unsigned long ap = mmu_get_ap(mmu_virtual_psize);
   	unsigned long pid, end;
 
Quoted 16 lines

arch/powerpc/mm/tlb-radix.c void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr) · line 372

Quoted 13 lines
arch/powerpc/mm/tlb-radix.c +2 -1
-
+	preempt_disable();
   	pid = mm ? mm->context.id : 0;
   	if (unlikely(pid == MMU_NO_CONTEXT))
   		goto no_context;
@@ -366,6 +366,7 @@ void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr)
   	/* 4k page size, just blow the world */
   	if (PAGE_SIZE == 0x1000) {
   		radix__flush_all_mm(mm);
+		preempt_enable();
   		return;
   	}
 

Can't we do a preempt_disable before the if (local) check?. That way we don't need that prempt_enable in that PAGE_SIZE==0x1000 path.We already do disable/enable correctly in radix__flush_all_mm(mm)

Quoted 3 lines

Well this is just to fix the imbalance. Nested preempt doesn't matter much, and these are all no-ops for !preempt kernel, unless you turn on debugging.

But this patch is still doing the mm_is_thread_local() test outside preempt_disable() right?

Quoted 5 lines

I already proposed another patch to bring those local tests under preempt disable but no response yet

https://patchwork.ozlabs.org/patch/811061/

That is a much better patch?

-aneesh

author reviewer
#4 lore raw
Quoted 36 lines · On Tue, 10 Oct 2017 19:09:54 +0530 "Aneesh Kumar K.V"…
Quoted 33 lines · Nicholas Piggin
Quoted 30 lines · On Tue, 10 Oct 2017 15:52:02 +0530 "Aneesh Kumar K.V"…
Quoted 19 lines · Nicholas Piggin
---
   arch/powerpc/mm/tlb-radix.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/mm/tlb-radix.c +1 -1
index b3e849c4886e..de414460287a 100644
@@ -358,7 +358,7 @@ void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr)
   	unsigned long ap = mmu_get_ap(mmu_virtual_psize);
   	unsigned long pid, end;
 
-
+	preempt_disable();
   	pid = mm ? mm->context.id : 0;
   	if (unlikely(pid == MMU_NO_CONTEXT))
   		goto no_context;

arch/powerpc/mm/tlb-radix.c void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr) · line 372

Quoted 7 lines
arch/powerpc/mm/tlb-radix.c +1 -0
@@ -366,6 +366,7 @@ void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr)
   	/* 4k page size, just blow the world */
   	if (PAGE_SIZE == 0x1000) {
   		radix__flush_all_mm(mm);
+		preempt_enable();
   		return;
   	}
 

Can't we do a preempt_disable before the if (local) check?. That way we don't need that prempt_enable in that PAGE_SIZE==0x1000 path.We already do disable/enable correctly in radix__flush_all_mm(mm)

Quoted 6 lines
Quoted 3 lines

Well this is just to fix the imbalance. Nested preempt doesn't matter much, and these are all no-ops for !preempt kernel, unless you turn on debugging.

But this patch is still doing the mm_is_thread_local() test outside preempt_disable() right?

Yes. As it does in some other place too. It's just a minimal fix for the imbalance issue as I said, because that's messing up debugging.

Quoted 7 lines
Quoted 5 lines

I already proposed another patch to bring those local tests under preempt disable but no response yet

https://patchwork.ozlabs.org/patch/811061/

That is a much better patch?

I'm planning to repost the series but have been side-tracked hitting testing it due to hitting bugs (!preempt though, so this has not been top priority).

Thanks,
Nick