Skip to contentSkip to conversation

x86/mm/cpa: Unconditionally avoid WBINDV when we can

PATCH In review Wen Yang 2 participants 4 messages Jul 5, 2022 Stable branch

lore
Share & tools
lore

Wen Yang

author
#0 lore raw

PATCH 1/1 x86/mm/cpa: Unconditionally avoid WBINDV when we can

From: Peter Zijlstra <[email protected]>

commit ddd07b750382adc2b78fdfbec47af8a6e0d8ef37 upstream.

CAT has happened, WBINDV is bad (even before CAT blowing away the entire cache on a multi-core platform wasn't nice), try not to use it ever.

---
 arch/x86/mm/pageattr.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)
arch/x86/mm/pageattr.c +2 -16
index 101f3ad0d6ad..ab87da7a6043 100644
@@ -239,26 +239,12 @@ static void cpa_flush_array(unsigned long *start, int numpages, int cache,
 			    int in_flags, struct page **pages)
 {
 	unsigned int i, level;
-#ifdef CONFIG_PREEMPT
-	/*
-	 * Avoid wbinvd() because it causes latencies on all CPUs,
-	 * regardless of any CPU isolation that may be in effect.
-	 *
-	 * This should be extended for CAT enabled systems independent of
-	 * PREEMPT because wbinvd() does not respect the CAT partitions and
-	 * this is exposed to unpriviledged users through the graphics
-	 * subsystem.
-	 */
-	unsigned long do_wbinvd = 0;
-#else
-	unsigned long do_wbinvd = cache && numpages >= 1024; /* 4M threshold */
-#endif
 
 	BUG_ON(irqs_disabled() && !early_boot_irqs_disabled);
 
-	on_each_cpu(__cpa_flush_all, (void *) do_wbinvd, 1);
+	flush_tlb_all();
 
-	if (!cache || do_wbinvd)
+	if (!cache)
 		return;
 
 	/*
Signature · 1 line
2.19.1.6.gb485710b
author
#1 lore raw

PATCH 1/1 x86/mm/cpa: Unconditionally avoid WBINDV when we can

From: Peter Zijlstra <[email protected]>

commit ddd07b750382adc2b78fdfbec47af8a6e0d8ef37 upstream.

CAT has happened, WBINDV is bad (even before CAT blowing away the entire cache on a multi-core platform wasn't nice), try not to use it ever.

Cc Bin Yang <[email protected]>
Cc Mark Gross <[email protected]>
Cc <[email protected]> # 4.14.x: d2479a3: x86/pti: Fix boot problems from Global-bit setting
Cc <[email protected]> # 4.14.x
---
 arch/x86/mm/pageattr.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)
arch/x86/mm/pageattr.c +2 -16
index 101f3ad0d6ad..ab87da7a6043 100644
@@ -239,26 +239,12 @@ static void cpa_flush_array(unsigned long *start, int numpages, int cache,
 			    int in_flags, struct page **pages)
 {
 	unsigned int i, level;
-#ifdef CONFIG_PREEMPT
-	/*
-	 * Avoid wbinvd() because it causes latencies on all CPUs,
-	 * regardless of any CPU isolation that may be in effect.
-	 *
-	 * This should be extended for CAT enabled systems independent of
-	 * PREEMPT because wbinvd() does not respect the CAT partitions and
-	 * this is exposed to unpriviledged users through the graphics
-	 * subsystem.
-	 */
-	unsigned long do_wbinvd = 0;
-#else
-	unsigned long do_wbinvd = cache && numpages >= 1024; /* 4M threshold */
-#endif
 
 	BUG_ON(irqs_disabled() && !early_boot_irqs_disabled);
 
-	on_each_cpu(__cpa_flush_all, (void *) do_wbinvd, 1);
+	flush_tlb_all();
 
-	if (!cache || do_wbinvd)
+	if (!cache)
 		return;
 
 	/*
Signature · 1 line
2.19.1.6.gb485710b
author
#2 lore raw

PATCH 1/1 x86/mm/cpa: Unconditionally avoid WBINDV when we can

In reply to Wen Yang

From: Wen Yang <[email protected]>

commit ddd07b750382adc2b78fdfbec47af8a6e0d8ef37 upstream.

CAT has happened, WBINDV is bad (even before CAT blowing away the entire cache on a multi-core platform wasn't nice), try not to use it ever.

Cc Bin Yang <[email protected]>
Cc Mark Gross <[email protected]>
Cc <[email protected]> # 4.9.x: d2479a3: x86/pti: Fix boot problems from Global-bit setting
Cc <[email protected]> # 4.9.x
---
 arch/x86/mm/pageattr.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/mm/pageattr.c +2 -3
index a586faeab0e5..e1b5b603eb48 100644
@@ -215,13 +215,12 @@ static void cpa_flush_array(unsigned long *start, int numpages, int cache,
 			    int in_flags, struct page **pages)
 {
 	unsigned int i, level;
-	unsigned long do_wbinvd = cache && numpages >= 1024; /* 4M threshold */
 
 	BUG_ON(irqs_disabled() && !early_boot_irqs_disabled);
 
-	on_each_cpu(__cpa_flush_all, (void *) do_wbinvd, 1);
+	flush_tlb_all();
 
-	if (!cache || do_wbinvd)
+	if (!cache)
 		return;
 
 	/*
Signature · 1 line
2.19.1.6.gb485710b
#3 lore raw
In reply to Wen Yang
Quoted 56 lines · Wen Yang

From: Peter Zijlstra <[email protected]>

commit ddd07b750382adc2b78fdfbec47af8a6e0d8ef37 upstream.

CAT has happened, WBINDV is bad (even before CAT blowing away the entire cache on a multi-core platform wasn't nice), try not to use it ever.

---
 arch/x86/mm/pageattr.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)
arch/x86/mm/pageattr.c +2 -16
index 101f3ad0d6ad..ab87da7a6043 100644
@@ -239,26 +239,12 @@ static void cpa_flush_array(unsigned long *start, int numpages, int cache,
 			    int in_flags, struct page **pages)
 {
 	unsigned int i, level;
-#ifdef CONFIG_PREEMPT
-	/*
-	 * Avoid wbinvd() because it causes latencies on all CPUs,
-	 * regardless of any CPU isolation that may be in effect.
-	 *
-	 * This should be extended for CAT enabled systems independent of
-	 * PREEMPT because wbinvd() does not respect the CAT partitions and
-	 * this is exposed to unpriviledged users through the graphics
-	 * subsystem.
-	 */
-	unsigned long do_wbinvd = 0;
-#else
-	unsigned long do_wbinvd = cache && numpages >= 1024; /* 4M threshold */
-#endif
 
 	BUG_ON(irqs_disabled() && !early_boot_irqs_disabled);
 
-	on_each_cpu(__cpa_flush_all, (void *) do_wbinvd, 1);
+	flush_tlb_all();
 
-	if (!cache || do_wbinvd)
+	if (!cache)
 		return;
 
 	/*
Signature · 1 line
2.19.1.6.gb485710b

As stated before, I am not allowed to accept this due to it being a requirement of a closed source kernel module. Please do not keep resending it hoping we will forget or I will have to add this to my email filters.

thanks,

greg k-h