Thus spake Matthew Dillon <[EMAIL PROTECTED]>: > 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 [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message