CPU scaling
The cpuscaling test exercises CPUs at varying frequencies using different scaling governors. You can run this test to verify that your system properly transitions between clock speeds and maintains performance during standardized workloads.
- What the test covers
- The cpuscaling test examines a CPU’s ability to increase and decrease its clock speed. The change responds to the compute demands placed on the system.
- RHEL version supported
-
- RHEL 8
- RHEL 9
- RHEL 10
- What the test does
-
The test exercises the CPUs at varying frequencies using different scaling governors. A scaling governor is a set of instructions that tells the CPU when to change clock speed. It also determines how fast the CPU makes that change. The test then measures the difference in time needed to complete a standardized workload. The test is scheduled when the hardware detection routines find the following directories in /sys containing more than one CPU frequency:
/sys/devices/system/cpu/cpuX/cpufreqThe cpuscaling test is planned once per package, rather than being listed once per logical CPU. When the test runs, it determines topology through
/sys/devices/system/cpu/cpuX/topology/physical_package_id. It then runs the test in parallel for all the logical CPUs in a particular package.The test runs the turbostat command first to gather the processor statistics. On supported architectures, turbostat checks if the advanced statistics columns are visible in the output file. It returns a warning if the file does not contain the columns. The test then attempts to run the cstate subtest and if it fails, runs pstate subtest. The test procedure for each CPU package is as follows.
The test uses the values found in the sysfs filesystem to determine the maximum and minimum CPU frequencies. You can see these values for any system with this command.
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequenciesThere are always at least two frequencies displayed, a maximum and a minimum. Some processors can perform finer CPU speed control and show more than two values in the file. The test does not specifically use any additional CPU speeds between the max and min.
The CPU may still use them while transitioning between max and min frequencies. The test procedure is as follows:
- The test records the maximum and minimum processor speeds from the file
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies. - The userspace governor is selected and maximum frequency is chosen.
- Maximum speed is confirmed by reading all processors'
/sys/devices/system/cpu/cpuX/cpufreq/scaling_cur_freqvalue. If this value does not match the selected frequency, the test reports a failure. - Every processor in the package is given the simultaneous task of calculating pi to 2x10^12 digits. The value for the pi calculation was chosen because it takes a meaningful amount of time to complete (about 30 seconds).
- The amount of time it took to calculate pi is recorded for each CPU, and an average is calculated for the package.
- The userspace governor is selected and the minimum speed is set.
- Minimum speed is confirmed by sysfs data, with a failure occurring if any CPU is not at the requested speed.
- The same pi calculation is performed by every processor in the package and the results recorded.
- The ondemand governor is chosen, which throttles the CPU between minimum and maximum speeds depending on workload.
- Minimum speed is confirmed by sysfs data, with a failure occurring if any CPU is not at the requested speed.
- The same pi calculation is performed by every processor in the package and the results recorded.
- The performance governor is chosen, which forces the CPU to maximum speed at all times.
- Maximum speed is confirmed by sysfs data, with a failure occurring if any CPU is not at the requested speed.
- The same pi calculation is performed by every processor, and the results are recorded. Now the analysis is performed on the three subsections. In steps one through eight, we obtain the pi calculation times at maximum and minimum CPU speeds.
The difference in time to calculate pi at the two speeds should be proportional to the CPU speed difference. For example, assume a hypothetical test system has a max frequency of 2GHz and a min of 1GHz.
If the max-speed pi calculation takes 30 seconds, we would expect the min-speed calculation to take 60 seconds. Perfect results are rarely obtained for various reasons, so we allow a 10% margin of error, faster or slower than expected.
In our hypothetical example, the minimum-speed run could take between 54 and 66 seconds and still pass. This range equals 90% to 110% of the expected 60-second result.
In steps nine through eleven, we test the pi calculation time using the ondemand governor. This confirms that the system can quickly increase CPU speed to maximum when work begins. We compare the calculation time from step eleven to the maximum-speed time from step five. A passing test has those two values differing by no more than 10%.
In steps twelve through fourteen, we test the pi calculation using the performance governor. This confirms that the system can hold the CPU at maximum frequency at all times.
We compare the step 14 calculation time to the maximum-speed time from step five. Again, a passing test has those two values differing by no more than 10%. An additional portion of the cpuscaling test runs on Intel processors with the TurboBoost feature.
The test detects TurboBoost through the ida CPU flag in
/proc/cpuinfo. This test chooses one CPU in each package, omitting CPU0 for housekeeping purposes. It measures the performance using the ondemand governor at maximum speed. It expects a result at least 5% faster than the previous test. That previous test ran all the cores in the package in parallel.
- The test records the maximum and minimum processor speeds from the file
- Preparing for the test
- To prepare for the test, ensure that CPU frequency scaling is enabled in the BIOS. Also ensure that a CPU is installed that meets the requirements explained in the Policy Guide.
- Running the test
-
The cpuscaling test is non-interactive. Run the following command and then select the appropriate
CPU scalingtest name from the list that displays.rhcert-run - Run time
- The cpuscaling test takes about 42 minutes on a 2013-era, single CPU, 6-core/12-thread 3.3GHz Intel-based workstation. This workstation runs Red Hat Enterprise Linux 6.4, AMD64 and Intel 64. Systems with higher core counts and more populated sockets take longer to complete. The required supportable test adds about a minute to the overall run time.