pesartain.com

where I remind myself what I've accomplished.

Power Saving

This isn't intended to be a how-to, more an aide-memoire. If you get something useful out of it, however, all the better.

Kernel config

The kernel must be aware of what hardware you're trying to operate on, and so you could do with setting the following:

  • Processor type and features
    • Processor family (to unlock any specific extensions)
    • Power management options
      • ACPI (as many options here as you have items on your motherboard)
      • CPU frequency scaling (ditto - make sure you get the right processor driver)

In my case the motherboard is a Abit KV8 Pro - this a socket 754 running a Athlon64 2GHz processor with a VIA KT8T800 Pro / VT8237 chipset. I end up with powernow-k8 driver enabled for CPU frequency scaling and a ton of ACPI features.

Suspend to ... what?

Suspend to disk (hibernate, S4) or suspend to ram (standby, S3)?

Hibernate writes the system state to your disk (over the swap partition) and places a marker so that during next boot the state will be resumed and you'll have your swap space returned to you, then shuts down the hardware. The key point here is that you must got through a normal BIOS boot procedure and partial Linux boot load before it'll resume. This actually isn't a significantly shorter boot procedure than turning the damn thing off in the first place.

Standby does the same thing, except doesn't write any data to the disk, preferring to keep it in RAM. Matthew Garret could explain much better than I, and infact, has already done so. The key point with standby is that there is no partial boot process, so many of your devices are likely to be uninitialised on resume.

Suspend to ram is, however, what I need. I want to shut the lid on my desktop and have the system pop back up later on when I've woken up.

Like others, I found that there are a plethora of methods for suspend to ram, but after a few false starts with a kernel recompile, the easiest one turned out to be manipulating the power state from the sysfs.

Adding “resume=/dev/sda3”, where sda3 is my swap partition, to lilo's append line allows all this to work. There is a default option in the kernel config that may be used to set this also.

To see what states are available to set this way:

~$ cat /sys/power/state
mem disk

If you're using an nVidia card like I am, beware that the 180 series of drivers cause some headaches with resuming (see ThinkWiki link below).

Finally:

~# echo -n "mem" > /sys/power/state

Will suspend to ram just fine. When all's said and done, it's that easy if I'm in X (which I mostly am).

Video comes up fine. Sound works fine, although any flash players with sound will need refreshing in the browser. Network card needs reenabling through rc.inet1 eth0_restart - that's really a job for a hook, which is precisely why pm-utils should be preferred in this case over just echoing the command into sysfs.

CPU frequency scaling

Plenty of information to be obtained from sysfs again:

~$ ls /sys/devices/system/cpu/cpu0/cpufreq/
affected_cpus     ondemand/                      scaling_driver    stats/
cpuinfo_cur_freq  scaling_available_frequencies  scaling_governor
cpuinfo_max_freq  scaling_available_governors    scaling_max_freq
cpuinfo_min_freq  scaling_cur_freq               scaling_min_freq

There are five governors:

  • performance - max freq
  • powersave - min freq
  • ondemand - hard ramp between min and max
  • conservative - soft ramp between min and max, better for laptops
  • userspace - custom speed

Setting the governor to ondemand is just fine for me, so the CPU will idle at 1GHz but ramp up to 2GHz during heavy load.

~# echo -n "ondemand" /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

To fix that so it'll be that way every boot:

~$ echo -n "echo -n ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" >> /etc/rc.d/rc.local

User-end Work

As Robby notes in his readme regarding pm-utils and automating the process of suspend:

A better option is to use a power manager daemon, but unless you happen to be running gnome or one of the pre-release xfce-4.6 builds, that's not an option.

More to come on possible solutions to this.

Links

Who am I? I answer to Piete or Pieter and I try to be more than just my job title.

Browse my blog, read about me, or listen to my music.