Friday 27 November 2009

Laptop Mode Tools - program which you have to have

There are many laptop power saving managers, I tested a lot of them but only one meet my expectations, which isn't so strict. This manager or rather set of a tools is of course Laptop Mode Tools, its posibilities are incredible, it takes care whole your hardware and software, you need to only fit configuration to your requirements. All configuration files are located in path:
/etc/laptop-mode
Directory contains following files/directories:
  • laptop-mode.conf  - main, most important configuration file
  • lm-profiler.conf - configuration file of lm-profiler tool, lm-profiler detects processes that use system resources and that cause activity of hard disc drive and help disable them
  • batt-start, batt-stop - directories containing scripts which will be executed depend on battery mode is starts or stops
  • lm-ac-start, lm-ac-stop - directories containing scripts which will be executed in case AC mode starts or stops and laptop-mode management is active during working on AC
  • nolm-ac-start, nolm-ac-stop - ame as above, but in case laptop-mode management is inactive during working on AC
  • conf.d - directory containing additional configuration files targeted to special parts of system like ethernet card, lcd brightness, auto hibernate, kernel schedulers etc.
All configuration files are very well commented, of course remember to add/enable init script of laptop-mode to a runlevel.

Advantages of Laptop Mode Tools:
  • automaticaty detection AC or battery power source
  • decreased hdd's usage (data read ahead and buffering data designed to write on a hdd)
  • data loss protection
  • you decide about each option, nothing is imposed on you
  • default configuration is effective
  • laptop-mode-tools manage everything, so you need no more programs
Disadvantages of Laptop Mode Tools:
  • CPU frequency management, this is only function having better substitution. I recomend Cpufreqd which is more flexible
http://samwel.tk/laptop_mode/   -  Link to Laptop Mode Tools project

Friday 13 November 2009

rmmod or modprobe?

Usually when we use our laptop, we needn't all resources working (for example we connect to Internet or local net via WIFI card or Ethernet card or modem but not all of them together), nevertheless operating system sets them ready to work. That means there are spend power necessary to run device even it isn't used, obviously nowadays most of hardware supports power save modes reducing power consumption, but there is no reason to turn on something which won't be used. Important requirements to manipulate hardware are:
  • drivers should be compiled as kernel modules
  • enabled option of loading and unloading modules 
If you use default kernel everything is done, but if you compile kernel with your own configuration, remember about above requirements.

OK, let's profit extra minutes working on battery.

To turn off the device we use following command (as root user):
rmmod < name of module >

Of course if we want running device back, command loading module is:
modprobe < name of module >

What we may turn off:
  • Wireless card
  • Ethernet card
  • Modem
  • USB device
  • Sound card and speakers
  • Web camera
  • Optical disc drive (like DVD-R/RW, CD-R/RW etc.)
  • many other
Research:
Hardware:       Wireless card Realtek RTL8187B
Mean Value:    WIFI on = 16.0396      WIFI off = 14.1703

As you see I profit almost 2 Watts when I am unload WIFI driver. I want to mention that wireless card wasn't connected.

How unloading kernel's modules affect power consumption

Saturday 26 September 2009

How color of screen affects power consumption

Probably everybody who has laptop knows that decreasing backlight reduces power consumption, but this is not only way to manipulate screen power.
There was a time when I interested in construction of LCD monitors and how they work, then I realized that power consumption depends on color and its hue. How is this possible, I will tell you. The most rear layer (called backlight) emit white light which passes through polarizer next glass layer next liquid crystal next second glass layer and finally second polarizer oriented perpendicular to the first one. Now we will focus on liquid crystal which is surrounded on two sides by electrodes. Unless we applied voltage on the electrodes, molecules of liquid crystal lay the perpendicular to the light (polarized before) and light will be rotated through an angle of 90 degrees, therefore it can passes through next polarizer. If we applied voltage on the electrodes, light isn't rotate (molecules lay the parallel to the light) and can't passes through second polarizer so pixel will be black. Summarizing, brighter colors uses less power or colors with higher value per each RGB bit uses less power.

Diagram of LCD monitor
diagram of LCD monitor
Research:
Hardware: 15.4'' TFT WXGA Toshiba TruBrite

Research for screen filled with colors white and black.
how color of screen affects power consumption

Thursday 13 August 2009

Frequency

CPU is just after the screen most power consuming part of laptop. The higher frequency the greater power consumption, each cycle uses a given amount of power, even there is nothing to do. Usually when you working on laptop you needn't full speed of processor, so why not decrease it? Each laptop's CPU supports technology called frequency scaling. Available frequencies depend on the model. You may check it by entering in terminal as root below commands.
Commands:
available frequencies
     cat /sys/devices/system/cpu/cpuN/cpufreq/scaling_available_frequencies

current frequency
     cat /sys/devices/system/cpu/cpuN/cpufreq/scaling_cur_freq

set frequency to X (only when 'userspace' governor is enabled)
     echo X > /sys/devices/system/cpu/cpuN/cpufreq/scaling_setspeed

 

 *where cpuN is processor/core number counted from 0.

Next thing are scaling governors which sets frequency depending on CPU usage.

Here is list of scaling governors:

  • Performance sets the speed to maximum, essentially disabling frequency scaling. 
  • Powersave drops CPU to its lowest supported frequency.
  • Userspace allows the CPU speed to be set manually or dynamically by software. 
  • Ondemand runs at the lowest possible frequency and increases to maximum when CPU usage hits 100%.
  • Conservative runs at the lowest possible frequency and increases incrementally as more power becomes necessary.
Commands:
available scaling governors
     cat /sys/devices/system/cpu/cpuN/scaling_available_governors

current scaling governor
     cat /sys/devices/system/cpu/cpuN/scaling_governor

set scaling governor
     echo 'governor' > /sys/devices/system/cpu/cpuN/scaling_governor

 

 *where cpuN is processor/core number counted from 0.

Attention

If above functions doesn't work, probably:
  • you haven't installed acpi or acpid or both packets
  • acpi-cpufreq module isn't loaded 
  • you haven't compiled this features into kernel
  • your processor doesn't support frequency scaling
Research:

Hardware: Intel Pentium Dual-Core Processor T2390 1,86 GHz

Available frequencies: 1867 1600 1333 1067 800 MHz


How CPU frequency affect power consumption

Monday 27 July 2009

Linux on Toshiba Satellite L300-129

Last updated: 31 July 2009

General Hardware Specifications of Toshiba Satellite L300-129

Hardware ComponentsStatus under Linux / Notes
Processor: Intel Pentium dual-core T2390 1.86 GHzWorking
System memory: 2048 MB DDR2 RAM (667 MHz)Working
Hard disk: 160 GB S.M.A.R.T. (5,400 rpm)Working
DVD/CD drive:DVD Super Multi driveWorking
Display: 15.4" TruBrite WXGA TFT High BrightnessWorking
Graphics adapter: Intel GMA X3100 358 MBX11 7.4 and higher
Expansion: Express Card slotNot checked
Wireless card: Realtek 8187B (0bda:8198) 802.11b/gkernel 2.6.29 and higher
Ethernet card: Fast Ethernet LAN 10BASE-T/100BASE-TXWorking
Modem: V.92 modem 56 Kbps data, 14.4 Kbps faxNot checked
Sound system: 24-bit stereoWorking
Pointing device: Touch PadWorking
Battery: Lithium-IonWorking
Web camera: 0.3 MPx VGA with built-in microphoneWorking
USB port3 x USB 2.0Working (since kernel 2.6.30 visible works on autosuspend)
Other ports:

- external monitor port

- external microphone

- headphone (stereo)

Working

lspci returns:

00:00.0 Host bridge: Intel Corporation Mobile PM965/GM965/GL960 Memory Controller Hub
00:02.0 VGA compatible controller: Intel Corporation Mobile GM965/GL960 Integrated Graphics Controller
00:02.1 Display controller: Intel Corporation Mobile GM965/GL960 Integrated Graphics Controller
00:1a.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #4
00:1a.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #5
00:1a.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #2
00:1b.0 Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller
00:1c.0 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 1
00:1c.4 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 5
00:1d.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #1
00:1d.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #2
00:1d.2 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #3
00:1d.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #1
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge
00:1f.0 ISA bridge: Intel Corporation 82801HEM (ICH8M) LPC Interface Controller
00:1f.1 IDE interface: Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) IDE Controller
00:1f.2 SATA controller: Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) SATA AHCI Controller
00:1f.3 SMBus: Intel Corporation 82801H (ICH8 Family) SMBus Controller
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8101E/RTL8102E PCI Express Fast Ethernet controller

In conclusion, Toshiba L300-129 hardware is supported by kernel especially 2.6.29 and higher version. I recommend update kernel to the newest one by virtue of intel's hardware, they do much work improving kernel's support, so you often observe that your laptop works better.

Checked GNU/Linux distributions:

  • openSUSE 11.1

Installation, configuration and using are indeed easy. During installation you need only check some basic options like language, desktop environment etc. and next wait until the end of installation. If I am not wrong, version 11.1 has 2.6.27 kernel, so you need update it to 2.6.29 cause drivers in earlier releases not support wireless properly. If everything was done correct you may start using this system.

  • Gentoo

Installation is a bit more difficult than openSUSE, but beside this discomfort you get powerful abilities. To do that you have to follow instructions contained in this manual, but personally I suggest read alternative installation method before, especially point five "Installing Gentoo from an existing Linux distribution".

REMEMBER!!! Use only the newest releases of stage and portage.

When you will have ready basic system, you may start install your favorite packages.

REMEMBER!!! Use primarily stable ebuilds, otherwise your life change into nightmare.

Of course sometimes unstable package may be better as in the case of x11-xorg, so if you have x11-xorg-7.2 installed or it doesn't work properly then update driver for Intel cards (xf86-video-intel) to unstable version (add ~ in ACCEPT_KEYWORDS variable in make.conf file).

Soon I write post dedicated to Gentoo's configuration on Toshiba Satellite L300-129 laptop with every details like kernel and X configuration. Please be patient.


If you have any questions, my email is: kamilzmija@gmail.com 

Wednesday 22 July 2009

Dictionary

  • read-ahead - it is a system that loads data with excess into the RAM, so next time when data is loaded from the following area it is readed from RAM not disc, which is much faster.
  • noatime - mounting option which doesn't update access timestamp when a file is readed
  • DNS - (Domain Name Server) server translating domain names to IP address eg. powerlinxlap.blogspot.com is translated to 66.102.13.132, this operation takes some time

Hard Disc Drive

HDD is next opportunity too get some extra minutes working on battery. Nowadays most of disc drives supports power saving modes especially SATA discs which uses less power than PATA during data transmission. There are many methods to save power, you can reduce transmission, change read-ahead, spin down drive or even turn off motor. Most known program is hdparm which supports all above options and many others. Worth attention is -S time option putting drive into idle mode, and also sets time determining how long to wait (with no disc activity) before turning off the motor. It may save a lot of power but you need use some other tricks which reduces the frequency of using disc drive. Below I listed most important (in my opinion):

  • add option noatime for each mounted partition in /etc/fstab configuration file
  • if you have enough RAM memory, you may disable swap partition by putting # in /etc/fstab file at the beginning of line responsible for mounting swap file system
  • set read-ahead using command hdparm -a [value] /dev/[your disc]  'value' should be large but not too much (I have 24576)
  • stop system message loggers like syslogd syslog-ng rsyslogd

All these things do laptop_mode, but this is subject for other post.

If you want to find out which process get access to your disc use following commands (as root)


kamil@lap ~ $ su
Password: 
lap kamil # echo 1 > /proc/sys/vm/block_dump
lap kamil # dmesg | tail
[ 9956.024000] pdflush(31): WRITE block 17040472 on sda1
[ 9956.024009] pdflush(31): WRITE block 17125584 on sda1
[ 9956.024043] pdflush(31): WRITE block 17170536 on sda1
[ 9956.024062] pdflush(31): WRITE block 0 on sda1
[ 9956.024073] pdflush(31): WRITE block 8 on sda1
[ 9956.030421] kjournald(46): WRITE block 11191960 on sda8
[ 9956.030692] kjournald(46): WRITE block 18694768 on sda8
[ 9956.030709] kjournald(46): WRITE block 18694776 on sda8
[ 9956.031003] kjournald(46): WRITE block 18694784 on sda8
[ 9958.427068] foobar2000.exe(5863): READ block 102237108 on sda5


Research:

   Hardware: 160GB 5400 rpm 2,5" SATA

   Notice: Graph isn't ideal, cause influence other section of laptop like fan, cpu etc.

hard disc drive power consumption
Most important options of hdparm:

COMMAND

     hdparm  [option]  [device]

OPTIONS

     -a  Get/set amount of sectors for filesystem read-ahead

     -B  Query/set Advanced Power Management feature, if it is supported. A low value means aggressive power management and higher means better performance. Possible values range from 1 to 127 (permit spin-down) and values from 128 to 254 (do not permit spin-down). A value of 255 disables  Advanced Power Management.

     -I  Returns detailed info directly from the drive.

     -S  Put drive into idle mode, and also sets time determining how long to wait (with no disc activity) before turning off the motor

WARRNING

     Be careful using hdparm, some of options are very dangerous and may damage your hardware!

Friday 17 July 2009

Backlight

The easiest way to save power is decrease brightness of your screen. Difference between the highest and the lowest level is a couple of watts but it also depends on screen's diagonal. Worth of recommendation is simple but useful program called xbacklight using RandR extension. It has text interface but you can use it in applets, other programs or commonly assign to keyboard shortcut.


Research:
Hardware: 15.4'' TFT WXGA Toshiba TruBrite
 
Below you can see comparison of power consumption when backlight brightness is set to 100% and 0%.
backlight brightness power consumption

Short description of using xbacklight:
COMMAND
       xbacklight [option]
OPTIONS
       -get   Returns the current backlight brightness
       -set [percent]   Sets backlight brightness 
       -dec [percent]   Decrease backlight brightness
       -inc [percent]   Increase backlight brightness
EXAMPLES
       xbacklight -set 75
       xbacklight -inc 10
       xbacklight -dec 5

About

One year ago I bought laptop (which I'm using now to write this post), but unfortunately it had installed Vista. After five days I was on the edge of mental stability, this OS uses huge amount of my laptop's resources without reason (Linux achieve better effects on worse hardware). Next I tried XP, of course it doesn't support my SATA disc drive and additional drivers also did not work, so at last I installed GNU/Linux openSUSE 11.0 and that was it. Before I had been using GNU/Linux on my PC, but in case of laptop I afraid about hardware (it's new, so there is possibility of damage it). Luckily Linux supported hardware (except wifi card), was stable and most important I could adjust OS to my own needs. Nevertheless there was still a lot of work. Initially GNU/Linux was targeted to servers and embeded systems, next desktops and now mobile PC and gadgets like laptops, notebooks, smartphones etc., but last one group is quite new for Linux, therefore some things didn't satisfy me, I wanted improve mobility my laptop especially power consumption.

I have been interesting power management for one year and now I want share my knowledge with free software community.Probably you say that there are many sites about power management and you have right but most of them are incomplete, outdated or contain ideas which nothing improve. I give you methods checked by myself and when I finish, this site will became complete manual which helps you reduce power consumption and get some additional time working on battery.

P.S. On my laptop I profit 1 hour