cpuhotplug07.sh 2.4 KB

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