From: Peter Zijlstra <peterz@infradead.org>
To: Don Zickus <dzickus@redhat.com>
Cc: x86@kernel.org, Andi Kleen <andi@firstfloor.org>,
gong.chen@linux.intel.com, LKML <linux-kernel@vger.kernel.org>,
Elliott@hp.com, fweisbec@gmail.com, dave.hansen@linux.intel.com
Subject: Re: [PATCH 1/6] x86, nmi: Implement delayed irq_work mechanism to handle lost NMIs
Date: Wed, 21 May 2014 21:38:30 +0200 [thread overview]
Message-ID: <20140521193830.GK2485@laptop.programming.kicks-ass.net> (raw)
In-Reply-To: <20140521190225.GC50500@redhat.com>
On Wed, May 21, 2014 at 03:02:25PM -0400, Don Zickus wrote:
> On Wed, May 21, 2014 at 07:51:49PM +0200, Peter Zijlstra wrote:
> > On Wed, May 21, 2014 at 12:45:25PM -0400, Don Zickus wrote:
> > > > > + /*
> > > > > + * Can't use send_IPI_self here because it will
> > > > > + * send an NMI in IRQ context which is not what
> > > > > + * we want. Create a cpumask for local cpu and
> > > > > + * force an IPI the normal way (not the shortcut).
> > > > > + */
> > > > > + bitmap_zero(nmi_mask, NR_CPUS);
> > > > > + mask = to_cpumask(nmi_mask);
> > > > > + cpu_set(smp_processor_id(), *mask);
> > > > > +
> > > > > + __this_cpu_xchg(nmi_delayed_work_pending, true);
> > > >
> > > > Why is this xchg and not __this_cpu_write() ?
> > > >
> > > > > + apic->send_IPI_mask(to_cpumask(nmi_mask), NMI_VECTOR);
> > > >
> > > > What's wrong with apic->send_IPI_self(NMI_VECTOR); ?
> > >
> > > I tried to explain that in my comment above. IPI_self uses the shortcut
> > > method to send IPIs which means the NMI_VECTOR will be delivered in IRQ
> > > context _not_ NMI context. :-( This is why I do the whole silly dance.
> >
> > I'm still not getting it, probably because I don't know how these APICs
> > really work, but the way I read both the comment and your explanation
> > here is that we get an NMI nested in the IRQ context we called it from,
> > which is pretty much exactly what we want.
>
> Um, ok. I think my concern with that is an NMI nested in IRQ context
> could be interrupted by a real NMI. I believe that would cause nmi_enter()
> to barf among other bad things in the nmi code.
Ohh, you mean the NMI handler will run as a regular interrupt? Yes, that
would be bad.
> > > So both my problems center around what guarantees does irq_work have to
> > > stay on the same cpu?
> >
> > Well, none as you used a global irq_work, so all cpus will now contend
> > on it on every NMI trying to queue it :-(
>
> Yes, I was stuck between using a per-cpu implementation in which every dummy
> NMI grabs the spin lock in the nmi handlers, or a global lock. I tried
> the global lock.
>
> I thought the irq_work lock seemed less contended because it was only read
> once before being acted upon (for a cacheline seperate from actual nmi work).
>
> Whereas a spin lock in the nmi handlers seems to keep reading the lock
> until it owns it thus slowing down useful work for the handler that owns
> the lock (because of the cache contention).
>
> I could be wrong though.
Well, pretty much every NMI will call irq_queue_work() which calls
irq_work_claim() which does an uncondition cmpxchg (locked rmw) on the
global cacheline.
Which is *hurt*.
will try and reply to the rest later..
next prev parent reply other threads:[~2014-05-21 19:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-15 19:25 [PATCH 0/6 V2] x86, nmi: Various fixes and cleanups Don Zickus
2014-05-15 19:25 ` [PATCH 1/6] x86, nmi: Implement delayed irq_work mechanism to handle lost NMIs Don Zickus
2014-05-21 10:29 ` Peter Zijlstra
2014-05-21 16:45 ` Don Zickus
2014-05-21 17:51 ` Peter Zijlstra
2014-05-21 19:02 ` Don Zickus
2014-05-21 19:38 ` Peter Zijlstra [this message]
2014-05-15 19:25 ` [PATCH 2/6] x86, nmi: Add new nmi type 'external' Don Zickus
2014-05-15 19:25 ` [PATCH 3/6] x86, nmi: Add boot line option 'panic_on_unrecovered_nmi' and 'panic_on_io_nmi' Don Zickus
2014-05-15 19:25 ` [PATCH 4/6] x86, nmi: Remove 'reason' value from unknown nmi output Don Zickus
2014-05-15 19:25 ` [PATCH 5/6] x86, nmi: Move default external NMI handler to its own routine Don Zickus
2014-05-21 10:38 ` Peter Zijlstra
2014-05-21 16:48 ` Don Zickus
2014-05-21 18:17 ` Peter Zijlstra
2014-05-21 19:13 ` Don Zickus
2014-05-15 19:25 ` [PATCH 6/6 V2] x86, nmi: Add better NMI stats to /proc/interrupts and show handlers Don Zickus
2014-05-15 20:28 ` [PATCH 0/6 V2] x86, nmi: Various fixes and cleanups Don Zickus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140521193830.GK2485@laptop.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=Elliott@hp.com \
--cc=andi@firstfloor.org \
--cc=dave.hansen@linux.intel.com \
--cc=dzickus@redhat.com \
--cc=fweisbec@gmail.com \
--cc=gong.chen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome