All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] x86: Use 32-bit counter for TLB clock on debug builds
@ 2026-01-13 12:09 Alejandro Vallejo
  2026-01-13 12:43 ` Andrew Cooper
  2026-01-13 14:17 ` Roger Pau Monné
  0 siblings, 2 replies; 5+ messages in thread
From: Alejandro Vallejo @ 2026-01-13 12:09 UTC (permalink / raw)
  To: xen-devel
  Cc: Alejandro Vallejo, Jan Beulich, Andrew Cooper,
	Roger Pau Monné

Debug builds traditionally ship with a 10-bit counter for the TLB
clock. This forces global TLB shootdowns with high frequency, making
debug builds unsuitable for any form of real time testing.

Remove this quirk, unifying release and debug under a wide counter.

Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@amd.com>
---
v1: https://lore.kernel.org/xen-devel/20260112140851.55590-1-alejandro.garciavallejo@amd.com/
v2:
  * Remove WRAP_MASK instead.
  * Commit message/title rewrites.
---
 xen/arch/x86/flushtlb.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/xen/arch/x86/flushtlb.c b/xen/arch/x86/flushtlb.c
index 09e676c151..23721bb52c 100644
--- a/xen/arch/x86/flushtlb.c
+++ b/xen/arch/x86/flushtlb.c
@@ -19,13 +19,6 @@
 #include <asm/pv/domain.h>
 #include <asm/spec_ctrl.h>
 
-/* Debug builds: Wrap frequently to stress-test the wrap logic. */
-#ifdef NDEBUG
-#define WRAP_MASK (0xFFFFFFFFU)
-#else
-#define WRAP_MASK (0x000003FFU)
-#endif
-
 #ifndef CONFIG_PV
 # undef X86_CR4_PCIDE
 # define X86_CR4_PCIDE 0
@@ -55,7 +48,7 @@ static u32 pre_flush(void)
         /* Clock wrapped: someone else is leading a global TLB shootdown. */
         if ( unlikely(t1 == 0) )
             goto skip_clocktick;
-        t2 = (t + 1) & WRAP_MASK;
+        t2 = t + 1;
     }
     while ( unlikely((t = cmpxchg(&tlbflush_clock, t1, t2)) != t1) );
 

base-commit: a2a34d76643e49ccc949296c9a45888034e50b55
-- 
2.43.0



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

* Re: [PATCH v2] x86: Use 32-bit counter for TLB clock on debug builds
  2026-01-13 12:09 [PATCH v2] x86: Use 32-bit counter for TLB clock on debug builds Alejandro Vallejo
@ 2026-01-13 12:43 ` Andrew Cooper
  2026-01-13 14:17 ` Roger Pau Monné
  1 sibling, 0 replies; 5+ messages in thread
From: Andrew Cooper @ 2026-01-13 12:43 UTC (permalink / raw)
  To: Alejandro Vallejo, xen-devel
  Cc: Andrew Cooper, Jan Beulich, Roger Pau Monné

On 13/01/2026 12:09 pm, Alejandro Vallejo wrote:
> Debug builds traditionally ship with a 10-bit counter for the TLB
> clock. This forces global TLB shootdowns with high frequency, making
> debug builds unsuitable for any form of real time testing.
>
> Remove this quirk, unifying release and debug under a wide counter.
>
> Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@amd.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>


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

* Re: [PATCH v2] x86: Use 32-bit counter for TLB clock on debug builds
  2026-01-13 12:09 [PATCH v2] x86: Use 32-bit counter for TLB clock on debug builds Alejandro Vallejo
  2026-01-13 12:43 ` Andrew Cooper
@ 2026-01-13 14:17 ` Roger Pau Monné
  2026-01-13 14:18   ` Andrew Cooper
  1 sibling, 1 reply; 5+ messages in thread
From: Roger Pau Monné @ 2026-01-13 14:17 UTC (permalink / raw)
  To: Alejandro Vallejo; +Cc: xen-devel, Jan Beulich, Andrew Cooper

On Tue, Jan 13, 2026 at 01:09:58PM +0100, Alejandro Vallejo wrote:
> Debug builds traditionally ship with a 10-bit counter for the TLB
> clock. This forces global TLB shootdowns with high frequency, making
> debug builds unsuitable for any form of real time testing.
> 
> Remove this quirk, unifying release and debug under a wide counter.

I wonder if it makes any sense to provide this as a Kconfig tunable,
set to 32bit width for both debug and release builds?

Not sure whether there's a ton of interest in stressing the flushing
however, and by then it's a small hack to adjust the code itself.

Regards, Roger.


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

* Re: [PATCH v2] x86: Use 32-bit counter for TLB clock on debug builds
  2026-01-13 14:17 ` Roger Pau Monné
@ 2026-01-13 14:18   ` Andrew Cooper
  2026-01-13 14:26     ` Roger Pau Monné
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cooper @ 2026-01-13 14:18 UTC (permalink / raw)
  To: Roger Pau Monné, Alejandro Vallejo
  Cc: Andrew Cooper, xen-devel, Jan Beulich

On 13/01/2026 2:17 pm, Roger Pau Monné wrote:
> On Tue, Jan 13, 2026 at 01:09:58PM +0100, Alejandro Vallejo wrote:
>> Debug builds traditionally ship with a 10-bit counter for the TLB
>> clock. This forces global TLB shootdowns with high frequency, making
>> debug builds unsuitable for any form of real time testing.
>>
>> Remove this quirk, unifying release and debug under a wide counter.
> I wonder if it makes any sense to provide this as a Kconfig tunable,
> set to 32bit width for both debug and release builds?

That was v1, and both Jan and myself said "prefer not".

~Andrew


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

* Re: [PATCH v2] x86: Use 32-bit counter for TLB clock on debug builds
  2026-01-13 14:18   ` Andrew Cooper
@ 2026-01-13 14:26     ` Roger Pau Monné
  0 siblings, 0 replies; 5+ messages in thread
From: Roger Pau Monné @ 2026-01-13 14:26 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Alejandro Vallejo, xen-devel, Jan Beulich

On Tue, Jan 13, 2026 at 02:18:22PM +0000, Andrew Cooper wrote:
> On 13/01/2026 2:17 pm, Roger Pau Monné wrote:
> > On Tue, Jan 13, 2026 at 01:09:58PM +0100, Alejandro Vallejo wrote:
> >> Debug builds traditionally ship with a 10-bit counter for the TLB
> >> clock. This forces global TLB shootdowns with high frequency, making
> >> debug builds unsuitable for any form of real time testing.
> >>
> >> Remove this quirk, unifying release and debug under a wide counter.
> > I wonder if it makes any sense to provide this as a Kconfig tunable,
> > set to 32bit width for both debug and release builds?
> 
> That was v1, and both Jan and myself said "prefer not".

We already have this fixed to 32-bit width in XenServer patch queue for
both release and debug builds.  Certainly no strong opinion, I never
had the need to tweak this, and anyone that has to will likely be
perfectly fine with adjusting the code.

Thanks, Roger.


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

end of thread, other threads:[~2026-01-13 14:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-13 12:09 [PATCH v2] x86: Use 32-bit counter for TLB clock on debug builds Alejandro Vallejo
2026-01-13 12:43 ` Andrew Cooper
2026-01-13 14:17 ` Roger Pau Monné
2026-01-13 14:18   ` Andrew Cooper
2026-01-13 14:26     ` Roger Pau Monné

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.