pespin has uploaded this change for review.

View Change

bpftrace: Introduce ksys_write_delay.bt

This will record latency of write() calls during ttcn3-bts-test run,
where some write() call on stderr seems to be taking ~0.32 seconds,
stalling the timerfd (71 times) and making osmo-bts exit.

Related: OS#6794
Change-Id: Ia1d2036ac7c6c9e2818d07e8787d857b3b3e5881
---
A ttcn3-bts-test/bpftrace/ksys_write_delay.bt
1 file changed, 39 insertions(+), 0 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/docker-playground refs/changes/77/41777/1
diff --git a/ttcn3-bts-test/bpftrace/ksys_write_delay.bt b/ttcn3-bts-test/bpftrace/ksys_write_delay.bt
new file mode 100644
index 0000000..969dd29
--- /dev/null
+++ b/ttcn3-bts-test/bpftrace/ksys_write_delay.bt
@@ -0,0 +1,39 @@
+#!/usr/bin/env bpftrace
+
+/* Script to obtain ksys_write() latency histograms.
+ * It will measure time between entry and exit and plot one histogram
+ * for each destination port number, indicating the amount of time spent.
+ *
+ * Implemented 2026 by Pau Espin Pedrol <pespin@sysmocom.de>
+ * SPDX-License-Identifier: CC0
+ *
+ * As no filtering on PID etc. is done, you will likely use this with 'bpftrace -p' like
+ *
+ * bpftrace ./ksys_write.bt -p PID
+ *
+ * (where PID is the PID of the process, like osmo-bts-trx)
+ */
+
+BEGIN
+{
+ printf("Tracing ksys_write() latency... Hit Ctrl-C to end.\n");
+}
+
+kprobe:ksys_write
+{
+ $fd = (int64)arg0;
+
+ @start[tid] = nsecs;
+ @fd[tid] = $fd;
+}
+
+kretprobe:ksys_write / @start[tid] /
+{
+ $delta_us = (nsecs - @start[tid]) / 1000;
+ @latency[@fd[tid]] = hist($delta_us);
+
+ delete(@start[tid]);
+ delete(@fd[tid]);
+}
+
+/* vim:set ts=2 sw=2 et: */

To view, visit change 41777. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-Change-Id: Ia1d2036ac7c6c9e2818d07e8787d857b3b3e5881
Gerrit-Change-Number: 41777
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>