From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07166C433F5 for ; Mon, 7 Mar 2022 20:17:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 719CB8D0002; Mon, 7 Mar 2022 15:17:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C8D18D0001; Mon, 7 Mar 2022 15:17:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 56A288D0002; Mon, 7 Mar 2022 15:17:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 4A33D8D0001 for ; Mon, 7 Mar 2022 15:17:48 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 23F1D1205AC for ; Mon, 7 Mar 2022 20:17:48 +0000 (UTC) X-FDA: 79218700974.05.AA226B8 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by imf08.hostedemail.com (Postfix) with ESMTP id 917BE16000B for ; Mon, 7 Mar 2022 20:17:47 +0000 (UTC) Received: by mail-pg1-f180.google.com with SMTP id e6so14528638pgn.2 for ; Mon, 07 Mar 2022 12:17:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IE33MNFmcLiUfT2SeIR7Z5A5TrPI+9cgpazyT5PX0I0=; b=eOE+cxc6Xuwvo/+Q/JI3RL1AAJ0ynlHNo7aZOoZlcDphD//vTauuwndlbyD+2auxNi 8dF4w1Qgur+7hWFsJRzL3svUsN/5W6WURdwEbGeoF9IGq9/IpR1XpliFS3DACsmNVnTD DjazJfNsoCwKbjLF48asNgmK92mT8btEb01LqyW63vHlXS2q6bdR/0xI1kT7PehWFjUR jJ1CnyX6GzJqXWKvppEt/vuX/+Zw6Cp3O6gnUTDZp1tk+myp6mww0FksXYQguRzRsej/ S6adSSbrjdYeEi3JJyPQV/N6BqkK4aPX2NiUb4vJuzr8aja4HBNx+4N+Ja2rGKY0D3Nq vxQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IE33MNFmcLiUfT2SeIR7Z5A5TrPI+9cgpazyT5PX0I0=; b=YJ2JY1nWViqaf2ANLUIOpUp0mqx2NX93xrS3wIOq5nqgCQ1VLBIIczAR78Yz39NGLt R8pMuoSPPYK6W5OsrZQbHRnx0AwdHA2pcOmDnUa5AUz0ctdSL27i+9iN3cFj/eusFiiu 7jC9h6PY5SdnF/t8QdM/R/aP3LB2/VYn4zVuqwh4y+UdqvYflJlD6zeDKJpuVuodkCVF au+MjNdKPRRj2qqlhM/M5wIfbGrpgzfIXOGQ5DxZiHJqDd/10vGjcMCBiktdypITUeDk IC6LufXeQ555PJV8MYMPGjTp6ec3qVerQKh6GAV3cP8z73AIBuVw7OceYuptXZkUyP+l 67Eg== X-Gm-Message-State: AOAM532tEENYtny+CoJ1xl8Dt7SNz5saza9RwLZfC+3rB9Mw/29i5qhs K6YD6/vTbP4BMis6XFy+9VDy5Ns6cq1rqpHObPQ= X-Google-Smtp-Source: ABdhPJwKfUQp7AdXNaIKZ0xvrWClL+7EBzqrC5z1DqpF0HBrOa+twOzmmANBNj4/M2wVkJ9NkWyQzngBA5G47/dcsvE= X-Received: by 2002:a63:571e:0:b0:378:9f08:129b with SMTP id l30-20020a63571e000000b003789f08129bmr11170307pgb.75.1646684266434; Mon, 07 Mar 2022 12:17:46 -0800 (PST) MIME-Version: 1.0 References: <351df0af-78f2-c20-2a6d-e5f978e5ca1@google.com> <9dda55d5-eafa-3177-2a4c-32ccb7e146e3@google.com> <90aafe84-fe7d-c70e-8e15-c222869f30fc@redhat.com> <6e5262ff-8596-a86-7388-eddb2b2c53c@google.com> <3eafa969-5b1a-accf-88fe-318784c791a@google.com> In-Reply-To: <3eafa969-5b1a-accf-88fe-318784c791a@google.com> From: Yang Shi Date: Mon, 7 Mar 2022 12:17:34 -0800 Message-ID: Subject: Re: [PATCH mmotm v2] mm: delete __ClearPageWaiters() To: Hugh Dickins Cc: Andrew Morton , David Hildenbrand , Matthew Wilcox , Nicholas Piggin , Yu Zhao , Michal Hocko , Linux Kernel Mailing List , Linux MM Content-Type: text/plain; charset="UTF-8" X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 917BE16000B X-Stat-Signature: ygjgoo1gfogrfxzgpdfcxkq591moti8b Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=eOE+cxc6; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of shy828301@gmail.com designates 209.85.215.180 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-HE-Tag: 1646684267-149271 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Mar 4, 2022 at 1:25 PM 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(), put_pages_list() and > release_pages() (and presumably copy-and-pasted free_zone_device_page()) > 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 folio_wake_bit(), and delete the superfluous comments. > > Signed-off-by: Hugh Dickins > Tested-by: Yu Zhao > --- > v2: Add Tested-by from Yu Zhao. > Update to latest function names in the commit message. > Reword comment in folio_wake_bit() per David Hildenbrand. Reviewed-by: Yang Shi > > include/linux/page-flags.h | 2 +- > mm/filemap.c | 23 ++++++++--------------- > mm/memremap.c | 2 -- > mm/swap.c | 4 ---- > 4 files changed, 9 insertions(+), 22 deletions(-) > > --- a/include/linux/page-flags.h > +++ b/include/linux/page-flags.h > @@ -481,7 +481,7 @@ static unsigned long *folio_flags(struct folio *folio, unsigned n) > TESTSETFLAG_FALSE(uname, lname) TESTCLEARFLAG_FALSE(uname, lname) > > __PAGEFLAG(Locked, locked, PF_NO_TAIL) > -PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) __CLEARPAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) > +PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) > PAGEFLAG(Error, error, PF_NO_TAIL) TESTCLEARFLAG(Error, error, PF_NO_TAIL) > PAGEFLAG(Referenced, referenced, PF_HEAD) > TESTCLEARFLAG(Referenced, referenced, PF_HEAD) > --- a/mm/filemap.c > +++ b/mm/filemap.c > @@ -1179,24 +1179,17 @@ 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. > + * That's okay, it's a rare case. The next waker will clear 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. > + * Note that, depending on the page pool (buddy, hugetlb, ZONE_DEVICE, > + * other), the flag may be cleared in the course of freeing the page; > + * but that is not required for correctness. > */ > - if (!waitqueue_active(q) || !key.page_match) { > + if (!waitqueue_active(q) || !key.page_match) > folio_clear_waiters(folio); > - /* > - * 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. > - * > - * That's okay, it's a rare case. The next waker will clear it. > - */ > - } > + > spin_unlock_irqrestore(&q->lock, flags); > } > > --- a/mm/memremap.c > +++ b/mm/memremap.c > @@ -487,8 +487,6 @@ void free_zone_device_page(struct page *page) > if (WARN_ON_ONCE(!page->pgmap->ops || !page->pgmap->ops->page_free)) > return; > > - __ClearPageWaiters(page); > - > mem_cgroup_uncharge(page_folio(page)); > > /* > --- a/mm/swap.c > +++ b/mm/swap.c > @@ -97,7 +97,6 @@ static void __page_cache_release(struct page *page) > mod_zone_page_state(page_zone(page), NR_MLOCK, -nr_pages); > count_vm_events(UNEVICTABLE_PGCLEARED, nr_pages); > } > - __ClearPageWaiters(page); > } > > static void __put_single_page(struct page *page) > @@ -152,7 +151,6 @@ void put_pages_list(struct list_head *pages) > continue; > } > /* Cannot be PageLRU because it's passed to us using the lru */ > - __ClearPageWaiters(page); > } > > free_unref_page_list(pages); > @@ -966,8 +964,6 @@ void release_pages(struct page **pages, int nr) > count_vm_event(UNEVICTABLE_PGCLEARED); > } > > - __ClearPageWaiters(page); > - > list_add(&page->lru, &pages_to_free); > } > if (lruvec)