Re: [PATCH v2 3/4] mm/memory: convert do_shared_fault() to folios

From: Matthew Wilcox
Date: Wed Jul 05 2023 - 16:19:38 EST


On Wed, Jul 05, 2023 at 01:16:25PM -0700, Sidhartha Kumar wrote:
> On 7/5/23 1:13 PM, Matthew Wilcox wrote:
> > On Wed, Jul 05, 2023 at 12:43:34PM -0700, Sidhartha Kumar wrote:
> > > /*
> > > * Check if the backing address space wants to know that the page is
> > > * about to become writable
> > > */
> > > if (vma->vm_ops->page_mkwrite) {
> > > - unlock_page(vmf->page);
> > > + folio_unlock(folio);
> > > tmp = do_page_mkwrite(vmf);
> > > if (unlikely(!tmp ||
> > > (tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) {
> > > - put_page(vmf->page);
> > > + folio_put(folio);
> >
> > This is _probably_ OK. However, do_page_mkwrite() calls
> > vm_ops->page_mkwrite(), and I think it's theoretically possible for the
> > driver to replace vmf->page with a different one. The chance of them
> > actually doing that is pretty low (particularly if they return error or
> > nopage!), but I'm going to flag it just in case it comes up.
> >
> > Also, should we pass a folio to do_page_mkwrite() instead of having it
> > extract the folio from vmf->page?
>
> I can take a look at doing this in a follow-up patch.
> >
> > Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
>
> Did you mean for this to be reviewed-by?

Uh, yes. Maybe I need to get more rest ...