From 8ab662ba75f2630954e0cf77e8267a8116919589 Mon Sep 17 00:00:00 2001 From: Rafael Folco Date: Thu, 31 Jul 2025 14:21:18 -0300 Subject: [PATCH] Add params and switch to rtla binaries --- multiplex.json | 16 +++++-- timerlat-client | 125 +++++++++++++++++++++++++++++++++++++++--------- workshop.json | 24 ++++++---- 3 files changed, 129 insertions(+), 36 deletions(-) diff --git a/multiplex.json b/multiplex.json index 0c12f7d..fbe723b 100644 --- a/multiplex.json +++ b/multiplex.json @@ -5,7 +5,8 @@ "integer_ge_zero": { "description": "a whole number >= 0", "args": [ - "dma-latency" + "dma-latency", + "deepest-idle-state" ], "vals": "[0-9]*$" }, @@ -14,7 +15,8 @@ "description": "a whole number > 0", "args": [ "duration", - "period" + "period", + "warm-up" ], "vals": "^[1-9][0-9]*$" }, @@ -22,7 +24,7 @@ "description": "a range of whole numbers >= 0", "args": [ "cpus", - "housekeeping" + "house-keeping" ], "vals": "(\\d+(-\\d+)?(,\\s*\\d+(-\\d+)?)*|\\d+(-\\d+)?)" }, @@ -39,8 +41,14 @@ "smt" ], "vals": "on|off" + }, + "thread_type": { + "description": "thread type (user/kernel)", + "args": [ + "thread" + ], + "vals": "u|k" } - } } diff --git a/timerlat-client b/timerlat-client index fe20a4b..13e1976 100755 --- a/timerlat-client +++ b/timerlat-client @@ -10,25 +10,17 @@ dump_runtime validate_label validate_sw_prereqs -if [ -z "${WORKLOAD_CPUS}" ]; then - exit_error "WORKLOAD_CPUS is not defined. This must be defined to run timerlat" -else - echo "WORKLOAD_CPUS: ${WORKLOAD_CPUS}" -fi -if [ -z "${HK_CPUS}" ]; then - exit_error "HK_CPUS is not defined. This must be defined to run timerlat" -else - echo "HK_CPUS: ${HK_CPUS}" -fi - no_load_balance=0 priority="" duration=60 smt="on" period=1000000 -housekeeping=${HK_CPUS} +house_keeping=${HK_CPUS} +warm_up="" +thread="" +dma_latency="" -opts=$(getopt -q -o "" --longoptions "cpus:,housekeeping:,priority:,no-load-balance:,duration:,smt:,period:" -n "getopt.sh" -- "$@"); ++opts=$(getopt -q -o "" --longoptions "cpus:,house-keeping:,priority:,no-load-balance:,duration:,smt:,period:,warm-up:,thread:,dma-latency:,deepest-idle-state:" -n "getopt.sh" -- "$@"); if [ $? -ne 0 ]; then printf -- "\tUnrecognized option specified\n\n" exit 1 @@ -41,9 +33,9 @@ while true; do cpus=$1 shift; ;; - --housekeeping) + --house-keeping) shift; - housekeeping=$1 + house_keeping=$1 shift; ;; --priority) @@ -71,6 +63,26 @@ while true; do no_load_balance=$1 shift; ;; + --warm-up) + shift; + warm_up=" --warm-up $1" + shift; + ;; + --thread) + shift; + thread="-$1" + shift; + ;; + --dma-latency) + shift; + dma_latency="--dma-latency $1" + shift; + ;; + --deepest-idle-state) + shift; + deepest_idle_state="--deepest-idle-state $1" + shift; + ;; --) shift; break @@ -81,11 +93,30 @@ while true; do esac done -if [ "$no_load_balance" == "1" ]; then - disable_balance $cpus_list +if [ -z "${WORKLOAD_CPUS}" ] && [ -z "${cpus}" ]; then + exit_error "Unable to auto-detect WORKLOAD_CPUS and the param 'cpus' is not specified." fi -# adjust CPUs to use +if [ -z "${HK_CPUS}" ] && [ -z "${house_keeping}" ]; then + exit_error "Unable to auto-detect HK_CPUS and the param 'house-keeping' is not specified." +fi + +# Override WORKLOAD_CPUS w/ cpus param (if defined) +if [ -n "${cpus}" ]; then + echo "'cpus' param is defined: ${cpus}" + # Cpu range to comma separated list: e.g. 1-5,10-12 ==> 1,2,3,4,5,10,11,12 + cmd="${TOOLBOX_HOME}/bin/cpumask.py --cpus ${cpus}" + echo "about to run: ${cmd}" + CMD_OUTPUT=$(${cmd}) + echo -e "${CMD_OUTPUT}" + WORKLOAD_CPUS=$(echo -e "${CMD_OUTPUT}" | grep cpulist | awk -F= '{print $2}') + echo "WORKLOAD_CPUS: ${WORKLOAD_CPUS}" +else + # Fallback to auto-detected WORKLOAD_CPUS list + echo "'cpus' undefined, using the auto-detected workload cpus: $WORKLOAD_CPUS." +fi + +# Update WORKLOAD_CPUS smt-wise cpu_str="" for cpu in $(echo $WORKLOAD_CPUS | sed -e "s/,/ /g"); do cpu_str+=" --cpu $cpu" @@ -97,9 +128,54 @@ echo -e "${CMD_OUTPUT}" WORKLOAD_CPUS=$(echo -e "${CMD_OUTPUT}" | grep "final cpus:" | awk '{ print $3 }') echo "WORKLOAD_CPUS: ${WORKLOAD_CPUS}" -# Run on the workload cpus (exclude hk cpus by default) -if [ -z ${cpus} ]; then - cpus=${WORKLOAD_CPUS} +# Transform the list of comma-separated cpus into range(s) e.g. 1,2,3->1-3 +cmd="${TOOLBOX_HOME}/bin/get-cpu-range.py ${WORKLOAD_CPUS}" +echo "about to run: ${cmd}" +CMD_OUTPUT=$(${cmd}) +echo -e "${CMD_OUTPUT}" +WORKLOAD_CPUS=${CMD_OUTPUT} +echo "WORKLOAD_CPUS: ${WORKLOAD_CPUS}" + +# Override HK_CPUS w/ house-keeping param (if defined) +if [ -n $house_keeping ]; then + echo "'house-keeping' param is defined: ${house_keeping}" + # Cpu range to comma separated list: e.g. 2-3 ==> 2,3 + cmd="${TOOLBOX_HOME}/bin/cpumask.py --cpus ${house_keeping}" + echo "about to run: ${cmd}" + CMD_OUTPUT=$(${cmd}) + echo -e "${CMD_OUTPUT}" + HK_CPUS=$(echo -e "${CMD_OUTPUT}" | grep cpulist | awk -F= '{print $2}') + echo "HK_CPUS: ${HK_CPUS}" +else + # fallback to auto-detected HK_CPUS + echo "'house-keeping' undefined, using the auto-detected house-keeping: $HK_CPUS." +fi + +# Update HK_CPUS smt-wise +cpu_str="" +for cpu in $(echo $HK_CPUS | sed -e "s/,/ /g"); do + if [[ ",$WORKLOAD_CPUS," =~ ",$cpu," ]]; then + exit_error "House-keeping must NOT overlap with the workload cpus." + fi + cpu_str+=" --cpu $cpu" +done +cmd="${TOOLBOX_HOME}/bin/get-cpus-ordered.py --smt ${smt} ${cpu_str}" +echo "about to run: ${cmd}" +CMD_OUTPUT=$(${cmd}) +echo -e "${CMD_OUTPUT}" +HK_CPUS=$(echo -e "${CMD_OUTPUT}" | grep "final cpus:" | awk '{ print $3 }') +echo "HK_CPUS: ${HK_CPUS}" + +# Transform the list of comma-separated cpus into range(s) e.g. 1,2,3->1-3 +cmd="${TOOLBOX_HOME}/bin/get-cpu-range.py ${HK_CPUS}" +echo "about to run: ${cmd}" +CMD_OUTPUT=$(${cmd}) +echo -e "${CMD_OUTPUT}" +HK_CPUS=${CMD_OUTPUT} +echo "HK_CPUS: ${HK_CPUS}" + +if [ "$no_load_balance" == "1" ]; then + disable_balance $cpus_list fi echo @@ -117,7 +193,12 @@ if [ $? != 0 ]; then exit_error "${output}" fi -cmd="taskset -c ${WORKLOAD_CPUS} rtla timerlat top --quiet --duration ${duration}s --house-keeping ${housekeeping} --cpus ${WORKLOAD_CPUS} --period ${period} $priority" +cmd="taskset -c ${HK_CPUS},${WORKLOAD_CPUS} + rtla timerlat top + --quiet --duration ${duration}s + --house-keeping ${HK_CPUS} --cpus ${WORKLOAD_CPUS} + --period ${period} + ${priority} ${warm_up} ${dma_latency} ${deepest_idle_state}" echo "About to run: $cmd" date +%s.%N >begin.txt $cmd >timerlat-bin-stderrout.txt 2>&1 diff --git a/workshop.json b/workshop.json index 87c73db..dc6c3aa 100644 --- a/workshop.json +++ b/workshop.json @@ -8,12 +8,7 @@ { "name": "default", "requirements": [ - "packages", - "gettext_src", - "flex_src", - "libtraceevent_src", - "libtracefs_src", - "linux_src" + "packages" ] } ], @@ -21,6 +16,15 @@ { "name": "packages", "type": "distro", + "distro_info": { + "packages": [ + "rtla" + ] + } + }, + { + "name": "src-dependencies", + "type": "distro", "distro_info": { "packages": [ "python3-docutils" @@ -92,11 +96,11 @@ "name": "linux_src", "type": "source", "source_info": { - "url": "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/snapshot/linux-6.11.tar.gz", - "filename": "linux.tar.gz", + "url": "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.12.31.tar.xz", + "filename": "linux.tar.xz", "commands": { - "unpack": "tar -xzf linux.tar.gz", - "get_dir": "tar -tzf linux.tar.gz | head -n 1", + "unpack": "tar -xf linux.tar.xz", + "get_dir": "tar -tf linux.tar.xz | head -n 1", "commands": [ "cd tools/tracing/rtla; make", "cd tools/tracing/rtla; make install",