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

Configure Feed

Select the types of activity you want to include in your feed.

tracing: selftests: Extend hotplug testing for trace remotes

The hotplug testing only tries reading a trace remote buffer, loaded
before a CPU is offline. Extend this testing to cover:

* A trace remote buffer loaded after a CPU is offline.
* A trace remote buffer loaded before a CPU is online.

Because of these added test cases, move the hotplug testing into a
separate hotplug.tc file.

Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
Link: https://patch.msgid.link/20260401045100.3394299-3-vdonnefort@google.com
Signed-off-by: Marc Zyngier <maz@kernel.org>

authored by

Vincent Donnefort and committed by
Marc Zyngier
ec07906b ce47b798

+115 -55
+15 -4
tools/testing/selftests/ftrace/test.d/remotes/functions
··· 24 24 25 25 assert_loaded() 26 26 { 27 - grep -q "(loaded)" buffer_size_kb 27 + grep -q "(loaded)" buffer_size_kb || return 1 28 28 } 29 29 30 30 assert_unloaded() 31 31 { 32 - grep -q "(unloaded)" buffer_size_kb 32 + grep -q "(unloaded)" buffer_size_kb || return 1 33 + } 34 + 35 + reload_remote() 36 + { 37 + echo 0 > tracing_on 38 + clear_trace 39 + assert_unloaded 40 + echo 1 > tracing_on 41 + assert_loaded 33 42 } 34 43 35 44 dump_trace_pipe() ··· 88 79 sed -n 's/^processor\s*:\s*\([0-9]\+\).*/\1/p' /proc/cpuinfo 89 80 } 90 81 91 - get_page_size() { 82 + get_page_size() 83 + { 92 84 sed -ne 's/^.*data.*size:\([0-9][0-9]*\).*/\1/p' events/header_page 93 85 } 94 86 95 - get_selftest_event_size() { 87 + get_selftest_event_size() 88 + { 96 89 sed -ne 's/^.*field:.*;.*size:\([0-9][0-9]*\);.*/\1/p' events/*/selftest/format | awk '{s+=$1} END {print s}' 97 90 }
+88
tools/testing/selftests/ftrace/test.d/remotes/hotplug.tc
··· 1 + #!/bin/sh 2 + # SPDX-License-Identifier: GPL-2.0 3 + # description: Test trace remote read with an offline CPU 4 + # requires: remotes/test 5 + 6 + . $TEST_DIR/remotes/functions 7 + 8 + hotunplug_one_cpu() 9 + { 10 + [ "$(get_cpu_ids | wc -l)" -ge 2 ] || return 1 11 + 12 + for cpu in $(get_cpu_ids); do 13 + echo 0 > /sys/devices/system/cpu/cpu$cpu/online || return 1 14 + break 15 + done 16 + 17 + echo $cpu 18 + } 19 + 20 + # Check non-consuming and consuming read 21 + check_read() 22 + { 23 + for i in $(seq 1 8); do 24 + echo $i > write_event 25 + done 26 + 27 + check_trace 1 8 trace 28 + 29 + output=$(dump_trace_pipe) 30 + check_trace 1 8 $output 31 + rm $output 32 + } 33 + 34 + test_hotplug() 35 + { 36 + echo 0 > trace 37 + assert_loaded 38 + 39 + # 40 + # Test a trace buffer containing an offline CPU 41 + # 42 + 43 + cpu=$(hotunplug_one_cpu) || exit_unsupported 44 + trap "echo 1 > /sys/devices/system/cpu/cpu$cpu/online" EXIT 45 + 46 + check_read 47 + 48 + # 49 + # Test a trace buffer with a missing CPU 50 + # 51 + 52 + reload_remote 53 + 54 + check_read 55 + 56 + # 57 + # Test a trace buffer with a CPU added later 58 + # 59 + 60 + echo 1 > /sys/devices/system/cpu/cpu$cpu/online 61 + trap "" EXIT 62 + assert_loaded 63 + 64 + check_read 65 + 66 + # Test if the ring-buffer for the newly added CPU is both writable and 67 + # readable 68 + for i in $(seq 1 8); do 69 + taskset -c $cpu echo $i > write_event 70 + done 71 + 72 + cd per_cpu/cpu$cpu/ 73 + 74 + check_trace 1 8 trace 75 + 76 + output=$(dump_trace_pipe) 77 + check_trace 1 8 $output 78 + rm $output 79 + 80 + cd - 81 + } 82 + 83 + if [ -z "$SOURCE_REMOTE_TEST" ]; then 84 + set -e 85 + 86 + setup_remote_test 87 + test_hotplug 88 + fi
+11
tools/testing/selftests/ftrace/test.d/remotes/hypervisor/hotplug.tc
··· 1 + #!/bin/sh 2 + # SPDX-License-Identifier: GPL-2.0 3 + # description: Test hypervisor trace read with an offline CPU 4 + # requires: remotes/hypervisor/write_event 5 + 6 + SOURCE_REMOTE_TEST=1 7 + . $TEST_DIR/remotes/hotplug.tc 8 + 9 + set -e 10 + setup_remote "hypervisor" 11 + test_hotplug
+1 -26
tools/testing/selftests/ftrace/test.d/remotes/trace.tc
··· 58 58 # 59 59 60 60 # Ensure the writer is not on the reader page by reloading the buffer 61 - echo 0 > tracing_on 62 - echo 0 > trace 63 - assert_unloaded 64 - echo 1 > tracing_on 65 - assert_loaded 61 + reload_remote 66 62 67 63 # Ensure ring-buffer overflow by emitting events from the same CPU 68 64 for cpu in $(get_cpu_ids); do ··· 92 96 93 97 cd - > /dev/null 94 98 done 95 - 96 - # 97 - # Test with hotplug 98 - # 99 - 100 - [ "$(get_cpu_ids | wc -l)" -ge 2 ] || return 0 101 - 102 - echo 0 > trace 103 - 104 - for cpu in $(get_cpu_ids); do 105 - echo 0 > /sys/devices/system/cpu/cpu$cpu/online || return 0 106 - break 107 - done 108 - 109 - for i in $(seq 1 8); do 110 - echo $i > write_event 111 - done 112 - 113 - check_trace 1 8 trace 114 - 115 - echo 1 > /sys/devices/system/cpu/cpu$cpu/online 116 99 } 117 100 118 101 if [ -z "$SOURCE_REMOTE_TEST" ]; then
-25
tools/testing/selftests/ftrace/test.d/remotes/trace_pipe.tc
··· 92 92 rm $output 93 93 cd - > /dev/null 94 94 done 95 - 96 - # 97 - # Test interaction with hotplug 98 - # 99 - 100 - [ "$(get_cpu_ids | wc -l)" -ge 2 ] || return 0 101 - 102 - echo 0 > trace 103 - 104 - for cpu in $(get_cpu_ids); do 105 - echo 0 > /sys/devices/system/cpu/cpu$cpu/online || return 0 106 - break 107 - done 108 - 109 - for i in $(seq 1 8); do 110 - echo $i > write_event 111 - done 112 - 113 - output=$(dump_trace_pipe) 114 - 115 - check_trace 1 8 $output 116 - 117 - rm $output 118 - 119 - echo 1 > /sys/devices/system/cpu/cpu$cpu/online 120 95 } 121 96 122 97 if [ -z "$SOURCE_REMOTE_TEST" ]; then