From owner-freebsd-hackers Fri Oct 11 6: 2: 7 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 CCA3D37B401 for ; Fri, 11 Oct 2002 06:02:05 -0700 (PDT) Received: from HAL9000.homeunix.com (12-232-220-15.client.attbi.com [12.232.220.15]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1835843EAF for ; Fri, 11 Oct 2002 06:02:05 -0700 (PDT) (envelope-from dschultz@uclink.Berkeley.EDU) Received: from HAL9000.homeunix.com (localhost [127.0.0.1]) by HAL9000.homeunix.com (8.12.6/8.12.5) with ESMTP id g9BD23BY016890; Fri, 11 Oct 2002 06:02:03 -0700 (PDT) (envelope-from dschultz@uclink.Berkeley.EDU) Received: (from das@localhost) by HAL9000.homeunix.com (8.12.6/8.12.5/Submit) id g9BD1tGc016889; Fri, 11 Oct 2002 06:01:55 -0700 (PDT) (envelope-from dschultz@uclink.Berkeley.EDU) Date: Fri, 11 Oct 2002 06:01:55 -0700 From: David Schultz To: Matthew Dillon Cc: Peter Wemm , Sean Kelly , hackers@FreeBSD.ORG Subject: Re: swapoff? Message-ID: <20021011130154.GA16549@HAL9000.homeunix.com> Mail-Followup-To: Matthew Dillon , Peter Wemm , Sean Kelly , hackers@FreeBSD.ORG 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> <200210081745.g98Hjkam078883@apollo.backplane.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200210081745.g98Hjkam078883@apollo.backplane.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 Thus spake Matthew Dillon : > 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; > } > } Thanks, your solution looks pretty good. I guess as part of the try_to_page_it_all_in, I'll want to call swap_pager_unswapped() on each page. Now I really wish I had noticed swap_pager_unswapped() earlier; it would have made my job much easier! I'm worried that vm_proc_swapin_all() has a similar race with the swapout daemon. Presently I assume that my references to the UPAGES object and the associated pages remain valid after the faultin(), and that I can use swap_pager_freeswapspace() to free the correct metadata, instead of calling swap_pager_unswapped() on each page. Should just hold the process lock until the metadata are freed? To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message