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 X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 883FFC43461 for ; Mon, 14 Sep 2020 13:00:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A91A520672 for ; Mon, 14 Sep 2020 13:00:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="QaqTekdt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A91A520672 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 03AFD6B0003; Mon, 14 Sep 2020 09:00:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F05EE6B0037; Mon, 14 Sep 2020 09:00:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DCD8A6B0055; Mon, 14 Sep 2020 09:00:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C20616B0003 for ; Mon, 14 Sep 2020 09:00:53 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5CA1752C0 for ; Mon, 14 Sep 2020 13:00:53 +0000 (UTC) X-FDA: 77261676786.10.honey16_43155ae27108 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 8199916A4DE for ; Mon, 14 Sep 2020 13:00:49 +0000 (UTC) X-HE-Tag: honey16_43155ae27108 X-Filterd-Recvd-Size: 6040 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Sep 2020 13:00:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=0ZdtjUyaEBKuIwHQY5MB0J39Zv1SWwFJ6sCPG5MsGs8=; b=QaqTekdt+P0mxDuC2AIEYbCpEc 9lnkdSynG/xFvwpD2HhyQHJ2bNu3CzzJcAKNil7eLpXkB6cyDdI9V2jlKoIvS1SsyYYRq2pDaqdXi i+fZ8Yanb7BjOkUwNGSvwBtazD1YCcIeU2Ecv+zzzNnvzvMe7e3gaMELXtKnhVTqEnZMtmnVILrSR eTJjDNNLqaxJTWgz8RgtnZ8NkXw3guXbKL+2iTXg8afT0htsPT0igQvkW38H/PT5wjNRjoIoIheiZ IzRaINUVlzT3avILLDg63ELfY1C6QaGMvu5c/tF+h4l/m5Atf4W3NY9C9fFdbz6ZjM0QRN8RP+lEl txWHDxPg==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHo6A-00030Y-DE; Mon, 14 Sep 2020 13:00:46 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Andrew Morton , Hugh Dickins , William Kucharski , Johannes Weiner , Jan Kara , Yang Shi , Dave Chinner , linux-kernel@vger.kernel.org Subject: [PATCH v2 09/12] mm: Pass pvec directly to find_get_entries Date: Mon, 14 Sep 2020 14:00:39 +0100 Message-Id: <20200914130042.11442-10-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200914130042.11442-1-willy@infradead.org> References: <20200914130042.11442-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8199916A4DE X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 Content-Transfer-Encoding: quoted-printable 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: All callers of find_get_entries() use a pvec, so pass it directly instead of manipulating it in the caller. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 3 +-- mm/filemap.c | 21 +++++++++------------ mm/shmem.c | 5 ++--- mm/swap.c | 4 +--- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index d440c6750757..788c280737e0 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -414,8 +414,7 @@ static inline struct page *find_subpage(struct page *= head, pgoff_t index) } =20 unsigned find_get_entries(struct address_space *mapping, pgoff_t start, - pgoff_t end, unsigned int nr_entries, struct page **entries, - pgoff_t *indices); + pgoff_t end, struct pagevec *pvec, pgoff_t *indices); unsigned find_get_pages_range(struct address_space *mapping, pgoff_t *st= art, pgoff_t end, unsigned int nr_pages, struct page **pages); diff --git a/mm/filemap.c b/mm/filemap.c index 6dc0a9b8c0fa..a4ad294a34dc 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1800,14 +1800,12 @@ static inline struct page *xas_find_get_entry(str= uct xa_state *xas, * @mapping: The address_space to search * @start: The starting page cache index * @end: The final page index (inclusive). - * @nr_entries: The maximum number of entries - * @entries: Where the resulting entries are placed + * @pvec: Where the resulting entries are placed. * @indices: The cache indices corresponding to the entries in @entries * - * find_get_entries() will search for and return a group of up to - * @nr_entries entries in the mapping. The entries are placed at - * @entries. find_get_entries() takes a reference against any actual - * pages it returns. + * find_get_entries() will search for and return a batch of entries in + * the mapping. The entries are placed in @pvec. find_get_entries() + * takes a reference on any actual pages it returns. * * The search returns a group of mapping-contiguous page cache entries * with ascending indexes. There may be holes in the indices due to @@ -1824,15 +1822,12 @@ static inline struct page *xas_find_get_entry(str= uct xa_state *xas, * Return: the number of pages and shadow entries which were found. */ unsigned find_get_entries(struct address_space *mapping, pgoff_t start, - pgoff_t end, unsigned int nr_entries, struct page **entries, - pgoff_t *indices) + pgoff_t end, struct pagevec *pvec, pgoff_t *indices) { XA_STATE(xas, &mapping->i_pages, start); struct page *page; unsigned int ret =3D 0; - - if (!nr_entries) - return 0; + unsigned nr_entries =3D PAGEVEC_SIZE; =20 rcu_read_lock(); while ((page =3D xas_find_get_entry(&xas, end, XA_PRESENT))) { @@ -1847,11 +1842,13 @@ unsigned find_get_entries(struct address_space *m= apping, pgoff_t start, } =20 indices[ret] =3D xas.xa_index; - entries[ret] =3D page; + pvec->pages[ret] =3D page; if (++ret =3D=3D nr_entries) break; } rcu_read_unlock(); + + pvec->nr =3D ret; return ret; } =20 diff --git a/mm/shmem.c b/mm/shmem.c index 404e45c285ca..b2b94025841a 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -963,9 +963,8 @@ static void shmem_undo_range(struct inode *inode, lof= f_t lstart, loff_t lend, while (index < end) { cond_resched(); =20 - pvec.nr =3D find_get_entries(mapping, index, end - 1, - PAGEVEC_SIZE, pvec.pages, indices); - if (!pvec.nr) { + if (!find_get_entries(mapping, index, end - 1, &pvec, + indices)) { /* If all gone or hole-punch or unfalloc, we're done */ if (index =3D=3D start || end !=3D -1) break; diff --git a/mm/swap.c b/mm/swap.c index d4e3ba4c967c..40b23300d353 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -1060,9 +1060,7 @@ unsigned pagevec_lookup_entries(struct pagevec *pve= c, struct address_space *mapping, pgoff_t start, pgoff_t end, pgoff_t *indices) { - pvec->nr =3D find_get_entries(mapping, start, end, PAGEVEC_SIZE, - pvec->pages, indices); - return pagevec_count(pvec); + return find_get_entries(mapping, start, end, pvec, indices); } =20 /** --=20 2.28.0