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