Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1667259pxm; Fri, 4 Mar 2022 00:50:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzuawycrtMbyvRo3pVdxGQHJcjD8pYnbDO6uru0A+wid66yUcmWelKIoxYvMVckFldd4Zeg X-Received: by 2002:a17:90b:240f:b0:1b8:e0b1:9667 with SMTP id nr15-20020a17090b240f00b001b8e0b19667mr9618335pjb.244.1646383849535; Fri, 04 Mar 2022 00:50:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646383849; cv=none; d=google.com; s=arc-20160816; b=m8aMU/vPDo61LIxf+tNJcmeF1tNF1shiELDdBrIq4Pa9wfPPwOSPzGjOKVO1f8jnF8 J7p2LGtz2L0UmPctDRvmXlLBtlGUtzLCkv+KWW5ZuVbzuG+wnsEhKJDQe0A3SSP6JdOu 4x38n3tVhg1yFLFdbsCTEUeHXKHMNoobEzJYt4mvRgOK3oVplXQcgcNpn5FbcVAd8erN OfGT5HZMNjUBUAnqb45MtLEUuCnE3+on6ovRtTngiVANwUmDu0gOj5n5Eu4HUb6bT7p7 ddpHcP7kPrPgVHX6QDEzTCxbkRZwF3c7/ER/qxar1NQAVXVzjt/NCX326XCFD4WOT1Pf 5kBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=o8PNL9ZIwccsqEW2LF/MiptJ7ri8E0HFY89rO2s9DaI=; b=kZQc9hO/HRaTQDa1KnWYEvIHdoM1pT7UL6r3vbaBqX8dv7BMQMEQJd1NQfNYcnF8Nv jJe2FNWgfp1d4gDFKc90L8M4S+8SmDautMebzg1vcgNAJ4Zdl3DsuNdqLE3UyfQujFYu vGrAhw8FnAZl05q+sOIX5GKb+gnfJm467OC2v3+AlO541YjbnatIRT+5v99++IjUpKCG lHErkQwirhwJO9VF16VEkI8F2MGfv2d/I/oqss3VXd+9vGJRE5h9vroRb2yoMfrNaKK7 5JKFtnhkJjnarlGoHIWU8tUmm1jIBDF6YcAbquw7yghXYes6IiBsSaA9W7PhOchgdPl6 rViQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cP8Vf0Ea; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z93-20020a17090a6d6600b001bef22367ddsi4255674pjj.162.2022.03.04.00.50.33; Fri, 04 Mar 2022 00:50:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cP8Vf0Ea; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236451AbiCDEf7 (ORCPT + 99 others); Thu, 3 Mar 2022 23:35:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232431AbiCDEf4 (ORCPT ); Thu, 3 Mar 2022 23:35:56 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59C8D17CC5F for ; Thu, 3 Mar 2022 20:35:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=o8PNL9ZIwccsqEW2LF/MiptJ7ri8E0HFY89rO2s9DaI=; b=cP8Vf0EaQl8V+qJsxxrzil+nbY kyyllCQIOP9fXghpU2YnWbNV8R//Gwynqi3tfZC1lwb7JDlNCXh3eQnO3rITMtuC3yIJjug8zQp8/ hKZhqCXN2Uui3RMoUb/8Me7g7bJibYoggbbiXsap/AYDSsXuhonsjRo4udctqxuJeBo6b8PDnMhLs iP4xkmPCfYzmF8FshO5IYlmtHZuY46ib3shUnTznsab0xV5ucRwKuhgftCYyALvGf1aJRITJGROJk JCpgNCVEG6o6UBgPVfr/frqNpfaHjsHm6WfOHey7FjNoop3avRdM0mtF0rW/fQnE1wvc8VCN9qqmR sGyFWdhQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nPzei-00CI7B-It; Fri, 04 Mar 2022 04:35:04 +0000 Date: Fri, 4 Mar 2022 04:35:04 +0000 From: Matthew Wilcox To: Hugh Dickins Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH mmotm] mm: filemap_unaccount_folio() large skip mapcount fixup Message-ID: References: <879c4426-4122-da9c-1a86-697f2c9a083@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <879c4426-4122-da9c-1a86-697f2c9a083@google.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 03, 2022 at 08:21:19PM -0800, Hugh Dickins wrote: > The page_mapcount_reset() when folio_mapped() while mapping_exiting() > was devised long before there were huge or compound pages in the cache. > It is still valid for small pages, but not at all clear what's right to > check and reset on large pages. Just don't try when folio_test_large(). Thanks for bringing this up! I was really unsure about this chunk of code when converting unaccount_page_cache_page() to filemap_unaccount_folio(). Part of me wants to just delete the whole thing. I'm unconvinced by the argument; surely it's better to leak memory than perhaps reuse a page which should not have been freed yet? Also, the code doesn't take into account that folio_mapped() is freaking expensive for THP (512 cache lines, blowing away 32kB of your L1 cache!), and we may as well calculate folio_mapcount() while we're doing it. Do you see this report often on machines that don't have VM_BUG_ON_FOLIO() enabled?