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 E343EC433EF for ; Tue, 15 Feb 2022 07:19:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 804B16B0078; Tue, 15 Feb 2022 02:19:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B4116B007D; Tue, 15 Feb 2022 02:19:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A36B6B007E; Tue, 15 Feb 2022 02:19:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 5ACEC6B0078 for ; Tue, 15 Feb 2022 02:19:25 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 12C6F90F6D for ; Tue, 15 Feb 2022 07:19:25 +0000 (UTC) X-FDA: 79144163490.11.BF4ED60 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf30.hostedemail.com (Postfix) with ESMTP id A4F5780004 for ; Tue, 15 Feb 2022 07:19:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; 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=vsvPeaqbWAUL4QGK7CM5RVivmBescAdGUwdMQ3Q2U6c=; b=TS0uS0b1yENg5Dbq7pS942lnrK bpjQjMtVZZEuPtj06ePwsMUTIp6BDXhIevsW+5wrjw/ANDGKtitW99nQYE5OHzhMB1zKjwvo9TjEJ RmAb6S5a5rrBZxZdQw8aRXhXvGrYQTCB1N9u4NhNDZs5otcfFQe+RHT36ANT43QOwiYBHQJ9J6XKN kGPQnfXFNm+RFBIcArnXxQVSLlJ/TsHM8h1unfKnwgBjVzoTxLK2WEOoD67+Sii4oaLTQz0q0KAKR LRVHfIpeqmSglPGqkAbrdRnpcXsdTQ9J0ReQVYVmAzkE4vQyVO7zXlJarA8R9ZlQLvv+9wOcvAjH0 HUzWKZNA==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJs7P-0017MR-0p; Tue, 15 Feb 2022 07:19:23 +0000 Date: Mon, 14 Feb 2022 23:19:22 -0800 From: Christoph Hellwig To: "Matthew Wilcox (Oracle)" 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: <20220214200017.3150590-5-willy@infradead.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: A4F5780004 X-Stat-Signature: mwpz486jmoecwe7o3p6z9crhspc8sf6y Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=TS0uS0b1; spf=none (imf30.hostedemail.com: domain of BATV+0ca47b70804f6e632d40+6750+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+0ca47b70804f6e632d40+6750+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none X-HE-Tag: 1644909564-729350 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 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.