Software and hardware annotations 2008 December

This document contains only my personal opinions and calls of judgement, and where any comment is made as to the quality of anybody's work, the comment is an opinion, in my judgement.

[file this blog page at: digg Technorati]

081227 Sat My laptop and cost of spares, Linux power management
My recent disappointment with loss of capacity of my laptop battery has made me think about some surrounding issues. The first is that my laptop should really have come with the 9 cell battery, which is what the competing Samsung Q45 had (at a higher price). But this is really part of the argument that one needs to buy spares with laptops and not just a spare power brick, but also spare batteries (given their short useful life). So far I have spent about £70 in spare power supplies and £200 in spare batteries for a laptop that cost around £560. I am still fairly happy with it anyhow.
I am also still fairly happy with the improvements in Linux power management that give it about 1 hour of light use operation per Ah, which is fairly competitive with MS-Windows. This is in part thanks to the careful tuning in my sabiwatts script but mostly to the haphazard yet continuous progression of the Linux power conservation efforts, including monitoring tools like powertop and acpitool (which is rather more informative than acpi even if less official).
I have also found that suspending to memory mostly works, as long as one is careful, which mostly means about sound and graphics hardware. I have written a script that seems to work in most cases:
# vim:set ft=sh:

ME="$(basename "$0")"


# Inspired by and

usevbetool()    { true; }

if ! usevbetool
then VGAPCI="$(/sbin/lspci | grep VGA | cut -d ' ' -f1 | sed -e 's|0000:||' -e 's|:|/|')"

VGAVCS="$(mktemp /var/tmp/vgavcs-XXXXXX)"
VGASET="$(mktemp /var/tmp/vgaset-XXXXXX)"
trap "rm -f '$VGASET' '$VGAVCS'" 0 1 15

chvt 1
cp /dev/vcsa "$VGAVCS"
if usevbetool
then vbetool vbestate save > "$VGASET"
else cp "/proc/bus/pci/$VGAPCI" "$VGASET"

sync; sleep 3; echo -n mem > /sys/power/state; sleep 3

if usevbetool
then vbetool post; vbetool vbestate restore & "$VGASET"
else cp "$VGASET" "/proc/bus/pci/$VGAPCI"
cp "$VGAVCS" /dev/vcsa
chvt "$VGACON"

When the system is suspended to RAM it keeps its information for a fairly long time, my estimate si around 4-6 times longer than in its lowest active power mode. I am not using suspend to disk for a couple of important reasons, one being that encrypted disk save files are not supported or awakward to setup, and the other is that suspend to disk is much riskier than to ram, as there is a lot more state to save and restore.
It would work well if both the hardware and the software had been designed to make it easy and reliable to save and restore state, but that has been retrofitted and not so well, and suspend to disk works well in some cases and no so well in others, and is not particularly useful to me.
081224 Wed More laptop battery decay, new high capacity battery
I am still fairly happy with my Satellite U300 laptop, but having noticed that one month ago its new 6 cells 5200mAh battery's capacity had decayed quite a bit I retested it and in one month it has gone down by 15m:
     PowerTOP version 1.9       (C) 2007 Intel Corporation

Cn                Avg residency       P-states (frequencies)
C0 (cpu running)        ( 0.2%)         1500 Mhz     0.0%
C1                0.0ms ( 0.0%)         1000 Mhz   100.0%
C2                0.0ms ( 0.0%)
C3              110.6ms (99.8%)

Wakeups-from-idle per second :  9.0     interval: 2.0s
Power usage (ACPI estimate): 12.1W (01:49 remaining)

Top causes for wakeups:
  42.9% (  3.0)        pop3-login : __mod_timer (process_timeout)
  14.3% (  1.0)      dovecot-auth : __mod_timer (process_timeout)
  14.3% (  1.0)           dovecot : __mod_timer (process_timeout)
  14.3% (  1.0)     <kernel core> : schedule_delayed_work_on (delayed_work_timer
A rate of decay of 15m/month, which sort of matches the one between February 2008 and November 2008, where 1h30m of duration was lost in 9 months (most of that in the months between July and November though).
Since the worsening duration of a charge has already caused me some data (email) loss as power was lost earlier than I had become used to, I have decided to buy the 9 cells 7800mAh for my laptop (model ST-PA3595U-1BRS) which costs around £110+VAT. Well, that's expensive but well worth it, as it lasts around 7-8h under light usage
     PowerTOP version 1.9       (C) 2007 Intel Corporation

Cn                Avg residency       P-states (frequencies)
C0 (cpu running)        ( 1.8%)         1500 Mhz     0.0%
C1                0.0ms ( 0.0%)         1000 Mhz   100.0%
C2                0.0ms ( 0.0%)
C3               20.8ms (98.2%)

Wakeups-from-idle per second : 47.2     interval: 2.0s
Power usage (ACPI estimate): 12.0W (08:05 remaining) (long term: 5.1W,/18.9h)

Top causes for wakeups:
  25.6% ( 11.0)            kicker : __mod_timer (process_timeout)
  16.3% (  7.0)            xemacs : __mod_timer (process_timeout)
  12.8% (  5.5)       <interrupt> : extra timer interrupt
  11.6% (  5.0)   <kernel module> : queue_delayed_work (delayed_work_timer_fn)
That's quite remarkable. It is a bit bigger than the others, as it protrudes from the back like many other high capacity laptop batteries, but that is used to advantage as the protrusion is used as a small pedestal that keeps the hot underside of the laptop a small distance from the desk and gives some inclination to the keyboard. The extra size is not a big deal, but the extra weight is noticeable, especially compared to the 4000mAh version.
As to that version, the one included with the laptop, I have tried it again recently, not having used it since February, and I have been surprised. The first surprise is that it was still fully charged after 10 months, and the second that its charge was reported as lasting a lot longer than I remembered:
     PowerTOP version 1.9       (C) 2007 Intel Corporation

Cn                Avg residency       P-states (frequencies)
C0 (cpu running)        ( 1.4%)         1500 Mhz     0.0%
C1                0.0ms ( 0.0%)         1000 Mhz   100.0%
C2                9.5ms ( 0.3%)
C3               14.0ms (98.3%)

Wakeups-from-idle per second : 70.6     interval: 15.0s
Power usage (ACPI estimate): 12.0W (03:18 remaining) (long term: 5.2W,/7.6h)

Top causes for wakeups:
  17.0% ( 11.7)            kicker : __mod_timer (process_timeout)
  15.1% ( 10.5)       <interrupt> : extra timer interrupt
  11.2% (  7.7)            xemacs : __mod_timer (process_timeout)
   9.3% (  6.4)      <kernel IPI> : Rescheduling interrupts
and 3h is not that bad indeed. Lithium-ion batteries lose capacity even if not used, and I haven't used the 4 cell battery since February, so it must have lost a bit of capacity; using acpitool shows it has lost 20% of its original capacity:
tree# acpitool -B
  Battery #1     : present
    Remaining capacity : 3200 mAh, 100.0%
    Design capacity    : 4000 mAh
    Last full capacity : 3200 mAh, 80.00% of design capacity
    Capacity loss      : 20.00%
    Present rate       : 0 mA
    Charging state     : discharging
    Battery type       : rechargeable, LION
    Model number       : NS2P3SZNJ4WR
    Serial number      : 18087
which for 10 months is not too bad. Instead the 6 cell battery I have been using for those 10 months has lost 65% of its capacity:
tree# acpitool -B
  Battery #1     : present
    Remaining capacity : 1814 mAh, 100.0%
    Design capacity    : 5200 mAh
    Last full capacity : 1814 mAh, 34.88% of design capacity
    Capacity loss      : 65.12%
    Present rate       : 0 mA
    Charging state     : charged
    Battery type       : rechargeable, LION
    Model number       : NS2P3SZNJ5WR
    Serial number      : 16507
and the new 9 cell one of course has lost none:
tree# acpitool -B
  Battery #1     : present
    Remaining capacity : 7800 mAh, 100.0%
    Design capacity    : 7800 mAh
    Last full capacity : 7800 mAh
    Present rate       : 0 mA
    Charging state     : charged
    Battery type       : rechargeable, LION
    Model number       : NS3P3SZNJSWR
    Serial number      : 12632
The capacity loss of the 6 cell battery in 10 months is quite remarkable, and checking some relevant sources (1, 2) the rate of decay depends very much on battery temperature (and on battery charge: a fully charged one decays more rapidly than a partially charged one). Keeping the battery plugged into the laptop even when on wired power seems a bad idea, also because it happens to be next to the CPU, whuch generates a lot of heat.
Since I have kept the 6 cell battery plugged in at all times in the past 10 months (except while traveling between work and home), I should not be that surprised, even if a loss of 65% of capacity is higher than the worst estimate in the sources I have read.
With the new 9 cell battery I have taken to unplug it whenever the laptop is on wired power, and part of it protrudes from the body of the laptop and will therefore be cooler.
081202 Tue Enabled video outputs can always draw power
Having just been dismayed by the rapid loss of capacity of my laptop battery, I have been the noticed that in low power mode the laptop was drawing 14-15W instead of the usual 11-12W. After some investigation it occurred to me that this might be related to having enabled the external VGA monitor output of my laptop; disabling it with xrandr power consumption went back down to 11-12W.
I have added therefore to my power configuration script the logic to disable under X all the disconnected outputs when switching to low power mode, and to enable all the connected ones when switching to normal power mode. This is not right in every circumstance, but it is in most and it is easy to undo.