fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/docker-playground/+/41778?usp=email )
Change subject: ttcn3-bts-test: bpftrace: filter by executable name ......................................................................
ttcn3-bts-test: bpftrace: filter by executable name
Filtering by pid does not work as expected, perhaps because we obtain it (by running pidof) in the container itself. Let's modify the scripts to filter by the executable name instead.
Change-Id: I04c2e36806534a8ca650733bacf521ea57950692 Related: OS#6794 --- M ttcn3-bts-test/bpftrace/ksys_write_delay.bt M ttcn3-bts-test/bpftrace/udp_sendmsg_delay.bt M ttcn3-bts-test/jenkins.sh 3 files changed, 10 insertions(+), 19 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/docker-playground refs/changes/78/41778/1
diff --git a/ttcn3-bts-test/bpftrace/ksys_write_delay.bt b/ttcn3-bts-test/bpftrace/ksys_write_delay.bt index 969dd29..bb964c3 100644 --- a/ttcn3-bts-test/bpftrace/ksys_write_delay.bt +++ b/ttcn3-bts-test/bpftrace/ksys_write_delay.bt @@ -7,11 +7,9 @@ * 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 + * The executable name must be passed as the first argument: * - * bpftrace ./ksys_write.bt -p PID - * - * (where PID is the PID of the process, like osmo-bts-trx) + * bpftrace ./ksys_write.bt osmo-bts-trx */
BEGIN @@ -19,7 +17,7 @@ printf("Tracing ksys_write() latency... Hit Ctrl-C to end.\n"); }
-kprobe:ksys_write +kprobe:ksys_write / comm == $1 / { $fd = (int64)arg0;
diff --git a/ttcn3-bts-test/bpftrace/udp_sendmsg_delay.bt b/ttcn3-bts-test/bpftrace/udp_sendmsg_delay.bt index 8525413..f09960e 100644 --- a/ttcn3-bts-test/bpftrace/udp_sendmsg_delay.bt +++ b/ttcn3-bts-test/bpftrace/udp_sendmsg_delay.bt @@ -7,11 +7,9 @@ * Implemented 2025 by Vadim Yanitskiy fixeria@osmocom.org * SPDX-License-Identifier: CC0 * - * As no filtering on PID etc. is done, you will likely use this with 'bpftrace -p' like + * The executable name must be passed as the first argument: * - * bpftrace ./udp_sendmsg_delay.bt -p PID - * - * (where PID is the PID of the process, like osmo-bts-trx) + * bpftrace ./udp_sendmsg_delay.bt osmo-bts-trx */
BEGIN @@ -19,7 +17,7 @@ printf("Tracing udp_sendmsg() latency... Hit Ctrl-C to end.\n"); }
-kprobe:udp_sendmsg +kprobe:udp_sendmsg / comm == $1 / { $sk = (struct sock *)arg0; /* poor man's ntohs() */ diff --git a/ttcn3-bts-test/jenkins.sh b/ttcn3-bts-test/jenkins.sh index 6e5cc67..0571d65 100755 --- a/ttcn3-bts-test/jenkins.sh +++ b/ttcn3-bts-test/jenkins.sh @@ -85,19 +85,14 @@ continue fi
- local logfile="$VOL_BASE_DIR"/bts/bpftrace/$(basename "$script" | sed s/.bt/.log/) - local startscript="$VOL_BASE_DIR"/bts/bpftrace/$(basename "$script" | sed s/.bt/.sh/) + local scriptfile="/data/bpftrace/$(basename "$script")" + local logfile="${scriptfile}.log"
cp "$script" "$VOL_BASE_DIR"/bts/bpftrace
- ( echo "#!/bin/sh -ex" - echo "bpftrace /data/bpftrace/$(basename "$script") -p $(pidof osmo-bts-$variant)" ) >"$startscript" - chmod +x "$startscript" - - docker exec \ + docker exec -d \ "${BUILD_TAG}-bts" \ - /usr/local/bin/respawn.sh /data/bpftrace/"$(basename "$startscript")" \ - >>"$logfile" 2>&1 & + /bin/sh -c "/usr/local/bin/respawn.sh bpftrace $scriptfile osmo-bts-$variant >>$logfile 2>&1" done fi }