gazelle/0157-perftool-add-lhist-statstic-tool.patch
yinbin6 491b6eeeb1 sync fix vlan filter can be added when vlan_mode=-1
(cherry picked from commit b8d978e49349fa34b9e40f561d20ea47c3e359fd)
2024-04-08 11:39:47 +08:00

42 lines
1.0 KiB
Diff

From 34c2f6cc1e1059ffe3e5edd7cebeb758e4ba9f36 Mon Sep 17 00:00:00 2001
From: wuchangye <wuchangye@huawei.com>
Date: Sun, 24 Mar 2024 00:10:08 +0800
Subject: [PATCH] perftool: add lhist statstic tool
---
tools/perf/glhist.bt | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 tools/perf/glhist.bt
diff --git a/tools/perf/glhist.bt b/tools/perf/glhist.bt
new file mode 100644
index 0000000..757f6e9
--- /dev/null
+++ b/tools/perf/glhist.bt
@@ -0,0 +1,21 @@
+#!/usr/bin/env bpftrace
+/*
+reference: https://github.com/bpftrace/bpftrace/blob/master/man/adoc/bpftrace.adoc
+prepare: yum install bpftrace
+example: ./glhist.bt rpc_poll_msg
+*/
+
+uprobe:/usr/lib64/liblstack.so:$1
+{
+ @t_start[tid] = nsecs;
+}
+
+uretprobe:/usr/lib64/liblstack.so:$1
+{
+ @t_dur[tid] = nsecs - @t_start[tid];
+ @t_count[tid] = count();
+ if (@t_dur[tid] < 1000000000) {
+ // lhist(int64 n, int64 min, int64 max, int64 step)
+ @t_hist[tid] = lhist(@t_dur[tid], 0, 4000, 100);
+ }
+}
\ No newline at end of file
--
2.33.0