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 4CDB2C433F5 for ; Fri, 4 Mar 2022 17:25:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D3EB78D0002; Fri, 4 Mar 2022 12:25:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CC6568D0001; Fri, 4 Mar 2022 12:25:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B40008D0002; Fri, 4 Mar 2022 12:25:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0190.hostedemail.com [216.40.44.190]) by kanga.kvack.org (Postfix) with ESMTP id 9DC1A8D0001 for ; Fri, 4 Mar 2022 12:25:55 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 6271A181AF5CA for ; Fri, 4 Mar 2022 17:25:55 +0000 (UTC) X-FDA: 79207381470.29.9437F60 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 782DF40015 for ; Fri, 4 Mar 2022 17:25:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646414753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZPOyywODPUcB/Gl9wy52x834Jjxc19V6YX/YVgiSHj0=; b=h5q6Nu+k9ztz1CEjXGNghy01Y5R6kIV6sv+RLX+vYOrptLEjcaPG1/wr8BrVa+1y4gjMzE olDdTKSmN7SCibciLMYNufmdyQ3vrJnXTZZeqRFZNmdtEbIQO6j87c/jzh8wrRwCwhr1wW NA5vu6v68EzTo9bh0jY8Skdt/yT6vDc= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-586-rvenWIrlN_e-EBdbF2uBLw-1; Fri, 04 Mar 2022 12:25:52 -0500 X-MC-Unique: rvenWIrlN_e-EBdbF2uBLw-1 Received: by mail-wm1-f70.google.com with SMTP id 20-20020a05600c231400b00389886f6b23so562157wmo.6 for ; Fri, 04 Mar 2022 09:25:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=ZPOyywODPUcB/Gl9wy52x834Jjxc19V6YX/YVgiSHj0=; b=vTtbmIk0aoxgf/65tSsjyw8n71yOqHWBPRaDQG9aTZjO2pDVhmjh2xbuDdvdPTWZ+a RVKBmAe+EKcKLd/4QI/7+kYTKJx05qdS/0RLLJ7lqtpXLCDQfrnDCNOaXGob35oScgZb Sa7aE+BfpNh56Axa75ZIP9KrhHq8wkX7uG0f1qd1mdh4pI69ACXT8eO4TIAx0YBlyXTn F8JCDTU9tyKqJOw08gpfgzaCY7nFrTIHVjLjLtNr0HV6fcQpjWSmIAf0YLDY/LSrF071 c2cAqs5kZI3P/MXWsGcpKSv0Oa5CqY2xxFWDAvMgLvBTnodGWRFihN1dC4dTO7cYPi8/ S1uQ== X-Gm-Message-State: AOAM530UhrPB4+Ad1Z5sxa8oXqs85DD/Sl6Xbg73Q0mVUqkfB4Sbo4t+ gQm70/J6kUC2vYLYwvoKRUW1H65AJb866DHgO6mWdN5IeCz0XH0PXZwreWig7UksKcKF/xFlf/p 9Wi0FqnnIxoU= X-Received: by 2002:a05:6000:1a88:b0:1f1:d8df:89d3 with SMTP id f8-20020a0560001a8800b001f1d8df89d3mr616958wry.321.1646414751390; Fri, 04 Mar 2022 09:25:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxGy5kZMQf6JCuBlEj/Ql0LQkTBALE9clC0CFLC5pel+5apqkghxKJLoJBkpnmtZWrdAqE4Ew== X-Received: by 2002:a05:6000:1a88:b0:1f1:d8df:89d3 with SMTP id f8-20020a0560001a8800b001f1d8df89d3mr616938wry.321.1646414751101; Fri, 04 Mar 2022 09:25:51 -0800 (PST) Received: from ?IPV6:2003:cb:c709:4600:7355:df2c:f6ff:94d? (p200300cbc70946007355df2cf6ff094d.dip0.t-ipconnect.de. [2003:cb:c709:4600:7355:df2c:f6ff:94d]) by smtp.gmail.com with ESMTPSA id o204-20020a1ca5d5000000b0038331f2f951sm15188818wme.0.2022.03.04.09.25.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Mar 2022 09:25:50 -0800 (PST) Message-ID: <90aafe84-fe7d-c70e-8e15-c222869f30fc@redhat.com> Date: Fri, 4 Mar 2022 18:25:49 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 To: Hugh Dickins Cc: Andrew Morton , Matthew Wilcox , Nicholas Piggin , Yu Zhao , Yang Shi , Michal Hocko , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <351df0af-78f2-c20-2a6d-e5f978e5ca1@google.com> <9dda55d5-eafa-3177-2a4c-32ccb7e146e3@google.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH mmotm] mm: delete __ClearPageWaiters() In-Reply-To: <9dda55d5-eafa-3177-2a4c-32ccb7e146e3@google.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 782DF40015 X-Stat-Signature: 84ggd6xhjmgynw6aq9h5j8xbm3xk1grd Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=h5q6Nu+k; spf=none (imf17.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-HE-Tag: 1646414754-933297 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 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 >>> --- >>> 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