Subject: Re: pmap_enter(9) flags in vmapbuf()
To: Jason Thorpe <thorpej@shagadelic.org>
From: Chuck Silvers <chuq@chuq.com>
List: port-mips
Date: 03/27/2005 10:13:47
On Sun, Mar 27, 2005 at 12:09:15AM -0800, Jason Thorpe wrote:
> 
> On Mar 26, 2005, at 2:39 AM, Izumi Tsutsui wrote:
> 
> >Precisely, is it worth to pass VM_PROT_READ (and VM_PROT_WRITE on  
> >B_READ)
> >to pmap_enter(9) flags in vmapbuf() on mips?
> >And should we pass VM_PROT_WRITE in pmap_enter() prot arg only
> >on B_READ too?

yea, these are both good ideas, the way the pmap stuff works these days.


> The pmap_enter() flags argument must always have at least the  
> permissions that are in the prot argument if flags also has PMAP_WIRED.

hmm, well apparently someone put words to that effect in the manpage,
but it doesn't really make a lot of sense when you look at the larger picture.
passing VM_PROT_WRITE here will make the page dirty, avoid the need of some
pmaps to fault when the page is actually written, but if the page belongs to
a vnode and it stays wired for long, it'll get written out to disk and marked
clean again, so we'll take a fault the next time the page is modified again
after that.  we don't really want to say that pages wired for write are
permanently dirty, since then we'd end up writing them back to disk again
and again even though they aren't actually changing.

so at this point, it can't really be necessary to pass the prot in the
pmap_enter() flags, but it is certainly recommended.  if we really want
to say that it's required, I'd think it would be better to say that
pmap implementations should add the prot bits to the flags when they
see that PMAP_WIRED is set.  that would probably lead to fewer mistakes.

I think you're the one who's pushed the idea that we should go to extreme
lengths to avoid taking faults on wired pages, but I think that's more than
is really necessary.  all we really need for wired pages is that we should
not have to sleep in order to access them.  taking faults on wired pages is
ok (and will be necessary if we want to optimize fsync() like was recently
discussed here), but such faults will need to be handled by the pmap layer
and should not result in a call to uvm_fault().

-Chuck