From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2A91C63777 for ; Mon, 30 Nov 2020 18:50:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B53420725 for ; Mon, 30 Nov 2020 18:50:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728659AbgK3Suh (ORCPT ); Mon, 30 Nov 2020 13:50:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:40018 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725870AbgK3Suh (ORCPT ); Mon, 30 Nov 2020 13:50:37 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6B49C20725; Mon, 30 Nov 2020 18:49:56 +0000 (UTC) Date: Mon, 30 Nov 2020 13:49:54 -0500 From: Steven Rostedt To: Andrea Righi Cc: Ingo Molnar , Masami Hiramatsu , linux-kernel@vger.kernel.org Subject: Re: [PATCH] ring-buffer: set the right timestamp in the slow path of __rb_reserve_next() Message-ID: <20201130134954.4ba23d0e@gandalf.local.home> In-Reply-To: References: X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 28 Nov 2020 10:15:17 +0100 Andrea Righi wrote: > In the slow path of __rb_reserve_next() a nested event(s) can happen > between evaluating the timestamp delta of the current event and updating > write_stamp via local_cmpxchg(); in this case the delta is not valid > anymore and it should be set to 0 (same timestamp as the interrupting > event), since the event that we are currently processing is not the last > event in the buffer. > > Link: https://lwn.net/Articles/831207 And it looks like we have a WINNER! Thanks! It shows someone is paying attention. There's a few other patches I need to test, but I've queued this up for my next pull request. -- Steve > Fixes: a389d86f7fd0 ("ring-buffer: Have nested events still record running time stamp") > Signed-off-by: Andrea Righi > --- > kernel/trace/ring_buffer.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c > index dc83b3fa9fe7..5e30e0cdb6ce 100644 > --- a/kernel/trace/ring_buffer.c > +++ b/kernel/trace/ring_buffer.c > @@ -3287,11 +3287,11 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer, > ts = rb_time_stamp(cpu_buffer->buffer); > barrier(); > /*E*/ if (write == (local_read(&tail_page->write) & RB_WRITE_MASK) && > - info->after < ts) { > + info->after < ts && > + rb_time_cmpxchg(&cpu_buffer->write_stamp, > + info->after, info->ts)) { > /* Nothing came after this event between C and E */ > info->delta = ts - info->after; > - (void)rb_time_cmpxchg(&cpu_buffer->write_stamp, > - info->after, info->ts); > info->ts = ts; > } else { > /*