From owner-freebsd-hackers Tue Oct 8 10:45:49 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 5DC8C37B401 for ; Tue, 8 Oct 2002 10:45:47 -0700 (PDT) Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id DC11F43E65 for ; Tue, 8 Oct 2002 10:45:46 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: from apollo.backplane.com (localhost [127.0.0.1]) by apollo.backplane.com (8.12.5/8.12.4) with ESMTP id g98HjkPQ078884; Tue, 8 Oct 2002 10:45:46 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.12.5/8.12.4/Submit) id g98Hjkam078883; Tue, 8 Oct 2002 10:45:46 -0700 (PDT) (envelope-from dillon) Date: Tue, 8 Oct 2002 10:45:46 -0700 (PDT) From: Matthew Dillon Message-Id: <200210081745.g98Hjkam078883@apollo.backplane.com> To: David Schultz Cc: Peter Wemm , Sean Kelly , hackers@FreeBSD.ORG Subject: Re: swapoff? References: <20020713071911.GA1558@HAL9000.wox.org> <20020713073404.9869A3811@overcee.wemm.org> <20020713115746.GA2162@HAL9000.wox.org> <200207131636.g6DGaoqh081285@apollo.backplane.com> <20021007153845.GA371@HAL9000.homeunix.com> <200210072347.g97Nl3Zo049415@apollo.backplane.com> <20021008113614.GA319@HAL9000.homeunix.com> 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 :... :detect when there is insufficient space. (I actually thought it :was right the first time.) Can you see anything obviously wrong :with my math? : :The code works fine in all of my tests, except that calling :swapoff() when the system is under heavy paging load and has :multiple swap devices sometimes leads to a few pages being missed :by the scan. I think the problem is that some process allocates :some swap and starts paging out just before the device is marked :as off-limits. Am I missing a simple solution to this problem? :(For now, I kludge around the issue by rescanning if there are :still blocks remaining.) Ok, I think the problem is in swap_pager_swapoff() and swp_pager_force_pagein(). Another process may be manipulating the swblock (or a prior swblock) while swp_pager_force_pagein() is blocked. In fact, the swap block can be ripped out from under swap_pager_swapoff() if swp_pager_force_pagein() blocks. i.e. the 'swap' structure may be invalid after you call swp_pager_force_pagein(). This is a sticky situation because both the VM object and the swblocks may be manipulated by other processes when you block. I think what you need to try to do is this (it's a mess, if you can think of a better solution definitely go another route!) while ((swap = *pswap) != NULL) { if (anything_is_swapped_to_the_device) { try_to_page_it_all_in (note that the swblock structure is invalid the moment you block, so swp_pager_force_pagein() should be given the whole range). /* fall through to retry */ } else if (the_related_object_pip_count_is_not_zero) { vm_object_pip_sleep(...) /* fall through to retry */ } else if (swap->swb_count <= 0) { free the swap block *pswap = swap->swb_hnext; } } -Matt Matthew Dillon To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message