lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240128041935.513800-1-dolinux.peng@gmail.com>
Date: Sat, 27 Jan 2024 20:19:35 -0800
From: Donglin Peng <dolinux.peng@...il.com>
To: peterz@...radead.org
Cc: jolsa@...nel.org,
	wangnan0@...wei.com,
	linux-perf-users@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Donglin Peng <dolinux.peng@...il.com>
Subject: [PATCH] perf/ring-buffer: refactor code of reading the value of data_tail

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@...il.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ