162306a36Sopenharmony_ciThis is cpufreq-bench, a microbenchmark for the cpufreq framework. 262306a36Sopenharmony_ci 362306a36Sopenharmony_ciPurpose 462306a36Sopenharmony_ci======= 562306a36Sopenharmony_ci 662306a36Sopenharmony_ciWhat is this benchmark for: 762306a36Sopenharmony_ci - Identify worst case performance loss when doing dynamic frequency 862306a36Sopenharmony_ci scaling using Linux kernel governors 962306a36Sopenharmony_ci - Identify average reaction time of a governor to CPU load changes 1062306a36Sopenharmony_ci - (Stress) Testing whether a cpufreq low level driver or governor works 1162306a36Sopenharmony_ci as expected 1262306a36Sopenharmony_ci - Identify cpufreq related performance regressions between kernels 1362306a36Sopenharmony_ci - Possibly Real time priority testing? -> what happens if there are 1462306a36Sopenharmony_ci processes with a higher prio than the governor's kernel thread 1562306a36Sopenharmony_ci - ... 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ciWhat this benchmark does *not* cover: 1862306a36Sopenharmony_ci - Power saving related regressions (In fact as better the performance 1962306a36Sopenharmony_ci throughput is, the worse the power savings will be, but the first should 2062306a36Sopenharmony_ci mostly count more...) 2162306a36Sopenharmony_ci - Real world (workloads) 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ciDescription 2562306a36Sopenharmony_ci=========== 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_cicpufreq-bench helps to test the condition of a given cpufreq governor. 2862306a36Sopenharmony_ciFor that purpose, it compares the performance governor to a configured 2962306a36Sopenharmony_cipowersave module. 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ciHow it works 3362306a36Sopenharmony_ci============ 3462306a36Sopenharmony_ciYou can specify load (100% CPU load) and sleep (0% CPU load) times in us which 3562306a36Sopenharmony_ciwill be run X time in a row (cycles): 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci sleep=25000 3862306a36Sopenharmony_ci load=25000 3962306a36Sopenharmony_ci cycles=20 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ciThis part of the configuration file will create 25ms load/sleep turns, 4262306a36Sopenharmony_cirepeated 20 times. 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ciAdding this: 4562306a36Sopenharmony_ci sleep_step=25000 4662306a36Sopenharmony_ci load_step=25000 4762306a36Sopenharmony_ci rounds=5 4862306a36Sopenharmony_ciWill increase load and sleep time by 25ms 5 times. 4962306a36Sopenharmony_ciTogether you get following test: 5062306a36Sopenharmony_ci25ms load/sleep time repeated 20 times (cycles). 5162306a36Sopenharmony_ci50ms load/sleep time repeated 20 times (cycles). 5262306a36Sopenharmony_ci.. 5362306a36Sopenharmony_ci100ms load/sleep time repeated 20 times (cycles). 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ciFirst it is calibrated how long a specific CPU intensive calculation 5662306a36Sopenharmony_citakes on this machine and needs to be run in a loop using the performance 5762306a36Sopenharmony_cigovernor. 5862306a36Sopenharmony_ciThen the above test runs are processed using the performance governor 5962306a36Sopenharmony_ciand the governor to test. The time the calculation really needed 6062306a36Sopenharmony_ciwith the dynamic freq scaling governor is compared with the time needed 6162306a36Sopenharmony_cion full performance and you get the overall performance loss. 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ciExample of expected results with ondemand governor: 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ciThis shows expected results of the first two test run rounds from 6762306a36Sopenharmony_ciabove config, you there have: 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci100% CPU load (load) | 0 % CPU load (sleep) | round 7062306a36Sopenharmony_ci 25 ms | 25 ms | 1 7162306a36Sopenharmony_ci 50 ms | 50 ms | 2 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ciFor example if ondemand governor is configured to have a 50ms 7462306a36Sopenharmony_cisampling rate you get: 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ciIn round 1, ondemand should have rather static 50% load and probably 7762306a36Sopenharmony_ciwon't ever switch up (as long as up_threshold is above). 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ciIn round 2, if the ondemand sampling times exactly match the load/sleep 8062306a36Sopenharmony_citrigger of the cpufreq-bench, you will see no performance loss (compare with 8162306a36Sopenharmony_cibelow possible ondemand sample kick ins (1)): 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ciBut if ondemand always kicks in in the middle of the load sleep cycles, it 8462306a36Sopenharmony_ciwill always see 50% loads and you get worst performance impact never 8562306a36Sopenharmony_ciswitching up (compare with below possible ondemand sample kick ins (2)):: 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci 50 50 50 50ms ->time 8862306a36Sopenharmony_ciload -----| |-----| |-----| |-----| 8962306a36Sopenharmony_ci | | | | | | | 9062306a36Sopenharmony_cisleep |-----| |-----| |-----| |---- 9162306a36Sopenharmony_ci |-----|-----|-----|-----|-----|-----|-----|---- ondemand sampling (1) 9262306a36Sopenharmony_ci 100 0 100 0 100 0 100 load seen by ondemand(%) 9362306a36Sopenharmony_ci |-----|-----|-----|-----|-----|-----|-----|-- ondemand sampling (2) 9462306a36Sopenharmony_ci 50 50 50 50 50 50 50 load seen by ondemand(%) 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ciYou can easily test all kind of load/sleep times and check whether your 9762306a36Sopenharmony_cigovernor in average behaves as expected. 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ciToDo 10162306a36Sopenharmony_ci==== 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ciProvide a gnuplot utility script for easy generation of plots to present 10462306a36Sopenharmony_cithe outcome nicely. 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_cicpufreq-bench Command Usage 10862306a36Sopenharmony_ci=========================== 10962306a36Sopenharmony_ci-l, --load=<long int> initial load time in us 11062306a36Sopenharmony_ci-s, --sleep=<long int> initial sleep time in us 11162306a36Sopenharmony_ci-x, --load-step=<long int> time to be added to load time, in us 11262306a36Sopenharmony_ci-y, --sleep-step=<long int> time to be added to sleep time, in us 11362306a36Sopenharmony_ci-c, --cpu=<unsigned int> CPU Number to use, starting at 0 11462306a36Sopenharmony_ci-p, --prio=<priority> scheduler priority, HIGH, LOW or DEFAULT 11562306a36Sopenharmony_ci-g, --governor=<governor> cpufreq governor to test 11662306a36Sopenharmony_ci-n, --cycles=<int> load/sleep cycles to get an average value to compare 11762306a36Sopenharmony_ci-r, --rounds<int> load/sleep rounds 11862306a36Sopenharmony_ci-f, --file=<configfile> config file to use 11962306a36Sopenharmony_ci-o, --output=<dir> output dir, must exist 12062306a36Sopenharmony_ci-v, --verbose verbose output on/off 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ciDue to the high priority, the application may not be responsible for some time. 12362306a36Sopenharmony_ciAfter the benchmark, the logfile is saved in OUTPUTDIR/benchmark_TIMESTAMP.log 12462306a36Sopenharmony_ci 125