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 59C99C433F5 for ; Fri, 25 Feb 2022 03:27:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E1D988D0003; Thu, 24 Feb 2022 22:27:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DA72D8D0001; Thu, 24 Feb 2022 22:27:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF9958D0003; Thu, 24 Feb 2022 22:27:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id A8A318D0001 for ; Thu, 24 Feb 2022 22:27:54 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 664A696F1D for ; Fri, 25 Feb 2022 03:27:54 +0000 (UTC) X-FDA: 79179868068.25.C2C41B0 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 6CCEA180004 for ; Fri, 25 Feb 2022 03:27:52 +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=c/iBllfX+pxhtCQ1NmE+ODFZ0uxqZ7F38CrDW8I3Tbs=; b=o0fr0YVRVSqN23KLwGLhxP1lDt w9nm8G83S55Zwe2f6Ui0zdhuqVlfnEqoNjddvs7eSDsKQl6FvzNgaMbZ3GLNwokPK/h63sV2mxRAR Kc627x1+F3qqMLSJ+eIWX/dLOqisC82Wu0DAQCZ88k3YLLWKdC1PNYMTo169V6ewf0wheKI6ARMlZ seWeEqH8D1ZJ72J+tyLoXsfvZlAdYUQyR9I2TQduqUUcOAoTYA7IjzlKxe1TmLyowpHLUUxg/5xw3 8TI9uK1r0qEW72lswk+AyqYt0u5FIRCItp/+6uNLq11iGtjVa6kt7+/UX65Wc5aKnttmySjZ1A1Mq +2KxXUfg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nNRGo-005QNm-FO; Fri, 25 Feb 2022 03:27:50 +0000 Date: Fri, 25 Feb 2022 03:27:50 +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: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 6CCEA180004 X-Stat-Signature: 176cswzqiputkx41xusxjpkzpyeeepwk Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=o0fr0YVR; spf=none (imf06.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-Rspam-User: X-HE-Tag: 1645759672-212039 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 Fri, Feb 25, 2022 at 01:31:09AM +0000, Matthew Wilcox 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. > > 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. This fixes it: +++ b/mm/truncate.c @@ -288,7 +288,8 @@ int invalidate_inode_page(struct page *page) if (folio_test_dirty(folio) || folio_test_writeback(folio)) return 0; /* The refcount will be elevated if any page in the folio is mapped */ - if (folio_ref_count(folio) > folio_nr_pages(folio) + 1) + if (folio_ref_count(folio) > + folio_nr_pages(folio) + 1 + folio_has_private(folio)) return 0; if (folio_has_private(folio) && !filemap_release_folio(folio, 0)) return 0; Too late for today's -next, but I'll push it out tomorrow.