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 40CCFC43461 for ; Mon, 14 Sep 2020 13:01:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D9CB22078D for ; Mon, 14 Sep 2020 13:01:23 +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="hlDUvXdj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9CB22078D 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 7B700900006; Mon, 14 Sep 2020 09:01:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7683A900004; Mon, 14 Sep 2020 09:01:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 56AB4900006; Mon, 14 Sep 2020 09:01:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0220.hostedemail.com [216.40.44.220]) by kanga.kvack.org (Postfix) with ESMTP id 35A7B900004 for ; Mon, 14 Sep 2020 09:01:01 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CDFF581D3215 for ; Mon, 14 Sep 2020 13:01:00 +0000 (UTC) X-FDA: 77261677080.12.cows16_0a03e7c27108 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 0289E18008CB0 for ; Mon, 14 Sep 2020 13:00:51 +0000 (UTC) X-HE-Tag: cows16_0a03e7c27108 X-Filterd-Recvd-Size: 6369 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.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=OLAOtiQJj0p7soapL1XVM7TPxz0RKAcScdgfX62Cymg=; b=hlDUvXdjv3VN7vmBYMmSuhcOLU ltWfmuOZlJNZuiCs8f8I/57YliBe5+bl603wvkGHA7lru2G04N3abfN4y8tFirPdnwk3kZxW0S0HX pUz0DMcH931OKwmj5X9ghvKHPvqZnpog7eWvKVQyvl9n73ChOgY868NTsQ6jV3noj9wQEFoIQwskx CJFijfWZM0KzsCvLZrgz+oydiOHoVjRB60sBjvUJP7d6HXpGCZveK4VaGAcIAbYqbbjDrqGm8lP5+ DRmLn9Ro096vhwXkkHq+Hhu+eev4AwQjPqa2nPTHOHtJtxXZc8Noo02mQuqZrWqDk1H1Vwl+YgIgE mB5aGC8g==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHo6B-00030t-83; Mon, 14 Sep 2020 13:00:47 +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 12/12] mm/filemap: Return only head pages from find_get_entries Date: Mon, 14 Sep 2020 14:00:42 +0100 Message-Id: <20200914130042.11442-13-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: 0289E18008CB0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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 now expect head (and base) pages, and can handle multiple head pages in a single batch, so make find_get_entries() behave that way. Also take the opportunity to make it use the pagevec infrastructure instead of open-coding how pvecs behave. This has the side-effect of being able to append to a pagevec with existing contents, although we don't make use of that functionality anywhere yet. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 2 -- mm/filemap.c | 36 ++++++++---------------------------- mm/internal.h | 2 ++ 3 files changed, 10 insertions(+), 30 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 788c280737e0..50d2c39b47ab 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -413,8 +413,6 @@ static inline struct page *find_subpage(struct page *= head, pgoff_t index) return head + (index & (thp_nr_pages(head) - 1)); } =20 -unsigned find_get_entries(struct address_space *mapping, pgoff_t start, - 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 a4ad294a34dc..dbe3f7050897 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1807,49 +1807,29 @@ static inline struct page *xas_find_get_entry(str= uct xa_state *xas, * 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 - * not-present pages. + * The entries have ascending indexes. The indices may not be consecuti= ve + * due to not-present entries or THPs. * * Any shadow entries of evicted pages, or swap entries from * shmem/tmpfs, are included in the returned array. * - * If it finds a Transparent Huge Page, head or tail, find_get_entries() - * stops at that page: the caller is likely to have a better way to hand= le - * the compound page as a whole, and then skip its extent, than repeated= ly - * calling find_get_entries() to return all its tails. - * - * Return: the number of pages and shadow entries which were found. + * Return: The number of entries which were found. */ unsigned find_get_entries(struct address_space *mapping, pgoff_t start, pgoff_t end, struct pagevec *pvec, pgoff_t *indices) { XA_STATE(xas, &mapping->i_pages, start); struct page *page; - unsigned int ret =3D 0; - unsigned nr_entries =3D PAGEVEC_SIZE; =20 rcu_read_lock(); while ((page =3D xas_find_get_entry(&xas, end, XA_PRESENT))) { - /* - * Terminate early on finding a THP, to allow the caller to - * handle it all at once; but continue if this is hugetlbfs. - */ - if (!xa_is_value(page) && PageTransHuge(page) && - !PageHuge(page)) { - page =3D find_subpage(page, xas.xa_index); - nr_entries =3D ret + 1; - } - - indices[ret] =3D xas.xa_index; - pvec->pages[ret] =3D page; - if (++ret =3D=3D nr_entries) + indices[pvec->nr] =3D xas.xa_index; + if (!pagevec_add(pvec, page)) break; } rcu_read_unlock(); =20 - pvec->nr =3D ret; - return ret; + return pagevec_count(pvec); } =20 /** @@ -1868,8 +1848,8 @@ unsigned find_get_entries(struct address_space *map= ping, pgoff_t start, * not returned. * * The entries have ascending indexes. The indices may not be consecuti= ve - * due to not-present entries, THP pages, pages which could not be locke= d - * or pages under writeback. + * due to not-present entries, THPs, pages which could not be locked or + * pages under writeback. * * Return: The number of entries which were found. */ diff --git a/mm/internal.h b/mm/internal.h index d17d9060902f..55da9860a54b 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -62,6 +62,8 @@ static inline void force_page_cache_readahead(struct ad= dress_space *mapping, =20 struct page *find_get_entry(struct address_space *mapping, pgoff_t index= ); struct page *find_lock_entry(struct address_space *mapping, pgoff_t inde= x); +unsigned find_get_entries(struct address_space *mapping, pgoff_t start, + pgoff_t end, struct pagevec *pvec, pgoff_t *indices); unsigned find_lock_entries(struct address_space *mapping, pgoff_t start, pgoff_t end, struct pagevec *pvec, pgoff_t *indices); =20 --=20 2.28.0