:... :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 <[EMAIL PROTECTED]> To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message