mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Andrea Righi <andrea.righi@canonical.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ring-buffer: set the right timestamp in the slow path of __rb_reserve_next()
Date: Mon, 30 Nov 2020 13:49:54 -0500	[thread overview]
Message-ID: <20201130134954.4ba23d0e@gandalf.local.home> (raw)
In-Reply-To: <X8IVJcp1gRE+FJCJ@xps-13-7390>

On Sat, 28 Nov 2020 10:15:17 +0100
Andrea Righi <andrea.righi@canonical.com> 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 <andrea.righi@canonical.com>
> ---
>  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 {
>  			/*


      reply	other threads:[~2020-11-30 18:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-28  9:15 Andrea Righi
2020-11-30 18:49 ` Steven Rostedt [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=20201130134954.4ba23d0e@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=andrea.righi@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    /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

all inboxes | Powered by JetHome®