1#!/bin/sh 2# 3# Test Case 7 4# 5# Runs continuous offline/online of CPUs along with 6# a kernel compilation load. 7 8export TCID="cpuhotplug07" 9export TST_TOTAL=1 10 11# Includes: 12. test.sh 13. cpuhotplug_testsuite.sh 14. cpuhotplug_hotplug.sh 15 16cat <<EOF 17Name: $TCID 18Date: `date` 19Desc: What happens when hotplugging during a heavy workload? 20Issue: Hotplug bugs have been found during kernel compiles 21 22EOF 23 24usage() 25{ 26 cat << EOF 27 usage: $0 -c cpu -l loop -d directory 28 29 OPTIONS 30 -c cpu which is specified for testing 31 -l number of cycle test 32 -d kernel directory where run this test 33 34EOF 35 exit 1 36} 37 38do_clean() 39{ 40 kill_pid ${KCOMPILE_LOOP_PID} 41} 42 43while getopts c:l:d: OPTION; do 44 case $OPTION in 45 c) 46 CPU_TO_TEST=$OPTARG;; 47 l) 48 HOTPLUG07_LOOPS=$OPTARG;; 49 d) 50 KERNEL_DIR=$OPTARG;; 51 ?) 52 usage;; 53 esac 54done 55 56LOOP_COUNT=1 57 58if tst_virt_hyperv; then 59 tst_brkm TCONF "Microsoft Hyper-V detected, no support for CPU hotplug" 60fi 61 62if [ $(get_present_cpus_num) -lt 2 ]; then 63 tst_brkm TCONF "system doesn't have required CPU hotplug support" 64fi 65 66if [ ! -d "${KERNEL_DIR}" ]; then 67 tst_brkm TCONF "kernel directory - $KERNEL_DIR - does not exist" 68fi 69 70if [ -z "${CPU_TO_TEST}" ]; then 71 tst_brkm TBROK "usage: ${0##*/} <CPU to offline> <Kernel \ 72 source code directory>" 73fi 74 75# Validate the specified CPU is available 76if ! cpu_is_valid "${CPU_TO_TEST}" ; then 77 tst_brkm TCONF "cpu${CPU_TO_TEST} doesn't support hotplug" 78fi 79 80if ! cpu_is_online ${CPU_TO_TEST}; then 81 if ! online_cpu ${CPU_TO_TEST}; then 82 tst_brkm TBROK "CPU${CPU_TO_TEST} cannot be onlined" 83 fi 84fi 85 86TST_CLEANUP=do_clean 87 88cpuhotplug_do_kcompile_loop $KERNEL_DIR > /dev/null 2>&1 & 89KCOMPILE_LOOP_PID=$! 90 91tst_resm TINFO "initial CPU affinity for kernel compile is: \ 92 $(get_affinity_mask ${KCOMPILE_LOOP_PID})" 93 94sleep 2 95 96until [ $LOOP_COUNT -gt $HOTPLUG07_LOOPS ]; do 97 98 tst_resm TINFO "Starting loop" 99 100 # Move spin_loop.sh to the CPU to offline. 101 set_affinity ${KCOMPILE_LOOP_PID} ${CPU_TO_TEST} 102 103 offline_cpu ${CPU_TO_TEST} 104 RC=$? 105 echo "Offlining cpu${CPU_TO_TEST}: Return Code = ${RC}" 106 107 NEW_CPU=`ps --pid=${KCOMPILE_LOOP_PID} -o psr --no-headers` 108 if [ -z "${NEW_CPU}" ]; then 109 tst_brkm TBROK "PID ${KCOMPILE_LOOP_PID} no longer running" 110 fi 111 if [ "${CPU_TO_TEST}" = "${NEW_CPU}" ]; then 112 tst_resm TFAIL "process did not change from CPU ${NEW_CPU}" 113 tst_exit 114 fi 115 116 online_cpu ${CPU_TO_TEST} 117 RC=$? 118 echo "Onlining cpu${CPU_TO_TEST}: Return Code = ${RC}" 119 120 LOOP_COUNT=$((LOOP_COUNT+1)) 121 122done 123 124tst_resm TPASS "turned off CPU ${CPU_TO_TEST}, process migrated to \ 125 CPU ${NEW_CPU}" 126 127sleep 2 128 129tst_exit 130