Date: Mon, 10 May 1999 15:40:19 -0700 From: Richard Johnson <raj@cisco.com> To: freebsd-mobile@freebsd.org Subject: 3.1 supporting disk spin down Message-ID: <199905102240.PAA01358@kitab.cisco.com>
next in thread | raw e-mail | index | archive | help
I realize that some people will tell me that I shouldn't be doing this, others will claim it's heresy, but it's working just fine for me, so there... :-) A while back I wrote to this list asking about ways to get my disk on my Toshiba Libretto to spin down. I was told it wasn't supported and that since FreeBSD (3.1-STABLE) is always writing to the disk at odd times it really woudn't work anyway. In my usual way, I didn't take "forget it" for an answer and I now have a perfectly working version of 3.1 which keeps my disk spun down most of the time! With 64Mb of memory it tends to do so much disk caching that I can ready quite a lot of email (MH under emacs) before the disk spins back up. If anyone's interested, I can send them diffs. I hesitate to send diffs to the FreeBSD support people because it was really very much a hack. Anyway, the basics are: * kern/vfs_subr.c has the new syncing code. I made "sched_sync" wait on my new "halfhour" event instead of "lbolt". * Inserted a new "halfhour" event into kern/kern_synch.c and setup code to trip it once every 1800 times (30 minutes) it trips "lbolt". * In i386/apm/apm.c I wrote a little routine to spin down all disks on the system. (I tried to spin down only my one drive but the only way the function seemed to work was to spin down *everything*. Fine. There's only one drive on my laptop anyway.) * Created a new ioctl function to spin down the drive on demand. * Created global variables "apm_disk_suspended" and "apm_disk_activity" to communicate between the apm functions and the wd driver. (This was part of the true *hack*.) * Created a new routine to see if the system is plugged into a wall outlet (so I could have it automatically not spin down in that case). I tried this out but decided I actually wanted more control than that and would like the drive to spin down even when it's plugged in sometimes, so I don't use the routine anymore. [I also drive a manual transmission car. ;-) ] * in i386/isa/wd.c I keep track of when I/O was last done to or from the drive. If we need to do I/O and "apm_disk_suspended" is true, I call wdunwedge() to completely reset the drive (just to make sure everyone knows the disk has been reset, that they know where the heads are now, etc.) wdunwedge() clears "apm_disk_suspended" after resetting the drive and prints the number of seconds it was suspended (this helped me see how well it was working). * Back in i386/apm/apm.c I created a new ioctl to set the number of minutes before disk spin down. * Modified the program "apm" to add "-x" to spin the disk down NOW, and "-w <minutes>" to tell the kernel how many minutes you want to wait before having it spin down the drive automatically ("-w 0" means don't spin down ever). * I soon discovered that syslogd was syncing the drive every now-and-then, so I removed the sync from it and recompiled. I now regularly run with "apm -w 1" and the drive stays down most of the time. I believe that's about it. (I did all of this over a few weeks a while back.) It's been working just perfectly for quite a few months now. Since FreeBSD is so stable I don't really worry about crashes, so syncing once every 30 minutes is fine. It seems to sync quicker if it needs to free up buffers and I haven't yet had any problems with the system locking up, etc. I was actually amazed at how easy it was to do! I'm not sure how much more battery time I'm getting now since I never really timed it. I seem to get around 4+ hours though. Mostly I like the complete quiet I get when I'm sitting in a meeting and simply taking notes with emacs (with autosave turned off, of course). Like I said, it's not for everyone, but I thought that some people who have laptops which don't support disk spin down in hardware (like my older AST did) would appreciate it. If you're interested, I'd be glad to send you what diffs I have. /raj To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-mobile" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199905102240.PAA01358>