Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756672AbcCBBr0 (ORCPT ); Tue, 1 Mar 2016 20:47:26 -0500 Received: from mail333.us4.mandrillapp.com ([205.201.137.77]:44579 "EHLO mail333.us4.mandrillapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755074AbcCAXx5 (ORCPT ); Tue, 1 Mar 2016 18:53:57 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; q=dns; s=mandrill; d=linuxfoundation.org; b=Gc3uw3Cz50uVF1+Ts7Rs5a2rZYdTuXg6AoVwktQMWTaediJnTydEVfp0WmV++voY6FOnM0CM0f6m 14JolIVWgZzzaHcmsbjPCgyu8xU1g2sltrdwGtpSiWHLGAoTcfffDMUx3RLMVGvMDaXGd9NXEajv ZDz0D1dy1gN0g/IbRdo=; From: Greg Kroah-Hartman Subject: [PATCH 3.14 068/130] ring-buffer: Update read stamp with first real commit on page X-Mailer: git-send-email 2.7.2 To: Cc: Greg Kroah-Hartman , , Steven Rostedt Message-Id: <20160301234502.210314961@linuxfoundation.org> In-Reply-To: <20160301234459.768886030@linuxfoundation.org> References: <20160301234459.768886030@linuxfoundation.org> X-Report-Abuse: Please forward a copy of this message, including all headers, to abuse@mandrill.com X-Report-Abuse: You can also report abuse here: http://mandrillapp.com/contact/abuse?id=30481620.5aa7fa939c2040c7adffca05c5b62b22 X-Mandrill-User: md_30481620 Date: Tue, 01 Mar 2016 23:53:36 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2088 Lines: 60 3.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Steven Rostedt (Red Hat) commit b81f472a208d3e2b4392faa6d17037a89442f4ce upstream. Do not update the read stamp after swapping out the reader page from the write buffer. If the reader page is swapped out of the buffer before an event is written to it, then the read_stamp may get an out of date timestamp, as the page timestamp is updated on the first commit to that page. rb_get_reader_page() only returns a page if it has an event on it, otherwise it will return NULL. At that point, check if the page being returned has events and has not been read yet. Then at that point update the read_stamp to match the time stamp of the reader page. Signed-off-by: Steven Rostedt Signed-off-by: Greg Kroah-Hartman --- kernel/trace/ring_buffer.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -1949,12 +1949,6 @@ rb_set_commit_to_write(struct ring_buffe goto again; } -static void rb_reset_reader_page(struct ring_buffer_per_cpu *cpu_buffer) -{ - cpu_buffer->read_stamp = cpu_buffer->reader_page->page->time_stamp; - cpu_buffer->reader_page->read = 0; -} - static void rb_inc_iter(struct ring_buffer_iter *iter) { struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer; @@ -3592,7 +3586,7 @@ rb_get_reader_page(struct ring_buffer_pe /* Finally update the reader page to the new head */ cpu_buffer->reader_page = reader; - rb_reset_reader_page(cpu_buffer); + cpu_buffer->reader_page->read = 0; if (overwrite != cpu_buffer->last_overrun) { cpu_buffer->lost_events = overwrite - cpu_buffer->last_overrun; @@ -3602,6 +3596,10 @@ rb_get_reader_page(struct ring_buffer_pe goto again; out: + /* Update the read_stamp on the first event */ + if (reader && reader->read == 0) + cpu_buffer->read_stamp = reader->page->time_stamp; + arch_spin_unlock(&cpu_buffer->lock); local_irq_restore(flags);