Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH] perf/aux: Order padding stores before publishing aux_head
@ 2026-12-02 15:45 Leo Yan
  2026-12-02 15:48 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Leo Yan @ 2026-12-02 15:45 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Will Deacon, Jiri Olsa, Ian Rogers,
	Adrian Hunter, James Clark
  Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, linux-perf-users, linux-kernel, Ingo Molnar,
	Leo Yan

Drivers commonly fill alignment gaps with CPU stores before calling
perf_aux_output_skip(). Put smp_wmb() in the helper so all callers
order their padding stores before publishing aux_head. This pairs with
the reader's smp_rmb() after loading aux_head.

Fixes: 1a5941312414 ("perf: Add wakeup watermark control to the AUX area")
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
Intel BTS, Arm SPE and CoreSight TRBE all use perf_aux_output_skip()
after writing padding. Ordering those stores in the helper covers all
three callers. Each PMU driver still handles its trace hardware's
synchronization requirements.
---
 kernel/events/ring_buffer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 95f4fbdfd2764de5b72d901d778c46302f525fad..b564abb7f1e8f798997683b753ced73fadafdcd3 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -558,6 +558,8 @@ int perf_aux_output_skip(struct perf_output_handle *handle, unsigned long size)
 
 	rb->aux_head += size;
 
+	/* Order any padding stores before publishing aux_head */
+	smp_wmb();
 	WRITE_ONCE(rb->user_page->aux_head, rb->aux_head);
 	if (rb_need_aux_wakeup(rb)) {
 		perf_output_wakeup(handle);

---
base-commit: 693c2e04e3f1d4c59af236e1211b7b8cb165a790
change-id: 20261202-perf-aux-padding-order-5e3ea6fa0b65

Best regards,
-- 
Leo Yan <leo.yan@arm.com>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-02 15:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 15:45 [PATCH] perf/aux: Order padding stores before publishing aux_head Leo Yan
2026-12-02 15:48 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox