All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/ACPI: invalidate all cache lines on ACPI C-state transitions
@ 2025-05-25 18:00 Khalid Ali
  2025-05-26 12:00 ` Peter Zijlstra
  0 siblings, 1 reply; 5+ messages in thread
From: Khalid Ali @ 2025-05-25 18:00 UTC (permalink / raw)
  To: rafael, tglx, mingo, bp, dave.hansen
  Cc: lenb, hpa, x86, linux-acpi, linux-kernel, Khalid Ali

From: Khalid Ali <khaliidcaliy@gmail.com>

According to ACPI spec 2.4 and 2.5, upon C-state
transitions(specifically C2 and C3) it is required and explicitly
mentioned to invalidate and writeback all modified cache line using
WBINVD.

However the current ACPI C-state entry using monitor/mwait instructions
it have been used CLFLUSH by flushing the cache line associated by
monitored address. That what all about this patch addresses,
invalidating all cache lines instead of single cache line.

Let me know if there any reason and decisions behind the current
implementation.

Signed-off-by: Khalid Ali <khaliidcaliy@gmail.com>
---
 arch/x86/kernel/acpi/cstate.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
index d5ac34186555..eb3d435e08ad 100644
--- a/arch/x86/kernel/acpi/cstate.c
+++ b/arch/x86/kernel/acpi/cstate.c
@@ -222,6 +222,9 @@ void __cpuidle acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cx)
 	struct cstate_entry *percpu_entry;
 
 	percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu);
+	/* flush and invalidate all modified cache line on C3 and C2 state entry*/
+	if (cx->type == ACPI_STATE_C3 || cx->type == ACPI_STATE_C2)
+		wbinvd();
 	mwait_idle_with_hints(percpu_entry->states[cx->index].eax,
 	                      percpu_entry->states[cx->index].ecx);
 }
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/ACPI: invalidate all cache lines on ACPI C-state transitions
  2025-05-25 18:00 [PATCH] x86/ACPI: invalidate all cache lines on ACPI C-state transitions Khalid Ali
@ 2025-05-26 12:00 ` Peter Zijlstra
  2025-05-26 13:45   ` Khalid Ali
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2025-05-26 12:00 UTC (permalink / raw)
  To: Khalid Ali
  Cc: rafael, tglx, mingo, bp, dave.hansen, lenb, hpa, x86, linux-acpi,
	linux-kernel

On Sun, May 25, 2025 at 06:00:42PM +0000, Khalid Ali wrote:
> From: Khalid Ali <khaliidcaliy@gmail.com>
> 
> According to ACPI spec 2.4 and 2.5, upon C-state
> transitions(specifically C2 and C3) it is required and explicitly
> mentioned to invalidate and writeback all modified cache line using
> WBINVD.
> 
> However the current ACPI C-state entry using monitor/mwait instructions
> it have been used CLFLUSH by flushing the cache line associated by
> monitored address. That what all about this patch addresses,
> invalidating all cache lines instead of single cache line.
> 
> Let me know if there any reason and decisions behind the current
> implementation.
> 
> Signed-off-by: Khalid Ali <khaliidcaliy@gmail.com>
> ---
>  arch/x86/kernel/acpi/cstate.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
> index d5ac34186555..eb3d435e08ad 100644
> --- a/arch/x86/kernel/acpi/cstate.c
> +++ b/arch/x86/kernel/acpi/cstate.c
> @@ -222,6 +222,9 @@ void __cpuidle acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cx)
>  	struct cstate_entry *percpu_entry;
>  
>  	percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu);
> +	/* flush and invalidate all modified cache line on C3 and C2 state entry*/
> +	if (cx->type == ACPI_STATE_C3 || cx->type == ACPI_STATE_C2)
> +		wbinvd();

This is absolutely insane. This day and age, nobody should use WBINVD
ever. We've managed to not do this for decades, and I'm thinking that
either the SPEC is 'mistaken' or otherwise out of line with reality.

If you hate performance, and you want to break things like CAT, feel
free to put this in your own kernel.

>  	mwait_idle_with_hints(percpu_entry->states[cx->index].eax,
>  	                      percpu_entry->states[cx->index].ecx);
>  }
> -- 
> 2.49.0
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/ACPI: invalidate all cache lines on ACPI C-state transitions
  2025-05-26 12:00 ` Peter Zijlstra
@ 2025-05-26 13:45   ` Khalid Ali
  2025-05-26 16:07     ` Peter Zijlstra
  0 siblings, 1 reply; 5+ messages in thread
From: Khalid Ali @ 2025-05-26 13:45 UTC (permalink / raw)
  To: peterz
  Cc: bp, dave.hansen, hpa, khaliidcaliy, lenb, linux-acpi,
	linux-kernel, mingo, rafael, tglx, x86

> This is absolutely insane. This day and age, nobody should use WBINVD
> ever. We've managed to not do this for decades, and I'm thinking that
> either the SPEC is 'mistaken' or otherwise out of line with reality.

> If you hate performance, and you want to break things like CAT, feel
> free to put this in your own kernel.
Sorry, i made a mistake, i meant ACPI 6.4 and 6.5. I already resent this patch
please check the resended one.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/ACPI: invalidate all cache lines on ACPI C-state transitions
  2025-05-26 13:45   ` Khalid Ali
@ 2025-05-26 16:07     ` Peter Zijlstra
  2025-05-26 17:04       ` Khalid Ali
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2025-05-26 16:07 UTC (permalink / raw)
  To: Khalid Ali
  Cc: bp, dave.hansen, hpa, lenb, linux-acpi, linux-kernel, mingo,
	rafael, tglx, x86

On Mon, May 26, 2025 at 01:45:33PM +0000, Khalid Ali wrote:
> > This is absolutely insane. This day and age, nobody should use WBINVD
> > ever. We've managed to not do this for decades, and I'm thinking that
> > either the SPEC is 'mistaken' or otherwise out of line with reality.
> 
> > If you hate performance, and you want to break things like CAT, feel
> > free to put this in your own kernel.
> Sorry, i made a mistake, i meant ACPI 6.4 and 6.5. I already resent this patch
> please check the resended one.

Doesn't matter. We're categorically not going to be doing this. Rafael,
who do we kick to get the ACPI SPEC fixed?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/ACPI: invalidate all cache lines on ACPI C-state transitions
  2025-05-26 16:07     ` Peter Zijlstra
@ 2025-05-26 17:04       ` Khalid Ali
  0 siblings, 0 replies; 5+ messages in thread
From: Khalid Ali @ 2025-05-26 17:04 UTC (permalink / raw)
  To: peterz
  Cc: bp, dave.hansen, hpa, khaliidcaliy, lenb, linux-acpi,
	linux-kernel, mingo, rafael, tglx, x86

> > > This is absolutely insane. This day and age, nobody should use WBINVD
> > > ever. We've managed to not do this for decades, and I'm thinking that
> > > either the SPEC is 'mistaken' or otherwise out of line with reality.
> 
> > > If you hate performance, and you want to break things like CAT, feel
> > > free to put this in your own kernel.
> > Sorry, i made a mistake, i meant ACPI 6.4 and 6.5. I already resent this patch
> > please check the resended one.
> Doesn't matter. We're categorically not going to be doing this. Rafael,
> who do we kick to get the ACPI SPEC fixed?

First of all, am i talking to some kinda roasting robot?
Please talk professionally, fix the way you talk before you fix a code (of course if i am talking to human being).
I am here waiting for a real answer, so please just tell me i don't know how hard is to say yes or no. 
And tell me the reason.

BTW, if your english isn't perfect, i get that and i am sorry for what i said.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-05-26 17:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-25 18:00 [PATCH] x86/ACPI: invalidate all cache lines on ACPI C-state transitions Khalid Ali
2025-05-26 12:00 ` Peter Zijlstra
2025-05-26 13:45   ` Khalid Ali
2025-05-26 16:07     ` Peter Zijlstra
2025-05-26 17:04       ` Khalid Ali

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.