[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240226135353.3103b360@gandalf.local.home>
Date: Mon, 26 Feb 2024 13:53:53 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: linke li <lilinke99@...com>
Cc: Masami Hiramatsu <mhiramat@...nel.org>, Mathieu Desnoyers
<mathieu.desnoyers@...icios.com>, linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH] ring-buffer: use READ_ONCE() to read
cpu_buffer->commit_page in concurrent environment
On Sun, 25 Feb 2024 15:03:02 -0500
Steven Rostedt <rostedt@...dmis.org> wrote:
> *But* looking at this deeper, the commit_page may need a READ_ONCE()
> but not for the reason you suggested.
>
> commit_page = cpu_buffer->commit_page;
> commit_ts = commit_page->page->time_stamp;
>
> The commit_page above *is* used again, and we want commit_ts to be part
> of the commit_page that was originally read and not a second reading.
>
> So, I think for the commit_page we do need a READ_ONCE() but that's
> because it is referenced again just below it and we don't want the
> compiler to read the memory location again for the second reference.
Care to send a v2 patch that just adds READ_ONCE() for the commit_page, and
change the change log stating that it is to fix the possibility that the
time_stamp may come from a different page.
-- Steve
Powered by blists - more mailing lists