Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf test: Add tests for latency and parallelism profiling

Ensure basic operation of latency/parallelism profiling and that
main latency/parallelism record/report invocations don't fail/crash.

Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Link: https://lore.kernel.org/r/c129c8f02f328f68e1e9ef2cdc582f8a9786a97d.1739437531.git.dvyukov@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Dmitry Vyukov and committed by
Namhyung Kim
257facfa 32ecca8d

+69 -1
+17 -1
tools/perf/tests/shell/base_report/setup.sh
··· 15 15 # include working environment 16 16 . ../common/init.sh 17 17 18 + TEST_RESULT=0 19 + 18 20 test -d "$HEADER_TAR_DIR" || mkdir -p "$HEADER_TAR_DIR" 19 21 20 22 SW_EVENT="cpu-clock" ··· 28 26 CHECK_EXIT_CODE=$? 29 27 30 28 print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "prepare the perf.data file" 31 - TEST_RESULT=$? 29 + (( TEST_RESULT += $? )) 30 + 31 + # Some minimal parallel workload. 32 + $CMD_PERF record --latency -o $CURRENT_TEST_DIR/perf.data.1 bash -c "for i in {1..100} ; do cat /proc/cpuinfo 1> /dev/null & done; sleep 1" 2> $LOGS_DIR/setup-latency.log 33 + PERF_EXIT_CODE=$? 34 + 35 + echo ================== 36 + cat $LOGS_DIR/setup-latency.log 37 + echo ================== 38 + 39 + ../common/check_all_patterns_found.pl "$RE_LINE_RECORD1" "$RE_LINE_RECORD2" < $LOGS_DIR/setup-latency.log 40 + CHECK_EXIT_CODE=$? 41 + 42 + print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "prepare the perf.data.1 file" 43 + (( TEST_RESULT += $? )) 32 44 33 45 print_overall_results $TEST_RESULT 34 46 exit $?
+52
tools/perf/tests/shell/base_report/test_basic.sh
··· 183 183 (( TEST_RESULT += $? )) 184 184 185 185 186 + ### latency and parallelism 187 + 188 + # Record with --latency should record with context switches. 189 + $CMD_PERF report -i $CURRENT_TEST_DIR/perf.data.1 --stdio --header-only > $LOGS_DIR/latency_header.log 190 + PERF_EXIT_CODE=$? 191 + 192 + ../common/check_all_patterns_found.pl ", context_switch = 1, " < $LOGS_DIR/latency_header.log 193 + CHECK_EXIT_CODE=$? 194 + 195 + print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "latency header" 196 + (( TEST_RESULT += $? )) 197 + 198 + 199 + # The default report for latency profile should show Overhead and Latency fields (in that order). 200 + $CMD_PERF report --stdio -i $CURRENT_TEST_DIR/perf.data.1 > $LOGS_DIR/latency_default.log 2> $LOGS_DIR/latency_default.err 201 + PERF_EXIT_CODE=$? 202 + 203 + ../common/check_all_patterns_found.pl "# Overhead Latency Command" < $LOGS_DIR/latency_default.log 204 + CHECK_EXIT_CODE=$? 205 + ../common/check_errors_whitelisted.pl "stderr-whitelist.txt" < $LOGS_DIR/latency_default.err 206 + (( CHECK_EXIT_CODE += $? )) 207 + 208 + print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "default report for latency profile" 209 + (( TEST_RESULT += $? )) 210 + 211 + 212 + # The latency report for latency profile should show Latency and Overhead fields (in that order). 213 + $CMD_PERF report --latency --stdio -i $CURRENT_TEST_DIR/perf.data.1 > $LOGS_DIR/latency_latency.log 2> $LOGS_DIR/latency_latency.err 214 + PERF_EXIT_CODE=$? 215 + 216 + ../common/check_all_patterns_found.pl "# Latency Overhead Command" < $LOGS_DIR/latency_latency.log 217 + CHECK_EXIT_CODE=$? 218 + ../common/check_errors_whitelisted.pl "stderr-whitelist.txt" < $LOGS_DIR/latency_latency.err 219 + (( CHECK_EXIT_CODE += $? )) 220 + 221 + print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "latency report for latency profile" 222 + (( TEST_RESULT += $? )) 223 + 224 + 225 + # Ensure parallelism histogram with parallelism filter does not fail/crash. 226 + $CMD_PERF report --hierarchy --sort latency,parallelism,comm,symbol --parallelism=1,2 --stdio -i $CURRENT_TEST_DIR/perf.data.1 > $LOGS_DIR/parallelism_hierarchy.log 2> $LOGS_DIR/parallelism_hierarchy.err 227 + PERF_EXIT_CODE=$? 228 + 229 + ../common/check_all_patterns_found.pl "# Latency Parallelism / Command / Symbol" < $LOGS_DIR/parallelism_hierarchy.log 230 + CHECK_EXIT_CODE=$? 231 + ../common/check_errors_whitelisted.pl "stderr-whitelist.txt" < $LOGS_DIR/parallelism_hierarchy.err 232 + (( CHECK_EXIT_CODE += $? )) 233 + 234 + print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "parallelism histogram" 235 + (( TEST_RESULT += $? )) 236 + 237 + 186 238 # TODO: $CMD_PERF report -n --showcpuutilization -TUxDg 2> 01.log 187 239 188 240 # print overall results