Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 453794 - sys-power/cpupower: init.d/conf.d files
Summary: sys-power/cpupower: init.d/conf.d files
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Samuli Suominen (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-24 10:49 UTC by Samuli Suominen (RETIRED)
Modified: 2014-01-01 08:25 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
cpupower rcscript (cpupower,679 bytes, text/plain)
2013-04-23 00:47 UTC, Khayyam
Details
/etc/conf.d/cpupower (cpupower,1007 bytes, text/plain)
2013-04-23 11:47 UTC, Khayyam
Details
/etc/conf.d/cpupower (cpupower,1013 bytes, text/plain)
2013-04-23 13:12 UTC, Khayyam
Details
patch for init.d (cpupower-initd.patch,1.30 KB, patch)
2013-04-24 13:37 UTC, Khayyam
Details | Diff
conf.d for cpupower (cpupower,1.58 KB, text/plain)
2013-04-24 13:38 UTC, Khayyam
Details
Patch to init script to ignore empty START/STOP_OPTS and skip nonexisting sysfs entry (cpupower.patch,1.25 KB, patch)
2013-09-27 15:00 UTC, Holger Hoffstätte
Details | Diff
Patch to init script to ignore empty START/STOP_OPTS and skip nonexisting sysfs entry (cpupower.patch,1.08 KB, patch)
2013-09-27 15:18 UTC, Holger Hoffstätte
Details | Diff
Patch to init script to skip nonexisting sysfs entry (cpupower.patch,720 bytes, patch)
2013-09-27 15:31 UTC, Holger Hoffstätte
Details | Diff
init.d-r3.diff (init.d-r3.diff,827 bytes, patch)
2013-10-21 17:05 UTC, Lars Wendler (Polynomial-C) (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Samuli Suominen (RETIRED) gentoo-dev 2013-01-24 10:49:54 UTC
...in order to be full replacement to other obsolete cpufreq packages in tree

looking at cpufrequtils/files/ for it's conf.d and init.d it should be rather easy to port those. The replacement for the commands used in cpufrequtils could be something like:

ebegin "Running cpupower frequency-set ${opts}"

... snip

for c in $(cpupower frequency-info | awk '$2 == "CPU" { print $3 }' | cut -c 1); 

... snip

cpupower frequency-set -c ${c} ${opts}
Comment 1 Khayyam 2013-04-23 00:46:21 UTC
(In reply to comment #0)

Samuli ...

> looking at cpufrequtils/files/ for it's conf.d and init.d it should be
> rather easy to port those. The replacement for the commands used in
> cpufrequtils could be something like:

> for c in $(cpupower frequency-info | awk '$2 == "CPU" { print $3 }' | cut -c
> 1);

That will also output the 'f' of 'frequency' as the line 'current' also has 'CPU' in the third field. Also, without a '-c cpulist' it defaults to '0' and so we'd only get '0' (and the stray 'f'). It would need to be more explicit:

cpupower -c all info |awk '{gsub(/:/,""); if ($2 == "CPU") print $3}'

or ...

cpupower -c all info |awk '/^analyzing.*/{gsub(/:/,""); print $3}'

... but really this isn't necessary, because we can use 'all' in the following and so don't need to collect the number of CPU's.

> cpupower frequency-set -c ${c} ${opts}

cpupower -c all frequency-set ${opts} >/dev/null 2>&1

The attatched rc works setting governer and EXTRA_OPTS (though I'm not sure what the policy is on rediecting stdout and stderr to /dev/null ... thats possible fround apon).

Still, there are a number of other features/options that might be worth adding, such as -u (maximum clock frequency) and -d (minimum clock frequency)
Comment 2 Khayyam 2013-04-23 00:47:27 UTC
Created attachment 346342 [details]
cpupower rcscript
Comment 3 Samuli Suominen (RETIRED) gentoo-dev 2013-04-23 01:49:17 UTC
Comment on attachment 346342 [details]
cpupower rcscript

Thanks. 

I've committed initial conf.d and init.d files (this attachement but only minorly cleaned up) to tree together with cpupower from final 3.8 release.

Trying to get more people onboard with this...
Comment 4 Khayyam 2013-04-23 11:46:27 UTC
(In reply to comment #3)

Samuli ...

> I've committed initial conf.d and init.d files (this attachement but only
> minorly cleaned up) to tree together with cpupower from final 3.8 release.

the conf.d from cpufrequtils had default governers for start/stop, and also had EXTRA_OPTS defined, the latter was commented but it does provide some idea of what values might be applied. As the rcscript also supports this it might be an idea to add something similar, I have:

SYSFS_EXTRA="ondemand/ignore_nice_load=1 ondemand/up_threshold=15 ondemand/sampling_down_factor=10"

It may also be good to add some description:

# up_threshold: threshold for stepping up frequency, where the value represents
# the percentage of cpu load. 
# down_threshold: threshold for stepping down frequency, where the value
# represents the percentage of cpu load.
# sampling_down_factor: determines how frequently the governor polls the cpu, a
# value greater than 1 improves performance by reducing the polling when the
# load it high. This tunable has no effect on behavior at lower CPU frequencies
# ignore_nice_load: when set to '1', the processes that are run with a 'nice'
# value will not count in the usage calculation.

The above up_threshold=15 will allow for idling at the lower frequencies but switching to a higher frequency should happen quickly, and so performance should be similar to running at a high frequency. I think the cpufrequtils conf.d had this set at 75, but I'm inclined to think a lower value would be a better default (your call).

Anyhow, attatched is a possible replacement.   
 
> Trying to get more people onboard with this...

I'll make somekind of post in the forum detailing the many ills of cpufreqd.

best ... khay
Comment 5 Khayyam 2013-04-23 11:47:52 UTC
Created attachment 346372 [details]
/etc/conf.d/cpupower
Comment 6 Samuli Suominen (RETIRED) gentoo-dev 2013-04-23 12:34:25 UTC
(In reply to comment #4)
> the conf.d from cpufrequtils had default governers for start/stop, and also
> had EXTRA_OPTS defined, the latter was commented but it does provide some
> idea of what values might be applied. As the rcscript also supports this it
> might be an idea to add something similar, I have:
> 
> SYSFS_EXTRA="ondemand/ignore_nice_load=1 ondemand/up_threshold=15
> ondemand/sampling_down_factor=10"

I wasn't sure if these values could be passed like that anymore... are you sure about the syntax?
Comment 7 Khayyam 2013-04-23 13:10:05 UTC
(In reply to comment #6)
> (In reply to comment #4)
> > SYSFS_EXTRA="ondemand/ignore_nice_load=1 ondemand/up_threshold=15
> > ondemand/sampling_down_factor=10"
> 
> I wasn't sure if these values could be passed like that anymore... are you
> sure about the syntax?

Yes, seems to work just as it did with cpufrequtils:

# cat /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
15
# cat /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
10
# cat /sys/devices/system/cpu/cpufreq/ondemand/ignore_nice_load
1

best ... khay
Comment 8 Khayyam 2013-04-23 13:12:36 UTC
Created attachment 346378 [details]
/etc/conf.d/cpupower

corrected some spelling and reorganised for better comprehension
Comment 9 Samuli Suominen (RETIRED) gentoo-dev 2013-04-24 09:44:29 UTC
(In reply to comment #7)
> Yes, seems to work just as it did with cpufrequtils:

OK, in Portage as =sys-power/cpupower-3.8-r1
Thanks again

Will still keep this open for a while so people find it easier and can post improvements here
Comment 10 Khayyam 2013-04-24 13:36:01 UTC
(In reply to comment #9)

Samuli ...

> Will still keep this open for a while so people find it easier and can post
> improvements here

ya, probably a good idea.

I'm attatching a patch for the rcscript that adds an -n test for '$opts', this way if the value is empty then the set is skipped. The reason for this is on a restart it doesn't make sense to set '-g performance' and then '-g ondemand' right after, with the test STOP_OPTS can be undefined and so the governer remain on START_OPT. If using ondemand then there is little reason to switch to performance (or some other governer) on shutdown, or when restarting the service.

I'm also attaching an updated conf.d with further information as to what can be set via *_OPTS, and removing the governer from STOP_OPTS. I've also raised the value for up_threshold in SYSFS_EXTRA (still commented), but I'm really not sure *what* value this might best be set to (perhaps the "75" as defined by cpufrequtils is a better default ... 95% being the value set by ondemand if nothing it provided).

Sorry to have all these minor changes come in such quick succession hopefully you see them an improvement rather than an annoyance.

best ... khay
Comment 11 Khayyam 2013-04-24 13:37:17 UTC
Created attachment 346468 [details, diff]
patch for init.d
Comment 12 Khayyam 2013-04-24 13:38:21 UTC
Created attachment 346470 [details]
conf.d for cpupower
Comment 13 hcaulfield57 2013-04-24 21:51:16 UTC
When I emerge sys-power/cpupower-3.8_rc4, it's not pulling in the conf.d or init.d files.
Comment 14 Samuli Suominen (RETIRED) gentoo-dev 2013-04-24 21:56:45 UTC
(In reply to comment #13)
> When I emerge sys-power/cpupower-3.8_rc4, it's not pulling in the conf.d or
> init.d files.

3.8_rc4 is not in portage anymore, time to emerge --sync
Comment 15 Jason Mours 2013-04-29 22:33:05 UTC
sys-power/cpupower-3.8-r1 :

I'm getting:

 /etc/init.d/cpupower : line 22 : ${o} : ambiguous redirect

:on boot, not having any problems setting frequency.
Comment 16 Samuli Suominen (RETIRED) gentoo-dev 2013-09-27 11:31:56 UTC
Comment on attachment 346468 [details, diff]
patch for init.d

In portage.
Comment 17 Samuli Suominen (RETIRED) gentoo-dev 2013-09-27 11:32:13 UTC
Comment on attachment 346470 [details]
conf.d for cpupower

In Portage.
Comment 18 Holger Hoffstätte 2013-09-27 13:23:38 UTC
I've been using the new Intel PState driver (CONFIG_X86_INTEL_PSTATE) with great success for a while now (it can be run in performance mode without the impact of the ondemand governor, even with tuning) and the init script fails for me:

root>/etc/init.d/cpupower start 
 * Running cpupower -c all frequency-set --governor ondemand ...                                                  [ !! ]
 * Setting extra options: 
/etc/init.d/cpupower: line 18: cd: /sys/devices/system/cpu/cpufreq: No such file or directory                     [ !! ]
 * ERROR: cpupower failed to start
root>ll /sys/devices/system/cpu 
total 0
drwxr-xr-x 8 root root    0 Sep 27 13:05 cpu0/
drwxr-xr-x 8 root root    0 Sep 27 13:05 cpu1/
drwxr-xr-x 8 root root    0 Sep 27 13:05 cpu2/
drwxr-xr-x 8 root root    0 Sep 27 13:05 cpu3/
drwxr-xr-x 2 root root    0 Sep 27 15:11 cpuidle/
drwxr-xr-x 2 root root    0 Sep 27 15:17 intel_pstate/
-r--r--r-- 1 root root 4.0K Sep 27 15:17 kernel_max
-r--r--r-- 1 root root 4.0K Sep 27 15:17 modalias
-r--r--r-- 1 root root 4.0K Sep 27 15:17 offline
-r--r--r-- 1 root root 4.0K Sep 27 13:03 online
-r--r--r-- 1 root root 4.0K Sep 27 15:17 possible
drwxr-xr-x 2 root root    0 Sep 27 15:17 power/
-r--r--r-- 1 root root 4.0K Sep 27 15:17 present
--w------- 1 root root 4.0K Sep 27 15:17 probe
--w------- 1 root root 4.0K Sep 27 15:17 release
-rw-r--r-- 1 root root 4.0K Sep 27 15:17 uevent
root>

What would be the best way to check whether the SYSFS_EXTRA options can be applied? Checking for the cpufreq sysfs entry?
Comment 19 Holger Hoffstätte 2013-09-27 15:00:42 UTC
Created attachment 359620 [details, diff]
Patch to init script to ignore empty START/STOP_OPTS and skip nonexisting sysfs entry

This patch will ignore empty START/STOP_OPTS (by default STOP_OPTS is empty) and skip any attempt to set SYSFS_EXTRA when the Intel pstate driver is used.
These changes work for me, though the changes may not bethe best Shell coding style.
Comment 20 Holger Hoffstätte 2013-09-27 15:18:45 UTC
Created attachment 359622 [details, diff]
Patch to init script to ignore empty START/STOP_OPTS and skip nonexisting sysfs entry

Proper patch, previous was bungled and didn't apply.
Comment 21 Holger Hoffstätte 2013-09-27 15:31:47 UTC
Created attachment 359624 [details, diff]
Patch to init script to skip nonexisting sysfs entry

My diff-fu is weak today: patch to only fix the sysfs issue.
Comment 22 Samuli Suominen (RETIRED) gentoo-dev 2013-10-20 14:17:53 UTC
Comment on attachment 359624 [details, diff]
Patch to init script to skip nonexisting sysfs entry

In portage.
Comment 23 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2013-10-21 17:05:11 UTC
Created attachment 361548 [details, diff]
init.d-r3.diff

When I run cpupower init script I get the following error message:

# /etc/init.d/cpupower restart
 * Caching service dependencies ...                                       [ ok ]
 * Running cpupower -c all frequency-set --governor performance ...       [ ok ]
 * Running cpupower -c all frequency-set --governor ondemand ...          [ ok ]
 * Setting extra options: 
/lib64/rc/sh/runscript.sh: 25: /lib64/rc/sh/runscript.sh: cannot create : Directory nonexistent                                                           [ ok ]

This is due to the SYSFS_EXTRA variable in conf.d/cpupower being unset / commented out.

The attached patch fixes this problem.
Comment 24 Samuli Suominen (RETIRED) gentoo-dev 2013-12-25 11:44:31 UTC
Comment on attachment 361548 [details, diff]
init.d-r3.diff

In portage -- starting with cpupower-3.12
Comment 25 Pacho Ramos gentoo-dev 2013-12-30 10:53:58 UTC
What is blocking this from being closed (well, I just got another report for the old cpufreqd in "maintainer-needed" alias and wondered if pointing people to cpupower would be ok at this stage :/) 

Thanks!
Comment 26 Samuli Suominen (RETIRED) gentoo-dev 2014-01-01 08:25:33 UTC
(In reply to Pacho Ramos from comment #25)
> What is blocking this from being closed (well, I just got another report for
> the old cpufreqd in "maintainer-needed" alias and wondered if pointing
> people to cpupower would be ok at this stage :/) 
> 
> Thanks!

we kept this bug open because of the active work being done on the init and conf files
so the bug could easily be found

but I guess we can close it now.  the cpupower package is ready far as I'm concerned, can be stabilized too at will