Re: [RFC PATCH] mm: Replace ->launder_folio() with flush and wait
From: David Howells
Date: Thu Mar 07 2024 - 03:27:06 EST
Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:
> commit e3db7691e9f3dff3289f64e3d98583e28afe03db
> Author: Trond Myklebust <Trond.Myklebust@xxxxxxxxxx>
> Date: Wed Jan 10 23:15:39 2007 -0800
>
> [PATCH] NFS: Fix race in nfs_release_page()
>...
> invalidate_inode_pages2() may find the dirty bit has been set on a page
> owing to the fact that the page may still be mapped after it was locked.
> Only after the call to unmap_mapping_range() are we sure that the page
> can no longer be dirtied.
Is that last sentence even true? It evicts folios from the TLB and/or
pagetables, but it doesn't actually trim any mmap made - in which case,
userspace is perfectly at liberty to regenerate and dirty the folio the moment
the folio is removed from the page tables. Otherwise DIO-to/from-mmap will
deadlock.
> but my belief is that we should be able to get rid of it.
I think you're probably correct. The best we can do, I think, is to preface
any call to invalidate_inode_pages2() with a flush-and-wait over the same
range.
David