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 <[email protected]>
---
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