Skip to contentSkip to conversation

powerpc/book3s64/radix/tlb: Determine hugepage flush correctly

PATCH Applied Aneesh Kumar K.V 4 participants 4 messages May 13, 2020 – Jun 9, 2020 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/book3s64/radix/tlb: Determine hugepage flush correctly

With a 64K page size flush with start and end value as below (start, end) = (721f680d0000, 721f680e0000) results in (hstart, hend) = (721f68200000, 721f68000000)

Avoid doing a __tlbie_va_range with the wrong hstart and hend value in this case.

__tlbie_va_range will skip the actual tlbie operation for start > end. But we still end up doing the tlbie fixup.

---
 arch/powerpc/mm/book3s64/radix_tlb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/mm/book3s64/radix_tlb.c +3 -3
index 758ade2c2b6e..d592f9e1c037 100644
@@ -884,10 +884,10 @@ static inline void __radix__flush_tlb_range(struct mm_struct *mm,
 		if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
 			hstart = (start + PMD_SIZE - 1) & PMD_MASK;
 			hend = end & PMD_MASK;
-			if (hstart == hend)
-				hflush = false;
-			else
+			if (hstart < hend)
 				hflush = true;
+			else
+				hflush = false;
 		}
 
 		if (local) {
Signature · 1 line
2.26.2
reviewer Reviewed-by on v1 1/1
#1 lore raw

Excerpts from Aneesh Kumar K.V's message of May 13, 2020 1:06 pm:

Quoted 9 lines

With a 64K page size flush with start and end value as below (start, end) = (721f680d0000, 721f680e0000) results in (hstart, hend) = (721f68200000, 721f68000000)

Avoid doing a __tlbie_va_range with the wrong hstart and hend value in this case.

__tlbie_va_range will skip the actual tlbie operation for start > end. But we still end up doing the tlbie fixup.

Hm, good catch.

Quoted 11 lines
---
 arch/powerpc/mm/book3s64/radix_tlb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/mm/book3s64/radix_tlb.c +0 -0
index 758ade2c2b6e..d592f9e1c037 100644

arch/powerpc/mm/book3s64/radix_tlb.c static inline void __radix__flush_tlb_range(struct mm_struct *mm, · line 890

Quoted 10 lines
arch/powerpc/mm/book3s64/radix_tlb.c +3 -3
@@ -884,10 +884,10 @@ static inline void __radix__flush_tlb_range(struct mm_struct *mm,
 		if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
 			hstart = (start + PMD_SIZE - 1) & PMD_MASK;
 			hend = end & PMD_MASK;
-			if (hstart == hend)
-				hflush = false;
-			else
+			if (hstart < hend)
 				hflush = true;
+			else
+				hflush = false;

We can probably get rid of the else part since it is already false.

Otherwise

#2 lore raw
Quoted 28 lines · Nicholas Piggin

Excerpts from Aneesh Kumar K.V's message of May 13, 2020 1:06 pm:

Quoted 9 lines

With a 64K page size flush with start and end value as below (start, end) = (721f680d0000, 721f680e0000) results in (hstart, hend) = (721f68200000, 721f68000000)

Avoid doing a __tlbie_va_range with the wrong hstart and hend value in this case.

__tlbie_va_range will skip the actual tlbie operation for start > end. But we still end up doing the tlbie fixup.

Hm, good catch.

Quoted 15 lines
---
 arch/powerpc/mm/book3s64/radix_tlb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/mm/book3s64/radix_tlb.c +0 -1
index 758ade2c2b6e..d592f9e1c037 100644
@@ -884,10 +884,10 @@ static inline void __radix__flush_tlb_range(struct mm_struct *mm,
 		if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
 			hstart = (start + PMD_SIZE - 1) & PMD_MASK;
 			hend = end & PMD_MASK;
-			if (hstart == hend)
Quoted 8 lines

arch/powerpc/mm/book3s64/radix_tlb.c static inline void __radix__flush_tlb_range(struct mm_struct *mm, · line 890

Quoted 6 lines
arch/powerpc/mm/book3s64/radix_tlb.c +3 -2
-				hflush = false;
-			else
+			if (hstart < hend)
 				hflush = true;
+			else
+				hflush = false;

We can probably get rid of the else part since it is already false.

Yeah I can do that when applying.

cheers

#3 lore raw
In reply to Aneesh Kumar K.V
Quoted 8 lines · Aneesh Kumar K.V

With a 64K page size flush with start and end value as below (start, end) = (721f680d0000, 721f680e0000) results in (hstart, hend) = (721f68200000, 721f68000000)

Avoid doing a __tlbie_va_range with the wrong hstart and hend value in this case.

[...]

Applied to powerpc/next.

[1/1] powerpc/book3s64/radix/tlb: Determine hugepage flush correctly

      https://git.kernel.org/powerpc/c/8f53f9c0f68ab2168f637494b9e24034899c1310

cheers