Here's a patch which is designed to make the kernel play more nicely with portable computers. I've been using it for a couple of days and it seems to do the right thing. I'm wondering if anyone has any comments/suggestions/etc. To test this code you'll also need http://www.zip.com.au/~akpm/linux/patches/2.4.20/pdflush-sysctl.patch (hmm. Server seems to be dead. So the patches are here, as attachments) Here's the algorithm, from the Documentation/filesystems/proc.txt section describing /proc/sys/vm/: laptop_mode ----------- Setting this entry to '1' will put the kernel's dirty data writeout algorithms into a mode which is better suited to laptop/notebook computers. This mode is specifically designed to minimise the frequency of disk spinups. Laptop mode works as follows: - Dirty data remains in memory for longer periods of time (controlled by laptop_writeback_centisecs). - If there is pending dirty data and the disk is spun up for any reason (even for a read) then all dirty data will be written back shortly afterwards. ie: when the disk is spun up, make good use of it. - When the decision is made to write back some dirty data, the kernel will write back all dirty data. laptop_writeback_centisecs -------------------------- This tunable determines the maximum age of dirty data when the machine is operating in Laptop mode. The default value is 30000 - five minutes. This means that if applications are generating a small amount of write traffic, the disk will spin up once per five minutes. If the disk is spun up for any other reason (such as for a read) then all dirty data will be flushed anyway, and this timer is reset to zero. laptop_writeback_centisecs has no effect when the machine is not operating in Laptop mode. This implementation doesn't try to be very smart - there's a direct call out of do_ide_request() into the writeback code. This couldn't be done from within ll_rw_blk.c because then a write to the ramdisk would spin the disk up. Even as-is, a read from the IDE CDROM drive will cause the IDE hard disk to spin up and flush data, so probably that call in do_ide_request() should only be made if the device is writable. Suggestions are sought, but let's try not to get too fancy here...