@@ -85,6 +85,7 @@ static void proc_cpufreq_output(void)
}
static int no_rounding;
+static int freq_info_truncated;
static void print_speed(unsigned long speed)
{
unsigned long tmp;
@@ -103,8 +104,10 @@ static void print_speed(unsigned long speed)
} else {
if (speed > 1000000) {
tmp = speed%10000;
- if (tmp >= 5000)
+ if (tmp >= 5000) {
+ freq_info_truncated = 1;
speed += 10000;
+ }
printf("%u.%02u GHz", ((unsigned int) speed/1000000),
((unsigned int) (speed%1000000)/10000));
} else if (speed > 100000) {
@@ -243,6 +246,7 @@ static int get_boost_mode(unsigned int cpu)
printf(_(" %.0f MHz max turbo 1 active cores\n"),
ratio * bclk);
}
+
return 0;
}
@@ -641,5 +645,12 @@ int cmd_freq_info(int argc, char **argv)
return ret;
printf("\n");
}
+
+ if (freq_info_truncated) {
+ printf(" Warning! Frequency values shown are rounded off\n");
+ printf(" To set frequency use frequency values provided\n");
+ printf(" by \"cpupower frequency-info -n \"\n");
+ }
+
return ret;
}
frequency-info currently rounds the frequnecy values to 2 decimal places while printing "available frequency steps". Hence frequencies with 3rd decimal place being greater than 5 will be rounded to next higher number like 2.227GHz will be rounded to 2.23Ghz. On setting this frequency, using "cpupower frequency-set -f <freq>" ,if the value does not match, then it will set to the next lowest frequency greater than provided frequency value (according to the userspace governor). Hence adding a warning if there are any cases where the displayed frequency cannot be used directly to set a perticular frequency, and insist the user to use the "-n" option. Simple usecase where it give counter intuitive results : bash# cpupower frequency-info ... available frequency steps: 2.43 GHz, 2.39 GHz, 2.36 GHz, 2.33 GHz, 2.29 GHz, 2.26 GHz, 2.23 GHz, 2.19 GHz, 2.16 GHz, 2.13 GHz bash# cpupower frequency-info -n ... available frequency steps: 2.427000 GHz, 2.394000 GHz, 2.360000 GHz, 2.327000 GHz, 2.294000 GHz, 2.261000 GHz, 2.227000 GHz, 2.194000 GHz, 2.161000 GHz, 2.128000 GHz bash# cpupower frequency-set -f 2.23Ghz bash# cpupower frequency-info ... current CPU frequency: 2.26 GHz (asserted by call to hardware) Signed-off-by: Akshay Adiga <akshay.adiga@linux.vnet.ibm.com> --- tools/power/cpupower/utils/cpufreq-info.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)