Re: [PATCH] zap_pte_range should not mark non-uptodate pages dirty

From: Andrew Morton
Date: Thu Oct 21 2004 - 18:55:42 EST


Andrea Arcangeli <andrea@xxxxxxxxxx> wrote:
>
> On Thu, Oct 21, 2004 at 04:02:33PM -0700, Andrew Morton wrote:
> > Andrea Arcangeli <andrea@xxxxxxxxxx> wrote:
> > >
> > > On Thu, Oct 21, 2004 at 02:45:31PM -0700, Andrew Morton wrote:
> > > > Maybe we should revisit invalidate_inode_pages2(). It used to be an
> > > > invariant that "pages which are mapped into process address space are
> > > > always uptodate". We broke that (good) invariant and we're now seeing
> > > > some fallout. There may be more.
> > >
> > > such invariant doesn't exists since 2.4.10. There's no way to get mmaps
> > > reload data from disk without breaking such an invariant.
> >
> > There are at least two ways:
> >
> > a) Set a new page flag in invalidate, test+clear that at fault time
>
> What's the point of adding a new page flag when the invariant
> !PageUptodate && page_mapcount(page) already provides the information?

Step back and think about this. What earthly sense is there in permitting
userspace access to non uptodate pages?

None. It's completely wrong and the invariant was a good one. We broke it
by introducing some kluge to force new I/O when someone does a new fault
against the page.

(A new PG_needs_rereading flag isn't sufficient btw - we'd also need
BH_Needs_Rereading and associated code. ug.)

> > b) shoot down all pte's mapping the locked page at invalidate time, mark the
> > page not uptodate.
>
> invalidate should run fast, I didn't enforce coherency or it'd hurt too
> much the O_DIRECT write if something is mapped, we only allow buffered
> read against O_DIRECT write to work coherently, the mmap coherency has
> never been provided to avoid having to search for vmas in the prio_tree
> for every single write to an inode.

I don't get it. invalidate has the pageframe. All it need to do is to
lock the page, examine mapcount and if it's non-zero, do the shootdown.
The only way in which we would be performing the shootdown a significant
number of times would be if someone was repeatedly faulting the thing back
in anyway, and in that case the physical I/O cost would dominate. Where's
the performance overhead??

Plus it makes the currently incorrect code correct for existing mmaps.

Plus it avoids the idiotic situation of having non uptodate pages
accessible to user processes.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/