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 32D77C433F5 for ; Fri, 4 Mar 2022 04:35:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A25A38D0002; Thu, 3 Mar 2022 23:35:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D5F08D0001; Thu, 3 Mar 2022 23:35:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C3B48D0002; Thu, 3 Mar 2022 23:35:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0035.hostedemail.com [216.40.44.35]) by kanga.kvack.org (Postfix) with ESMTP id 78DC58D0001 for ; Thu, 3 Mar 2022 23:35:09 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 33FA118179376 for ; Fri, 4 Mar 2022 04:35:09 +0000 (UTC) X-FDA: 79205439138.18.1D68131 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf26.hostedemail.com (Postfix) with ESMTP id 37BA5140005 for ; Fri, 4 Mar 2022 04:35:08 +0000 (UTC) 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-Rspamd-Server: rspam10 X-Rspam-User: X-Stat-Signature: fw37dxaacatbg3qds61j33p68r1noxww Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cP8Vf0Ea; spf=none (imf26.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Queue-Id: 37BA5140005 X-HE-Tag: 1646368508-721058 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 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?