From 1c4ac772bb76e58eda91e323163f8596b7a95c8e Mon Sep 17 00:00:00 2001 From: Huang Yang Date: Tue, 27 Feb 2024 11:40:24 +0800 Subject: [PATCH 1/3] add loongarch64 in specfile --- bpftrace.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bpftrace.spec b/bpftrace.spec index 6fac9bd..959d150 100644 --- a/bpftrace.spec +++ b/bpftrace.spec @@ -1,6 +1,6 @@ Name: bpftrace Version: 0.19.1 -Release: 1 +Release: 2 Summary: High-level tracing language for Linux eBPF License: ASL 2.0 @@ -9,7 +9,7 @@ Source0: %{url}/archive/refs/tags/v%{version}.tar.gz # Arches will be included as upstream support is added and dependencies are # satisfied in the respective arches -ExclusiveArch: x86_64 %{power64} aarch64 riscv64 +ExclusiveArch: x86_64 %{power64} aarch64 riscv64 loongarch64 BuildRequires: gcc-c++ bison flex cmake elfutils-libelf-devel BuildRequires: zlib-devel llvm-devel clang clang-tools-extra clang-devel llvm-test @@ -68,6 +68,9 @@ find %{buildroot}%{_datadir}/%{name}/tools -type f -exec \ %changelog +* Tue Feb 27 2024 Huang Yang - 0.19.1-2 +- add loongarch64 support + * Mon Jan 08 2024 Paul Thomas - 0.19.1-1 - update to version 0.19.1 -- Gitee From 308b8c859467f95b032ea02b9fed1420745a232a Mon Sep 17 00:00:00 2001 From: changtao Date: Thu, 30 May 2024 23:47:04 +0800 Subject: [PATCH 2/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 --- ...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 From f21ec0b620657fe12abc04ed94c7354757f05cf5 Mon Sep 17 00:00:00 2001 From: changtao Date: Sat, 10 Aug 2024 14:41:03 +0800 Subject: [PATCH 3/3] fix runqlat.bt run error --- ...rt-fix-biosnoop-to-block-tracepoints.patch | 74 ------------------- backport-fix-runqlat-error.patch | 29 ++++++++ bpftrace.spec | 8 +- 3 files changed, 33 insertions(+), 78 deletions(-) delete mode 100644 backport-fix-biosnoop-to-block-tracepoints.patch create mode 100644 backport-fix-runqlat-error.patch diff --git a/backport-fix-biosnoop-to-block-tracepoints.patch b/backport-fix-biosnoop-to-block-tracepoints.patch deleted file mode 100644 index 614c4d6..0000000 --- a/backport-fix-biosnoop-to-block-tracepoints.patch +++ /dev/null @@ -1,74 +0,0 @@ -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/backport-fix-runqlat-error.patch b/backport-fix-runqlat-error.patch new file mode 100644 index 0000000..645b34c --- /dev/null +++ b/backport-fix-runqlat-error.patch @@ -0,0 +1,29 @@ +diff -Nuar bpftrace-0.19.1/tools/runqlat.bt bpftrace-0.19.1.new/tools/runqlat.bt +--- bpftrace-0.19.1/tools/runqlat.bt 2023-10-04 16:18:18.000000000 +0800 ++++ bpftrace-0.19.1.new/tools/runqlat.bt 2024-08-10 13:56:53.016113910 +0800 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env bpftrace ++#!/usr/bin/bpftrace + /* + * runqlat.bt CPU scheduler run queue latency as a histogram. + * For Linux, uses bpftrace, eBPF. +@@ -11,7 +11,19 @@ + * 17-Sep-2018 Brendan Gregg Created this. + */ + ++//#include ++ ++#ifndef BPFTRACE_HAVE_BTF + #include ++#else ++/* ++ * With BTF providing types, full headers are not needed. ++ * We only need to supply the preprocessor defines used in this script. ++ * TASK_RUNNING is not arch-dependant and has not changed in the linux ++ * git history (it is not part of the stable API though) ++ */ ++#define TASK_RUNNING 0 ++#endif + + BEGIN + { diff --git a/bpftrace.spec b/bpftrace.spec index f0342e8..29148da 100644 --- a/bpftrace.spec +++ b/bpftrace.spec @@ -6,7 +6,7 @@ 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 +Patch0001: backport-fix-runqlat-error.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,9 +68,9 @@ 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 +* Sat Aug 10 2024 changtao - 0.19.1-3 +- fix runqlat.bt run error for BPF +- for kernel 6.6.0 * Tue Feb 27 2024 Huang Yang - 0.19.1-2 - add loongarch64 support -- Gitee