Skip to content

Commit 7f21738

Browse files
JasonXingakpm00
authored andcommitted
blktrace: use rbuf->stats.full as a drop indicator in relayfs
Replace internal subbuf_start in blktrace with the default policy in relayfs. Remove dropped field from struct blktrace. Correspondingly, call the common helper in relay. By incrementing full_count to keep track of how many times we encountered a full buffer issue, user space will know how many events were lost. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Jason Xing <[email protected]> Reviewed-by: Yushan Zhou <[email protected]> Reviewed-by: Jens Axboe <[email protected]> Reviewed-by: Masami Hiramatsu (Google) <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Steven Rostedt <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent a53202c commit 7f21738

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

kernel/trace/blktrace.c

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,10 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
415415
size_t count, loff_t *ppos)
416416
{
417417
struct blk_trace *bt = filp->private_data;
418+
size_t dropped = relay_stats(bt->rchan, RELAY_STATS_BUF_FULL);
418419
char buf[16];
419420

420-
snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
421+
snprintf(buf, sizeof(buf), "%zu\n", dropped);
421422

422423
return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
423424
}
@@ -456,23 +457,6 @@ static const struct file_operations blk_msg_fops = {
456457
.llseek = noop_llseek,
457458
};
458459

459-
/*
460-
* Keep track of how many times we encountered a full subbuffer, to aid
461-
* the user space app in telling how many lost events there were.
462-
*/
463-
static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
464-
void *prev_subbuf)
465-
{
466-
struct blk_trace *bt;
467-
468-
if (!relay_buf_full(buf))
469-
return 1;
470-
471-
bt = buf->chan->private_data;
472-
atomic_inc(&bt->dropped);
473-
return 0;
474-
}
475-
476460
static int blk_remove_buf_file_callback(struct dentry *dentry)
477461
{
478462
debugfs_remove(dentry);
@@ -491,7 +475,6 @@ static struct dentry *blk_create_buf_file_callback(const char *filename,
491475
}
492476

493477
static const struct rchan_callbacks blk_relay_callbacks = {
494-
.subbuf_start = blk_subbuf_start_callback,
495478
.create_buf_file = blk_create_buf_file_callback,
496479
.remove_buf_file = blk_remove_buf_file_callback,
497480
};
@@ -580,7 +563,6 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
580563
}
581564

582565
bt->dev = dev;
583-
atomic_set(&bt->dropped, 0);
584566
INIT_LIST_HEAD(&bt->running_list);
585567

586568
ret = -EIO;

0 commit comments

Comments
 (0)