* [PATCH] perf/ring-buffer: refactor code of reading the value of data_tail
@ 2024-01-28 4:19 Donglin Peng
0 siblings, 0 replies; only message in thread
From: Donglin Peng @ 2024-01-28 4:19 UTC (permalink / raw)
To: peterz; +Cc: jolsa, wangnan0, linux-perf-users, linux-kernel, Donglin Peng
The tail variable will only be accessed when overwrite is 0, so we can
put the assignment statement in the if branch.
Fixes: d1b26c70246b ("perf/ring_buffer: Prepare writing into the ring-buffer from the end")
Signed-off-by: Donglin Peng <dolinux.peng@gmail.com>
---
kernel/events/ring_buffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 60ed43d1c29e..86b150a822b7 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -194,8 +194,8 @@ __perf_output_begin(struct perf_output_handle *handle,
offset = local_read(&rb->head);
do {
head = offset;
- tail = READ_ONCE(rb->user_page->data_tail);
if (!rb->overwrite) {
+ tail = READ_ONCE(rb->user_page->data_tail);
if (unlikely(!ring_buffer_has_space(head, tail,
perf_data_size(rb),
size, backward)))
--
2.25.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-28 4:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-28 4:19 [PATCH] perf/ring-buffer: refactor code of reading the value of data_tail Donglin Peng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).