Re: [V4][PATCH 4/6] x86, nmi: add in logic to handle multipleevents and unknown NMIs

From: Robert Richter
Date: Wed Sep 14 2011 - 16:22:29 EST


On 14.09.11 08:56:40, Don Zickus wrote:
> On Tue, Sep 13, 2011 at 04:58:27PM -0400, Don Zickus wrote:
> >
> > V3:
> > - redesigned the algorithm to utilize Avi's idea of detecting a back-to-back
> > NMI with %rip.
>
> Hi Robert,
>
> I realized I added an optimization for executing the nmi handlers to help
> minimize the impact on the virt folks and realize it might break your IBS
> stuff.
>
> > -static int notrace __kprobes nmi_handle(unsigned int type, struct pt_regs *regs)
> > +static int notrace __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2b)
> > {
> > struct nmi_desc *desc = nmi_to_desc(type);
> > struct nmiaction *next_a, *a, **ap = &desc->head;
> > @@ -87,6 +87,16 @@ static int notrace __kprobes nmi_handle(unsigned int type, struct pt_regs *regs)
> >
> > handled += a->handler(type, regs);
> >
> > + /*
> > + * Optimization: only loop once if this is not a
> > + * back-to-back NMI. The idea is nothing is dropped
> > + * on the first NMI, only on the second of a back-to-back
> > + * NMI. No need to waste cycles going through all the
> > + * handlers.
> > + */
> > + if (!b2b && handled)
> > + break;
> > +
> > a = next_a;
> > }
> > rcu_read_unlock();
>
> The optimization is to run through the handlers until one of them claims
> the NMI but only for the first NMI. Whereas on the second half of a
> back-to-back NMI, run through all the handlers regardless of how many
> claim they handled it.
>
> Does your IBS stuff need to always run through two handlers?

As said in my previous answer, it might probably work, but I will test
it.

-Robert

--
Advanced Micro Devices, Inc.
Operating System Research Center

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/