Re: [PATCH v5 9/9] x86/nmi: Include NMI-source information in tracepoint and debug prints

Sohil Mehta
2025-05-08T00:02:52Z

On 5/7/2025 2:48 PM, Steven Rostedt wrote:
> On Tue, 6 May 2025 18:21:45 -0700
> Sohil Mehta <sohil.mehta@intel.com> wrote:
>
>> diff --git a/include/trace/events/nmi.h b/include/trace/events/nmi.h
>> index 18e0411398ba..6e4a1ff70a44 100644
>> --- a/include/trace/events/nmi.h
>> +++ b/include/trace/events/nmi.h
>> @@ -10,29 +10,32 @@
>>
>> TRACE_EVENT(nmi_handler,
>>
>> - TP_PROTO(void *handler, s64 delta_ns, int handled),
>> + TP_PROTO(void *handler, s64 delta_ns, int handled, unsigned long source_bitmap),
>
> Even though x86 is currently the only architecture using the nmi
> tracepoint, this "source_bitmap" makes it become very x86 specific.
>

Sure. Will move it into x86.

> This file should be moved into arch/x86/include/asm/trace/
>
> And that would require adding to the Makefile:
>
> CFLAGS_nmi.o := -I $(src)/../include/asm/trace
>

Thank you for the detailed instructions. It makes it a lot easier.

> diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
> index 183e3e717326..b9ece0b63ca7 100644
> --- a/arch/x86/kernel/nmi.c
> +++ b/arch/x86/kernel/nmi.c
> @@ -202,7 +202,7 @@ static int nmi_handle(unsigned int type, struct pt_regs *regs)
> thishandled = a->handler(type, regs);
> handled += thishandled;
> delta = sched_clock() - delta;
> - trace_nmi_handler(a->handler, (int)delta, thishandled);
> + trace_nmi_handler(a->handler, (int)delta, thishandled, source_bitmap);
>
> nmi_check_duration(a, delta);
> }

Also, I just realized that the source_bitmap information might be
incorrect for !NMI_LOCAL. With the new changes suggested by PeterZ in
patch 5, the source_bitmap would be significantly different from the
original one received from fred_event_data().

I need to figure out a solution to print it accurately in all situations.

Sohil