View previous topic :: View next topic |
Author |
Message |
Hypnos Advocate
Joined: 18 Jul 2002 Posts: 2889 Location: Omnipresent
|
Posted: Sat May 08, 2004 9:59 am Post subject: Tips for notebook users w.r.t kernel 2.6.x |
|
|
UPDATES:
* 5/16/04 : Tweaks for kernels >= 2.6.6
--------------
Overview
1. "Laptop mode"
2. Suspend-to-disk
3. "Swappiness"
4. Conclusion
"Laptop mode"
"Laptop mode" is being merged into 2.6.6, according to its homepage:
http://www.xs4all.nl/~bsamwel/laptop_mode/
Until then, you can do something like what I do on my machine:
Code: | # echo 60000 > /proc/sys/vm/dirty_writeback_centisecs
# echo 0 > /proc/sys/vm/dirty_expire_centisecs
|
This sets the kernel daemon pdflush to wake up only every 10 minutes instead of the default 30 seconds; also, it sets all dirty buffers "expired," so when the daemon does wake up, everything queued to be written is committed at once while the hard disk happens to be spun up.
Consider putting this into your /etc/conf.d/local.start .
Suspend-to-disk
suspend-to-disk works reliably and speedily since 2.6.5+swsusp2.
swsusp2 patch is available at its homepage http://swsusp.sf.net
They distribute a suspend-to-disk script; my own script (much simpler):
Code: | #!/bin/sh
export PATH="/sbin:/usr/sbin:$PATH"
echo "You sure? (enter to continue)"
read foo
OLDCON=`fgconsole`
echo "* Stopping all DHCP connections"
killall -q dhcpcd
echo "* Stopping wavelan"
/etc/init.d/wlan stop >& /dev/null
echo "* Changing consoles ..."
chvt 1
echo "*** New console ***"
echo "* Stopping hotplugging"
/etc/init.d/hotplug stop
echo "* Saving system time to hardware"
hwclock --systohc
echo "* Flushing disk I/O"
sync
echo "* Enter sandman ..."
echo > /proc/swsusp/activate
echo "* Sleepers wake!"
echo "* Retrieving system time from hardware"
hwclock --hctosys
echo "* Restarting hotplugging"
/etc/init.d/hotplug start
echo "*** Returning to previous console ***"
chvt $OLDCON
echo "* Back to original console ..."
echo "* Flushing disk I/O"
sync
|
"Swappiness"
"Swappiness" is an arbitrary measure of how prone the virtual memory manager is to push idle data out of physical memory into swap. Consider turning down your "swappiness" to prevent hard disk flailing. On my machine:
Code: | # echo 30 > /proc/sys/vm/swapiness |
reduces swappiness from the default 60 to a more conservative 30.
Consider putting this into your /etc/conf.d/local.start
Conclusion
Altogether, these tweaks should significantly lengthen battery life and reduce wear-and-tear on your hard disk. _________________ Personal overlay | Simple backup scheme
Last edited by Hypnos on Sun May 16, 2004 12:04 pm; edited 1 time in total |
|
Back to top |
|
|
allucid Veteran
Joined: 02 Nov 2002 Posts: 1314 Location: atlanta
|
Posted: Sat May 08, 2004 9:04 pm Post subject: Re: Tips for notebook users w.r.t kernel 2.6.x |
|
|
Hypnos wrote: |
"Laptop mode" is being merged into 2.6.6, according to its homepage:
http://www.xs4all.nl/~bsamwel/laptop_mode/
Until then, you can do something like what I do on my machine:
Code: | # echo 60000 > /proc/sys/vm/dirty_writeback_centisecs
# echo 0 > /proc/sys/vm/dirty_expire_centisecs
|
|
So if we are already running 2.6.6 we don't need to make these changes? I am running 2.6.6-rc3-mm1 and I don't see any "Laptop mode" related options. dirty_writeback_centisecs is set to 500 and dirty_expire_centisecs is at 3000 on my machine so I don't believe the changes are in yet (unless I misunderstood something).
Quote: | Suspend-to-disk
... |
I have ACPI disabled and APM enabled and suspend to disk works well without any configuration as far as I can tell. I may check out swsusp2, though, just to see if there is any difference.
Also, if your laptop supports speed stepping you probably want to look into cpufreqd or powernowd to control stepping when on battery power.
Thanks for the tips! |
|
Back to top |
|
|
Hypnos Advocate
Joined: 18 Jul 2002 Posts: 2889 Location: Omnipresent
|
Posted: Sun May 09, 2004 1:12 am Post subject: Re: Tips for notebook users w.r.t kernel 2.6.x |
|
|
allucid wrote: | So if we are already running 2.6.6 we don't need to make these changes? I am running 2.6.6-rc3-mm1 and I don't see any "Laptop mode" related options. dirty_writeback_centisecs is set to 500 and dirty_expire_centisecs is at 3000 on my machine so I don't believe the changes are in yet (unless I misunderstood something). |
I have not seen the 2.6.6 codebase myself, so that's why I said "according to"
The laptop-mode settings would be in /proc/sys/vm
Quote: | I have ACPI disabled and APM enabled and suspend to disk works well without any configuration as far as I can tell. I may check out swsusp2, though, just to see if there is any difference. |
swsusp2 doesn't rely on any power subsystem for suspension process, so it should work with either. It's best feature over PM suspend is that it uses compression, so suspend/resume are very, very fast.
Unfortunately, my laptop, like many others, cannot operate without ACPI.
Quote: | Thanks for the tips! |
My pleasure! _________________ Personal overlay | Simple backup scheme |
|
Back to top |
|
|
hanzotutu Apprentice
Joined: 10 Apr 2003 Posts: 170
|
Posted: Sun May 09, 2004 4:09 am Post subject: |
|
|
Nice tips.
I found /proc/sys/vm is already there without laptop-mode patch.
Code: |
root@scimd: pts/0: 13 files 0b-> ls
autoswappiness lower_zone_protection overcommit_ratio
dirty_background_ratio max_map_count page-cluster
dirty_expire_centisecs min_free_kbytes swappiness
dirty_ratio nr_pdflush_threads
dirty_writeback_centisecs overcommit_memory
|
and
Code: |
root@scimd: pts/0: 13 files 0b-> cat dirty_expire_centisecs
3000
Sat May 8 21:07:03 PDT 2004=====>[/proc/sys/vm]
root@scimd: pts/0: 13 files 0b-> cat dirty_writeback_centisecs
500
Sat May 8 21:07:10 PDT 2004=====>[/proc/sys/vm]
root@scimd: pts/0: 13 files 0b-> cat swappiness
37
|
I will definitely give swsusp2 a try. However, I am wondering how much swap space it requires. When I installed the gentoo on my laptop, I only allocated 200M to swap (512M memory). Is it enough? _________________ Dell D600, P-M 1.4G, 512M DDR, Radeon M9 32M |
|
Back to top |
|
|
Hypnos Advocate
Joined: 18 Jul 2002 Posts: 2889 Location: Omnipresent
|
Posted: Sun May 09, 2004 4:21 am Post subject: |
|
|
hanzotutu wrote: | I found /proc/sys/vm is already there without laptop-mode patch. |
Yes, it's default in 2.6.x; "laptop mode" changes those parameters en masse, and some Reiser/ext3/etc. internals.
Quote: | I will definitely give swsusp2 a try. However, I am wondering how much swap space it requires. When I installed the gentoo on my laptop, I only allocated 200M to swap (512M memory). Is it enough? |
Eh, might be a problem. I have 512M memory and 1GB of swap; altogether, my virtual memory usage is rarely more than 512M, so I can suspend with or without compression.
With compression (as in swsusp2), you could probably get away with 512GB of swap. You could try with 200M -- swsusp2 will just complain and quit safely if you don't have enough space (link to FAQ).
The older suspend implementations, i.e. those included with 2.6.x kernels, might b0rk you data instead of quitting safely! _________________ Personal overlay | Simple backup scheme |
|
Back to top |
|
|
hanzotutu Apprentice
Joined: 10 Apr 2003 Posts: 170
|
Posted: Sun May 09, 2004 5:51 am Post subject: |
|
|
Just tried swsusp2. No problem to hibernate and resume in console.
For X, hibernation has no problem as long as my 200M swap is enough to hold the image. However, resume is broken. I guess ati-drivers might be the reason.
BTW, how to suspend to swap file? It's said in swsusp's features that suspend to swap file is supported, but how? _________________ Dell D600, P-M 1.4G, 512M DDR, Radeon M9 32M
Last edited by hanzotutu on Sun May 09, 2004 6:08 am; edited 1 time in total |
|
Back to top |
|
|
Hypnos Advocate
Joined: 18 Jul 2002 Posts: 2889 Location: Omnipresent
|
Posted: Sun May 09, 2004 5:56 am Post subject: |
|
|
hanzotutu wrote: | Just tried swsusp2. No problem to hibernate and resume in console.
For X, hibernation has no problem as long as my 200M swap is enough to hold the image. However, resume is broken. I guess ati-drivers might be the reason. Anyway, I will try it again when swap file is supported. |
When running X, try switching to a text console and hibernating, then switching back to X's console if you are resuming back.
This is a requirement for me; I am running an ATI Radeon 7500 w/ DRI drivers in Xorg. _________________ Personal overlay | Simple backup scheme |
|
Back to top |
|
|
hanzotutu Apprentice
Joined: 10 Apr 2003 Posts: 170
|
Posted: Sun May 09, 2004 6:11 am Post subject: |
|
|
yeah...I am gonna try it with DRI driver in xorg instead. Before that, I need figure out how to suspend to swap file first. Is it documented in swsusp.sf.net? _________________ Dell D600, P-M 1.4G, 512M DDR, Radeon M9 32M |
|
Back to top |
|
|
marshall_j Tux's lil' helper
Joined: 22 Jan 2003 Posts: 98 Location: NZ
|
Posted: Mon May 10, 2004 7:04 am Post subject: |
|
|
*ahem*
you are the mantis!1!
just what i was looking for.
thank you very much |
|
Back to top |
|
|
Hypnos Advocate
Joined: 18 Jul 2002 Posts: 2889 Location: Omnipresent
|
Posted: Mon May 10, 2004 7:54 pm Post subject: |
|
|
hanzotutu wrote: | yeah...I am gonna try it with DRI driver in xorg instead. Before that, I need figure out how to suspend to swap file first. Is it documented in swsusp.sf.net? |
* Browsing the mailing list, freezing to swap file might not work with 2.6.x kernels.
* If it does work, the syntax for parameter you pass to the kernel is "resum2=swap:/dev/<partition containing swap file>/<filesystem address>" where you get the filesystem address by cat-ing /proc/swsusp/headerlocations having booted up with "resume2=swap:/dev/<partition containing swap file>".
Eep! _________________ Personal overlay | Simple backup scheme |
|
Back to top |
|
|
Hypnos Advocate
Joined: 18 Jul 2002 Posts: 2889 Location: Omnipresent
|
Posted: Mon May 10, 2004 7:55 pm Post subject: |
|
|
marshall_j wrote: | *ahem*
you are the mantis!1! |
I don't know what that means
Quote: | just what i was looking for.
thank you very much |
you're very welcome _________________ Personal overlay | Simple backup scheme |
|
Back to top |
|
|
Handyman n00b
Joined: 13 Aug 2003 Posts: 8 Location: California, USA
|
Posted: Wed May 12, 2004 6:23 am Post subject: |
|
|
Is there an ebuilt kernel sources that has both the laptop patches and swsusp2? |
|
Back to top |
|
|
andyjeffries Apprentice
Joined: 14 Apr 2004 Posts: 196 Location: Stevenage, Herts, UK
|
Posted: Fri May 14, 2004 10:20 am Post subject: Re: Tips for notebook users w.r.t kernel 2.6.x |
|
|
Hypnos wrote: | Suspend-to-disk
suspend-to-disk works reliably and speedily since 2.6.5+swsusp2.
swsusp2 patch is available at its homepage http://swsusp.sf.net
They distribute a suspend-to-disk script; my own script (much simpler):
|
@Hypnos: just wanted to drop you a quick note to say thanks for this page. I now have swsusp2 working perfectly on my Sony VAIO GRX316. I wrote a small script so that users can suspend by clicking on a button in GNOME which I posted in this thread.
Anyway, thanks a lot! _________________ Developer of gPHPEdit
A8N-SLI/AMD X2 4800+/2GB Dual Channel/GF 7900GT OC |
|
Back to top |
|
|
Hypnos Advocate
Joined: 18 Jul 2002 Posts: 2889 Location: Omnipresent
|
Posted: Sat May 15, 2004 2:59 pm Post subject: Re: Tips for notebook users w.r.t kernel 2.6.x |
|
|
andyjeffries wrote: | @Hypnos: just wanted to drop you a quick note to say thanks for this page. I now have swsusp2 working perfectly on my Sony VAIO GRX316. |
Good!
Quote: | I wrote a small script so that users can suspend by clicking on a button in GNOME which I posted in this thread. |
Using zenity is a slick touch -- I've incorporated it in my suspend script now _________________ Personal overlay | Simple backup scheme |
|
Back to top |
|
|
Hypnos Advocate
Joined: 18 Jul 2002 Posts: 2889 Location: Omnipresent
|
Posted: Sun May 16, 2004 12:01 pm Post subject: |
|
|
I highly recommend the following thread now that there is swsusp2 for kernel 2.6.6 (which incorporates laptop-mode, and the new CFQ IO scheduler, which is really slick):
[SCRIPT]s to handle ACPI events (incl. laptop-mode)
https://forums.gentoo.org/viewtopic.php?t=80077
I rolled my own ACPI event scripts to actuate the userspace CPU governor and tune the hard disks when I switch between AC and battery power:
/etc/acpi/events/ac :
Code: | event=ac_adapter.*
action=/etc/acpi/ac.sh %e
|
/etc/acpi/ac.sh :
Code: | #!/bin/sh
# Script for tuning disk, cpu when AC adapter is removed
set $*
case "$4" in
00000000)
sync
echo 1200000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
echo 1 > /proc/sys/vm/laptop_mode
hdparm -S1 -B1 -a16484 /dev/hda
;;
00000001)
sync
echo 1600000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
echo 0 > /proc/sys/vm/laptop_mode
hdparm -S0 -B235 -a256 /dev/hda
;;
*)
logger "ACPI $*"
;;
esac |
N.B.: If you install the 2nd script, please change the CPU speeds to suit your machine, and tweak the hdparm settings to taste. The syntax for hdparm is in the man page. _________________ Personal overlay | Simple backup scheme |
|
Back to top |
|
|
andyjeffries Apprentice
Joined: 14 Apr 2004 Posts: 196 Location: Stevenage, Herts, UK
|
Posted: Mon May 17, 2004 8:09 am Post subject: Re: Tips for notebook users w.r.t kernel 2.6.x |
|
|
Hypnos wrote: | Using zenity is a slick touch -- I've incorporated it in my suspend script now |
I'm mostly a GNOME user so it makes sense to have a GUI dialog asking for confirmation...
I'm probably not using Zenity properly (I leave the text as the default) but it works... _________________ Developer of gPHPEdit
A8N-SLI/AMD X2 4800+/2GB Dual Channel/GF 7900GT OC |
|
Back to top |
|
|
ela n00b
Joined: 04 Jul 2002 Posts: 18 Location: Munich / Germany / EU
|
Posted: Wed Jun 02, 2004 2:53 pm Post subject: Re: Tips for notebook users w.r.t kernel 2.6.x |
|
|
Hey Hypnos!
Thanks for your tips. I use #1 and #3 here, and would like to use all of them. You write:
Hypnos wrote: | Suspend-to-disk
suspend-to-disk works reliably and speedily since 2.6.5+swsusp2.
swsusp2 patch is available at its homepage http://swsusp.sf.net
|
I got software-suspend-core-2.0-whole and software-suspend-linux-2.6.5-test16-whole (the only one available for 2.6.5 from the download page), and a vanilla 2.6.5 kernel. But when I try to compile it w/ patches applied (in the right order) it gives me:
Code: |
CC kernel/kallsyms.o
CC kernel/power/main.o
CC kernel/power/process.o
CC kernel/power/ui.o
CC kernel/power/pm.o
make[2]: *** Keine Regel vorhanden, um das Target >>kernel/power/utility.o<<,
ben?tigt von >>kernel/power/built-in.o<<, zu erstellen. Schluss.
make[1]: *** [kernel/power] Fehler 2
make: *** [kernel] Fehler 2
| (No rule to make kernel/power/utility.o whis is needed by kernel/power/built-in.o .)
How did you build it w/ 2.6.5? (I can't just switch to 2.6.6 since cisco-vpnclient refuses to work with it, and I need that one at Uni.)
I've tried around with SWSUSP(1) and PMDISK for quite some time, since I'd really LOVE to get hybernation working. You are the first person I know of who actually got some kind of hybernation to work on Linux.
Bye, Michaela. _________________ Jabber: ela_AT_jabber_DOT_org |
|
Back to top |
|
|
Hypnos Advocate
Joined: 18 Jul 2002 Posts: 2889 Location: Omnipresent
|
Posted: Wed Jun 02, 2004 4:27 pm Post subject: Re: Tips for notebook users w.r.t kernel 2.6.x |
|
|
ela wrote: | I got software-suspend-core-2.0-whole and software-suspend-linux-2.6.5-test16-whole (the only one available for 2.6.5 from the download page), and a vanilla 2.6.5 kernel. But when I try to compile it w/ patches applied (in the right order) it gives me:
Code: |
CC kernel/kallsyms.o
CC kernel/power/main.o
CC kernel/power/process.o
CC kernel/power/ui.o
CC kernel/power/pm.o
make[2]: *** Keine Regel vorhanden, um das Target >>kernel/power/utility.o<<,
ben?tigt von >>kernel/power/built-in.o<<, zu erstellen. Schluss.
make[1]: *** [kernel/power] Fehler 2
make: *** [kernel] Fehler 2
| (No rule to make kernel/power/utility.o whis is needed by kernel/power/built-in.o .)
How did you build it w/ 2.6.5? (I can't just switch to 2.6.6 since cisco-vpnclient refuses to work with it, and I need that one at Uni.) |
Hmmm, 2.6.5+swsusp2 went quit smoothly for me -- no build issues.
What if you just manually add utility.o to the objects to be built in the Makefile in kernel/power ? _________________ Personal overlay | Simple backup scheme |
|
Back to top |
|
|
Kioshen Tux's lil' helper
Joined: 23 Sep 2003 Posts: 109 Location: Montreal, PQ
|
Posted: Wed Jun 02, 2004 4:53 pm Post subject: |
|
|
Hi excellent tips you got there !
May I suggest the following ... instead of putting your tweaks in /etc/conf.d/local.start you can put them in /etc/sysctl.conf as it's a tool that is responsible for doing that at runtime (man sysctl). Here's a snippet of my file :
Code: |
# /etc/sysctl.conf:
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/sysctl.conf,v 1.3 2002/11/18$
# Disables packet forwarding
#net.ipv4.ip_forward = 0
# Disables IP dynaddr
#net.ipv4.ip_dynaddr = 0
# Disable ECN
net.ipv4.tcp_ecn = 0
# Enables source route verification
#net.ipv4.conf.default.rp_filter = 1
# Disables the magic-sysrq key
#kernel.sysrq = 0
###########
### Laptop Optimisations
# Control how much the kernel should favor swapping out applications (0-100)
vm.swappiness = 20
# Sets the kernel daemon pdflush to wake up only every 10 minutes
vm.dirty_writeback_centisecs = 60000
# Sets all dirty buffers to "expired"
vm.dirty_expire_centisecs = 0
|
After you have edited the file you can enter this command
And it will commit the changes live. As for the next reboot I'm not sure but if it doesn't commit the changes at startup just add sysctl -p to /etc/conf.d/local.start. I think it is more "clean" and centralised this way. Hopes this helps ! _________________ -= United we share =-
Adopt an unanswered post today!
Why emerge -U will kill your Gentoo |
|
Back to top |
|
|
icefox13 Tux's lil' helper
Joined: 19 Apr 2004 Posts: 78 Location: Munich, Germany
|
Posted: Wed Jun 02, 2004 10:23 pm Post subject: Re: Tips for notebook users w.r.t kernel 2.6.x |
|
|
ela wrote: | I got software-suspend-core-2.0-whole and software-suspend-linux-2.6.5-test16-whole (the only one available for 2.6.5 from the download page), and a vanilla 2.6.5 kernel. But when I try to compile it w/ patches applied (in the right order) it gives me:
Code: |
CC kernel/kallsyms.o
CC kernel/power/main.o
CC kernel/power/process.o
CC kernel/power/ui.o
CC kernel/power/pm.o
make[2]: *** Keine Regel vorhanden, um das Target >>kernel/power/utility.o<<,
ben?tigt von >>kernel/power/built-in.o<<, zu erstellen. Schluss.
make[1]: *** [kernel/power] Fehler 2
make: *** [kernel] Fehler 2
| (No rule to make kernel/power/utility.o whis is needed by kernel/power/built-in.o .) |
Edit: I think I've solved the problem:
try applying the software-suspend-core-2.0.0.66-incremental patch after applying the core-2.0-whole patch to the kernel tree. After that there exists the kernel/power/utility.c file so the kernel should compile cleanly.
Good luck
icefox13 |
|
Back to top |
|
|
ela n00b
Joined: 04 Jul 2002 Posts: 18 Location: Munich / Germany / EU
|
Posted: Thu Jun 03, 2004 1:29 am Post subject: Re: Tips for notebook users w.r.t kernel 2.6.x |
|
|
Hi icefox!
icefox13 wrote: | Edit: I think I've solved the problem:
try applying the software-suspend-core-2.0.0.66-incremental patch after applying the core-2.0-whole patch to the kernel tree. After that there exists the kernel/power/utility.c file so the kernel should compile cleanly. |
Wow! That did it! You saved my day! I am so happy! Yippie! I've been trying to make this work for months!
Thank you very much!
Ela. _________________ Jabber: ela_AT_jabber_DOT_org |
|
Back to top |
|
|
|