powertop.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* Re: [Powertop] cpu wiggle changes userspace governor settings
@ 2016-07-27  7:07 Thomas Ilsche
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Ilsche @ 2016-07-27  7:07 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 2148 bytes --]

Hi Joe,

seems the patch was already applied successfully:

https://github.com/fenrus75/powertop/commit/1636ce2c01d9bba024f2840f114b6c0554d05724

On 2016-07-26 19:27, Joe Konno wrote:
> Hi Thomas,
>
> I cannot apply your diff to either the v2.8 tag or master. Could you
> rebase it atop master and re-submit? Thanks!
>
> PS: I'll address the question about wiggle particulars separately.
> To be perfectly honest I have some digging to do. ^_^
>
> On Thu, 21 Jul 2016 12:13:17 +0200
> Thomas Ilsche <thomas.ilsche(a)tu-dresden.de> wrote:
>
>> Dear Powertop Team,
>>
>> I have noticed that 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.
>>
>> Please note that I don't really understand what you are trying to
>> achieve with the wiggle in the first place. It seems for instance
>> that this doesn't do anything if max_freq == min_freq.
>>
>> Best Regards,
>> Thomas Ilsche
>>
>

-- 
Dipl. Inf. Thomas Ilsche
Computer Scientist
Highly Adaptive Energy-Efficient Computing
CRC 912 HAEC: http://tu-dresden.de/sfb912
Technische Universität Dresden
Center for Information Services and High Performance Computing (ZIH)
01062 Dresden, Germany

Phone: +49 351 463-42168
Fax: +49 351 463-37773
E-Mail: thomas.ilsche(a)tu-dresden.de


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5132 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Powertop] cpu wiggle changes userspace governor settings
@ 2016-07-27 14:34 Joe Konno
  0 siblings, 0 replies; 7+ messages in thread
From: Joe Konno @ 2016-07-27 14:34 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 2072 bytes --]

On Wed, 27 Jul 2016 09:07:04 +0200
Thomas Ilsche <thomas.ilsche(a)tu-dresden.de> wrote:

> Hi Joe,
> 
> seems the patch was already applied successfully:
> 
> https://github.com/fenrus75/powertop/commit/1636ce2c01d9bba024f2840f114b6c0554d05724
> 

Hah! Sorry for the noise. Cheers, and thanks for the contribution!

> On 2016-07-26 19:27, Joe Konno wrote:
> > Hi Thomas,
> >
> > I cannot apply your diff to either the v2.8 tag or master. Could you
> > rebase it atop master and re-submit? Thanks!
> >
> > PS: I'll address the question about wiggle particulars separately.
> > To be perfectly honest I have some digging to do. ^_^
> >
> > On Thu, 21 Jul 2016 12:13:17 +0200
> > Thomas Ilsche <thomas.ilsche(a)tu-dresden.de> wrote:
> >  
> >> Dear Powertop Team,
> >>
> >> I have noticed that 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.
> >>
> >> Please note that I don't really understand what you are trying to
> >> achieve with the wiggle in the first place. It seems for instance
> >> that this doesn't do anything if max_freq == min_freq.
> >>
> >> Best Regards,
> >> Thomas Ilsche
> >>  
> >  
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Powertop] cpu wiggle changes userspace governor settings
@ 2016-07-27 13:04 Arjan van de Ven
  0 siblings, 0 replies; 7+ messages in thread
From: Arjan van de Ven @ 2016-07-27 13:04 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 706 bytes --]

On 7/27/2016 12:10 AM, Thomas Ilsche wrote:
> On 2016-07-26 20:20, Joe Konno wrote:
>>> >
>>> > Please note that I don't really understand what you are trying to
>>> > achieve with the wiggle in the first place. It seems for instance
>>> > that this doesn't do anything if max_freq == min_freq.
>> We need to force a perf event at the beginning of the sampling
>> period. That's the only way the code can determine the starting
>> frequency. There may be other/better ways to do this. Patches, input
>> always welcome.
>
> If the event is only used to get the frequency at the start, is there a reason why scaling_cur_freq is not used instead?
>
mostly scaling_cur_freq returns a lie ;-(



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Powertop] cpu wiggle changes userspace governor settings
@ 2016-07-27  7:10 Thomas Ilsche
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Ilsche @ 2016-07-27  7:10 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 960 bytes --]

On 2016-07-26 20:20, Joe Konno wrote:
>> >
>> > Please note that I don't really understand what you are trying to
>> > achieve with the wiggle in the first place. It seems for instance
>> > that this doesn't do anything if max_freq == min_freq.
> We need to force a perf event at the beginning of the sampling
> period. That's the only way the code can determine the starting
> frequency. There may be other/better ways to do this. Patches, input
> always welcome.

If the event is only used to get the frequency at the start, is there a reason why scaling_cur_freq is not used instead?


-- 
Dipl. Inf. Thomas Ilsche
Computer Scientist
Highly Adaptive Energy-Efficient Computing
CRC 912 HAEC: http://tu-dresden.de/sfb912
Technische Universität Dresden
Center for Information Services and High Performance Computing (ZIH)
01062 Dresden, Germany

Phone: +49 351 463-42168
Fax: +49 351 463-37773
E-Mail: thomas.ilsche(a)tu-dresden.de


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5132 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Powertop] cpu wiggle changes userspace governor settings
@ 2016-07-26 18:20 Joe Konno
  0 siblings, 0 replies; 7+ messages in thread
From: Joe Konno @ 2016-07-26 18:20 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1514 bytes --]

On Thu, 21 Jul 2016 12:13:17 +0200
Thomas Ilsche <thomas.ilsche(a)tu-dresden.de> wrote:

> Dear Powertop Team,
> 
> I have noticed that 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.
> 
> Please note that I don't really understand what you are trying to
> achieve with the wiggle in the first place. It seems for instance
> that this doesn't do anything if max_freq == min_freq.

We need to force a perf event at the beginning of the sampling
period. That's the only way the code can determine the starting
frequency. There may be other/better ways to do this. Patches, input
always welcome.

> 
> Best Regards,
> Thomas Ilsche
> 


[-- Attachment #2: attachment.sig --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Powertop] cpu wiggle changes userspace governor settings
@ 2016-07-26 17:27 Joe Konno
  0 siblings, 0 replies; 7+ messages in thread
From: Joe Konno @ 2016-07-26 17:27 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1551 bytes --]

Hi Thomas,

I cannot apply your diff to either the v2.8 tag or master. Could you
rebase it atop master and re-submit? Thanks!

PS: I'll address the question about wiggle particulars separately.
To be perfectly honest I have some digging to do. ^_^

On Thu, 21 Jul 2016 12:13:17 +0200
Thomas Ilsche <thomas.ilsche(a)tu-dresden.de> wrote:

> Dear Powertop Team,
> 
> I have noticed that 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.
> 
> Please note that I don't really understand what you are trying to
> achieve with the wiggle in the first place. It seems for instance
> that this doesn't do anything if max_freq == min_freq.
> 
> Best Regards,
> Thomas Ilsche
> 


[-- Attachment #2: attachment.sig --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Powertop] cpu wiggle changes userspace governor settings
@ 2016-07-21 10:13 Thomas Ilsche
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Ilsche @ 2016-07-21 10:13 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1122 bytes --]

Dear Powertop Team,

I have noticed that 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.

Please note that I don't really understand what you are trying to achieve with the wiggle in the first place. It seems for instance that this doesn't do anything if max_freq == min_freq.

Best Regards,
Thomas Ilsche


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: wiggle_frequency_userspace.patch --]
[-- Type: text/x-patch, Size: 1308 bytes --]

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)
 {


[-- Attachment #3: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5132 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-07-27 14:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-27  7:07 [Powertop] cpu wiggle changes userspace governor settings Thomas Ilsche
  -- strict thread matches above, loose matches on Subject: below --
2016-07-27 14:34 Joe Konno
2016-07-27 13:04 Arjan van de Ven
2016-07-27  7:10 Thomas Ilsche
2016-07-26 18:20 Joe Konno
2016-07-26 17:27 Joe Konno
2016-07-21 10:13 Thomas Ilsche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).