Gentoo Archives: gentoo-user

From: Walter Dnes <waltdnes@××××××××.org>
To: Gentoo Users List <gentoo-user@l.g.o>
Subject: [gentoo-user] Questions about cpu frequency utils scripting
Date: Tue, 21 Apr 2015 01:05:32
1 It seems like many of the cpu speed/governor switcher utilities in
2 /usr/portage/sys-power don't work due to being too old. I cobbled
3 together a simple bash script (YES!) that sort of emulates the eselect
4 interface, and allows me to switch between
5 userspace/powersave/performance/ondemend/conservative governors. Root
6 permission is required, of course, to write to the /sys pseudo
7 filesystem. I want to add some basic error-checking and documentation
8 in the comments before releasing it in the wild.
10 The only thing I can't get working is setting specific speeds. I do
11 set the governor to "userspace" first. I can't think of any other
12 problem. Given that I can switch between performance and powersave and
13 ondemand/conservative, I'm not too worried about this, but I'd like to
14 know for completeness.
16 Another item I'm missing is wildcarding directories in bash. The
17 selected values are applied to the CPUs in a loop that goes like so...
19 for core in /sys/devices/system/cpu/cpu[0-9]/
20 do
21 echo "${governor[${choiceminus}]}" > ${core}cpufreq/scaling_governor
22 echo -n "CPU ${core:27:1} set to "
23 cat ${core}cpufreq/scaling_governor
24 done
26 That works fine for notebooks with say 8 cores. But what happens when
27 you hit 16 cores? I can't come up with one bash wildcard expression
28 that handles "/sys/devices/system/cpu/cpu[0-9]/" and
29 "/sys/devices/system/cpu/cpu[0-9][0-9]/" simultaneously. There's
30 probably an elegant solution right under my nose, but my Google-fu is
31 failing me right now. In a worst-case-scenario, I could have one loop
32 for "/sys/devices/system/cpu/cpu[0-9]/". Then test for the existance of
33 "/sys/devices/system/cpu/cpu10]/". If it exists, run a separate loop
34 for "/sys/devices/system/cpu/cpu[0-9][0-9]/". Ugly, but it would work.
36 --
37 Walter Dnes <waltdnes@××××××××.org>
38 I don't run "desktop environments"; I run useful applications


Subject Author
Re: [gentoo-user] Questions about cpu frequency utils scripting Emanuele Rusconi <emarsk@×××××.com>
Re: [gentoo-user] Questions about cpu frequency utils scripting Alec Ten Harmsel <alec@××××××××××××××.com>
Re: [gentoo-user] Questions about cpu frequency utils scripting Mike Gilbert <floppym@g.o>
[gentoo-user] A bash-based CPU governor/speed-control utility Walter Dnes <waltdnes@××××××××.org>