From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Steven Rostedt <rostedt@goodmis.org>,
LKML <linux-kernel@vger.kernel.org>,
Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mark Rutland <mark.rutland@arm.com>
Subject: Re: [PATCH v3] ring-buffer: Simplify reservation with try_cmpxchg() loop
Date: Tue, 20 Feb 2024 09:50:13 -0500 [thread overview]
Message-ID: <168765ff-98ea-42a1-82f7-56178bfcf7ec@efficios.com> (raw)
In-Reply-To: <20240220091922.45848d9a@gandalf.local.home>
On 2024-02-20 09:19, Steven Rostedt wrote:
> On Mon, 19 Feb 2024 18:20:32 -0500
> Steven Rostedt <rostedt@goodmis.org> wrote:
>
>> Instead of using local_add_return() to reserve the ring buffer data,
>> Mathieu Desnoyers suggested using local_cmpxchg(). This would simplify the
>> reservation with the time keeping code.
>>
>> Although, it does not get rid of the double time stamps (before_stamp and
>> write_stamp), using cmpxchg() does get rid of the more complex case when
>> an interrupting event occurs between getting the timestamps and reserving
>> the data, as when that happens, it just tries again instead of dealing
>> with it.
>>
>> Before we had:
>>
>> w = local_read(&tail_page->write);
>> /* get time stamps */
>> write = local_add_return(length, &tail_page->write);
>> if (write - length == w) {
>> /* do simple case */
>> } else {
>> /* do complex case */
>> }
>>
>> By switching the local_add_return() to a local_try_cmpxchg() it can now be:
>>
>> w = local_read(&tail_page->write);
>> again:
>> /* get time stamps */
>> if (!local_try_cmpxchg(&tail_page->write, &w, w + length))
>> goto again;
>>
>> /* do simple case */
>
> Something about this logic is causing __rb_next_reserve() to sometimes
> always return -EAGAIN and triggering the:
>
> RB_WARN_ON(cpu_buffer, ++nr_loops > 1000)
>
> Which disables the ring buffer.
>
> I'm not sure what it is, but until I do, I'm removing the patch from my
> queue.
Try resetting the info->add_timestamp flags to add_ts_default on goto again
within __rb_reserve_next().
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
next prev parent reply other threads:[~2024-02-20 14:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-19 23:20 [PATCH v3] ring-buffer: Simplify reservation with try_cmpxchg() loop Steven Rostedt
2024-02-20 14:19 ` Steven Rostedt
2024-02-20 14:50 ` Mathieu Desnoyers [this message]
2024-02-20 15:40 ` Steven Rostedt
2024-02-20 21:53 ` Steven Rostedt
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=168765ff-98ea-42a1-82f7-56178bfcf7ec@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
/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