From: Don Zickus <dzickus@redhat.com>
To: ZAK Magnus <zakmagnus@google.com>, peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
Mandeep Singh Baines <msb@chromium.org>
Subject: Re: [PATCH v4 2/2] Output stall traces in /proc
Date: Mon, 8 Aug 2011 16:19:51 -0400 [thread overview]
Message-ID: <20110808201951.GY1972@redhat.com> (raw)
In-Reply-To: <CAAuSN91Pi8SbWbU87v7QdDWS_N1GiXsM8dGUYSYKTUCUp+2Mww@mail.gmail.com>
(adding Peter to the discussion)
On Fri, Aug 05, 2011 at 02:26:12PM -0700, ZAK Magnus wrote:
> On Fri, Aug 5, 2011 at 11:43 AM, Don Zickus <dzickus@redhat.com> wrote:
> > I missed that you defined that as a pointer to a spinlock and assigned it
> > later. I see what you are doing now, but I am not a fan of it because you
> > are now using the same spinlock in both the NMI context and the userspace
> > context. This can cause deadlocks if something got screwed up in the
> > seq_printf functions or produced a very large amount of data. Normally
> > you don't want to do that.
> >
> > What others have done like perf and the APEI error handling is use
> > something called irq_work_queue(??). Basically you would capture the
> > tracae in the NMI context, put it on an irq_work_queue and in the
> > interrupt context save it to your global trace variable. Then you could
> > put spin_lock_irqsave inside the proc sys function and the work queue
> > function and not have any potential deadlocks.
> Work queue? Okay. The worker thread still needs a lock in order to
not work_queue, irq_work_queue.
> share the intermediate buffer with the NMI context, though. Any chance
> of something screwing up in the middle of copying that structure,
> causing a stall and deadlocking with the NMI?
I believe irq_work_queue uses cmpxchg for all its locking and just swaps
entries on to a linked list?
>
> Or maybe the intermediate buffer should be dynamically allocated. That
> would work without a lock, although it seems slightly inefficient.
Peter,
How does the irq_work_queue work such that you can save info in the NMI
context and safely pass it to the irq context for processing?
>
> Regarding the lock between the work queue thread and the system call,
> maybe that should become a mutex instead, since it's all outside of
> interrupt context at that point?
No it is still in the irq context.
Peter,
If we want to expose data captured in the NMI context through the procfs,
I assume we can pass that info along using irq_work_queue. But then when
reading from procfs do we just lock the data with 'spin_lock_irq' to block
the irq_work_queue from manipulating the data? (note we are expecting
data to be overwritten with fresh data, not serialized out like
trace/perf).
Cheers,
Don
>
> > The softstall case should be ok though.
> Why's that? The soft stall traces are not written in a NMI context but
> just in a regular interrupt context, right? Doesn't that pose similar
> problems?
>
>
> These are weird rare corner cases anyway, right? Maybe the simplest
> thing could be to let the interrupts only try_lock(), so they might
> sometimes fail to record a stall, but it would be a pretty big
> coincidence.
next prev parent reply other threads:[~2011-08-08 20:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-04 22:13 [PATCH v4 1/2] Track hard and soft "short lockups" or "stalls." Alex Neronskiy
2011-08-04 22:13 ` [PATCH v4 2/2] Output stall traces in /proc Alex Neronskiy
2011-08-05 13:40 ` Don Zickus
2011-08-05 17:12 ` Alex Neronskiy
2011-08-05 18:43 ` Don Zickus
2011-08-05 21:26 ` ZAK Magnus
2011-08-08 20:19 ` Don Zickus [this message]
2011-08-08 20:52 ` Peter Zijlstra
2011-08-08 21:37 ` Don Zickus
2011-08-08 23:34 ` Alex Neronskiy
2011-08-09 21:08 ` Don Zickus
2011-08-09 21:44 ` Alex Neronskiy
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=20110808201951.GY1972@redhat.com \
--to=dzickus@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=msb@chromium.org \
--cc=peterz@infradead.org \
--cc=zakmagnus@google.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.