All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, stable <stable@vger.kernel.org>,
	Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	David Sharp <dhsharp@google.com>
Subject: Re: [PATCH 4/4] ring-buffer: Fix uninitialized read_stamp
Date: Fri, 6 Jul 2012 11:14:15 +0200	[thread overview]
Message-ID: <20120706091415.GA30152@gmail.com> (raw)
In-Reply-To: <20120706091153.GD24449@gmail.com>


* Ingo Molnar <mingo@kernel.org> wrote:

> * Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> > On Thu, 2012-06-28 at 19:16 -0400, Steven Rostedt wrote:
> > > From: Steven Rostedt <srostedt@redhat.com>
> > > 
> > > The ring buffer reader page is used to swap a page from the writable
> > > ring buffer. If the writer happens to be on that page, it ends up on the
> > > reader page, but will simply move off of it, back into the writable ring
> > > buffer as writes are added.
> > > 
> > > The time stamp passed back to the readers is stored in the cpu_buffer per
> > > CPU descriptor. This stamp is updated when a swap of the reader page takes
> > > place, and it reads the current stamp from the page taken from the writable
> > > ring buffer. Everytime a writer goes to a new page, it updates the time stamp
> > > of that page.
> > > 
> > > The problem happens if a reader reads a page from an empty per CPU ring buffer.
> > > If the buffer is empty, the swap still takes place, placing the writer at the
> > > start of the reader page. If at a later time, a write happens, it updates the
> > > page's time stamp and continues. But the problem is that the read_stamp does
> > > not get updated, because the page was already swapped.
> > > 
> > > The solution to this was to not swap the page if the ring buffer happens to
> > > be empty. This also removes the side effect that the writes on the reader
> > > page will not get updated because the writer never gets back on the reader
> > > page without a swap. That is, if a read happens on an empty buffer, but then
> > > no reads happen for a while. If a swap took place, and the writer were to start
> > > writing a lot of data (function tracer), it will start overflowing the ring buffer
> > > and overwrite the older data. But because the writer never goes back onto the
> > > reader page, the data left on the reader page never gets overwritten. This
> > > causes the reader to see really old data, followed by a jump to newer data.
> > > 
> > > Link: http://lkml.kernel.org/r/1340060577-9112-1-git-send-email-dhsharp@google.com
> > > Google-Bug-Id: 6410455
> > > Reported-by: David Sharp <dhsharp@google.com>
> > > tested-by: David Sharp <dhsharp@google.com>
> > > Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> > 
> > I'm starting to consider that this patch should be in stable.
> > 
> > Ingo, should I push this to urgent?
> 
> Yeah, probably makes sense to do so, especially as it's rather 
> small.

FYI, I have cherry picked it over into perf/urgent:

01c4359c155e ring-buffer: Fix uninitialized read_stamp


Thanks,

	Ingo

      reply	other threads:[~2012-07-06  9:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-28 23:16 [PATCH 0/4] [GIT PULL][v3.6] tracing: updates Steven Rostedt
2012-06-28 23:16 ` [PATCH 1/4] tracing/selftest: Add a WARN_ON() if a tracer test fails Steven Rostedt
2012-06-28 23:16 ` [PATCH 2/4] tracing/kvm: Use __print_hex() for kvm_emulate_insn tracepoint Steven Rostedt
2012-06-28 23:16 ` [PATCH 3/4] tracing: Remove NR_CPUS array from trace_iterator Steven Rostedt
2012-06-28 23:16 ` [PATCH 4/4] ring-buffer: Fix uninitialized read_stamp Steven Rostedt
2012-07-02 16:16   ` Steven Rostedt
2012-07-06  9:11     ` Ingo Molnar
2012-07-06  9:14       ` Ingo Molnar [this message]

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=20120706091415.GA30152@gmail.com \
    --to=mingo@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=dhsharp@google.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.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 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.