On Sat, Jul 13, 2002 at 03:17:33AM -0700, Terry Lambert wrote:
> Matthew Dillon wrote:
> >         * Flag the swap device being removed and then scan all OBJT_SWAP
> >           VM Objects looking for swap blocks associated with the device,
> >           and force a page-in of those blocks.  The getpages code for the
> >           swap backing store would detect the flag and not clear the swap
> >           bitmap bits as it pages-in the data.
> > 
> >           (Forcing a pagein may force pages to cycle back out to another
> >           swap device, so special treatment of the paged-in pages (like
> >           immediately placing it in the VM page cache instead of the
> >           active or inactive queues) is necessary to reduce load effects
> >           on the system.
> 
> Uh... so you set the bit that tells you it's allocated to prevent
> it being allocated?
> 
> When I swap something in and the bit is set, how do I know that it's
> in, except that it's not allocated?
>
> In other words, I do what you say... how do I know when the device
> has been drained out, vs. being in use?
> 
> I think you have to disable swapping to the device some other way,
> and then return fromt he "swapoff" only when the bitmap is all zero.
> 

Well, I think that disabling the device another way would probably
be a better approach, but you don't *have* to do it another way.
You can:

  1) Flag the device as being removed.
  2) Scan through the bitmap, and for each page allocated, add it to a list
     if pages to be paged in. For each page free, set its bit to keep it from
     being used.
  3) Once you've set all of the bits to 1, force a pagein of every page on the
     list. If the size of the list of prohibitive, you can force the pagein
     every time the list becomes full (a low/high watermark system would
     probably be the most effective).
  3) When pages get paged in, check the 'device being removed' flag
     and only clear the bit in the bitmap if the flag isn't set. Also,
     decrement a counter of the total pages in use on the device.
  4) When the counter reaches zero, remove the device.

One would need to increment the counter when they page out, obviously, but
that is not a problem.

This works, but it has the potential problem that if the list of pages to be
paged in can't grow large enough, you might page pages out to the device you're
trying to disable, only to page them back in basically immediately. This is
rather silly, but would still function.

Personally, I think it would be more intuitive to add a check to the allocation
algorithm that forces it to not consider devices flaged for removal, and
mark each page as free after it comes in. When the bitmap is clean you're done. 
However, you're still going to want to count the pages allocated on a device
because it's a lot easier to check the counter than to scan the whole bitmap.

-- 
Jonathan Mini <[EMAIL PROTECTED]>
http://www.freebsd.org/

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to