Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp676871pxb; Thu, 12 Nov 2020 13:30:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8WsjUGcpUCe5Ys2dh4Q7JDLt7VCgialkqdHvGRh9ed+cmhcKiEYlxx1Yw4a8LZ4eSNtai X-Received: by 2002:a17:906:6d52:: with SMTP id a18mr1302498ejt.224.1605216608433; Thu, 12 Nov 2020 13:30:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605216608; cv=none; d=google.com; s=arc-20160816; b=cVYFcywOnTXJ8cJPOWgucBjNNGxxH6sIdJ9M5s2w93JmqOf3D1BoVauMoiLDHsO8i4 l4ASOGpQvZcKAh6oCjkDaU9flH1tX/0H2eMKNRJ6hZq7SnFH88Z5q3I3NbsUdSX7EsRt fU5tvsOSwadyZF9tRlt0NaBA+S1ZxitKwLTXJclSInOyvw4WC+kEO639+utnq84MzM5Y ORESNmQehphfR81EQLb9u2cDZ/+tO6FpSr24acmmsS58OqjGtf6hD95fTzShPJ3AMgoj TQOO/d2uOENj11QqR0+I5HiAgHvkLnDmvarVmO0TsK5j/VyThAiwKPNh2ZtRQUHPIZF+ pWGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MOhcev08Qr0q0WFBcUAlxQv3z5m+M7Jp4y+munP9EsA=; b=NhIzFlXT0Ntoo9HM5nrh7G/wSE2CCJy+h/V/gHIOupnvdj/vSFyRpdt0TzqK4FyrC6 8FV7ZsoovfT8pGnQ/If9QxTH9wWKvqBwn5YWto0zTVMPORGb/ReypsWbfw/7ol38ni+M zKJkom1pinoL4o0j460UutrXHJFqCl3Jojsk6vQf0F5PQ4KEYRYaVSKzZB2YBje3jIYo 2jQuE+vStvmsRews29Iy0QAojJNwEwQx34zps4dYyJeooXuRKw//aJsaAp0HPP0qubwd nDh7cN7Xs1bJmLmJXBZsLSfx31OgYuZ3cL2CUlvVFLibQq0W+0TnRgzQiv84OjFYGZY9 WWYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=CHIbihY1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn7si4613582edb.498.2020.11.12.13.29.46; Thu, 12 Nov 2020 13:30:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=CHIbihY1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727470AbgKLV0z (ORCPT + 99 others); Thu, 12 Nov 2020 16:26:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727359AbgKLV0w (ORCPT ); Thu, 12 Nov 2020 16:26:52 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B43CAC0613D4; Thu, 12 Nov 2020 13:26:51 -0800 (PST) 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=MOhcev08Qr0q0WFBcUAlxQv3z5m+M7Jp4y+munP9EsA=; b=CHIbihY1P2M/Ip+chUtSUhnj3r elD6u7bsS9+RzgTnl0LJCsB2RDtvlKb/+FO69euC9vy1E3NlerVYFVjsiEGnTP1A4MWEdMHWHygHD Ndv51Z65hEpInchnaYCGWnWG4KLGe9ZLqfKTKBcyboFB7bk0ORTAmoDL4oDne4UWWwNduDwKrtcuk tp3f+pO5bImAQqt9oneNQYyOXWiubs66lAQ+73plyA/m5OTZUTNw+ElLdntFoQ/S1zRiV28vyBUjX ypR0pp2gkQttKWVfxGupREgDAXSNa2Bq9G3sYKzOJQ8ZekiODCTlFjvA5W3dsslgQmn8diNXHHsQs RuC5wYfw==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdK7F-0007Ha-GX; Thu, 12 Nov 2020 21:26:49 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , akpm@linux-foundation.org, hughd@google.com, hch@lst.de, hannes@cmpxchg.org, yang.shi@linux.alibaba.com, dchinner@redhat.com, linux-kernel@vger.kernel.org, Jan Kara , William Kucharski Subject: [PATCH v4 13/16] mm: Pass pvec directly to find_get_entries Date: Thu, 12 Nov 2020 21:26:38 +0000 Message-Id: <20201112212641.27837-14-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201112212641.27837-1-willy@infradead.org> References: <20201112212641.27837-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) Reviewed-by: Jan Kara Reviewed-by: William Kucharski --- 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 c7c26a902743..46d4b1704770 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -449,8 +449,7 @@ static inline struct page *find_subpage(struct page *head, pgoff_t index) } 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 *start, pgoff_t end, unsigned int nr_pages, struct page **pages); diff --git a/mm/filemap.c b/mm/filemap.c index b3b89a62ab1a..479cbbadd93b 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1871,14 +1871,12 @@ static inline struct page *find_get_entry(struct xa_state *xas, pgoff_t max, * @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 @@ -1895,15 +1893,12 @@ static inline struct page *find_get_entry(struct xa_state *xas, pgoff_t max, * 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 = 0; - - if (!nr_entries) - return 0; + unsigned nr_entries = PAGEVEC_SIZE; rcu_read_lock(); while ((page = find_get_entry(&xas, end, XA_PRESENT))) { @@ -1918,11 +1913,13 @@ unsigned find_get_entries(struct address_space *mapping, pgoff_t start, } indices[ret] = xas.xa_index; - entries[ret] = page; + pvec->pages[ret] = page; if (++ret == nr_entries) break; } rcu_read_unlock(); + + pvec->nr = ret; return ret; } diff --git a/mm/shmem.c b/mm/shmem.c index 7a62dc967d7d..e01457988dd6 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -965,9 +965,8 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, while (index < end) { cond_resched(); - pvec.nr = 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 == start || end != -1) break; diff --git a/mm/swap.c b/mm/swap.c index 9a562f7fd200..7cf585223566 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -1102,9 +1102,7 @@ unsigned pagevec_lookup_entries(struct pagevec *pvec, struct address_space *mapping, pgoff_t start, pgoff_t end, pgoff_t *indices) { - pvec->nr = find_get_entries(mapping, start, end, PAGEVEC_SIZE, - pvec->pages, indices); - return pagevec_count(pvec); + return find_get_entries(mapping, start, end, pvec, indices); } /** -- 2.28.0