Linux : power saving on a desktop box and using a mobile cpu . ----------------------------------------------------- keywords : linux , a7v333 , athlon , mobile cpu , acpi , 'power saving' This is a long note on what I did in an attempt to reduce the power consumption on my own box . The conclusions are at the end if you want to get to that and skip the ramblings. Intro ----- This started out with an attempt to understand where my large electricity bill came from and what I could do about it. The house overall consumption is about 25kwh per day . I bought a power meter from maplin to try to determine where it was going . There are 5 computers in use in the house , - my own 'jackass' box {a7v333 mobo, athlon xp 1800 , 1GB ram , 2x ide drive , ati 9600 pro 256MB , + 17 inch ctx 1600x1200 monitor } in use ~15hr a day - rockhopper old box used to pull mail from my isp , fired up spasmodically (dont get much mail that is of interest) - my wifes box - a hp something , used occasionally - my sons box , similar spec to mine but now with a tft monitor , and on for maybe 14 hr / day - old laptop which was bought second hand for my wife with win98se which was replaced by the hp box, and now has deli linux installed with the intention of being a general scribbling and browsing box So main computer usage is my jackass box ( power = ~130w idle , plus 70w monitor ie total of ~200w idle ) and my sons box ( guess same for box + 17w for his 17 inch 1280x1024 tft monito) . so total computer usage 360 w/hr -> 5.4 kwh / day , so a sizeable proportion. So I decided to investigate what I could do on my box to reduce the power consumption .... I spend a lot of my day typing and thinking, some months I do a lot of compiling and debugging, but most of the time my computer is idling , so I was especially interested in reducing power when the computer was doing little. acpi ---- So I read up on acpi , with various howtos and an offical overview and of course the actual spec. The linux howto was very focused on howto compile acpi into your kernel , dated about 2004, and talked muchos about patching your 2.4 kernel . Most of the dev activity is in the 2.6 branch and so it seemed that simplest was to download the latest stable kernel 2.6.21 and configure and compile that, and assume that all stuff was in the kernel. There were (at least) two other howtos out there with a different focus. The official overview was interesting , and it spoke of states (G0 - working ,G1 - sleeping , G2 soft off, G3 mech off) , and of interaction between the OS and the machine (vs the bios for apm), and of the cpu states S0,S1 - standby , S3 - suspend , S4-hibernate and of throttling etc , but at the end of all the reading I felt extremely confused and could not seem to find exactly how or whether acpi would help me to save power on my desktop box . This was very frustrating . One of the howtos was strong on software suspend , talking about how to do it and what was needed , and mentioned the dangers of losing data with it. Software suspend or hardware suspend were not of interest for my normal usage , I take coffeee breaks and meal breaks and if I go out for a couple of hours I shut the box down, so I dont care about the suspend capability. What I wanted was the capability to reduce power whilst idle and the power consumption when idle was significantly lower than at full bore ie 100% cpu , 126w vs 150w . Apparently the linux idle loop uses the hlt instruction, which stops the processor until an interrupt and is quite successful at reducing power. on my system , cat /proc/acpi/processor/CPU0/info processor id: 0 acpi id: 0 bus mastering control: no power management: no throttling control: no limit interface: no the acpi4linux wiki says that need bus mastering control : yes to enable the cpu to go into sleep states and save power . So it looks like my old (or newer) processor cant do anything to save power . I am sure this is the case ... all the acpi stuff will do nothing for the power saving on my desktop system . mobile processor ---------------- I bought a second hand athlon mobile *socketA* 2000 processor { AXMH2000FQQ3C } from ebay for 25gbp (+p&p) to see what that would do for me. A search on the number turned up the frequency and Vcore settings that could be used. I also bought a cheap cooler from novatech to replace my zalman as I mistakenly thought that the heatsink was attached to the processor (is attached to the socket) . So it turned out I didnt need the new cooler , but this is so much quieter , I am glad I did. I installed the cpu and the cooler and booted it . I was surprised when it actually came up , but the bios detected it and set the clock to 400MHz , which I accepted to get the system up and running. Later I set the basic freq to 800MHz ... there wasnt much choice in the bios . So I thought it should be able to do 400MHz and 800MHz. The actual primary power saving item is the cpufreq stuff . This is a system developed by intel and amd , and the idea was to reduce the frequency and the voltage on the fly using (often) a table of cpu frequency and voltage constants , together with frequency , which should be supplied by the bios. Linux has a core cpufreq chunk of code /usr/src/linux/drivers/cpufreq with 'governors' /usr/src/linux/arch/i386/kernel/cpu/cpufreq with powernow-k7.c /usr/src/linux/Documentation/cpu-freq If the cpufreq code is compiled in, then the (frex) powernow-k7 can be compiled as a module and modprobe'd into the kernel. Then the governor is set - the ondemand is ok for a desktop box. The cpufreq calls the governor at a fixed sample rate (200ms on this sys) to check the load and call the driver with any changes to the frequency. To do the cpufreq capabilities, then need a PST table for the cpu, which *should* be supplied by the bios but most desktop ones dont. My bios did not supply a PST table , so upgraded the bios from 1017 to 1018 beta , which did not change this , but had problem getting to the bios at boot , so eventually reverted back to my original bios. There was also an option to use the cpu info , which also did not work. Finally, there was a copy of the powernow-k7.c with a create_fake_pst code chunk, which worked and I then changed the table values to get the full frequency , and also a low frequency. It uses a multiplier of the fsb (133MHz), and set it for 4x, 5x, 6x, 7x, 9x, 12.5x . There are two components to reducing the power , the frequency AND the voltage . Both of these are set in the PST , but the powernow-k7 says that changing the voltage is dangerous and have to supply a msr_force_voltage_scaling=1 , but I cant detect any power usage change whether I modprobe with this set or not . When I looked thru the code later, I found that with the create_fake_pst code, the msr forcing was bypassed anyway. The a7v333 bios was set to auto in the expectation that that would allow the frequency and the voltage to be set by the code. Looked at the vid jumpers , and found they were not in the default position, which the mobo manual says should allow the voltage to be set automatically. I guess when I bought the mobo and original cpu, that I had found the bios menu vcore wrong and had set them manually to give me 1.65V . I only found this out as I had finished writing this and went back for 'one last time' to try to get the vidtable to work. I set the vid jumpers to default, went back to the 1018 beta bios again, but still no joy. I was however able to adjust the voltage down using the jumpers so as to get 1.475V in the bios menu, which corresponded to a 1.50V lm-sensors measured value. This does give a lower power consumption than before so some goodness out of the frustrations of trying to get the vid table to work. End conclusion (vid) : doesnt adjust as it is supposed to do , and set jumpers manually for voltage for the cpu (for mine this was 1.45V). The vid jumpers were set with only one jumper on vid4 pins 1-2 . FWIW, I took a look at some other mobile athlons , and a 2600 one, looked similar to the 2000 one I have , but the vcore was 1.65 , so would have higher power from that alone. I had installed lm-sensors , run sensors-detect , recompiled the kernel for the missing bits (asb100 , i2c-viapro at least) and was then able to run the sensors to get the various temperatures and the voltages. asb100-i2c-0-2d Adapter: SMBus Via Pro adapter at e800 VCore 1: +1.49 V (min = +1.17 V, max = +1.76 V) +3.3V: +3.28 V (min = +2.96 V, max = +3.63 V) +5V: +5.08 V (min = +4.49 V, max = +5.51 V) +12V: +12.16 V (min = +9.55 V, max = +14.41 V) -12V (reserved): -12.70 V (min = -0.00 V, max = -0.00 V) -5V (reserved): -5.33 V (min = -0.00 V, max = -0.00 V) CPU Fan: 0 RPM (min = -1 RPM, div = 2) Chassis Fan: 0 RPM (min = -1 RPM, div = 2) Power Fan: 0 RPM (min = -1 RPM, div = 2) M/B Temp: +82°F (high = +176°F, hyst = +167°F) CPU Temp (Intel): +85°F (high = +176°F, hyst = +158°F) Power Temp: +57°F (high = +176°F, hyst = +167°F) CPU Temp (AMD): +82°F (high = +176°F, hyst = +167°F) vid: +1.475 V (VRM Version 9.0) alarms: and at max f and max load 100% cpu, 114w) get only change is: CPU Temp (AMD): +106°F . NB the voltage read , has not changed . So it powers up, then have to modprobe powernow-k7 , and then cd /sys/devices/system/cpu/cpu0/cpufreq , echo -n ondemand > scaling_governor (the ondemand governor attempts to set the frequency to match the load) and it then runs quite well. The box power old athlon mobile saving idle 126 86 40 full bore 150 114 36 the mobile has a 2000 vs 1800 rating (1.11x) or a ck 1666 vs 1533 (1.09) , so is ~10% faster . on the boot sequence (with mobile cpu) , modprobe powenow-k7 , default 'governor' = performance ie max freq = 1668 , power = 95 w set governor = ondemand , idle so freq = 534 power = 80 w so a saving of 15 w idling at f = 534 vs 1668 . starting X , increases the power from 80 to 87 , which does not disappear when kill X and go back to console . I assume that the graphics card changes mode (or something) and there is the delta of ~7w . With usual 6 xterms , idle power = 87 w , and with full bore loop, power = 114 w . One load that I use for testing is running xine , which with the new system runs at ~50% idle , at min freq (534) . This had the strange problem that the power was steady with xine running but when stopped it would jump around , and be larger. Tracked this down to a a bug in the ondemand governor code which happened sometimes at no load when the unsigned ints of idle_ticks (51) was greater than total_ticks (50) and so subtraction wrapped round and gave a maximum load . Fixed this on my sys and works fine now. The mobile processor + powernow reduced the power consumption by ~40w , and with the quieter fan , was a significant change. (Was it worth it from a money pov ? - 0.60kwh/day -> ~20gbp / year, so would take ~2yr to recoup, so probably break even ). One irritation is that if try to provide a PST entry for 400MHz ie 3x fsb , the system hangs , whereas 4x ie 533 works . No idea why. Also dont understand why the mobile_vid_table and esp fid_codes have 32 entries ie 5 bits yet a dowloaded "AMD AthlonTM XP Processor Model 8 Data Sheet" has a fid table with only 4 bits - but the 533MHz entry has an index of 0x12 ie 18 ie > 16, and that seems to work . Colour me confused ! Other power saving thoughts ----------------------------- The largest power saving could be in using a TFT monitor rather than my glass ctx one . One problem in making a decision is the lack of precision in the info provided with monitors . I used the novatech web site for info (they are cheap, local(ish) ) , and on that, some give a 'power' value , some nothing , some a 'typical' power , some a max power , and a very few give a typ and max . My son's tft (17 inch LG 1280x1024) uses only 17w for him and ditto when I tried it on my box . Turning the brightness and constrast took it up to nearly 30w , but I was happy at the 17w level. So I dont know if this is a LG 30w rated . I need to try 1280x1024 (normally use 1600x1200 withe 6 (overlapping) xterms per virtual screen ) and see if I can make that usable . I guess years back 1024x768 would have been considered to be great , I certainly would have thought so, but it is difficult to go back. That has the potential to save 72w - 17w -> 55w . the other parts of the box that use power : disk drives ----------- There are figure around for these of ~9w spinning , and 12w active ie seeking or reading/writing . The traditional hard disk has several heads that rest on the surfaces when stationary , and which are designed to 'fly' when the disks are spinning , using their shape to force the air under the head , which acts like an 'air bearing' . The disks have lubrication on the surface, but the startup and landing times are when the maximum rubbing occurs between the disk and the head , and eventually , this will lead to parts of the disk comming off, lodging under the head and causing a head crash . The system is designed to stop and start with the heads over a special area of the disk used only as the landing zone. The alternative to this method , is to have the heads off the disk under stopped conditions and then to 'load' them down to the disk surface when the disk is spinning. This prevents the rubbing and was the common mechanism in the old days when most disk systems had replacable disk packs . All (?) laptops use disks with load/unload capability and they also have sleep capability. Hitachi has a range of 3.5inch disks that have this technology (others may have as well) , and one supplier and product I found was http://svp.co.uk/products-solo.php?pid=1708 disclaimer : I have never dealt with them . These would be a worthwhile choice if looking for a new hard disk, as it should reduce power consumption for normal home use. External usb hard drives are available , which are a good idea for backups as well as storing normal info . Obviously they can easily be disconnected , taken elsewhere and reconnected. I think the prime objection to this vs an internal hd , is the probability of it being knocked over or onto the floor and being damaged. Or can do as my son does and keep it on the floor - minimise the gravitational potential energy :-) . So using one of these on a system with one internal ide hard drive preferrably a load/unload technology one , could be a good idea. My son's external hard drive was measured at 7w with it at idle . I had 2 hard drives in my box and one started to go bad a couple of months ago. That was before I became focussed on on saving power , but if that happened now , I might replace with an external drive , and if the other one went, would replace with the hitachi 3.5 load/unload hard drive. It isnt worth changing just for the power saving : 10w for 15 hr / day gives 0.15 kwh/day -> 365 * 0.15 = ~55kwh pa -> ~5gbp (at 9p per kwh). so at ~40gbp for a hdd would take 8yrs to cover ... clearly a do it when replacing , strategy is best. graphics card ------------- Experimenting with powering up the computer with various bits unplugged indicates that my graphics card (ati 9600 pro 256MB) takes about 12w in base mode and +7w after X has beens started ie ~19w total at idle. dont know if say 3d games use any more or not but using xine doesnt seem to . I cant find any references to desktop graphics card with switchable low power capability . I am sure that laptops have this sort of capability built in. It may be possible to use a base low power graphics card or it may be possible to underclock some , but I have not found any links. There seem to be only 2 ati cards out there which have mobility graphics chips, one is an old ati rage 8MB card, and the other is a radeon mobility 7500 . I bought one of these on ebay for a total of 6-50gbp (inc p&p) and plugged it in, and eventually got it running . It does save the 14w or so that I expected . xine runs much as before. glxgears runs at 70% idle, ints=900, fps=788 , with normal ints = 112, and 112+788 = 900 . So it seems that as configured , the glxgears process is waiting for the graphics card to do its stuff. Dont know what causes this and if there is an option somewhere to fix it , but I dont really care ... full 3d performance will have the 9600 back in . It would be good if they made desktop graphics cards with some form of clock control. found a recent post on ucol giving "man 4 radeon" which gives the config info that would have helped me had I been aware of it beforehand. Power used ---------- original configuration (in X) idle 126w 100% cpu 150w config : mobile athlon 2000XP , powernow-k7 (ondemand) , radeon 9600 , Vcore = 1.5 idle 86w (f=534) 100% cpu 113w (f=1668) new config : mobile athlon 2000XP , powernow-k7(ondemand), 7500 radeon mobility, Vcore=1.5 idle 72w (f=534) 100% cpu 99w (f=1668) so savings of ~50w with mobile CPU, cpufreq , low power graphics, and reduced Vcore (for mobile cpu). Conclusions ------------ - Acpi per se did not do a lot for me . - The mobile processor uses much less power than the original athlon. - The amd powernow has made a significant saving of power . - Dont know if the original athlon would have used powernow ie is it possible that powernow works on standard (old) athlons ... if I were starting again on this process, then I would check that out. - Needed the create_fake_pst change for the powernow-k7.c code, and to modify the table to match the processor I had. - Newer athlons use coolnquiet which presumably is at least as good as powernow . - ondemand governor had a small bug , but now runs fine. - there is a bug in my powernow-k7 which means that cant unload and then reload ... system crashes - so I reboot if want to reload (saves all the fscking ) . I dont know if this exists in the normal version or only in my mangled one. For my old mobo , replacing the original athlon with a mobile version has produced reasonable saving of ~20w . The powernow has also produced some savings of maybe 18w , and the graphics card change has save another ~14w , so have total savings of about 50w at idle and full load. If I were replacing hard disks then I would use an external drive and/or a load/unload hdd. It feels good to use less power , but not sure that has been worth it. Best savings probably yet to come from TFT monitor , or using old laptop with deli linux installed (20w total !) . Steve Houseman 4 August 2007