Subject: Re: loaning for read() of regular files
To: Chuck Silvers <chuq@chuq.com>
From: Stephan Uphoff <ups@tree.com>
List: tech-kern
Date: 02/16/2005 15:31:11
On Wed, 2005-02-16 at 12:31, Chuck Silvers wrote:
> On Wed, Feb 16, 2005 at 12:15:36PM -0500, Stephan Uphoff wrote:
> > On Tue, 2005-02-15 at 21:49, Chuck Silvers wrote:
> > > On Tue, Feb 15, 2005 at 05:00:09PM -0500, Stephan Uphoff wrote:
> > > > Hi Chuck,
> > > > 
> > > > looks great !
> > > > 
> > > > You may want to call pmap_remove for failed pmap_enter calls
> > > > (or remove PMAP_CANFAIL?) to prevent stale page table entries.
> > > 
> > > good point, it's not really specified whether a failed pmap_enter(PMAP_CANFAIL)
> > > that was replacing an existing mapping is required to remove the old mapping
> > > or not.  we appear to have different behaviour on different platforms.
> > > 
> > > I would say that it should always remove the old mapping, since otherwise
> > > the caller will have to take care of it explicitly anyway.  if everyone
> > > agrees on this, I'll clarify this in the manpage and see about fixing
> > > the implementations.
> > 
> > I kind of like the current behaviour (On some platforms :-( ?).
> > 
> > It allows trying to replace one wired mapping with another.
> > If pmap_enter fails the operation can be retried later with the old
> > mapping still intact.
> > 
> > Frank van der Linden requested that mappings must be changed atomically
> > (no time where no page is mapped in the VA) when I did some SMP fixes to
> > the i386 pmap.
> > I think he mentioned wired pages when he requested the change but this
> > was a long time ago.
> 
> well, the reason why PMAP_CANFAIL would fail is that it needs to allocate
> memory (such as for a page-table page or a pv entry) but there is no memory
> available.  if there was previous mapping, then the new mapping can reuse
> the resources that the old mapping was using, so it shouldn't fail.
> I think all the existing implementations can easily accomodate this
> (though some of them don't work this way currently), and it seems
> reasonable to assert that any pmap implementation could work this way.
> 
> so I think we can require both that a failed pmap_enter(PMAP_CANFAIL)
> should not leave an old mapping behind, and that entering a wired mapping
> on top of an existing wired mapping should be atomic as you describe
> and should never fail.

It adds a little complexity (at least to the manual page) and some ports
need to be fixed.

I have a tiny bit of a bad feeling about this but not nearly enough for
any real objections.

Stephan