Jens Axboe recently posted a patch for the 2.4 stable kernel introducing a "laptop_mode" sysctl variable aimed at increasing battery time on laptops. The patch accomplishes this in a couple of main ways. First, when a specific write happens, the systems finds any other data that is also ready to be written and writes it at the same time. Additionally, whenever a read happens, the system again finds any data that is ready to be written and writes it following the read. In each case, the idea is to minimize the frequency that a laptop's hard drive has to spin up, thus prolonging battery life.
When posting a second version of the patch with "a few tweaks and adjustments", Jens noted, "I've gotten several mails [from people] who really like the patch and [say] that it really adds a [non-insignificant] amount of extra battery time. I consider the patch final at this point." The patch is against the 2.4.21-rc2 stable kernel, though Jens acknowledged that he intends to port the patch to the 2.5 development kernel in the near future. Read on for much of the resulting discussion.
From: Jens Axboe To: Linux Kernel Subject: [PATCH] 2.4 laptop mode Date: Wed, 14 May 2003 11:35:04 +0200 Hi, Now, this isn't the prettiest patch in the world. But it does allow me to get good spin down times on my laptop hard drive. It was somewhat inspired by the 2.5.early version akpm did. Basically, it adds: - a laptop_mode sysctl variable that controls: - write back of dirty data. when we have to do it, write back all of it. - when a read is scheduled, write out dirty pending data right after. purpose of that is to make good use of a disk that was potentially spun down before. - a block_dump sysctl variable. when this is set, it dumps info to dmesg about which process scheduled the read/write. this is helpful for determining _why_ the disk is spinning up all the time. Patch also sets expire time of buffer and kupdated intervals to 10 minutes, this should probably just be done from a script. ext3's jbd is changed to set the journal expire time to the same as the buffer expire time. [patch] -- Jens Axboe
From: Martin Waitz Subject: Re: [PATCH] 2.4 laptop mode Date: Thu, 15 May 2003 10:59:12 +0200 hi :) On Wed, May 14, 2003 at 11:35:04AM +0200, Jens Axboe wrote: > Now, this isn't the prettiest patch in the world. But it does allow me > to get good spin down times on my laptop hard drive. It was somewhat > inspired by the 2.5.early version akpm did. Basically, it adds: if you are interested in spinning down hard drives, you might want to read http://www4.informatik.uni-erlangen.de/Publications/pdf/ Weissel-Beutel-Bellosa-OSDI-CoopIO.pdf they describe strategies to get maximum sleep times for drives by bundling accesses to hard discs. they even go a little bit faster and allow user space to give hints about when they need data. i only had a brief look at the sources but i guess this could be folded into the aio interface. (CoopIO as described above adds its own system calls) it would be great if somethink like that could be ported to 2.5... -- CU, / Friedrich-Alexander University Erlangen, Germany Martin Waitz // Department of Computer Science 3 _________ ______________/// - - - - - - - - - - - - - - - - - - - - /// dies ist eine manuell generierte mail, sie beinhaltet // tippfehler und ist auch ohne grossbuchstaben gueltig. /
From: Jens Axboe Subject: Re: [PATCH] 2.4 laptop mode Date: Thu, 15 May 2003 12:06:53 +0200 On Thu, May 15 2003, Martin Waitz wrote: > hi :) > > On Wed, May 14, 2003 at 11:35:04AM +0200, Jens Axboe wrote: > > Now, this isn't the prettiest patch in the world. But it does allow me > > to get good spin down times on my laptop hard drive. It was somewhat > > inspired by the 2.5.early version akpm did. Basically, it adds: > > if you are interested in spinning down hard drives, you might want to read > http://www4.informatik.uni-erlangen.de/Publications/pdf/ > Weissel-Beutel-Bellosa-OSDI-CoopIO.pdf > Interesting, I did not know about this paper. A lot of what my patch does is identical to what they describe, I stop at the OS level though and haven't (and don't really want to) extend it to applications. I think that we can get 'pretty good' power saves without going that extra mile. Note that I also operate outside of the 4 ide power states described, sleep -> standby -> idle -> active. I chose to disregard sleep, because it requires a reset and drive program when transitioning from sleep to idle. It's my feeling that most drives do the idle -> active transition (and vice versa) on their own. So for me, that just leaves on interesting operating mode (idle-active :). However, I added the acoustic management in-between that. So when the drive is considered 'active' (ie serving requests), the amount of io will determine how fast the seeks go by switching between the acoustic levels. So with my patch, we are pretty close to the ECU level described in the paper. With the laptop patch, we handle the writeout of dirty data at appropriate times (when reads spin up the disk, etc) as well. > they describe strategies to get maximum sleep times for drives by > bundling accesses to hard discs. I bundle writes with reads (slighly postponed), doing more would require the added new syscalls. > they even go a little bit faster and allow user space to give hints > about when they need data. > i only had a brief look at the sources but i guess this could be folded > into the aio interface. > (CoopIO as described above adds its own system calls) Yeah, using aio would make it a lot easier and wouldn't require many changes to the existing aio interface. > it would be great if somethink like that could be ported to 2.5... What's stopping you? -- Jens Axboe
From: Martin Waitz Subject: Re: [PATCH] 2.4 laptop mode Date: Thu, 15 May 2003 14:54:13 +0200 hi :) On Thu, May 15, 2003 at 12:06:53PM +0200, Jens Axboe wrote: > > it would be great if somethink like that could be ported to 2.5... > What's stopping you? well the group that did that work does not have enough money to fund new staff, so i can't get paid to do it... and i don't have enough free time :( but anyway, your work on this topic is great, too! :) i am really looking forward to having a laptop-optimized os -- CU, / Friedrich-Alexander University Erlangen, Germany Martin Waitz // Department of Computer Science 3 _________ ______________/// - - - - - - - - - - - - - - - - - - - - /// dies ist eine manuell generierte mail, sie beinhaltet // tippfehler und ist auch ohne grossbuchstaben gueltig. /
From: Jens Axboe Subject: Re: [PATCH] 2.4 laptop mode Date: Thu, 15 May 2003 17:14:28 +0200 On Thu, May 15 2003, Martin Waitz wrote: > hi :) > > On Thu, May 15, 2003 at 12:06:53PM +0200, Jens Axboe wrote: > > > it would be great if somethink like that could be ported to 2.5... > > What's stopping you? > > well the group that did that work does not have enough money to > fund new staff, so i can't get paid to do it... > > and i don't have enough free time :( Ah > but anyway, your work on this topic is great, too! :) > i am really looking forward to having a laptop-optimized os Thanks, I'll surely move it to 2.5 at some point in the near future. But only to the extent of what it does know, I don't care enough to take it further I'm afraid. The benefit would not justify the time spent, compared to what the OS only solution gets me :) -- Jens Axboe
From: Jens Axboe Subject: [PATCH] laptop mode, #2 Date: Fri, 16 May 2003 13:33:09 +0200 Hi, Made a few tweaks and adjustments: - If block_dump is set, also dump who is marking a page/buffer as dirty. akpm recommended this. - Don't touch default bdflush parameters (see script) That's about it. I've gotten several mails who really like the patch and that it really adds a non-significant amount of extra battery time. I consider the patch final at this point. Patch is against 2.4.21-rc2 (ish) [patch] [control script] -- Jens Axboe
From: Pavel Machek Subject: Re: [PATCH] laptop mode, #2 Date: Fri, 16 May 2003 21:55:36 +0200 Hi! > Made a few tweaks and adjustments: > > - If block_dump is set, also dump who is marking a page/buffer as dirty. > akpm recommended this. > > - Don't touch default bdflush parameters (see script) > > That's about it. I've gotten several mails who really like the patch and > that it really adds a non-significant amount of extra battery > time. I Non-significant? Like it adds no time at all? > consider the patch final at this point. > > Patch is against 2.4.21-rc2 (ish) It looks nice, but without Documentation/laptop_mode, I can't say much more ;-)))). Pavel -- When do you have a heart between your knees? [Johanka's followup: and *two* hearts?]
From: Jens Axboe Subject: Re: [PATCH] laptop mode, #2 Date: Sat, 17 May 2003 10:16:58 +0200 On Fri, May 16 2003, Pavel Machek wrote: > Hi! > > > Made a few tweaks and adjustments: > > > > - If block_dump is set, also dump who is marking a page/buffer as dirty. > > akpm recommended this. > > > > - Don't touch default bdflush parameters (see script) > > > > That's about it. I've gotten several mails who really like the patch and > > that it really adds a non-significant amount of extra battery > > time. I > > Non-significant? Like it adds no time at all? Woops, that was reversed :) > > consider the patch final at this point. > > > > Patch is against 2.4.21-rc2 (ish) > > It looks nice, but without Documentation/laptop_mode, I can't say much > more ;-)))). The attached script basically explained everything, but yes I will add a laptop_mode file as well. -- Jens Axboe
Journaling file systems?
I read through the patch, and noticed something ext3 specific (the JBD stuff). Does this work for XFS/JFS/ReiserFS too, or would we need to write FS specific patches for them too?
Sorry, I could just be being a dumbass... ;-)
Michael
Adding to 2.4.21 serie...
I hope Marcello wakes up from his dream and add this patch to incoming 2.4.21 serie.
Haaswurscht
Did Marcelo post anything the last months to LKML besides some kernel-2.4.21-rcx announcements? - No.
I don't really think this will even get into 2.4.22 (to be released next year).
Marcelo's dreams ?
Is there any _good_ reason why it tooks so long to go from 2.4.20 to 2.4.21 ? I'm sure Marcelo is doing a good job, just wanted to know if there is some technical problem or if he just want to be sure to make a rock solid release.
Anyway, i think it's taking too long, there are important things in the actual -rc2 that needs to be in a 2.4.21 release as soon as possible.
Marcelo's Dream
I see a long delay between a patch release on LKML and its entry on Marcelo's BK tree. So, will we have a 2.4.21 soon? I don't think so.
Marcelo's Dream
You are right, there haven't been any updates to his BK tree for 12 days. Maybe he is on vacation or something.
"Significant amount of extra battery time"?
What kind of numbers are we talking about here?
-ck kernel
One really interesting thing, was integrating this patch in Con Kolivas enhanced kernel for desktop computing...I use it in my laptop and I would really love to have this code running too!
I can't integrate it myself mostly due to lack of time and some knowledge, so I hope someone (or CK himself) will pick this suggestion up and make this excellent kernel, even better :)
Thanx
Speed issues
I applied the patch and I experienced slowdown. A feeling of slowdown. I have not ran benchmarks to test if it is true. Any takers?
Slowdown expected
That would make sense given the design of the patch. Once it detects the drive is being used, keep using it - this will create more i/o induced pauses.
Also, the spinup of the HD wo
Also, the spinup of the HD would impact things too.
-wolk kernel
AFAIK, this patch is already included in WOLK
A question about spinups and spindowns
I played with bdflush on my old laptop a while ago and found a configuration that suited me. But im eager to try this new patch (we all want longer batterytime). To get to the point, I was just thinking about all the spindown and spinups. Doesn't that wear alot on the harddrives? Perhaps keeping the harddrive constantly spinning will give it a longer life. Don't know if this is an issue on newer HDs but I think it might be better for my old HD.
Laptops are rated for hundred
Laptops are rated for hundreds of thousands of spin-ups/spin-downs (I don't remember exact figures). Laptop drives are rated for even more than desktop hard drives because of the environment they are used in.
So no, there is no reason at all to be worried about it.
what about 2.4.22/2.6.0-test4?
So does this patch already included in 2.4.22, 2.6.0-test4, or another patches (like -ck)? I tried it on 2.4.21 - it's very nice.
btw, does anybody know another good laptop-specific patches?