From 308b8c859467f95b032ea02b9fed1420745a232a Mon Sep 17 00:00:00 2001 From: changtao Date: Thu, 30 May 2024 23:47:04 +0800 Subject: [PATCH] since functions blk_account_io_start and blk_account_io_done became static and can't be used as kprobes & fix biosnoop to block tracepoints --- ...rt-fix-biosnoop-to-block-tracepoints.patch | 74 +++++++++++++++++++ bpftrace.spec | 8 +- 2 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 backport-fix-biosnoop-to-block-tracepoints.patch diff --git a/backport-fix-biosnoop-to-block-tracepoints.patch b/backport-fix-biosnoop-to-block-tracepoints.patch new file mode 100644 index 0000000..614c4d6 --- /dev/null +++ b/backport-fix-biosnoop-to-block-tracepoints.patch @@ -0,0 +1,74 @@ +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); + } diff --git a/bpftrace.spec b/bpftrace.spec index 959d150..f0342e8 100644 --- a/bpftrace.spec +++ b/bpftrace.spec @@ -1,12 +1,12 @@ Name: bpftrace Version: 0.19.1 -Release: 2 +Release: 3 Summary: High-level tracing language for Linux eBPF License: ASL 2.0 URL: https://github.com/iovisor/bpftrace Source0: %{url}/archive/refs/tags/v%{version}.tar.gz - +Patch0001: backport-fix-biosnoop-to-block-tracepoints.patch # Arches will be included as upstream support is added and dependencies are # satisfied in the respective arches ExclusiveArch: x86_64 %{power64} aarch64 riscv64 loongarch64 @@ -68,6 +68,10 @@ find %{buildroot}%{_datadir}/%{name}/tools -type f -exec \ %changelog +* Fri Jun 7 2024 changtao - 0.19.1-3 +- since functions blk_account_io_start and blk_account_io_done became static and can't be used as kprobes +- fix-biosnoop-to-block-tracepoints + * Tue Feb 27 2024 Huang Yang - 0.19.1-2 - add loongarch64 support -- Gitee