Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3819475pxu; Mon, 30 Nov 2020 10:54:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxL0uRByp1Y28bx7MMtGPwcZx67e8Z4DoRxTCtWFkhzASRFOeHxlkSPe1rI+hDuBP847DN0 X-Received: by 2002:a17:906:1450:: with SMTP id q16mr3093424ejc.524.1606762483254; Mon, 30 Nov 2020 10:54:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606762483; cv=none; d=google.com; s=arc-20160816; b=WUSg+wjzawO51s7LKsrh0rGKl08vg4+C4lawHZCorgZBYrKRSCM6agmmrlIXELM99U KgG6ntTuhWuWa2QOtmg0AlQglL1278961JeJ+4IoS4KPU05Kio2A7I9Lxhk7Ppx9WDDf 4pyRCDsbNGm2DfO5ql8hZh2+IQhLwFpabScSGobJtSM5l/ARr3Lt4yT6bxaxOXCX1Nif nAAbqNbnZXbdCALVww18gEPfnIUdC8na8ZaWQlT3hTDil5EchEFblkt8npdDG4lb3VTE W44KeIFLWr7jtrALJkyzpBava7zjDMVJeL4FzWUjirvj44hMBbiz/HDRkfZ7SBqH8q9V 5qYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=8QLQ8VCOkqQYRJeAofb4UvWKmwccVw7KHgngmNn91z4=; b=RjjClGDNWXTDjkfek45/6M844NiZr4YTe1XpImMMxYY/o1Spom5Xx1j3Hu2/OIbiVU jC95XNAJRyVJLtRqDP2DSiJT0Ud8E1dWMhN+DjB+KW5LflIdDs/R8b89qhhNRQfMo8l1 hWugYr/YPtv7okiLaXoQNIOjK0Oys8cHtXccZjkao01I4LUjcgl78I4g965YQMKoSgC0 P9aFSwByvemo40t0li9SzjJyVFAqwbHvI8Fo+KU1zywwGiwhlf8cY1NW1m3KV3QpDE+R RC1A1KvMrSpPRcnO8gqbrL1VEkY1lvn67kBga95dBSmrrbOvQEYU8CKak6uRMXyDKac7 MbIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si3048538edw.478.2020.11.30.10.54.20; Mon, 30 Nov 2020 10:54:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728149AbgK3Suh (ORCPT + 99 others); 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 { > /*