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 7FE16C433F5 for ; Tue, 15 Feb 2022 20:12:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED6446B007B; Tue, 15 Feb 2022 15:12:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E85DE6B007D; Tue, 15 Feb 2022 15:12:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D4D2B6B007E; Tue, 15 Feb 2022 15:12:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0030.hostedemail.com [216.40.44.30]) by kanga.kvack.org (Postfix) with ESMTP id C2D3D6B007B for ; Tue, 15 Feb 2022 15:12:16 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7C7D395262 for ; Tue, 15 Feb 2022 20:12:16 +0000 (UTC) X-FDA: 79146111072.12.0C6FB43 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id 2663E180008 for ; Tue, 15 Feb 2022 20:12:15 +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=sXm/DHXdyNxnI4eHPXlB/RiETdyus6Zo0rV31LImf4Y=; b=Y3b2//SuYlBMtEXImCJWF+qfQa M3BX60KtpXmwLzD9lSOomVBmbK80p0PpN/4/uM81Oai3uySyxtzK6+UsIb5q43fAZFjot/4GZoS4N gBXPzM5IkshUpF/Hs9hjL0txrRSbu2OLBIHK8uZ66p1kwns2eQtRmqrIYAESyUm5zAbYpqyt9Hx8I aYZhHwwk4wyGbXh9KkHrR84xTEh2pGdf6HVydU6GbDCE97qPHgRQzJdDuDm8lUAXmhG7WFzZKrFC3 6QeYkKVbL8zBUrdNm+oJ9EPvY2b0UF6F0L7HH90nCZJHQe6BShT7cNQfUZeMrB6N5UuA5+vqjAyw+ osylwXVg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nK4BJ-00E8rS-2b; Tue, 15 Feb 2022 20:12:13 +0000 Date: Tue, 15 Feb 2022 20:12:13 +0000 From: Matthew Wilcox To: Christoph Hellwig Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 04/10] mm/truncate: Replace page_mapped() call in invalidate_inode_page() Message-ID: References: <20220214200017.3150590-1-willy@infradead.org> <20220214200017.3150590-5-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 2663E180008 X-Stat-Signature: imcpw6tj76wxxwksak5uawq4suxiimt9 X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="Y3b2//Su"; dmarc=none; spf=none (imf24.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1644955935-430169 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 Mon, Feb 14, 2022 at 11:19:22PM -0800, Christoph Hellwig wrote: > On Mon, Feb 14, 2022 at 08:00:11PM +0000, Matthew Wilcox (Oracle) wrote: > > folio_mapped() is expensive because it has to check each page's mapcount > > field. A cheaper check is whether there are any extra references to > > the page, other than the one we own and the ones held by the page cache. > > The call to remove_mapping() will fail in any case if it cannot freeze > > the refcount, but failing here avoids cycling the i_pages spinlock. > > I wonder if something like this should also be in a comment near > the check in the code. /* The refcount will be elevated if any page in the folio is mapped */ is what I've added for now.