Re: [PATCH v6 3/9] x86/nmi: Extend the registration interface to include the NMI-source vector

From: Sohil Mehta
Date: Tue Jun 03 2025 - 14:03:03 EST


On 6/3/2025 10:07 AM, Dave Hansen wrote:
> On 5/13/25 13:37, Sohil Mehta wrote:

>> - retval = register_nmi_handler(NMI_IO_CHECK, hpwdt_pretimeout, 0, "hpwdt");
>> + retval = register_nmi_handler(NMI_IO_CHECK, hpwdt_pretimeout, 0, "hpwdt", 0);
>> if (retval)
>
> Could we get rid of all these random 0's, please? (or at least try to
> keep them from proliferating).
>

I had patches for avoiding both zeros, but I ended up not including
them. I wasn't sure if folks prefer '0' when not using a parameter or
explicitly prefer to deny.

> Either do a:
>
> register_nmi_handler_source()
>
> that takes a source and leave
>
> register_nmi_handler()
>
> in place and not take a source. Or, do this:

>
> retval = register_nmi_handler(NMI_IO_CHECK, hpwdt_pretimeout,
> 0, "hpwdt", NMI_NO_SOURCE);
>

I prefer this approach. Since we are touching all these lines, maybe
it's a good time to get rid of the other 0 as well (in a separate patch).

The 3rd parameter pertains to handler "flags". The only flag in use
right now is NMI_FLAG_FIRST. Assuming that more flags might get added
later, the 0 should probably correspond to NMI_FLAG_NONE. Agree?

The other option would be NMI_FLAG_LAST, which would be the opposite of
NMI_FLAG_FIRST, but that seems shortsighted.


> where the 0 is at least given a symbolic name.