mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Donglin Peng <dolinux.peng@gmail.com>
To: peterz@infradead.org
Cc: jolsa@kernel.org, wangnan0@huawei.com,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	Donglin Peng <dolinux.peng@gmail.com>
Subject: [PATCH] perf/ring-buffer: refactor code of reading the value of data_tail
Date: Sat, 27 Jan 2024 20:19:35 -0800	[thread overview]
Message-ID: <20240128041935.513800-1-dolinux.peng@gmail.com> (raw)

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


                 reply	other threads:[~2024-01-28  4:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240128041935.513800-1-dolinux.peng@gmail.com \
    --to=dolinux.peng@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=wangnan0@huawei.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®