[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250512024935.64704-4-kerneljasonxing@gmail.com>
Date: Mon, 12 May 2025 10:49:33 +0800
From: Jason Xing <kerneljasonxing@...il.com>
To: axboe@...nel.dk,
rostedt@...dmis.org,
mhiramat@...nel.org,
mathieu.desnoyers@...icios.com,
akpm@...ux-foundation.org
Cc: linux-kernel@...r.kernel.org,
linux-block@...r.kernel.org,
linux-trace-kernel@...r.kernel.org,
Jason Xing <kernelxing@...cent.com>,
Yushan Zhou <katrinzhou@...cent.com>
Subject: [PATCH v1 3/5] blktrace: use rbuf->stats.full as a drop indicator in relayfs
From: Jason Xing <kernelxing@...cent.com>
Replace internal subbuf_start with the default policy in relayfs.
Remove dropped field from struct blk_trace. Correspondingly, use per-cpu
buffer mechanism to replace atomic operation. Through incrementing
full counter to keep track of how many times we encountered a full
subbuffer, it aids the user space app in telling how many lost events
there were.
Sum up all the fields gathered from all cpus when application is reading.
Reviewed-by: Yushan Zhou <katrinzhou@...cent.com>
Signed-off-by: Jason Xing <kernelxing@...cent.com>
---
kernel/trace/blktrace.c | 23 ++---------------------
1 file changed, 2 insertions(+), 21 deletions(-)
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index d1a89714e805..09d42c40ac9f 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -415,9 +415,9 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
size_t count, loff_t *ppos)
{
struct blk_trace *bt = filp->private_data;
- char buf[16];
+ char buf[RELAY_DUMP_BUF_MAX_LEN];
- snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
+ relay_dump(bt->rchan, buf, RELAY_DUMP_BUF_MAX_LEN, RELAY_DUMP_BUF_FULL);
return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
}
@@ -456,23 +456,6 @@ static const struct file_operations blk_msg_fops = {
.llseek = noop_llseek,
};
-/*
- * Keep track of how many times we encountered a full subbuffer, to aid
- * 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)
-{
- struct blk_trace *bt;
-
- if (!relay_buf_full(buf))
- return 1;
-
- bt = buf->chan->private_data;
- atomic_inc(&bt->dropped);
- return 0;
-}
-
static int blk_remove_buf_file_callback(struct dentry *dentry)
{
debugfs_remove(dentry);
@@ -491,7 +474,6 @@ static struct dentry *blk_create_buf_file_callback(const char *filename,
}
static const struct rchan_callbacks blk_relay_callbacks = {
- .subbuf_start = blk_subbuf_start_callback,
.create_buf_file = blk_create_buf_file_callback,
.remove_buf_file = blk_remove_buf_file_callback,
};
@@ -580,7 +562,6 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
}
bt->dev = dev;
- atomic_set(&bt->dropped, 0);
INIT_LIST_HEAD(&bt->running_list);
ret = -EIO;
--
2.43.5
Powered by blists - more mailing lists