1 Star 0 Fork 35

changtao/bpftrace

forked from src-openEuler/bpftrace 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-fix-biosnoop-to-block-tracepoints.patch 2.11 KB
一键复制 编辑 原始数据 按行查看 历史
diff -Nuar bpftrace-0.19.1/tools/biosnoop.bt bpftrace-0.19.1.new/tools/biosnoop.bt
--- bpftrace-0.19.1/tools/biosnoop.bt 2023-10-04 16:18:18.000000000 +0800
+++ bpftrace-0.19.1.new/tools/biosnoop.bt 2024-05-30 23:23:45.817005781 +0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env bpftrace
+#!/usr/bin/bpftrace
/*
* biosnoop.bt Block I/O tracing tool, showing per I/O latency.
* For Linux, uses bpftrace, eBPF.
@@ -7,6 +7,7 @@
*
* This is a bpftrace version of the bcc tool of the same name.
*
+ * 10-Dec-2023 Costa Shulyupin Switched to block tracepoints.
* 15-Nov-2017 Brendan Gregg Created this.
*/
@@ -17,32 +18,30 @@
BEGIN
{
- printf("%-12s %-7s %-16s %-6s %7s\n", "TIME(ms)", "DISK", "COMM", "PID", "LAT(ms)");
+ printf("%-12s %-7s %-16s %-6s %7s\n", "TIME(ms)", "DEVICE", "COMM", "PID", "LAT(ms)");
}
-kprobe:blk_account_io_start,
-kprobe:__blk_account_io_start
+tracepoint:block:block_bio_queue
{
- @start[arg0] = nsecs;
- @iopid[arg0] = pid;
- @iocomm[arg0] = comm;
- @disk[arg0] = ((struct request *)arg0)->q->disk->disk_name;
+ @start[args.dev, args.sector] = nsecs;
+ @iopid[args.dev, args.sector] = pid;
+ @iocomm[args.dev, args.sector] = comm;
}
-kprobe:blk_account_io_done,
-kprobe:__blk_account_io_done
-/@start[arg0] != 0 && @iopid[arg0] != 0 && @iocomm[arg0] != ""/
-
+tracepoint:block:block_rq_complete,
+tracepoint:block:block_bio_complete
+/@start[args.dev, args.sector]/
{
- $now = nsecs;
- printf("%-12u %-7s %-16s %-6d %7d\n",
- elapsed / 1e6, @disk[arg0], @iocomm[arg0], @iopid[arg0],
- ($now - @start[arg0]) / 1e6);
-
- delete(@start[arg0]);
- delete(@iopid[arg0]);
- delete(@iocomm[arg0]);
- delete(@disk[arg0]);
+ printf("%-12u %4d:%-2d %-16s %-6d %7d\n",
+ elapsed / 1e6,
+ // like MAJOR(dev), MINOR(dev):
+ args.dev >> 20, args.dev & 0xfffff,
+ @iocomm[args.dev, args.sector],
+ @iopid[args.dev, args.sector],
+ (nsecs - @start[args.dev, args.sector]) / 1e6);
+ delete(@start[args.dev, args.sector]);
+ delete(@iopid[args.dev, args.sector]);
+ delete(@iocomm[args.dev, args.sector]);
}
END
@@ -50,5 +49,4 @@
clear(@start);
clear(@iopid);
clear(@iocomm);
- clear(@disk);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/changtao615/bpftrace.git
git@gitee.com:changtao615/bpftrace.git
changtao615
bpftrace
bpftrace
master

搜索帮助