From: David Hildenbrand <david@redhat.com>
To: Hugh Dickins <hughd@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Matthew Wilcox <willy@infradead.org>,
Nicholas Piggin <npiggin@gmail.com>, Yu Zhao <yuzhao@google.com>,
Yang Shi <shy828301@gmail.com>, Michal Hocko <mhocko@suse.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH mmotm] mm: delete __ClearPageWaiters()
Date: Fri, 4 Mar 2022 18:25:49 +0100 [thread overview]
Message-ID: <90aafe84-fe7d-c70e-8e15-c222869f30fc@redhat.com> (raw)
In-Reply-To: <9dda55d5-eafa-3177-2a4c-32ccb7e146e3@google.com>
On 03.03.22 23:28, Hugh Dickins wrote:
> 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@google.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?
In this context we can consider ZONE_DEVICE pages just like any other
pages that, although getting freed, are not returned to the buddy, but
instead are returned to another pool. So PAGE_FLAGS_CHECK_AT_PREP won't
apply and free_pages_prepare() won't apply.
Another example would be hugetlb pages, that are returned to the hugetlb
pool, but not back to the buddy unless the huge page pool is shrunk.
So I feel like the underlying principle here is: we don't *care* if
PG_waiter is cleared when a page gets freed, because it will simply get
cleared by the next waker if it sticks around.
Then, I agree, we can just drop the comment regarding
PAGE_FLAGS_CHECK_AT_PREP and instead have something like
"
That's okay, it's a rare case and the next waker will just clear it.
Note that, depending on the page pool (buddy, ZONE_DEVICE, hugetlb), we
might clear the flag while freeing the page, however, this is not
required for correctness.
"
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2022-03-04 17:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-03 1:56 Hugh Dickins
2022-03-03 2:15 ` Yu Zhao
2022-03-03 8:54 ` David Hildenbrand
2022-03-03 22:28 ` Hugh Dickins
2022-03-03 22:41 ` Matthew Wilcox
2022-03-04 17:25 ` David Hildenbrand [this message]
2022-03-04 21:17 ` Hugh Dickins
2022-03-04 21:25 ` [PATCH mmotm v2] " Hugh Dickins
2022-03-07 8:41 ` David Hildenbrand
2022-03-07 20:17 ` Yang Shi
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=90aafe84-fe7d-c70e-8e15-c222869f30fc@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=npiggin@gmail.com \
--cc=shy828301@gmail.com \
--cc=willy@infradead.org \
--cc=yuzhao@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox