Re: [PATCH -v2 4/7] x86, NMI, Rewrite NMI handler

Huang Ying
2010-09-28T01:03:56Z

On Mon, 2010-09-27 at 21:25 +0800, Robert Richter wrote:
> On 27.09.10 08:39:24, huang ying wrote:
>
> Looking at all you comments below I would vote for the following:
>
> We implement all handlers using DIE_NMI and set its priority
> accordingly in struct notifier_block when registering the the nmi
> handler. We define NMI priorities as macros such as
> NMI_PRIORITY_LOCAL, NMI_PRIORITY_WATCHDOG, NMI_PRIORITY_IO, etc. and
> require all handlers to set the priority. register_die_notifier() with
> (!nb->priority) should return -EINVAL. DIE_NMI_UNKNOWN should only be
> used if there is a handler for the case when all others fail such as
> implemented in the perf nmi handler or when reporting an unknown nmi.
>
> This will avoid all the confusion below and also makes the code much
> cleaner.

Use priority to enforce the order has some issues except what Don
pointed out (two registers for two call in chain):

- Almost all direct call in default_do_nmi() must be turned into
notifier_block. I know this is what you want. But I am not a big fan of
notifier chain :)

- This makes order of notifier call more implicitly. And I think the
order is important for NMI handler to work properly.

- In your scheme, both die_val (DIE_NMI or DIE_NMI_UNKNOWN) and priority
are used to determine the order of call. This makes code more complex
and no additional benefit.

So I think it is better to use different die_val to determine the order,
and insert some direct call between them.

Best Regards,
Huang Ying