Subject: Re: swapoff=YES as default? (was Re: Additional swap/dump magic)
To: None <tech-userlevel@NetBSD.org>
From: Alan Barrett <apb@cequrux.com>
List: tech-userlevel
Date: 08/29/2006 11:27:00
On Tue, 29 Aug 2006, Daniel Carosone wrote:
> > Can anyone tell me why changing the default of swapoff=NO to swapoff=YES
> > in /etc/defaults/rc.conf would be wrong?
> It might even hang or livelock the reboot, if there's something that
> won't die holding on to those pages when swapoff is run.

Yes, I have certainly encountered that.  My workaround was to have one
rc.d script spawn a background sapoff process, and to have another rc.d
script wait for the swapoff process.  I think I used the swap1 and swap2
scripts for that.  Also ensure that as many daemons as possible are
killed explicitly during the shutdown process (just hive each daemin an
rc.d script with "# KEYWORD: shutdown").

> It also seems possible that the kernel could close the device once the
> last process owning pages in the swap space exits, long after a
> userland swapoff might have a chance to make a difference.  There was
> a discussion a while back about shutdown hook ordering that is
> relevant here, where swap, raid, cgd, etc devices might be stacked in
> different orders.

I still think that shutdown hooks would be the right solution.  See
<http://mail-index.netbsd.org/tech-kern/2005/05/09/0001.html> for my
proposal.

--apb (Alan Barrett)