Subject: Re: Status report: sysmon_cpufreq(9) + powerctl(8)
To: Iain Hibbert <plunky@rya-online.net>
From: Juan RP <juan@xtrarom.org>
List: tech-kern
Date: 10/01/2006 16:04:04
On Sun, 1 Oct 2006 09:52:42 +0100 (BST)
Iain Hibbert <plunky@rya-online.net> wrote:

> I think when you use _IOWR then you also must use _sendrecv_ (will
> look properly in a bit, but I think both ioctls you have are IOWR?)

Right... something is wrong on my system because Quentin has sent me
a LKM/userland test and it does not work, the code works fine for him.

Anyway until it's fixed I'm using _IOWR and sendrecv... it's enough to
continue the development.

I've made more progress... now it supports two dictionary types:
CPUFREQ_TYPE_LIST (for drivers like est/powernow/longrun) and
CPUFREQ_TYPE_PERCENTAGE (acpi_throttle, p4tcc).

powerctl can change the value for any supported driver:

[juan@nocturno][~]> modstat 
Type    Id   Offset Loadaddr Size Info     Rev Module Name
MISC      0       - cdd00000 0004 cdd00284   2 type_list2
MISC      1       - cdd01000 0004 cdd01234   2 type_percentage
[juan@nocturno][~]>

[juan@nocturno][~]> ./powerctl                    
(type_list2)
        current:        1867 MHz [1537 mV]
        frequencies:    800 1067 1333 1600 1867 (in MHz)
(type_percentage)
        current power:  100%
[juan@nocturno][~]>

(Of course, CPUFREQ_TYPE_PERCENTAGE values can only use a value
between 0 and 100 otherwise error).

[juan@nocturno][~]> ./powerctl -d type_percentage -f 50
(type_percentage) 100 -> 50
[juan@nocturno][~]>

[juan@nocturno][~]> ./powerctl -d type_percentage -f 200
powerctl: error: Invalid argument
[juan@nocturno][~]>

[juan@nocturno][~]> ./powerctl                      
(type_list2)
        current:        1867 MHz [1537 mV]
        frequencies:    800 1067 1333 1600 1867 (in MHz)
(type_percentage)
        current power:  50%
[juan@nocturno][~]>

Current XML structure with these drivers:

[juan@nocturno][~]> drvctl -p cpu0 
Properties for device `cpu0':
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0">
<dict>
        <key>type_list2</key>
        <dict>
                <key>current-frequency</key>
                <integer>0x74b</integer>
                <key>current-voltage</key>
                <integer>0x601</integer>
                <key>driver-type</key>
                <string>list</string>
                <key>list-of-frequencies</key>
                <array>
                        <integer>0x320</integer>
                        <integer>0x42b</integer>
                        <integer>0x535</integer>
                        <integer>0x640</integer>
                        <integer>0x74b</integer>
                </array>
        </dict>
        <key>type_percentage</key>
        <dict>
                <key>current-power-in-percentage</key>
                <integer>0x32</integer>
                <key>driver-type</key>
                <string>percentage</string>
        </dict>
</dict>
</plist>
[juan@nocturno][~]>

Now I need more comments for the last driver type, it's of type
CPUFREQ_TYPE_LOWHIGH (for drivers like piixpcib/ichlpcib) and
its XML structure is:

<key>piixpcib</key>
<dict>
	<key>available-states</key>
	<array>
		<integer>800</integer>
		<integer>1200</integer>
	</array>
	<key>current-state</key>
	<integer>800</key>
</dict>

I'm not sure if I should use integer objects rather than strings because
there will only be two values, low and high.

Any suggestion? more things to fix in the code?

http://www.xtrarom.org/~juan/sysmon_cpufreq/

Cheers.