diff options
author | Thomas Ilsche <thomas.ilsche@tu-dresden.de> | 2016-07-21 16:40:54 -0700 |
---|---|---|
committer | Nivedita Swaminathan <nivedita.swaminathan@intel.com> | 2016-07-21 16:40:54 -0700 |
commit | 1636ce2c01d9bba024f2840f114b6c0554d05724 (patch) | |
tree | 9094c2f5247e8afebc1dfe34b4fbef7f055e6a3c | |
parent | bd8ca689fb90268dab1b35aa95d826614981d582 (diff) | |
download | powertop-2.0-1636ce2c01d9bba024f2840f114b6c0554d05724.tar.gz |
powertop changes the frequency set by the userspace governor to the minimum available frequency.
This is caused by abstract_cpu::wiggle that touches the {min,max}_freq. By doing so, it also narrows
down the scaling_setspeed setting within the min-max-range, but it is not reset upon restoring max_freq.
To illustrate what is happening behind the scenes:
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_{min,max,cur}_freq
1200000
2901000
2000000
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_{governor,setspeed}
userspace
2000000
$ echo 1200000 | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
1200000
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
1200000
(Tested with Linux 4.4.0-21 Ubuntu)
Attached is a patch that resets the setspeed value if it was set to a numeric value before the wiggle.
-rw-r--r-- | src/cpu/abstract_cpu.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/cpu/abstract_cpu.cpp b/src/cpu/abstract_cpu.cpp index f419dbf..bc32336 100644 --- a/src/cpu/abstract_cpu.cpp +++ b/src/cpu/abstract_cpu.cpp @@ -443,6 +443,7 @@ void abstract_cpu::wiggle(void) ifstream ifile; ofstream ofile; uint64_t minf,maxf; + uint64_t setspeed = 0; /* wiggle a CPU so that we have a record of it at the start and end of the perf trace */ @@ -456,6 +457,13 @@ void abstract_cpu::wiggle(void) ifile >> minf; ifile.close(); + /* In case of the userspace governor, remember the old setspeed setting, it will be affected by wiggle */ + snprintf(filename, sizeof(filename), "/sys/devices/system/cpu/cpu%i/cpufreq/scaling_setspeed", first_cpu); + ifile.open(filename, ios::in); + /* Note that non-userspace governors report "<unsupported>". In that case ifile will fail and setspeed remains 0 */ + ifile >> setspeed; + ifile.close(); + ofile.open(filename, ios::out); ofile << maxf; ofile.close(); @@ -470,6 +478,12 @@ void abstract_cpu::wiggle(void) ofile << maxf; ofile.close(); + if (setspeed != 0) { + snprintf(filename, sizeof(filename), "/sys/devices/system/cpu/cpu%i/cpufreq/scaling_setspeed", first_cpu); + ofile.open(filename, ios::out); + ofile << setspeed; + ofile.close(); + } } uint64_t abstract_cpu::total_pstate_time(void) { |