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

From: Andi Kleen

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


On Mon, Nov 02, 2026 at 06:27:30PM +0200, Adrian Hunter wrote:
> On 02/11/2026 18:15, Andi Kleen wrote:
> >> +
> >> +/*
> >> + * Tracing must not continue into a kexec'ed kernel, which may reuse the
> >> + * trace buffer memory, so stop tracing on all CPUs and prevent it from
> >> + * being started again. Events are left in place, but record nothing more.
> >> + */
> >> +static void pt_syscore_shutdown(void *data)
> >> +{
> >> + WRITE_ONCE(pt_shutdown, true);
> >> + on_each_cpu(pt_shutdown_cpu, NULL, 1);
> >
> > I don't think adding more and more broadcast NMIs to the panic path
> > is a good idea. It's always a very big hammer and a risky operation
> > that risks breaking the actual dump. panic reallhy needs to be
> > simple and reliable, and this is the total opposite.
>
> Is pt_syscore_shutdown() called on a panic path? I can't find a way.

It's called from kexec which can be called from panic.

>
> >
> > KVM already does one at least (which I never liked either). At a
> > minimum please find a way to consolidate those into a single
> > one (as in have a notifier chain that is called on the target CPU).
> >
> > But better would be to not do this and find some other way.
> >
> > How about just passing the PT region as reserved and maybe free
> > it later after the target kernel had a chance to reinitialize all CPUs?
>
> Intel PT has cpu_emergency_stop_pt().

?