18c2ecf20Sopenharmony_ciThis is cpufreq-bench, a microbenchmark for the cpufreq framework. 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ciPurpose 48c2ecf20Sopenharmony_ci======= 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ciWhat is this benchmark for: 78c2ecf20Sopenharmony_ci - Identify worst case performance loss when doing dynamic frequency 88c2ecf20Sopenharmony_ci scaling using Linux kernel governors 98c2ecf20Sopenharmony_ci - Identify average reaction time of a governor to CPU load changes 108c2ecf20Sopenharmony_ci - (Stress) Testing whether a cpufreq low level driver or governor works 118c2ecf20Sopenharmony_ci as expected 128c2ecf20Sopenharmony_ci - Identify cpufreq related performance regressions between kernels 138c2ecf20Sopenharmony_ci - Possibly Real time priority testing? -> what happens if there are 148c2ecf20Sopenharmony_ci processes with a higher prio than the governor's kernel thread 158c2ecf20Sopenharmony_ci - ... 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ciWhat this benchmark does *not* cover: 188c2ecf20Sopenharmony_ci - Power saving related regressions (In fact as better the performance 198c2ecf20Sopenharmony_ci throughput is, the worse the power savings will be, but the first should 208c2ecf20Sopenharmony_ci mostly count more...) 218c2ecf20Sopenharmony_ci - Real world (workloads) 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ciDescription 258c2ecf20Sopenharmony_ci=========== 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cicpufreq-bench helps to test the condition of a given cpufreq governor. 288c2ecf20Sopenharmony_ciFor that purpose, it compares the performance governor to a configured 298c2ecf20Sopenharmony_cipowersave module. 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ciHow it works 338c2ecf20Sopenharmony_ci============ 348c2ecf20Sopenharmony_ciYou can specify load (100% CPU load) and sleep (0% CPU load) times in us which 358c2ecf20Sopenharmony_ciwill be run X time in a row (cycles): 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci sleep=25000 388c2ecf20Sopenharmony_ci load=25000 398c2ecf20Sopenharmony_ci cycles=20 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ciThis part of the configuration file will create 25ms load/sleep turns, 428c2ecf20Sopenharmony_cirepeated 20 times. 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ciAdding this: 458c2ecf20Sopenharmony_ci sleep_step=25000 468c2ecf20Sopenharmony_ci load_step=25000 478c2ecf20Sopenharmony_ci rounds=5 488c2ecf20Sopenharmony_ciWill increase load and sleep time by 25ms 5 times. 498c2ecf20Sopenharmony_ciTogether you get following test: 508c2ecf20Sopenharmony_ci25ms load/sleep time repeated 20 times (cycles). 518c2ecf20Sopenharmony_ci50ms load/sleep time repeated 20 times (cycles). 528c2ecf20Sopenharmony_ci.. 538c2ecf20Sopenharmony_ci100ms load/sleep time repeated 20 times (cycles). 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ciFirst it is calibrated how long a specific CPU intensive calculation 568c2ecf20Sopenharmony_citakes on this machine and needs to be run in a loop using the performance 578c2ecf20Sopenharmony_cigovernor. 588c2ecf20Sopenharmony_ciThen the above test runs are processed using the performance governor 598c2ecf20Sopenharmony_ciand the governor to test. The time the calculation really needed 608c2ecf20Sopenharmony_ciwith the dynamic freq scaling governor is compared with the time needed 618c2ecf20Sopenharmony_cion full performance and you get the overall performance loss. 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ciExample of expected results with ondemand governor: 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ciThis shows expected results of the first two test run rounds from 678c2ecf20Sopenharmony_ciabove config, you there have: 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci100% CPU load (load) | 0 % CPU load (sleep) | round 708c2ecf20Sopenharmony_ci 25 ms | 25 ms | 1 718c2ecf20Sopenharmony_ci 50 ms | 50 ms | 2 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ciFor example if ondemand governor is configured to have a 50ms 748c2ecf20Sopenharmony_cisampling rate you get: 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ciIn round 1, ondemand should have rather static 50% load and probably 778c2ecf20Sopenharmony_ciwon't ever switch up (as long as up_threshold is above). 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ciIn round 2, if the ondemand sampling times exactly match the load/sleep 808c2ecf20Sopenharmony_citrigger of the cpufreq-bench, you will see no performance loss (compare with 818c2ecf20Sopenharmony_cibelow possible ondemand sample kick ins (1)): 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ciBut if ondemand always kicks in in the middle of the load sleep cycles, it 848c2ecf20Sopenharmony_ciwill always see 50% loads and you get worst performance impact never 858c2ecf20Sopenharmony_ciswitching up (compare with below possible ondemand sample kick ins (2)):: 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci 50 50 50 50ms ->time 888c2ecf20Sopenharmony_ciload -----| |-----| |-----| |-----| 898c2ecf20Sopenharmony_ci | | | | | | | 908c2ecf20Sopenharmony_cisleep |-----| |-----| |-----| |---- 918c2ecf20Sopenharmony_ci |-----|-----|-----|-----|-----|-----|-----|---- ondemand sampling (1) 928c2ecf20Sopenharmony_ci 100 0 100 0 100 0 100 load seen by ondemand(%) 938c2ecf20Sopenharmony_ci |-----|-----|-----|-----|-----|-----|-----|-- ondemand sampling (2) 948c2ecf20Sopenharmony_ci 50 50 50 50 50 50 50 load seen by ondemand(%) 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ciYou can easily test all kind of load/sleep times and check whether your 978c2ecf20Sopenharmony_cigovernor in average behaves as expected. 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ciToDo 1018c2ecf20Sopenharmony_ci==== 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ciProvide a gnuplot utility script for easy generation of plots to present 1048c2ecf20Sopenharmony_cithe outcome nicely. 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_cicpufreq-bench Command Usage 1088c2ecf20Sopenharmony_ci=========================== 1098c2ecf20Sopenharmony_ci-l, --load=<long int> initial load time in us 1108c2ecf20Sopenharmony_ci-s, --sleep=<long int> initial sleep time in us 1118c2ecf20Sopenharmony_ci-x, --load-step=<long int> time to be added to load time, in us 1128c2ecf20Sopenharmony_ci-y, --sleep-step=<long int> time to be added to sleep time, in us 1138c2ecf20Sopenharmony_ci-c, --cpu=<unsigned int> CPU Number to use, starting at 0 1148c2ecf20Sopenharmony_ci-p, --prio=<priority> scheduler priority, HIGH, LOW or DEFAULT 1158c2ecf20Sopenharmony_ci-g, --governor=<governor> cpufreq governor to test 1168c2ecf20Sopenharmony_ci-n, --cycles=<int> load/sleep cycles to get an average value to compare 1178c2ecf20Sopenharmony_ci-r, --rounds<int> load/sleep rounds 1188c2ecf20Sopenharmony_ci-f, --file=<configfile> config file to use 1198c2ecf20Sopenharmony_ci-o, --output=<dir> output dir, must exist 1208c2ecf20Sopenharmony_ci-v, --verbose verbose output on/off 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ciDue to the high priority, the application may not be responsible for some time. 1238c2ecf20Sopenharmony_ciAfter the benchmark, the logfile is saved in OUTPUTDIR/benchmark_TIMESTAMP.log 1248c2ecf20Sopenharmony_ci 125