Add a new script check-cgroup-match.sh that retrieves the cgroup of the main rtla process and compares it to the cgroup of the rtla workload threads.
Add a new test based on this script, for both osnoise and timerlat tools, testing the variant of -C without argument (which sets the cgroup of the workload to the cgroup of the rtla main process). Note that this has to be tested in kernel mode to be significant for timerlat tool, as user workloads inherit the parent rtla process cgroup even without the option. Signed-off-by: Tomas Glozar <[email protected]> --- tools/tracing/rtla/tests/osnoise.t | 3 +++ .../rtla/tests/scripts/check-cgroup-match.sh | 17 +++++++++++++++++ tools/tracing/rtla/tests/timerlat.t | 3 +++ 3 files changed, 23 insertions(+) create mode 100755 tools/tracing/rtla/tests/scripts/check-cgroup-match.sh diff --git a/tools/tracing/rtla/tests/osnoise.t b/tools/tracing/rtla/tests/osnoise.t index d0b623233db5..06787471d0e8 100644 --- a/tools/tracing/rtla/tests/osnoise.t +++ b/tools/tracing/rtla/tests/osnoise.t @@ -18,6 +18,9 @@ check_top_q_hist "verify the --trace param" \ check_top_q_hist "verify the --priority/-P param" \ "osnoise TOOL -P F:1 -c 0 -r 900000 -d 10s -S 1 --on-threshold shell,command=\"tests/scripts/check-priority.sh SCHED_FIFO 1\"" \ 2 "Priorities are set correctly" +check_top_q_hist "verify the -C/--cgroup param" \ + "osnoise TOOL -C -c 0 -r 900000 -d 10s -S 1 --on-threshold shell,command=\"tests/scripts/check-cgroup-match.sh\"" \ + 2 "cgroup matches for all workload PIDs" check_top_q_hist "verify the -c/--cpus param" \ "osnoise TOOL -P F:1 -c 0 -r 900000 -d 10s -S 1 --on-threshold shell,command=tests/scripts/check-cpus.sh" 2 "^Affinity of threads: 0$" check_top_q_hist "verify the -H/--house-keeping param" \ diff --git a/tools/tracing/rtla/tests/scripts/check-cgroup-match.sh b/tools/tracing/rtla/tests/scripts/check-cgroup-match.sh new file mode 100755 index 000000000000..fdc2c68c5957 --- /dev/null +++ b/tools/tracing/rtla/tests/scripts/check-cgroup-match.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +. "$(dirname $0)/lib/get_workload_pids.sh" +rtla_pid=$(echo $(ps -o ppid= $$)) +rtla_cgroup=$(</proc/$rtla_pid/cgroup) +echo "RTLA cgroup: $rtla_cgroup" +for pid in $(get_workload_pids) +do + pid_cgroup=$(</proc/$pid/cgroup) + echo "PID $pid cgroup: $pid_cgroup" + if ! [ "$pid_cgroup" = "$rtla_cgroup" ] + then + echo "Mismatch!" + exit 0 + fi +done +echo "cgroup matches for all workload PIDs" diff --git a/tools/tracing/rtla/tests/timerlat.t b/tools/tracing/rtla/tests/timerlat.t index 3557adbdebae..3ebfe316b39e 100644 --- a/tools/tracing/rtla/tests/timerlat.t +++ b/tools/tracing/rtla/tests/timerlat.t @@ -43,6 +43,9 @@ check_top_hist "disable auto-analysis" \ check_top_hist "verify -P/--priority" \ "timerlat TOOL -P F:1 -c 0 -d 10s -T 1 --on-threshold shell,command=\"tests/scripts/check-priority.sh SCHED_FIFO 1\"" \ 2 "Priorities are set correctly" +check_top_hist "verify -C/--cgroup" \ + "timerlat TOOL -k -C -c 0 -d 10s -T 1 --on-threshold shell,command=\"tests/scripts/check-cgroup-match.sh\"" \ + 2 "cgroup matches for all workload PIDs" check_top_q_hist "verify -c/--cpus" \ "timerlat TOOL -c 0 -d 10s -T 1 --on-threshold shell,command=tests/scripts/check-cpus.sh" 2 "^Affinity of threads: 0$" check_top_q_hist "verify -H/--house-keeping" \ -- 2.53.0
