Re: [PATCH v2 x86 1/2] fix page faults by nmiaction in nmi if kmemcheck is enabled

Wim Van Sebroeck
2012-03-05T10:29:22Z

Hi Li,

> diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
> index 8464ea1..e575e63 100644
> --- a/drivers/watchdog/hpwdt.c
> +++ b/drivers/watchdog/hpwdt.c
> @@ -689,9 +689,22 @@ static void __devinit dmi_find_icru(const struct dmi_header *dm, void *dummy)
> }
> }
>
> +static struct nmiaction hpwdt_nmiaction[] = {
> + {
> + .handler = hpwdt_pretimeout,
> + .name = "hpwdt",
> + },
> + {
> + .handler = hpwdt_pretimeout,
> + .flags = NMI_FLAG_FIRST,
> + .name = "hpwdt",
> + },
> +};
> +
> static int __devinit hpwdt_init_nmi_decoding(struct pci_dev *dev)
> {
> int retval;
> + struct nmiaction *na = hpwdt_nmiaction;
>
> /*
> * On typical CRU-based systems we need to map that service in
> @@ -733,9 +746,11 @@ static int __devinit hpwdt_init_nmi_decoding(struct pci_dev *dev)
> * die notify list to handle a critical NMI. The default is to
> * be last so other users of the NMI signal can function.
> */
> - retval = register_nmi_handler(NMI_UNKNOWN, hpwdt_pretimeout,
> - (priority) ? NMI_FLAG_FIRST : 0,
> - "hpwdt");
> +
> + if (priority)
> + na = &hpwdt_nmiaction[1];
> +
> + retval = register_nmi_handler(NMI_UNKNOWN, na);
> if (retval != 0) {
> dev_warn(&dev->dev,
> "Unable to register a die notifier (err=%d).\n",

Why not do something like;

static struct nmiaction hpwdt_nmiaction = {
.handler = hpwdt_pretimeout,
.name = "hpwdt",
};

...
if (priority)
hpwdt_nmiaction.flags = NMI_FLAG_FIRST;
...

Kind regards,
Wim.