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] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 3 Mar 2022 14:28:46 -0800 (PST)
From:   Hugh Dickins <hughd@...gle.com>
To:     David Hildenbrand <david@...hat.com>
cc:     Hugh Dickins <hughd@...gle.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Matthew Wilcox <willy@...radead.org>,
        Nicholas Piggin <npiggin@...il.com>,
        Yu Zhao <yuzhao@...gle.com>, Yang Shi <shy828301@...il.com>,
        Michal Hocko <mhocko@...e.com>, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org
Subject: Re: [PATCH mmotm] mm: delete __ClearPageWaiters()

On Thu, 3 Mar 2022, David Hildenbrand wrote:
> On 03.03.22 02:56, Hugh Dickins wrote:
> > The PG_waiters bit is not included in PAGE_FLAGS_CHECK_AT_FREE, and
> > vmscan.c's free_unref_page_list() callers rely on that not to generate
> > bad_page() alerts.  So __page_cache_release() and release_pages() (and
> > the presumably copy-and-pasted put_zone_device_private_or_public_page())

Hah, I'm showing my age there, or the patch's age: it's been rebranded
frequently since then, with linux-next calling it free_zone_device_page(),
as you kindly point out.  How long before it's free_zone_device_folio()?

> > are redundant and misleading to make a special point of clearing it (as
> > the "__" implies, it could only safely be used on the freeing path).
> > 
> > Delete __ClearPageWaiters().  Remark on this in one of the "possible"
> > comments in wake_up_page_bit(), and delete the superfluous comments.
> > 
> > Signed-off-by: Hugh Dickins <hughd@...gle.com>
> > ---
> > We've used this since 2018, and I see Yu Zhao posted similar in 2020:
> > https://lore.kernel.org/linux-mm/20200818184704.3625199-3-yuzhao@google.com/
> > I couldn't join in at that time, but think its reception was over-cautious.
> > 
> >  include/linux/page-flags.h |  2 +-
> >  mm/filemap.c               | 22 +++++++---------------
> >  mm/memremap.c              |  2 --
> >  mm/swap.c                  |  4 ----
> >  4 files changed, 8 insertions(+), 22 deletions(-)
> > 
> > --- a/mm/filemap.c
> > +++ b/mm/filemap.c
> > @@ -1179,24 +1179,16 @@ static void folio_wake_bit(struct folio *folio, int bit_nr)
> >  	}
> >  
> >  	/*
> > -	 * It is possible for other pages to have collided on the waitqueue
> > -	 * hash, so in that case check for a page match. That prevents a long-
> > -	 * term waiter
> > +	 * It's possible to miss clearing waiters here, when we woke our page
> > +	 * waiters, but the hashed waitqueue has waiters for other pages on it.
> >  	 *
> > -	 * It is still possible to miss a case here, when we woke page waiters
> > -	 * and removed them from the waitqueue, but there are still other
> > -	 * page waiters.
> > +	 * That's okay, it's a rare case. The next waker will clear it. Or,
> > +	 * it might be left set until the page is freed: when it's masked off
> > +	 * with others in PAGE_FLAGS_CHECK_AT_PREP, by free_pages_prepare().
> >  	 */
> 
> Does that also apply to ZONE_DEVICE pages via free_zone_device_page()?

I'm sure you could tell me a lot more about ZONE_DEVICE pages than I
could ever tell you.  But, if they don't ever reach the main page freer,
then they're in the same category as other pages not freed until reboot:
any clearing of left-behind PG_waiters will be done by the next waker,
not by reaching free_pages_prepare().  Does that really require special
mention of ZONE_DEVICE pages here?  Would I do better just to remove
the comment on PAGE_FLAGS_CHECK_AT_PREP being one of the clearers?

(I had to do a bit of research before answering: temporarily confused
about the role of PG_waiters, I worried that removing copy-and-pasted
__ClearPageWaiters from free_zone_device_page() might risk gradually
clogging up the hash queues with spuriously waited pages; no, nonsense,
it's just a matter of how efficient the next folio_unlock() will be.)

Hugh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ