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 20DE5C433EF for ; Tue, 15 Feb 2022 08:33:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B356A6B007D; Tue, 15 Feb 2022 03:33:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AE4C16B007E; Tue, 15 Feb 2022 03:33:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D4406B0080; Tue, 15 Feb 2022 03:33:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id 8FFFD6B007D for ; Tue, 15 Feb 2022 03:33:03 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 4848A180AD837 for ; Tue, 15 Feb 2022 08:33:03 +0000 (UTC) X-FDA: 79144349046.30.4CA031B Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf09.hostedemail.com (Postfix) with ESMTP id EA525140007 for ; Tue, 15 Feb 2022 08:33:01 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4JyZ7r5WPSzccm8; Tue, 15 Feb 2022 16:31:52 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Tue, 15 Feb 2022 16:32:57 +0800 Subject: Re: [PATCH 04/10] mm/truncate: Replace page_mapped() call in invalidate_inode_page() To: "Matthew Wilcox (Oracle)" , , References: <20220214200017.3150590-1-willy@infradead.org> <20220214200017.3150590-5-willy@infradead.org> From: Miaohe Lin Message-ID: <7e9447a6-f456-82ed-c9cd-c7075d258547@huawei.com> Date: Tue, 15 Feb 2022 16:32:57 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20220214200017.3150590-5-willy@infradead.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: EA525140007 X-Stat-Signature: zmcq1sxf9rnrj1ohhxpdexnbzm656jfy X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-HE-Tag: 1644913981-361908 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 2022/2/15 4:00, 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. > > Signed-off-by: Matthew Wilcox (Oracle) > --- LGTM. Thanks. Reviewed-by: Miaohe Lin > mm/truncate.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > 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; >