All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Soma Nakata <soma.nakata01@gmail.com>,
	linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/filemap: set folio->mapping to NULL before xas_store()
Date: Tue, 26 Mar 2024 22:50:50 +0000	[thread overview]
Message-ID: <ZgNRSvcohDoLj3G2@casper.infradead.org> (raw)
In-Reply-To: <20240326140533.a0d0041371e21540dd934722@linux-foundation.org>

On Tue, Mar 26, 2024 at 02:05:33PM -0700, Andrew Morton wrote:
> On Sat, 23 Mar 2024 06:04:54 +0900 Soma Nakata <soma.nakata01@gmail.com> wrote:
> > Functions such as __filemap_get_folio() check the truncation of
> > folios based on the mapping field. Therefore setting this field to NULL
> > earlier prevents unnecessary operations on already removed folios.
> > 
> > ...
> >
> > --- a/mm/filemap.c
> > +++ b/mm/filemap.c
> > @@ -139,11 +139,12 @@ static void page_cache_delete(struct address_space *mapping,
> >  
> >  	VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
> >  
> > +	folio->mapping = NULL;
> > +	/* Leave page->index set: truncation lookup relies upon it */
> > +
> >  	xas_store(&xas, shadow);
> >  	xas_init_marks(&xas);
> >  
> > -	folio->mapping = NULL;
> > -	/* Leave page->index set: truncation lookup relies upon it */
> >  	mapping->nrpages -= nr;
> >  }
> 
> Seems at least harmless, but I wonder if it can really make any
> difference.  Don't readers of folio->mapping lock the folio first?

I can't think of anywhere that doesn't ... most of the places that check
folio->mapping have "goto unlock" as the very next line.  I don't think
this patch accomplishes anything.

  reply	other threads:[~2024-03-26 22:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22 21:04 [PATCH] mm/filemap: set folio->mapping to NULL before xas_store() Soma Nakata
2024-03-26 21:05 ` Andrew Morton
2024-03-26 22:50   ` Matthew Wilcox [this message]
2024-03-26 22:52   ` Soma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZgNRSvcohDoLj3G2@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=soma.nakata01@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.