FAILED: patch "[PATCH] ring-buffer: Allow splice reads on static buffers" failed to apply to 6.12-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 6365c44a824ff138e7926413932bb5c2e28a4c8c
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090939-revisable-paving-9733@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 6365c44a824ff138e7926413932bb5c2e28a4c8c Mon Sep 17 00:00:00 2001
From: Vincent Donnefort <[email protected]>
Date: Tue, 1 Sep 2026 16:54:42 +0100
Subject: [PATCH] ring-buffer: Allow splice reads on static buffers
ring_buffer_read_page() rejects splice (full=1) reads on static buffers (that is user-mapped, persistent or remote) because !read check assumes unread pages must be swapped. However for those buffers we have no other choice than memcpy the data.
For the memcpy case, only return an error when the writer is still on the reader page for the splice interface to wait.
kernel/trace/ring_buffer.c +2 -9
@@ -7193,15 +7193,8 @@ int ring_buffer_read_page(struct trace_buffer *buffer,unsigned int event_size;unsigned int flags =0 ; -/* -* If a full page is expected, this can still be returned -* if there's been a previous partial read and the -* rest of the page can be read and the commit page is off -* the reader page. -*/ -if (full && - (!read || (len < (size - read)) || - cpu_buffer->reader_page == cpu_buffer->commit_page)) +/* If a full page is requested, it cannot be the commit page */ +if (full && cpu_buffer->reader_page == cpu_buffer->commit_page)return -1 ;if (len > (size - read))
Sasha Levin
maintainerPATCH 1/2 ring-buffer: Show persistent buffer dropped events in trace_pipe file
From: Steven Rostedt <[email protected]>
[ Upstream commit 8928e4a3be34bf053f9ef1cad67263604bf4f05e ]
When the persistent ring buffer is validated on boot up, if a subbuffer is deemed invalid, it resets the buffer and continues. Have the code preserve the RB_MISSED_EVENTS flag in the commit portion of the subbuffer header and pass that back so that the trace_pipe file can show the missed events like the trace file does.
For example:
<...>-1242 [005] d.... 4429.120116: page_fault_user: address=0x7ffaebb6e728 ip=0x7ffaeb9d4960 error_code=0x7 <...>-1242 [005] ..... 4429.120124: mm_page_alloc: page=00000000055254f3 pfn=0x1373bd order=0 migratetype=1 gfp_flags=GFP_HIGHUSER_MOVABLE|__GFP_COMP <...>-1242 [005] d..2. 4429.120132: tlb_flush: pages:1 reason:local MM shootdown (3) CPU:5 [LOST EVENTS] <...>-1242 [005] d.... 4429.120661: page_fault_user: address=0x55ba7c2d0944 ip=0x55ba7c20cd02 error_code=0x7 <...>-1242 [005] ..... 4429.120669: mm_page_alloc: page=0000000005a02500 pfn=0x12b6e4 order=0 migratetype=1 gfp_flags=GFP_HIGHUSER_MOVABLE|__GFP_COMP <...>-1242 [005] d..2. 4429.120680: tlb_flush: pages:1 reason:local MM shootdown (3)
Backport notes for 6.18:
Keep the ring_buffer_read_page() changes needed as context for 6365c44a824f ("ring-buffer: Allow splice reads on static buffers"). Separate the raw commit flags from the page byte count and preserve the lost-events flag when copying page contents. Keep the existing bpage name, rb_page_capacity(reader) bounds and unsigned lost-event count. Read and mask bpage->commit directly instead of adding the newer data-page helpers.
Drop the reader-page unknown-loss propagation: this tree lacks the persistent invalid-subbuffer recovery and signed-loss reporting changes that make that path meaningful.
Keep the copy loop bounded by the page size, not event_size, avoiding the one-event-per-read regression subsequently fixed by af05b4e06279. Preserve the loss flag when trimming a swapped page to real_end, and combine output flags with bitwise OR so an already-set flag is not added a second time.
Stable-dep-of: 6365c44a824f ("ring-buffer: Allow splice reads on static buffers")
--- kernel/trace/ring_buffer.c | 56 ++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 24 deletions(-)
kernel/trace/ring_buffer.c +32 -24
@@ -6524,6 +6524,7 @@ int ring_buffer_read_page(struct trace_buffer *buffer,struct buffer_page *reader;unsigned long missed_events;unsigned int commit; +unsigned int size;unsigned int read;u64 save_timestamp;
@@ -6558,7 +6559,8 @@ int ring_buffer_read_page(struct trace_buffer *buffer, event =rb_reader_event (cpu_buffer); read = reader->read; - commit =rb_page_size (reader); + commit =rb_page_commit (reader); + size =rb_page_size (reader);/* Check if any events were dropped */ missed_events = cpu_buffer->lost_events;
@@ -6570,13 +6572,14 @@ int ring_buffer_read_page(struct trace_buffer *buffer,* we must copy the data from the page to the buffer. * Otherwise, we can simply swap the page with the one passed in. */ -if (read || (len < (commit - read)) || +if (read || (len < (size - read)) || cpu_buffer->reader_page == cpu_buffer->commit_page || cpu_buffer->mapped) {struct buffer_data_page *rpage = cpu_buffer->reader_page->page;unsigned int rpos = read;unsigned int pos =0 ; -unsigned int size; +unsigned int event_size; +unsigned int flags =0 ;/* * If a full page is expected, this can still be returned
@@ -6585,19 +6588,22 @@ int ring_buffer_read_page(struct trace_buffer *buffer,* the reader page. */ if (full && - (!read || (len < (commit - read)) || + (!read || (len < (size - read)) || cpu_buffer->reader_page == cpu_buffer->commit_page))return -1 ; -if (len > (commit - read)) - len = (commit - read); +if (len > (size - read)) + len = (size - read);/* Always keep the time extend and data together */ - size =rb_event_ts_length (event); + event_size =rb_event_ts_length (event); -if (len < size) +if (len < event_size)return -1 ; +if (commit &RB_MISSED_EVENTS ) + flags =RB_MISSED_EVENTS ; +/* save the current timestamp, since the user will need it */ save_timestamp = cpu_buffer->read_stamp;
@@ -6609,25 +6615,25 @@ int ring_buffer_read_page(struct trace_buffer *buffer,* one or two events. * We have already ensured there's enough space if this * is a time extend. */ - size =rb_event_length (event); -memcpy (bpage->data + pos, rpage->data + rpos, size); + event_size =rb_event_length (event); +memcpy (bpage->data + pos, rpage->data + rpos, event_size); - len -= size; + len -= event_size;rb_advance_reader (cpu_buffer); rpos = reader->read; - pos += size; + pos += event_size; -if (rpos >= commit) +if (rpos >= size)break ; event =rb_reader_event (cpu_buffer);/* Always keep the time extend and data together */ - size =rb_event_ts_length (event); - }while (len >= size); + event_size =rb_event_ts_length (event); + }while (len >= event_size);/* update bpage */ -local_set (&bpage->commit, pos); +local_set (&bpage->commit, pos | flags); bpage->time_stamp = save_timestamp;/* we copied everything to the beginning */
@@ -6652,12 +6658,14 @@ int ring_buffer_read_page(struct trace_buffer *buffer,* on the page. */ if (reader->real_end) -local_set (&bpage->commit, reader->real_end); +local_set (&bpage->commit, reader->real_end | + (commit &RB_MISSED_EVENTS )); } cpu_buffer->lost_events =0 ; commit =local_read (&bpage->commit); + size = commit & ~RB_MISSED_MASK ;/* * Set a flag in the commit field if we lost events */
@@ -6665,20 +6673,20 @@ int ring_buffer_read_page(struct trace_buffer *buffer,/* If there is room at the end of the page to save the * missed events, then record it there. */ -if (rb_page_capacity (reader) - commit >=sizeof (missed_events)) { -memcpy (&bpage->data[commit], &missed_events, +if (rb_page_capacity (reader) - size >=sizeof (missed_events)) { +memcpy (&bpage->data[size], &missed_events,sizeof (missed_events)); -local_add (RB_MISSED_STORED , &bpage->commit); - commit +=sizeof (missed_events); + commit |=RB_MISSED_STORED ; + size +=sizeof (missed_events); } -local_add (RB_MISSED_EVENTS , &bpage->commit); +local_set (&bpage->commit, commit |RB_MISSED_EVENTS ); }/* * This page may be off to user land. Zero it out here. */ -if (commit <rb_page_capacity (reader)) -memset (&bpage->data[commit],0 ,rb_page_capacity (reader) - commit); +if (size <rb_page_capacity (reader)) +memset (&bpage->data[size],0 ,rb_page_capacity (reader) - size);return read; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 ring-buffer: Allow splice reads on static buffers
From: Vincent Donnefort <[email protected]>
[ Upstream commit 6365c44a824ff138e7926413932bb5c2e28a4c8c ]
ring_buffer_read_page() rejects splice (full=1) reads on static buffers (that is user-mapped, persistent or remote) because !read check assumes unread pages must be swapped. However for those buffers we have no other choice than memcpy the data.
For the memcpy case, only return an error when the writer is still on the reader page for the splice interface to wait.
--- kernel/trace/ring_buffer.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
kernel/trace/ring_buffer.c +2 -9
@@ -6581,15 +6581,8 @@ int ring_buffer_read_page(struct trace_buffer *buffer,unsigned int event_size;unsigned int flags =0 ; -/* -* If a full page is expected, this can still be returned -* if there's been a previous partial read and the -* rest of the page can be read and the commit page is off -* the reader page. -*/ -if (full && - (!read || (len < (size - read)) || - cpu_buffer->reader_page == cpu_buffer->commit_page)) +/* If a full page is requested, it cannot be the commit page */ +if (full && cpu_buffer->reader_page == cpu_buffer->commit_page)return -1 ;if (len > (size - read))
Signature · 1 line
2.53.0