lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAOpe7Sc1PByy+c9V4eWH=fo9_zjgNGw1D6TWAiZ9-ujKgNdq_w@mail.gmail.com>
Date: Wed, 27 Mar 2024 07:52:51 +0900
From: Soma <soma.nakata01@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-mm@...ck.org, "Matthew Wilcox (Oracle)" <willy@...radead.org>, linux-fsdevel@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/filemap: set folio->mapping to NULL before xas_store()

On Wed, Mar 27, 2024 at 6:05 AM Andrew Morton <akpm@...ux-foundation.org> wrote:
>
> On Sat, 23 Mar 2024 06:04:54 +0900 Soma Nakata <soma.nakata01@...il.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?

Yes, the reader locks the folio.
Only __filemap_remove_folio() calls page_cache_delete(),
and it says the caller has to lock the folio or make sure
that usage is safe. In the latter case, this patch improves
efficiency a little bit.
However, I found that there is not any latter case actually,
so discard it or apply, also to make the order of operations in
page_cache_delete() and page_cache_delete_batch() the same
for a cleanup.
Thanks,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ