From owner-freebsd-hackers Sat Jul 13 0:34: 8 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B048137B400 for ; Sat, 13 Jul 2002 00:34:05 -0700 (PDT) Received: from canning.wemm.org (canning.wemm.org [192.203.228.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id 574CE43E58 for ; Sat, 13 Jul 2002 00:34:05 -0700 (PDT) (envelope-from peter@wemm.org) Received: from fw.wemm.org (canning.wemm.org [192.203.228.65]) by canning.wemm.org (Postfix) with ESMTP id 1E5422A7D6 for ; Sat, 13 Jul 2002 00:34:05 -0700 (PDT) (envelope-from peter@wemm.org) Received: from overcee.wemm.org (overcee.wemm.org [10.0.0.3]) by fw.wemm.org (Postfix) with ESMTP id BFF034C248 for ; Sat, 13 Jul 2002 00:34:04 -0700 (PDT) (envelope-from peter@wemm.org) Received: from wemm.org (localhost [127.0.0.1]) by overcee.wemm.org (Postfix) with ESMTP id 9869A3811; Sat, 13 Jul 2002 00:34:04 -0700 (PDT) (envelope-from peter@wemm.org) X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: David Schultz Cc: Matthew Dillon , Sean Kelly , hackers@FreeBSD.ORG Subject: Re: swapoff? In-Reply-To: <20020713071911.GA1558@HAL9000.wox.org> Date: Sat, 13 Jul 2002 00:34:04 -0700 From: Peter Wemm Message-Id: <20020713073404.9869A3811@overcee.wemm.org> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG David Schultz wrote: > Thus spake Matthew Dillon : > > Implementing swapoff is a bunch of grunt-work but not too hard in > > concept. Basically the work involved is this: > > Sounds like a plan, and not too tricky. Perhaps I'll see if I can > figure it out when I have some free time. > > > * Make a calculation to be sure that it is possible to turn off > > the swap device and not run the system out of VM. If it is not > > possible do not allow the swapoff. > > Can't you have a race condition here where you decide that you > have enough space, and by the time you've deallocated half of the > swapfile that's no longer the case? It seems like the correct > thing to do in that case is abort the system call (which could be > painful). Perhaps the best thing to do in this case is wait for > vm_pageout_scan to kill a few pigs. One system I used to use years and years ago seperated this process into stages. The swap(1M) command could be used to enable, disable and 'weight' allocation to swap areas. The add was easy. 'delete' would cause the device to be attempted to be paged in, but if the system looked like it was going to run out of resources it would fail and stop right there. You could either turn allocation back on, or kill processes or wait for the pager catch up with moving stuff out to other swap spaces. When (if) it finally hit zero inuse, it would be deleted. It did manage multiple swap spaces as seperate entities with different fill levels etc [rather than one giant logical swap area], so doing it this way kinda made sense. I did actually use it once and it even worked. :-) (I cannibalized my /tmp file system and used it for swap for a project, and then turned it off and re-mkfs'ed it) Cheers, -Peter -- Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com "All of this is for nothing if we don't go to the stars" - JMS/B5 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message