Re: [PATCH 3/6] perf/x86/intel/pt: Stop tracing at syscore shutdown

From: Peter Zijlstra

Date: Mon Nov 02 2026 - 06:02:40 EST


On Mon, Nov 02, 2026 at 12:23:57PM +0200, Adrian Hunter wrote:
> On 02/11/2026 12:04, Peter Zijlstra wrote:
> > On Mon, Nov 02, 2026 at 09:40:36AM +0200, Adrian Hunter wrote:
> >> +static void pt_shutdown_cpu(void *info)
> >> +{
> >> + u64 ctl;
> >> +
> >> + /*
> >> + * After VMXON on CPUs without PT support in VMX operation,
> >> + * TraceEn is already clear and RTIT_CTL must not be written.
> >> + */
> >> + rdmsrq(MSR_IA32_RTIT_CTL, ctl);
> >> + if (ctl & RTIT_CTL_TRACEEN)
> >> + wrmsrq(MSR_IA32_RTIT_CTL, ctl & ~RTIT_CTL_TRACEEN);
> >> +}
> >
> > Why not unconditionally do: wrmsrq(MSR_IA32_RTIT_CTL, 0), at this point?
>
> Writing 0 instead of ctl & ~RTIT_CTL_TRACEEN would be fine, but the
> condition is needed. The comment tries to explain.
>
> The first processor to support Intel PT (BDW) will #GP if a write is
> made to RTIT_CTL while VMX is on. Since VMXON clears TRACEEN,
> if TRACEEN is set, then the write is safe.

I hate computers...