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 E571EC433F5 for ; Fri, 25 Feb 2022 01:31:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA4628D0002; Thu, 24 Feb 2022 20:31:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E54D78D0001; Thu, 24 Feb 2022 20:31:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D437C8D0002; Thu, 24 Feb 2022 20:31:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id C4A698D0001 for ; Thu, 24 Feb 2022 20:31:16 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 875BE20FB9 for ; Fri, 25 Feb 2022 01:31:16 +0000 (UTC) X-FDA: 79179574152.07.04BD729 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf12.hostedemail.com (Postfix) with ESMTP id 9B4F140009 for ; Fri, 25 Feb 2022 01:31: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:To:From:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description; bh=bxUWNXJPmP2dqlG2R2ijTql/9SV3EFcmDkRPpJMxdmc=; b=Dhqn5x9/achbCcLtY66/uH3rnd tvCnjubomQ8obLO2PVh1TI/iUgi1WwXCjtCksCpIh8ObCEyqORtZxFgYH0y3vKr2tb3nxQH0iF9xJ 8Dxyc2zE0DhBofYkEgsc9/RWI9NJDSR5BP/fry0CcQl/ZdDMfJPE5YjJAyH2Dftyt/cOw8xbd8lIa waajnOcjc7foaCSteCPjqJYIDV6fTD0GEIS/yVlkn0WSv4OGHfKULCDOT1GYQhUq49sIWaXBmFRi5 ehc91XPgNi7JWaHPMiFtzYNT0N0jCViKssxzh6xfPFQjgfMnz9tDYyzc4ziXUjZKYePGAphyFgMrM ABrAZ2tQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nNPRt-005LW0-FA; Fri, 25 Feb 2022 01:31:09 +0000 Date: Fri, 25 Feb 2022 01:31:09 +0000 From: Matthew Wilcox To: 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> Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="Dhqn5x9/"; dmarc=none; spf=none (imf12.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 9B4F140009 X-Stat-Signature: yow111xagiowb91k7tcpiukmtubp8575 X-HE-Tag: 1645752675-481295 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. This is the patch that's causing ltp's readahead02 test to break. Haven't dug into why yet, but it happens without large folios, so I got something wrong. > diff --git a/mm/truncate.c b/mm/truncate.c > index b73c30c95cd0..d67fa8871b75 100644 > --- a/mm/truncate.c > +++ b/mm/truncate.c > @@ -287,7 +287,7 @@ int invalidate_inode_page(struct page *page) > return 0; > if (folio_test_dirty(folio) || folio_test_writeback(folio)) > return 0; > - if (page_mapped(page)) > + if (folio_ref_count(folio) > folio_nr_pages(folio) + 1) > return 0; > if (folio_has_private(folio) && !filemap_release_folio(folio, 0)) > return 0; > -- > 2.34.1 >