Question on (ab)using the swap pager and VM

Terry Lambert tlambert2 at mindspring.com
Thu May 22 08:46:20 PDT 2003


Peter Edwards wrote:
> What I'm less sure about is how to write to the swap pager. My best guess
> is that I can modify the page with impunity once it's wired, then
> do something like what vm_proc_swapout() does, calling vm_page_dirty()
> and vm_page_unwire() to put it back on to the correct queue, where the
> swapper can launder it if neccessary.
> 
> Overall, can I do something like this to allocate and write a single
> page to the swap pager? (modulo locking stuff)

Just allocate pageable kernel memory.  There's a function to do
that, though it's not often used.

When you want to swap something out, let the VM decide to do it
for you: it's smarter than your policy enforcement routine.  So
just dirty the page, and let it happen automatically.

You will need to make your FS able to pause in case of page
faults, so you will have to be very careful, internally, about
locking.

And yes, it's a criminal thing to do... you will be eating KVA
mappings for the pages.  8-).  You are better off considering
a kernel process (not thread) to give it a seperate address
space from the kernel's KVA, and doing your operations in that
address space instead.  That will decrease KVA pressure from
your evil scheme, and will increase the size of the FS you
can back this way.

-- Terry


More information about the freebsd-hackers mailing list