]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
relayfs: abolish prev_padding
authorJason Xing <kernelxing@tencent.com>
Thu, 12 Jun 2025 06:11:57 +0000 (14:11 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 10 Jul 2025 05:57:51 +0000 (22:57 -0700)
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>
drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
drivers/net/wwan/iosm/iosm_ipc_trace.c
drivers/net/wwan/t7xx/t7xx_port_trace.c
include/linux/relay.h
kernel/relay.c
kernel/trace/blktrace.c

index e8a04e476c57107d485941f372f0f517abe1e6b9..09a64f224c491694656bb7465aa8d8a5db9cea7d 100644 (file)
@@ -220,8 +220,7 @@ static int guc_action_control_log(struct intel_guc *guc, bool enable,
  */
 static int subbuf_start_callback(struct rchan_buf *buf,
                                 void *subbuf,
-                                void *prev_subbuf,
-                                size_t prev_padding)
+                                void *prev_subbuf)
 {
        /*
         * Use no-overwrite mode by default, where relay will stop accepting
index eeecfa3d10c5abcaaea901280641fb2e39ec7f99..9656254c1c6c3b3b925c3852147151cdfb489e7b 100644 (file)
@@ -51,8 +51,7 @@ static int ipc_trace_remove_buf_file_handler(struct dentry *dentry)
 }
 
 static int ipc_trace_subbuf_start_handler(struct rchan_buf *buf, void *subbuf,
-                                         void *prev_subbuf,
-                                         size_t prev_padding)
+                                         void *prev_subbuf)
 {
        if (relay_buf_full(buf)) {
                pr_err_ratelimited("Relay_buf full dropping traces");
index 4ed8b4e29bf1d9022bf36e6236cda5146e16efb0..f16d3b01302cdef06669f12090b4859d91c11fb9 100644 (file)
@@ -33,7 +33,7 @@ static int t7xx_trace_remove_buf_file_handler(struct dentry *dentry)
 }
 
 static int t7xx_trace_subbuf_start_handler(struct rchan_buf *buf, void *subbuf,
-                                          void *prev_subbuf, size_t prev_padding)
+                                          void *prev_subbuf)
 {
        if (relay_buf_full(buf)) {
                pr_err_ratelimited("Relay_buf full dropping traces");
index b3224111d074cc0665cacf5ffd25a5d1747167b9..e10a0fdf4325157d88d0a04df185d374527b14f6 100644 (file)
@@ -47,7 +47,6 @@ struct rchan_buf
        unsigned int page_count;        /* number of current buffer pages */
        unsigned int finalized;         /* buffer has been finalized */
        size_t *padding;                /* padding counts per sub-buffer */
-       size_t prev_padding;            /* temporary variable */
        size_t bytes_consumed;          /* bytes consumed in cur read subbuf */
        size_t early_bytes;             /* bytes consumed before VFS inited */
        unsigned int cpu;               /* this buf's cpu */
@@ -84,7 +83,6 @@ struct rchan_callbacks
         * @buf: the channel buffer containing the new sub-buffer
         * @subbuf: the start of the new sub-buffer
         * @prev_subbuf: the start of the previous sub-buffer
-        * @prev_padding: unused space at the end of previous sub-buffer
         *
         * The client should return 1 to continue logging, 0 to stop
         * logging.
@@ -100,8 +98,7 @@ struct rchan_callbacks
         */
        int (*subbuf_start) (struct rchan_buf *buf,
                             void *subbuf,
-                            void *prev_subbuf,
-                            size_t prev_padding);
+                            void *prev_subbuf);
 
        /*
         * create_buf_file - create file to represent a relay channel buffer
index 3ee5b038d0d90fe58b0171b592706c11c9725878..fc6ad76b789da4cdfa77a2ae69a2e9976558b281 100644 (file)
@@ -249,13 +249,13 @@ EXPORT_SYMBOL_GPL(relay_buf_full);
  */
 
 static int relay_subbuf_start(struct rchan_buf *buf, void *subbuf,
-                             void *prev_subbuf, size_t prev_padding)
+                             void *prev_subbuf)
 {
        if (!buf->chan->cb->subbuf_start)
                return !relay_buf_full(buf);
 
        return buf->chan->cb->subbuf_start(buf, subbuf,
-                                          prev_subbuf, prev_padding);
+                                          prev_subbuf);
 }
 
 /**
@@ -301,7 +301,7 @@ static void __relay_reset(struct rchan_buf *buf, unsigned int init)
        for (i = 0; i < buf->chan->n_subbufs; i++)
                buf->padding[i] = 0;
 
-       relay_subbuf_start(buf, buf->data, NULL, 0);
+       relay_subbuf_start(buf, buf->data, NULL);
 }
 
 /**
@@ -554,9 +554,11 @@ size_t relay_switch_subbuf(struct rchan_buf *buf, size_t length)
                goto toobig;
 
        if (buf->offset != buf->chan->subbuf_size + 1) {
-               buf->prev_padding = buf->chan->subbuf_size - buf->offset;
+               size_t prev_padding;
+
+               prev_padding = buf->chan->subbuf_size - buf->offset;
                old_subbuf = buf->subbufs_produced % buf->chan->n_subbufs;
-               buf->padding[old_subbuf] = buf->prev_padding;
+               buf->padding[old_subbuf] = prev_padding;
                buf->subbufs_produced++;
                if (buf->dentry)
                        d_inode(buf->dentry)->i_size +=
@@ -581,7 +583,7 @@ size_t relay_switch_subbuf(struct rchan_buf *buf, size_t length)
        new_subbuf = buf->subbufs_produced % buf->chan->n_subbufs;
        new = buf->start + new_subbuf * buf->chan->subbuf_size;
        buf->offset = 0;
-       if (!relay_subbuf_start(buf, new, old, buf->prev_padding)) {
+       if (!relay_subbuf_start(buf, new, old)) {
                buf->offset = buf->chan->subbuf_size + 1;
                return 0;
        }
index 3f6a7bdc6edf68a8a36c77c974ed9346cb770a60..d3083c88474e6a4c8c83cd43de963a76738f425e 100644 (file)
@@ -461,7 +461,7 @@ static const struct file_operations blk_msg_fops = {
  * the user space app in telling how many lost events there were.
  */
 static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
-                                    void *prev_subbuf, size_t prev_padding)
+                                    void *prev_subbuf)
 {
        struct blk_trace *bt;