^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/bin/bash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) # Special test cases reported by people
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) # Testcase 1: Reported here: http://marc.info/?l=linux-pm&m=140618592709858&w=2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) # protect against multiple inclusion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) if [ $FILE_SPECIAL ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) return 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) FILE_SPECIAL=DONE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) source cpu.sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) source cpufreq.sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) source governor.sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) # Test 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) # $1: policy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) __simple_lockdep()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) # switch to ondemand
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) __switch_governor $1 "ondemand"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) # cat ondemand files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) local ondir=$(find_gov_directory $1 "ondemand")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) if [ -z $ondir ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) printf "${FUNCNAME[0]}Ondemand directory not created, quit"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) cat $ondir/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) # switch to conservative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) __switch_governor $1 "conservative"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) simple_lockdep()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) printf "** Test: Running ${FUNCNAME[0]} **\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) for_each_policy __simple_lockdep
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) # Test 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) # $1: policy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) __concurrent_lockdep()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) for i in `seq 0 100`; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) __simple_lockdep $1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) concurrent_lockdep()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) printf "** Test: Running ${FUNCNAME[0]} **\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) for_each_policy_concurrent __concurrent_lockdep
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) # Test 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) quick_shuffle()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) # this is called concurrently from governor_race
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) for I in `seq 1000`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) echo ondemand | sudo tee $CPUFREQROOT/policy*/scaling_governor &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) echo userspace | sudo tee $CPUFREQROOT/policy*/scaling_governor &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) governor_race()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) printf "** Test: Running ${FUNCNAME[0]} **\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) # run 8 concurrent instances
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) for I in `seq 8`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) quick_shuffle &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) # Test 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) # $1: cpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) hotplug_with_updates_cpu()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) local filepath="$CPUROOT/$1/cpufreq"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) # switch to ondemand
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) __switch_governor_for_cpu $1 "ondemand"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) for i in `seq 1 5000`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) reboot_cpu $1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) done &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) local freqs=$(cat $filepath/scaling_available_frequencies)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) local oldfreq=$(cat $filepath/scaling_min_freq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) for j in `seq 1 5000`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) # Set all frequencies one-by-one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) for freq in $freqs; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) echo $freq > $filepath/scaling_min_freq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) # restore old freq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) echo $oldfreq > $filepath/scaling_min_freq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) hotplug_with_updates()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) for_each_non_boot_cpu hotplug_with_updates_cpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }