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.

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/20250612061201.34272-5-kerneljasonxing@gmail.com
Signed-off-by: Jason Xing <kernelxing@tencent.com>
Reviewed-by: Yushan Zhou <katrinzhou@tencent.com>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
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
7f217389 a53202ce

+2 -20
+2 -20
kernel/trace/blktrace.c
··· 415 415 size_t count, loff_t *ppos) 416 416 { 417 417 struct blk_trace *bt = filp->private_data; 418 + size_t dropped = relay_stats(bt->rchan, RELAY_STATS_BUF_FULL); 418 419 char buf[16]; 419 420 420 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped)); 421 + snprintf(buf, sizeof(buf), "%zu\n", dropped); 421 422 422 423 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf)); 423 424 } ··· 457 456 .llseek = noop_llseek, 458 457 }; 459 458 460 - /* 461 - * Keep track of how many times we encountered a full subbuffer, to aid 462 - * the user space app in telling how many lost events there were. 463 - */ 464 - static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf, 465 - void *prev_subbuf) 466 - { 467 - struct blk_trace *bt; 468 - 469 - if (!relay_buf_full(buf)) 470 - return 1; 471 - 472 - bt = buf->chan->private_data; 473 - atomic_inc(&bt->dropped); 474 - return 0; 475 - } 476 - 477 459 static int blk_remove_buf_file_callback(struct dentry *dentry) 478 460 { 479 461 debugfs_remove(dentry); ··· 475 491 } 476 492 477 493 static const struct rchan_callbacks blk_relay_callbacks = { 478 - .subbuf_start = blk_subbuf_start_callback, 479 494 .create_buf_file = blk_create_buf_file_callback, 480 495 .remove_buf_file = blk_remove_buf_file_callback, 481 496 }; ··· 563 580 } 564 581 565 582 bt->dev = dev; 566 - atomic_set(&bt->dropped, 0); 567 583 INIT_LIST_HEAD(&bt->running_list); 568 584 569 585 ret = -EIO;