From: Frederic Weisbecker <fweisbec@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 3/3] ring-buffer: make cpu buffer entries counter atomic
Date: Sat, 2 May 2009 00:10:23 +0200 [thread overview]
Message-ID: <20090501221022.GC6404@nowhere> (raw)
In-Reply-To: <alpine.DEB.2.00.0905011023580.20374@gandalf.stny.rr.com>
On Fri, May 01, 2009 at 10:28:13AM -0400, Steven Rostedt wrote:
>
>
>
> On Fri, 1 May 2009, Frederic Weisbecker wrote:
>
> > On Fri, May 01, 2009 at 01:50:47PM +0200, Ingo Molnar wrote:
> > >
> > > * Steven Rostedt <rostedt@goodmis.org> wrote:
> > >
> > > > From: Steven Rostedt <srostedt@redhat.com>
> > > >
> > > > The entries counter in cpu buffer is not atomic. Although it only
> > > > gets updated by a single CPU, interrupts may come in and update
> > > > the counter too. This would cause missing entries to be added.
> > >
> > > > - unsigned long entries;
> > > > + atomic_t entries;
> > >
> > > Hm, that's not really good as atomics can be rather expensive and
> > > this is the fastpath.
> > >
> > > This is the upteenth time or so that the fact that we do not disable
> > > irqs while generating trace entries bites us in one way or another.
> > > IRQs can come in and confuse function trace output, etc. etc.
> > >
> > > Please lets do what i suggested a long time ago: disable irqs _once_
> > > in any trace point and run atomically from that point on, and enable
> > > them once, at the end.
> > >
> > > The cost is very small and it turns into a win immediately by
> > > elimination of a _single_ atomic instruction. (even on Nehalem they
> > > cost 20 cycles. More on older CPUs.) We can drop the preempt-count
> > > disable/enable as well and a lot of racy code as well. Please.
> > >
> > > Ingo
> >
> >
> > I also suspect one other good effect on doing this.
> >
> > As you know, between a lock_reserve and a discard, several interrupts
> > can trigger some traces. It means that if some rooms have already been
> > reserved, the discard will really create a discarded entry and we
> > can't reuse it.
> >
> > For example in the case of filters with lock tracing, we rapidly run
> > into entries overriden, making the lock events tracing about useless
> > because we rapidly lose everything.
>
> If you want, we can disable interrupts from the event tracer, not the ring
> buffer.
>
> We would have to go back to the original ring buffer code that passed in
> flags.
Or may be just copy the entry on the stack and filter on it,
then only reserve if it is eligible.
> >
> > At least that's an effect I observed. I'm not sure the discard is the
> > real cause but it seems to make sense.
> >
> > That's a pity because believe me it is very useful to hunt a softlockup.
> >
> > Of course it doesn't prevent from NMI tempest, but we already have
> > protections for that.
>
> If we do not allow interrupts to be traced, we can not allow NMIs either.
> If we do not let the ring buffer be re-entrant, then we will not be able
> to trace any NMI (to be safe).
>
> Going this route, there would be no need to make a lockless ring buffer
> either.
Hm that's really not what we want, indeed :-)
Just forget about what I said.
>
> -- Steve
>
next prev parent reply other threads:[~2009-05-01 22:15 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-01 2:22 [PATCH 0/3] [GIT PULL] tracing/ringbuffer: updates for tip Steven Rostedt
2009-05-01 2:22 ` [PATCH 1/3] ring-buffer: add counters for commit overrun and nmi dropped entries Steven Rostedt
2009-05-01 3:00 ` Andrew Morton
2009-05-01 3:11 ` Steven Rostedt
2009-05-01 3:22 ` Andrew Morton
2009-05-01 3:33 ` Steven Rostedt
2009-05-01 3:38 ` Andrew Morton
2009-05-01 3:55 ` Steven Rostedt
2009-05-01 2:22 ` [PATCH 2/3] tracing: export stats of ring buffers to userspace Steven Rostedt
2009-05-01 3:08 ` Frederic Weisbecker
2009-05-01 3:23 ` Steven Rostedt
2009-05-01 12:43 ` Frederic Weisbecker
2009-05-01 2:22 ` [PATCH 3/3] ring-buffer: make cpu buffer entries counter atomic Steven Rostedt
2009-05-01 3:06 ` Andrew Morton
2009-05-01 3:28 ` Steven Rostedt
2009-05-01 11:50 ` Ingo Molnar
2009-05-01 13:42 ` Frederic Weisbecker
2009-05-01 14:28 ` Steven Rostedt
2009-05-01 22:10 ` Frederic Weisbecker [this message]
2009-05-01 14:23 ` Steven Rostedt
2009-05-01 16:14 ` Steven Rostedt
2009-05-01 16:20 ` Ingo Molnar
2009-05-01 16:31 ` Steven Rostedt
2009-05-01 16:32 ` Steven Rostedt
2009-05-01 16:52 ` Ingo Molnar
2009-05-01 17:11 ` Steven Rostedt
2009-05-01 17:14 ` Ingo Molnar
2009-05-01 17:36 ` Steven Rostedt
2009-05-01 17:42 ` Ingo Molnar
2009-05-01 17:56 ` Steven Rostedt
2009-05-01 21:17 ` Steven Rostedt
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=20090501221022.GC6404@nowhere \
--to=fweisbec@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.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