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 E0F97C433F5 for ; Thu, 3 Mar 2022 01:56:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 64E0A8D0002; Wed, 2 Mar 2022 20:56:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5FC628D0001; Wed, 2 Mar 2022 20:56:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C4CD8D0002; Wed, 2 Mar 2022 20:56:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 3DA848D0001 for ; Wed, 2 Mar 2022 20:56:15 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 049F2208CB for ; Thu, 3 Mar 2022 01:56:14 +0000 (UTC) X-FDA: 79201409910.12.43C28A2 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) by imf08.hostedemail.com (Postfix) with ESMTP id 88248160003 for ; Thu, 3 Mar 2022 01:56:14 +0000 (UTC) Received: by mail-ot1-f54.google.com with SMTP id j3-20020a9d7683000000b005aeed94f4e9so3328083otl.6 for ; Wed, 02 Mar 2022 17:56:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version; bh=aA7IZZm4zyyhiO5xDecbrXdcaMTK2IMv+LtAOtcYUws=; b=UfNPa4oNTZc+bYm0qOheqHrAgDQa2Fbq+wftjdDYMglREQu0FOhiNinlLbGUmJMExn aElYwa/R7YjjdfXf3Akr8ghfT4Z4RwDK/HkmMj3Mt3fIKj44Jfe86teJrx89zX1TGG2Q Nhy6GKoafaXDSlNBfD3BJs8qXOtGkhtG67KoZLFSYkhq5mrsBSyzFrh1ctN1sPB8t+qx qBxjwQ7yIV875tlUD9HY9SbP6xA8cvZy8gISuXGoBBVL/L++u0Ck4y6NSUAkO/u5shPE E/PrhviHT3yBED6mlbRm/+3PY6rE6izYU5BPXv1gszN6HQ+UMypb1r0b1iHqW9T9KYRT q7tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version; bh=aA7IZZm4zyyhiO5xDecbrXdcaMTK2IMv+LtAOtcYUws=; b=5uaKCDIlrxwEXF6TOlGx4WHXPhdxpK7mN080rnLQcFFfpqNgAphRs3b7HU8qk4Fc27 ISXjcQrW8xWJgwxK5G4O44kgzpfo9l+6nZWxhqDgAKo1a/uKitIgwR3nSbhNL6VD1VOm HiWwoA4yjuRCvukqLG4pjCu9kX3zMMyeg6blAel6KO/EszItActKnwOlwd1ogmNjzNS5 XKBp4jLgFivhtPj9jvhpEaK4qDIjF7SkwvZjExQ9F23KGmB0c1NQR2FRLQwDTM+hb5dH +Qcoyqjzvi/WV4tC3j1s3jpJkqUI8E1qTREnzox1C3Armapv51vrlz3raEjR/Ni7YG/K daQQ== X-Gm-Message-State: AOAM532HflPhXjcKXQ2BoKE8VC6PhvcsgYBAQkIp9u4gu5YYbzfhYOlt bGt2LS0NsV3gH0JnHnsZIu0K/Q== X-Google-Smtp-Source: ABdhPJxmUisfwugiR3RBhee8kl5Y+/lwmVxZqlQOEK81+pR4wIF61AxDI5Jf4JZesOO1MZ+gewdBww== X-Received: by 2002:a05:6830:25cc:b0:5ad:7fe:3bbd with SMTP id d12-20020a05683025cc00b005ad07fe3bbdmr17009974otu.354.1646272573599; Wed, 02 Mar 2022 17:56:13 -0800 (PST) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id q13-20020a0568080ecd00b002d44f01f1d7sm323654oiv.40.2022.03.02.17.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 17:56:12 -0800 (PST) Date: Wed, 2 Mar 2022 17:56:11 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Andrew Morton cc: Matthew Wilcox , Nicholas Piggin , Yu Zhao , Yang Shi , Michal Hocko , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH mmotm] mm: delete __ClearPageWaiters() Message-ID: <351df0af-78f2-c20-2a6d-e5f978e5ca1@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 88248160003 X-Stat-Signature: yby6egnsuzmzj3ophdikkpxcs5ebbh3c Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=UfNPa4oN; spf=pass (imf08.hostedemail.com: domain of hughd@google.com designates 209.85.210.54 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1646272574-644337 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: 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()) 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 --- 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/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,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(). */ - 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)