On Sun, Sep 13, 2020 at 10:40:57AM +1000, Dave Chinner wrote: > > The reason the apache benchmark regresses is that it basically does a > > web server test with a single file ("test.html") that gets served by > > just mmap'ing it, and sending it out that way. Using lots of threads, > > and using lots of different mappings. So they *all* fault on the read > > of that page, and they *all* do that "lock page, check that the > > mapping is valid, insert page" dance. > > Hmmmm. So this is a typically a truncate race check, but this isn't > sufficient to protect the fault against all page invalidation races > as the page can be re-inserted into the same mapping at a different > page->index now within EOF. No it can't. find_get_page() returns the page with an elevated refcount. The page can't be reused until we call put_page(). It can be removed from the page cache, but can't go back to the page allocator until the refcount hits zero. > 5) filesystems will still need to be able to exclude page faults > over a file range while they directly manipulate file metadata to > change the user data in the file Yes, but they can do that with a lock inside ->readpage (and, for that matter in ->readahead()), so there's no need to take a lock for pages which are stable in cache.