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. |
9 |
|
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. |
15 |
|
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... |
18 |
|
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 |
25 |
|
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. |
35 |
|
36 |
-- |
37 |
Walter Dnes <waltdnes@××××××××.org> |
38 |
I don't run "desktop environments"; I run useful applications |