original comment: +Wilson03172004,marked due to this pci host does not support MWI
[linux-2.4.git] / Documentation / laptop-mode.txt
1 Laptop mode
2 ===========
3
4 This small doc describes the 2.4 laptop mode patch.
5
6 Last updated 2003-05-25, Jens Axboe <axboe@suse.de>
7
8 Introduction
9 ------------
10
11 A few properties of the Linux vm makes it virtually impossible to attempt
12 to spin down the hard drive in a laptop for a longer period of time (more
13 than a handful of seconds). This means you are lucky if you can even reach
14 the break even point with regards to power consumption, let alone expect any
15 decrease.
16
17 One problem is the age time of dirty buffers. Linux uses 30 seconds per
18 default, so if you dirty any data then flusing of that data will commence
19 at most 30 seconds from then. Another is the journal commit interval of
20 journalled file systems such as ext3, which is 5 seconds on a stock kernel.
21 Both of these are tweakable either from proc/sysctl or as mount options
22 though, and thus partly solvable from user space.
23
24 The kernel update daemon (kupdated) also runs at specific intervals, flushing
25 old dirty data out. Default is every 5 seconds, this too can be tweaked
26 from sysctl.
27
28 So what does the laptop mode patch do? It attempts to fully utilize the
29 hard drive once it has been spun up, flushing the old dirty data out to
30 disk. Instead of flushing just the expired data, it will clean everything.
31 When a read causes the disk to spin up, we kick off this flushing after
32 a few seconds. This means that once the disk spins down again, everything
33 is up to date. That allows longer dirty data and journal expire times.
34
35 It follows that you have to set long expire times to get long spin downs.
36 This means you could potentially loose 10 minutes worth of data, if you
37 set a 10 minute expire count instead of just 30 seconds worth. The biggest
38 risk here is undoubtedly running out of battery.
39
40 Settings
41 --------
42
43 The main knob is /proc/sys/vm/laptop_mode. Setting that to 1 switches the
44 vm (and block layer) to laptop mode. Leaving it to 0 makes the kernel work
45 like before. When in laptop mode, you also want to extend the intervals
46 desribed above. See the laptop-mode.sh script for how to do that.
47
48 It can happen that the disk still keeps spinning up and you don't quite
49 know why or what causes it. The laptop mode patch has a little helper for
50 that as well, /proc/sys/vm/block_dump. When set to 1, it will dump info to
51 the kernel message buffer about what process caused the io. Be very careful
52 when playing with this setting, it is advisable to shut down syslog first!
53
54 Result
55 ------
56
57 Using the laptop-mode.sh script with its default settings, I get the full
58 10 minutes worth of drive spin down. Provided your work load is cached,
59 the disk will only spin up every 10 minutes (well actually, 9 minutes and 55
60 seconds due to the 5 second delay in flushing dirty data after the last read
61 completes). I can't tell you exactly how much extra battery life you will
62 gain in laptop mode, it will vary greatly on the laptop and workload in
63 question. The only way to know for sure is to try it out. Getting 10% extra
64 battery life is not unrealistic.
65
66 Notes
67 -----
68
69 Patch only changes journal expire time for ext3. reiserfs uses a hardwire
70 value, should be trivial to adapt though (basically just make it call
71 get_buffer_flushtime() and uses that). I have not looked at other
72 journalling file systems, I'll happily accept patches to rectify that!