Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 May 2003 08:45:07 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Peter Edwards <pmedwards@eircom.net>
Cc:        hackers@freebsd.org
Subject:   Re: Question on (ab)using the swap pager and VM
Message-ID:  <3ECCF083.A6CA789F@mindspring.com>
References:  <20030521180222.0FA3343F3F@mx1.FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3ECCF083.A6CA789F>