Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

relayfs: abolish prev_padding

Patch series "relayfs: misc changes", v5.

The series mostly focuses on the error counters which helps every user
debug their own kernel module.


This patch (of 5):

prev_padding represents the unused space of certain subbuffer. If the
content of a call of relay_write() exceeds the limit of the remainder of
this subbuffer, it will skip storing in the rest space and record the
start point as buf->prev_padding in relay_switch_subbuf(). Since the buf
is a per-cpu big buffer, the point of prev_padding as a global value for
the whole buffer instead of a single subbuffer (whose padding info is
stored in buf->padding[]) seems meaningless from the real use cases, so we
don't bother to record it any more.

Link: https://lkml.kernel.org/r/20250612061201.34272-1-kerneljasonxing@gmail.com
Link: https://lkml.kernel.org/r/20250612061201.34272-2-kerneljasonxing@gmail.com
Signed-off-by: Jason Xing <kernelxing@tencent.com>
Reviewed-by: Yushan Zhou <katrinzhou@tencent.com>
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Jason Xing and committed by
Andrew Morton
2489e958 c9e3fb05

+13 -16
+1 -2
drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
··· 220 220 */ 221 221 static int subbuf_start_callback(struct rchan_buf *buf, 222 222 void *subbuf, 223 - void *prev_subbuf, 224 - size_t prev_padding) 223 + void *prev_subbuf) 225 224 { 226 225 /* 227 226 * Use no-overwrite mode by default, where relay will stop accepting
+1 -2
drivers/net/wwan/iosm/iosm_ipc_trace.c
··· 51 51 } 52 52 53 53 static int ipc_trace_subbuf_start_handler(struct rchan_buf *buf, void *subbuf, 54 - void *prev_subbuf, 55 - size_t prev_padding) 54 + void *prev_subbuf) 56 55 { 57 56 if (relay_buf_full(buf)) { 58 57 pr_err_ratelimited("Relay_buf full dropping traces");
+1 -1
drivers/net/wwan/t7xx/t7xx_port_trace.c
··· 33 33 } 34 34 35 35 static int t7xx_trace_subbuf_start_handler(struct rchan_buf *buf, void *subbuf, 36 - void *prev_subbuf, size_t prev_padding) 36 + void *prev_subbuf) 37 37 { 38 38 if (relay_buf_full(buf)) { 39 39 pr_err_ratelimited("Relay_buf full dropping traces");
+1 -4
include/linux/relay.h
··· 47 47 unsigned int page_count; /* number of current buffer pages */ 48 48 unsigned int finalized; /* buffer has been finalized */ 49 49 size_t *padding; /* padding counts per sub-buffer */ 50 - size_t prev_padding; /* temporary variable */ 51 50 size_t bytes_consumed; /* bytes consumed in cur read subbuf */ 52 51 size_t early_bytes; /* bytes consumed before VFS inited */ 53 52 unsigned int cpu; /* this buf's cpu */ ··· 83 84 * @buf: the channel buffer containing the new sub-buffer 84 85 * @subbuf: the start of the new sub-buffer 85 86 * @prev_subbuf: the start of the previous sub-buffer 86 - * @prev_padding: unused space at the end of previous sub-buffer 87 87 * 88 88 * The client should return 1 to continue logging, 0 to stop 89 89 * logging. ··· 98 100 */ 99 101 int (*subbuf_start) (struct rchan_buf *buf, 100 102 void *subbuf, 101 - void *prev_subbuf, 102 - size_t prev_padding); 103 + void *prev_subbuf); 103 104 104 105 /* 105 106 * create_buf_file - create file to represent a relay channel buffer
+8 -6
kernel/relay.c
··· 249 249 */ 250 250 251 251 static int relay_subbuf_start(struct rchan_buf *buf, void *subbuf, 252 - void *prev_subbuf, size_t prev_padding) 252 + void *prev_subbuf) 253 253 { 254 254 if (!buf->chan->cb->subbuf_start) 255 255 return !relay_buf_full(buf); 256 256 257 257 return buf->chan->cb->subbuf_start(buf, subbuf, 258 - prev_subbuf, prev_padding); 258 + prev_subbuf); 259 259 } 260 260 261 261 /** ··· 301 301 for (i = 0; i < buf->chan->n_subbufs; i++) 302 302 buf->padding[i] = 0; 303 303 304 - relay_subbuf_start(buf, buf->data, NULL, 0); 304 + relay_subbuf_start(buf, buf->data, NULL); 305 305 } 306 306 307 307 /** ··· 554 554 goto toobig; 555 555 556 556 if (buf->offset != buf->chan->subbuf_size + 1) { 557 - buf->prev_padding = buf->chan->subbuf_size - buf->offset; 557 + size_t prev_padding; 558 + 559 + prev_padding = buf->chan->subbuf_size - buf->offset; 558 560 old_subbuf = buf->subbufs_produced % buf->chan->n_subbufs; 559 - buf->padding[old_subbuf] = buf->prev_padding; 561 + buf->padding[old_subbuf] = prev_padding; 560 562 buf->subbufs_produced++; 561 563 if (buf->dentry) 562 564 d_inode(buf->dentry)->i_size += ··· 583 581 new_subbuf = buf->subbufs_produced % buf->chan->n_subbufs; 584 582 new = buf->start + new_subbuf * buf->chan->subbuf_size; 585 583 buf->offset = 0; 586 - if (!relay_subbuf_start(buf, new, old, buf->prev_padding)) { 584 + if (!relay_subbuf_start(buf, new, old)) { 587 585 buf->offset = buf->chan->subbuf_size + 1; 588 586 return 0; 589 587 }
+1 -1
kernel/trace/blktrace.c
··· 461 461 * the user space app in telling how many lost events there were. 462 462 */ 463 463 static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf, 464 - void *prev_subbuf, size_t prev_padding) 464 + void *prev_subbuf) 465 465 { 466 466 struct blk_trace *bt; 467 467