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 4444AC433F5 for ; Tue, 15 Feb 2022 09:37:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5CE46B007D; Tue, 15 Feb 2022 04:37:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D0C936B007E; Tue, 15 Feb 2022 04:37:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BFC3E6B0080; Tue, 15 Feb 2022 04:37:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0098.hostedemail.com [216.40.44.98]) by kanga.kvack.org (Postfix) with ESMTP id B18236B007D for ; Tue, 15 Feb 2022 04:37:53 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 782829008C for ; Tue, 15 Feb 2022 09:37:53 +0000 (UTC) X-FDA: 79144512426.27.547F28A Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf15.hostedemail.com (Postfix) with ESMTP id 3E6BAA0005 for ; Tue, 15 Feb 2022 09:37:52 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4JybZh3Frxzccxy; Tue, 15 Feb 2022 17:36:44 +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 17:37:49 +0800 Subject: Re: [PATCH 09/10] mm/truncate: Combine invalidate_mapping_pagevec() and __invalidate_mapping_pages() To: "Matthew Wilcox (Oracle)" , , References: <20220214200017.3150590-1-willy@infradead.org> <20220214200017.3150590-10-willy@infradead.org> From: Miaohe Lin Message-ID: <54cc232e-9eb9-efbf-2f93-e23cfa3d6c36@huawei.com> Date: Tue, 15 Feb 2022 17:37:49 +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-10-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 Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam07 X-Rspam-User: X-Rspamd-Queue-Id: 3E6BAA0005 X-Stat-Signature: pwqw5rrzhxpkxyxn7bcm3ped6h7hhkr5 X-HE-Tag: 1644917872-905640 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: > We can save a function call by combining these two functions, which > are identical except for the return value. Also move the prototype > to mm/internal.h. > > Signed-off-by: Matthew Wilcox (Oracle) LGTM. Thanks. Reviewed-by: Miaohe Lin > --- > include/linux/fs.h | 4 ---- > mm/internal.h | 2 ++ > mm/truncate.c | 32 +++++++++++++------------------- > 3 files changed, 15 insertions(+), 23 deletions(-) > > diff --git a/include/linux/fs.h b/include/linux/fs.h > index e2d892b201b0..85c584c5c623 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -2749,10 +2749,6 @@ extern bool is_bad_inode(struct inode *); > unsigned long invalidate_mapping_pages(struct address_space *mapping, > pgoff_t start, pgoff_t end); > > -void invalidate_mapping_pagevec(struct address_space *mapping, > - pgoff_t start, pgoff_t end, > - unsigned long *nr_pagevec); > - > static inline void invalidate_remote_inode(struct inode *inode) > { > if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || > diff --git a/mm/internal.h b/mm/internal.h > index d886b87b1294..6bbe40a1880a 100644 > --- a/mm/internal.h > +++ b/mm/internal.h > @@ -102,6 +102,8 @@ int truncate_inode_folio(struct address_space *mapping, struct folio *folio); > bool truncate_inode_partial_folio(struct folio *folio, loff_t start, > loff_t end); > long invalidate_inode_page(struct page *page); > +unsigned long invalidate_mapping_pagevec(struct address_space *mapping, > + pgoff_t start, pgoff_t end, unsigned long *nr_pagevec); > > /** > * folio_evictable - Test whether a folio is evictable. > diff --git a/mm/truncate.c b/mm/truncate.c > index 14486e75ec28..6b94b00f4307 100644 > --- a/mm/truncate.c > +++ b/mm/truncate.c > @@ -492,7 +492,18 @@ void truncate_inode_pages_final(struct address_space *mapping) > } > EXPORT_SYMBOL(truncate_inode_pages_final); > > -static unsigned long __invalidate_mapping_pages(struct address_space *mapping, > +/** > + * invalidate_mapping_pagevec - Invalidate all the unlocked pages of one inode > + * @mapping: the address_space which holds the pages to invalidate > + * @start: the offset 'from' which to invalidate > + * @end: the offset 'to' which to invalidate (inclusive) > + * @nr_pagevec: invalidate failed page number for caller > + * > + * This helper is similar to invalidate_mapping_pages(), except that it accounts > + * for pages that are likely on a pagevec and counts them in @nr_pagevec, which > + * will be used by the caller. > + */ > +unsigned long invalidate_mapping_pagevec(struct address_space *mapping, > pgoff_t start, pgoff_t end, unsigned long *nr_pagevec) > { > pgoff_t indices[PAGEVEC_SIZE]; > @@ -557,27 +568,10 @@ static unsigned long __invalidate_mapping_pages(struct address_space *mapping, > unsigned long invalidate_mapping_pages(struct address_space *mapping, > pgoff_t start, pgoff_t end) > { > - return __invalidate_mapping_pages(mapping, start, end, NULL); > + return invalidate_mapping_pagevec(mapping, start, end, NULL); > } > EXPORT_SYMBOL(invalidate_mapping_pages); > > -/** > - * invalidate_mapping_pagevec - Invalidate all the unlocked pages of one inode > - * @mapping: the address_space which holds the pages to invalidate > - * @start: the offset 'from' which to invalidate > - * @end: the offset 'to' which to invalidate (inclusive) > - * @nr_pagevec: invalidate failed page number for caller > - * > - * This helper is similar to invalidate_mapping_pages(), except that it accounts > - * for pages that are likely on a pagevec and counts them in @nr_pagevec, which > - * will be used by the caller. > - */ > -void invalidate_mapping_pagevec(struct address_space *mapping, > - pgoff_t start, pgoff_t end, unsigned long *nr_pagevec) > -{ > - __invalidate_mapping_pages(mapping, start, end, nr_pagevec); > -} > - > /* > * This is like invalidate_inode_page(), except it ignores the page's > * refcount. We do this because invalidate_inode_pages2() needs stronger >