Bug 42671

Summary: cpufreq userspace governor doesn't work on Intel Core 2 Gen 2 CPUs (NOTABUG - don't trust i7z)
Product: Power Management Reporter: Artem S. Tashkinov (aros)
Component: cpufreqAssignee: Rafael J. Wysocki (rjw)
Status: CLOSED INVALID    
Severity: normal CC: alan, lenb, lv.zheng
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: All known Subsystem:
Regression: No Bisected commit-id:
Attachments: /proc/cpuinfo

Description Artem S. Tashkinov 2012-01-27 19:43:49 UTC
On my Intel Core i5 2500 CPU with acpi-cpufreq module loaded I do this

# echo 2000000 | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_setspeed

then

# cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
2000000
2000000
2000000
2000000

so theoretically it should work.

However i7z (http://code.google.com/p/i7z/) shows that CPU frequency is freely floating and turbo boost gets enabled as soon as I have any discernible load, in other words userspace CPU frequency driver doesn't work at all and it doesn't really enforce the specified CPU frequency.
Comment 1 Len Brown 2012-01-31 02:58:30 UTC
are you sure that you are using the userspace governor?
few people do, as it is generally obsolted by ondemand.

When ondemand is running, scaling_setspeed does nothing,
and you can "manually" control what ondemand does by
setting its maximum and minimum frequencies.

Please show the output from
grep .  /sys/devices/system/cpu/cpu0/cpufreq/*
Comment 2 Artem S. Tashkinov 2012-01-31 06:57:41 UTC
(In reply to comment #1)
> are you sure that you are using the userspace governor?
> few people do, as it is generally obsolted by ondemand.
> 
> When ondemand is running, scaling_setspeed does nothing,
> and you can "manually" control what ondemand does by
> setting its maximum and minimum frequencies.
> 
> Please show the output from
> grep .  /sys/devices/system/cpu/cpu0/cpufreq/*

/sys/devices/system/cpu/cpu0/cpufreq/affected_cpus:0
/sys/devices/system/cpu/cpu0/cpufreq/bios_limit:3301000
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq:3301000
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq:3301000
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq:1600000
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_transition_latency:10000
/sys/devices/system/cpu/cpu0/cpufreq/related_cpus:0 1 2 3
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies:3301000 3300000 3200000 3100000 3000000 2900000 2800000 2700000 2600000 2500000 2400000 2300000 2200000 2100000 2000000 1600000
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors:ondemand powersave userspace conservative performance
/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq:2000000
/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver:acpi-cpufreq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor:userspace
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq:3301000
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq:1600000
/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed:2000000
Comment 3 Artem S. Tashkinov 2012-02-07 09:14:56 UTC
Is there any other information I can provide to help resolve this bug, Len?
Comment 4 Lv Zheng 2012-07-11 08:11:58 UTC
Hi, could you please offer the cpu information by executing "cat /proc/cpuinfo"?

Please take a look at the "flags" column, is there "constant_tsc" flag listed for your CPU?
Comment 5 Artem S. Tashkinov 2012-07-11 08:27:51 UTC
Created attachment 75211 [details]
/proc/cpuinfo

(In reply to comment #4)
> Hi, could you please offer the cpu information by executing "cat
> /proc/cpuinfo"?
> 
> Please take a look at the "flags" column, is there "constant_tsc" flag listed
> for your CPU?

This flag is present.
Comment 6 Lv Zheng 2012-07-11 08:57:20 UTC
I obtained the i7z code and found it's estimation of HZ is based on the TSC.  This is not correct for invariant TSC platforms.

You can also measure current cpufreq using turbostat.
Please find this tool in the kernel source tree:
tools/power/x86/turbostat
The recent turbostat will exit failure on invariant TSC platforms.

So it's not a bug of the cpufreq but of the i7z.
Comment 7 Artem S. Tashkinov 2012-07-11 11:28:55 UTC
(In reply to comment #6)
> I obtained the i7z code and found it's estimation of HZ is based on the TSC. 
> This is not correct for invariant TSC platforms.
> 
> You can also measure current cpufreq using turbostat.
> Please find this tool in the kernel source tree:
> tools/power/x86/turbostat
> The recent turbostat will exit failure on invariant TSC platforms.
> 
> So it's not a bug of the cpufreq but of the i7z.

You seem to be right:

# ./turbostat

Under load:
cor CPU    %c0  GHz  TSC    %c1    %c3    %c6    %c7   %pc2   %pc3   %pc6   %pc7
         94.46 2.00 3.30   0.09   0.01   5.44   0.00   0.77   0.01   1.52   0.00
  0   0  93.58 2.00 3.30   0.03   0.00   6.39   0.00   0.77   0.01   1.52   0.00
  1   1  92.91 2.00 3.30   0.20   0.03   6.85   0.00   0.77   0.01   1.52   0.00
  2   2  97.29 2.00 3.30   0.09   0.01   2.62   0.00   0.77   0.01   1.52   0.00
  3   3  94.06 2.00 3.30   0.04   0.01   5.89   0.00   0.77   0.01   1.52   0.00

No load:
cor CPU    %c0  GHz  TSC    %c1    %c3    %c6    %c7   %pc2   %pc3   %pc6   %pc7
          2.75 1.94 3.30   1.07   0.11  96.07   0.00  27.12   0.15  58.31   0.00
  0   0   1.85 1.97 3.30   0.70   0.04  97.41   0.00  27.12   0.15  58.31   0.00
  1   1   4.84 1.91 3.30   1.96   0.15  93.04   0.00  27.12   0.15  58.31   0.00
  2   2   3.83 1.97 3.30   1.38   0.20  94.60   0.00  27.12   0.15  58.31   0.00
  3   3   0.47 1.93 3.30   0.25   0.04  99.24   0.00  27.12   0.15  58.31   0.00