~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/amd-pstate/gitsource.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/testing/selftests/amd-pstate/gitsource.sh (Version linux-6.12-rc7) and /tools/testing/selftests/amd-pstate/gitsource.sh (Version linux-4.11.12)


  1 #!/bin/bash                                       
  2 # SPDX-License-Identifier: GPL-2.0                
  3                                                   
  4 # Testing and monitor the cpu desire performan    
  5 # power consumption and throughput etc. when t    
  6 # gitsource test.                                 
  7 # 1) Download and tar gitsource codes.            
  8 # 2) Run gitsource benchmark on specific gover    
  9 # 3) Run tbench benchmark comparative test on     
 10 # 4) Get desire performance, frequency, load b    
 11 # 5) Get power consumption and throughput by a    
 12 # 6) Get run time by /usr/bin/time.               
 13 # 7) Analyse test results and save it in file     
 14 #8) Plot png images about time, energy and per    
 15                                                   
 16 # protect against multiple inclusion              
 17 if [ $FILE_GITSOURCE ]; then                      
 18         return 0                                  
 19 else                                              
 20         FILE_GITSOURCE=DONE                       
 21 fi                                                
 22                                                   
 23 git_name="git-2.15.1"                             
 24 git_tar="$git_name.tar.gz"                        
 25 gitsource_url="https://github.com/git/git/arch    
 26 gitsource_governors=("ondemand" "schedutil")      
 27                                                   
 28 # $1: governor, $2: round, $3: des-perf, $4: f    
 29 store_csv_gitsource()                             
 30 {                                                 
 31         echo "$1, $2, $3, $4, $5, $6, $7, $8"     
 32 }                                                 
 33                                                   
 34 # clear some special lines                        
 35 clear_csv_gitsource()                             
 36 {                                                 
 37         if [ -f $OUTFILE_GIT.csv ]; then          
 38                 sed -i '/Comprison(%)/d' $OUTF    
 39                 sed -i "/$(scaling_name)/d" $O    
 40         fi                                        
 41 }                                                 
 42                                                   
 43 # find string $1 in file csv and get the numbe    
 44 get_lines_csv_gitsource()                         
 45 {                                                 
 46         if [ -f $OUTFILE_GIT.csv ]; then          
 47                 return `grep -c "$1" $OUTFILE_    
 48         else                                      
 49                 return 0                          
 50         fi                                        
 51 }                                                 
 52                                                   
 53 pre_clear_gitsource()                             
 54 {                                                 
 55         post_clear_gitsource                      
 56         rm -rf gitsource_*.png                    
 57         clear_csv_gitsource                       
 58 }                                                 
 59                                                   
 60 post_clear_gitsource()                            
 61 {                                                 
 62         rm -rf results/tracer-gitsource*          
 63         rm -rf $OUTFILE_GIT*.log                  
 64         rm -rf $OUTFILE_GIT*.result               
 65 }                                                 
 66                                                   
 67 install_gitsource()                               
 68 {                                                 
 69         if [ ! -d $SCRIPTDIR/$git_name ]; then    
 70                 pushd $(pwd) > /dev/null 2>&1     
 71                 cd $SCRIPTDIR                     
 72                 printf "Download gitsource, pl    
 73                 wget -O $git_tar $gitsource_ur    
 74                                                   
 75                 printf "Tar gitsource ...\n\n"    
 76                 tar -xzf $git_tar                 
 77                 popd > /dev/null 2>&1             
 78         fi                                        
 79 }                                                 
 80                                                   
 81 # $1: governor, $2: loop                          
 82 run_gitsource()                                   
 83 {                                                 
 84         echo "Launching amd pstate tracer for     
 85         $TRACER -n tracer-gitsource-$1-$2 -i $    
 86                                                   
 87         printf "Make and test gitsource for $1    
 88         BACKUP_DIR=$(pwd)                         
 89         pushd $BACKUP_DIR > /dev/null 2>&1        
 90         cd $SCRIPTDIR/$git_name                   
 91         $PERF stat -a --per-socket -I 1000 -e     
 92         popd > /dev/null 2>&1                     
 93                                                   
 94         for job in `jobs -p`                      
 95         do                                        
 96                 echo "Waiting for job id $job"    
 97                 wait $job                         
 98         done                                      
 99 }                                                 
100                                                   
101 # $1: governor, $2: loop                          
102 parse_gitsource()                                 
103 {                                                 
104         awk '{print $5}' results/tracer-gitsou    
105         avg_des_perf=$(awk 'BEGIN {i=0; sum=0}    
106         printf "Gitsource-$1-#$2 avg des perf:    
107                                                   
108         awk '{print $7}' results/tracer-gitsou    
109         avg_freq=$(awk 'BEGIN {i=0; sum=0};{i+    
110         printf "Gitsource-$1-#$2 avg freq: $av    
111                                                   
112         awk '{print $11}' results/tracer-gitso    
113         avg_load=$(awk 'BEGIN {i=0; sum=0};{i+    
114         printf "Gitsource-$1-#$2 avg load: $av    
115                                                   
116         grep user $OUTFILE_GIT.time-gitsource-    
117         time_sum=$(awk 'BEGIN {sum=0};{sum +=     
118         printf "Gitsource-$1-#$2 user time(s):    
119                                                   
120         grep Joules $OUTFILE_GIT-perf-$1-$2.lo    
121         en_sum=$(awk 'BEGIN {sum=0};{sum += $1    
122         printf "Gitsource-$1-#$2 power consump    
123                                                   
124         # Permance is the number of run gitsou    
125         # seconds. It is well known that P=E/t    
126         # and t is time measured in seconds(s)    
127         #        1/t     1/t     1                
128         #       ----- = ----- = ---               
129         #         P      E/t     E                
130         # with unit given by 1 per joule.         
131         ppw=`echo "scale=9;1/$en_sum" | bc | a    
132         printf "Gitsource-$1-#$2 performance p    
133         printf "\n" | tee -a $OUTFILE_GIT.resu    
134                                                   
135         driver_name=`echo $(scaling_name)`        
136         store_csv_gitsource "$driver_name-$1"     
137 }                                                 
138                                                   
139 # $1: governor                                    
140 loop_gitsource()                                  
141 {                                                 
142         printf "\nGitsource total test times i    
143         for i in `seq 1 $LOOP_TIMES`              
144         do                                        
145                 run_gitsource $1 $i               
146                 parse_gitsource $1 $i             
147         done                                      
148 }                                                 
149                                                   
150 # $1: governor                                    
151 gather_gitsource()                                
152 {                                                 
153         printf "Gitsource test result for $1 (    
154         printf "\n----------------------------    
155                                                   
156         grep "Gitsource-$1-#" $OUTFILE_GIT.res    
157         avg_des_perf=$(awk 'BEGIN {sum=0};{sum    
158         printf "Gitsource-$1 avg des perf: $av    
159                                                   
160         grep "Gitsource-$1-#" $OUTFILE_GIT.res    
161         avg_freq=$(awk 'BEGIN {sum=0};{sum +=     
162         printf "Gitsource-$1 avg freq: $avg_fr    
163                                                   
164         grep "Gitsource-$1-#" $OUTFILE_GIT.res    
165         avg_load=$(awk 'BEGIN {sum=0};{sum +=     
166         printf "Gitsource-$1 avg load: $avg_lo    
167                                                   
168         grep "Gitsource-$1-#" $OUTFILE_GIT.res    
169         time_sum=$(awk 'BEGIN {sum=0};{sum +=     
170         printf "Gitsource-$1 total user time(s    
171                                                   
172         avg_time=$(awk 'BEGIN {sum=0};{sum +=     
173         printf "Gitsource-$1 avg user times(s)    
174                                                   
175         grep "Gitsource-$1-#" $OUTFILE_GIT.res    
176         en_sum=$(awk 'BEGIN {sum=0};{sum += $1    
177         printf "Gitsource-$1 total power consu    
178                                                   
179         avg_en=$(awk 'BEGIN {sum=0};{sum += $1    
180         printf "Gitsource-$1 avg power consump    
181                                                   
182         # Permance is the number of run gitsou    
183         # seconds. It is well known that P=E/t    
184         # and t is time measured in seconds(s)    
185         #        1/t     1/t     1                
186         #       ----- = ----- = ---               
187         #         P      E/t     E                
188         # with unit given by 1 per joule.         
189         ppw=`echo "scale=9;1/$avg_en" | bc | a    
190         printf "Gitsource-$1 performance per w    
191         printf "\n" | tee -a $OUTFILE_GIT.resu    
192                                                   
193         driver_name=`echo $(scaling_name)`        
194         store_csv_gitsource "$driver_name-$1"     
195 }                                                 
196                                                   
197 # $1: base scaling_driver $2: base governor $3    
198 __calc_comp_gitsource()                           
199 {                                                 
200         base=`grep "$1-$2" $OUTFILE_GIT.csv |     
201         comp=`grep "$3-$4" $OUTFILE_GIT.csv |     
202                                                   
203         if [ -n "$base" -a -n "$comp" ]; then     
204                 printf "\n====================    
205                 printf "Gitsource comparison $    
206                 printf "\n====================    
207                                                   
208                 # get the base values             
209                 des_perf_base=`echo "$base" |     
210                 freq_base=`echo "$base" | awk     
211                 load_base=`echo "$base" | awk     
212                 time_base=`echo "$base" | awk     
213                 energy_base=`echo "$base" | aw    
214                 ppw_base=`echo "$base" | awk '    
215                                                   
216                 # get the comparison values       
217                 des_perf_comp=`echo "$comp" |     
218                 freq_comp=`echo "$comp" | awk     
219                 load_comp=`echo "$comp" | awk     
220                 time_comp=`echo "$comp" | awk     
221                 energy_comp=`echo "$comp" | aw    
222                 ppw_comp=`echo "$comp" | awk '    
223                                                   
224                 # compare the base and comp va    
225                 des_perf_drop=`echo "scale=4;(    
226                 printf "Gitsource-$1 des perf     
227                                                   
228                 freq_drop=`echo "scale=4;($fre    
229                 printf "Gitsource-$1 freq base    
230                                                   
231                 load_drop=`echo "scale=4;($loa    
232                 printf "Gitsource-$1 load base    
233                                                   
234                 time_drop=`echo "scale=4;($tim    
235                 printf "Gitsource-$1 time base    
236                                                   
237                 energy_drop=`echo "scale=4;($e    
238                 printf "Gitsource-$1 energy ba    
239                                                   
240                 ppw_drop=`echo "scale=4;($ppw_    
241                 printf "Gitsource-$1 performan    
242                 printf "\n" | tee -a $OUTFILE_    
243                                                   
244                 store_csv_gitsource "$1-$2 VS     
245         fi                                        
246 }                                                 
247                                                   
248 # calculate the comparison(%)                     
249 calc_comp_gitsource()                             
250 {                                                 
251         # acpi-cpufreq-ondemand VS acpi-cpufre    
252         __calc_comp_gitsource ${all_scaling_na    
253                                                   
254         # amd-pstate-ondemand VS amd-pstate-sc    
255         __calc_comp_gitsource ${all_scaling_na    
256                                                   
257         # acpi-cpufreq-ondemand VS amd-pstate-    
258         __calc_comp_gitsource ${all_scaling_na    
259                                                   
260         # acpi-cpufreq-schedutil VS amd-pstate    
261         __calc_comp_gitsource ${all_scaling_na    
262 }                                                 
263                                                   
264 # $1: file_name, $2: title, $3: ylable, $4: co    
265 plot_png_gitsource()                              
266 {                                                 
267         # all_scaling_names[1] all_scaling_nam    
268         #    amd-pstate           acpi-cpufreq    
269         #         N                   N           
270         #         N                   Y           
271         #         Y                   N           
272         #         Y                   Y           
273         ret=`grep -c "${all_scaling_names[1]}"    
274         if [ $ret -eq 0 ]; then                   
275                 ret=`grep -c "${all_scaling_na    
276                 if [ $ret -eq 0 ]; then           
277                         flag=0                    
278                 else                              
279                         flag=1                    
280                 fi                                
281         else                                      
282                 ret=`grep -c "${all_scaling_na    
283                 if [ $ret -eq 0 ]; then           
284                         flag=2                    
285                 else                              
286                         flag=3                    
287                 fi                                
288         fi                                        
289                                                   
290         gnuplot << EOF                            
291                 set term png                      
292                 set output "$1"                   
293                                                   
294                 set title "$2"                    
295                 set xlabel "Test Cycles (round    
296                 set ylabel "$3"                   
297                                                   
298                 set grid                          
299                 set style data histogram          
300                 set style fill solid 0.5 borde    
301                 set boxwidth 0.8                  
302                                                   
303                 if ($flag == 1) {                 
304                         plot \                    
305                         "<(sed -n -e 's/,//g'     
306                         "<(sed -n -e 's/,//g'     
307                 } else {                          
308                         if ($flag == 2) {         
309                                 plot \            
310                                 "<(sed -n -e '    
311                                 "<(sed -n -e '    
312                         } else {                  
313                                 if ($flag == 3    
314                                         plot \    
315                                         "<(sed    
316                                         "<(sed    
317                                         "<(sed    
318                                         "<(sed    
319                                 }                 
320                         }                         
321                 }                                 
322                 quit                              
323 EOF                                               
324 }                                                 
325                                                   
326 amd_pstate_gitsource()                            
327 {                                                 
328         printf "\n----------------------------    
329         printf "*** Running gitsource             
330         printf "\n----------------------------    
331                                                   
332         pre_clear_gitsource                       
333                                                   
334         install_gitsource                         
335                                                   
336         get_lines_csv_gitsource "Governor"        
337         if [ $? -eq 0 ]; then                     
338                 # add titles and unit for csv     
339                 store_csv_gitsource "Governor"    
340                 store_csv_gitsource "Unit" ""     
341         fi                                        
342                                                   
343         backup_governor                           
344         for governor in ${gitsource_governors[    
345                 printf "\nSpecified governor i    
346                 switch_governor $governor         
347                 loop_gitsource $governor          
348                 gather_gitsource $governor        
349         done                                      
350         restore_governor                          
351                                                   
352         plot_png_gitsource "gitsource_time.png    
353         plot_png_gitsource "gitsource_energy.p    
354         plot_png_gitsource "gitsource_ppw.png"    
355                                                   
356         calc_comp_gitsource                       
357                                                   
358         post_clear_gitsource                      
359 }                                                 
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php