Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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
8hotunplug_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
21check_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
34test_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
83if [ -z "$SOURCE_REMOTE_TEST" ]; then
84 set -e
85
86 setup_remote_test
87 test_hotplug
88fi