From patchwork Wed Dec 8 04:22:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12663741 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 E367EC433F5 for ; Wed, 8 Dec 2021 06:32:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5ECFB6B007E; Wed, 8 Dec 2021 01:23:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 575766B0080; Wed, 8 Dec 2021 01:23:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 416AA6B0085; Wed, 8 Dec 2021 01:23:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay034.a.hostedemail.com [64.99.140.34]) by kanga.kvack.org (Postfix) with ESMTP id 3236D6B007E for ; Wed, 8 Dec 2021 01:23:56 -0500 (EST) Received: by unirelay01.hostedemail.com (Postfix, from userid 108) id 73033606BB; Wed, 8 Dec 2021 05:38:45 +0000 (UTC) Received: by unirelay01.hostedemail.com (Postfix, from userid 108) id DB7C0605D7; Wed, 8 Dec 2021 05:32:08 +0000 (UTC) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2605E609EE for ; Wed, 8 Dec 2021 04:23:14 +0000 (UTC) X-FDA: 78893332308.16.8C75373 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id BB7B91900 for ; Wed, 8 Dec 2021 04:23:12 +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=uCaFGZPNrDIvJ/RaktaqTtu3XrQ4Je459+upnkc0xsU=; b=LxpvwjxBZz00iz3SIC9Sr0xVQb HWICEjt/jzZFnq4UlSgWK0ni+rgkCEjwXhMPSET7+g9KCSu/VUM6ascOeq+5z8PbVBARezxPFFVSB 5xyf5RH/2Pkp3A7wsaWnPKeM2tYNOKoRvPijVzxsDMUSRYJt+x3bgYxA/QskF9yZkienHEYq4ROcn p8sKN3ImlEHijdffLogipscgB0ZrDeGI6oxtch2JrSxKW1yLB/4HmM0CueApx0uSsAMJQarySKyfu FsQ0qL7bdcd90I2zlnAQlTg/Yj53IxMEr5Y6Gv18dAa1mM2ng9iGer7wbnrxOP2S5JqbZSjff079w 65K3EHJg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1muoU3-0084Y0-Cw; Wed, 08 Dec 2021 04:23:11 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 16/48] filemap: Convert filemap_get_read_batch to use folios Date: Wed, 8 Dec 2021 04:22:24 +0000 Message-Id: <20211208042256.1923824-17-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211208042256.1923824-1-willy@infradead.org> References: <20211208042256.1923824-1-willy@infradead.org> MIME-Version: 1.0 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=LxpvwjxB; dmarc=none; spf=none (imf22.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: BB7B91900 X-Stat-Signature: nw5ogstnni3p84us4h6y8jc1ftauwup9 X-HE-Tag: 1638937392-449905 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: The page cache only stores folios, never tail pages. Saves 29 bytes due to removing calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig --- mm/filemap.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 2a51ec720e9e..120df74f3c7c 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2339,32 +2339,31 @@ static void filemap_get_read_batch(struct address_space *mapping, pgoff_t index, pgoff_t max, struct pagevec *pvec) { XA_STATE(xas, &mapping->i_pages, index); - struct page *head; + struct folio *folio; rcu_read_lock(); - for (head = xas_load(&xas); head; head = xas_next(&xas)) { - if (xas_retry(&xas, head)) + for (folio = xas_load(&xas); folio; folio = xas_next(&xas)) { + if (xas_retry(&xas, folio)) continue; - if (xas.xa_index > max || xa_is_value(head)) + if (xas.xa_index > max || xa_is_value(folio)) break; - if (!page_cache_get_speculative(head)) + if (!folio_try_get_rcu(folio)) goto retry; - /* Has the page moved or been split? */ - if (unlikely(head != xas_reload(&xas))) + if (unlikely(folio != xas_reload(&xas))) goto put_page; - if (!pagevec_add(pvec, head)) + if (!pagevec_add(pvec, &folio->page)) break; - if (!PageUptodate(head)) + if (!folio_test_uptodate(folio)) break; - if (PageReadahead(head)) + if (folio_test_readahead(folio)) break; - xas.xa_index = head->index + thp_nr_pages(head) - 1; + xas.xa_index = folio->index + folio_nr_pages(folio) - 1; xas.xa_offset = (xas.xa_index >> xas.xa_shift) & XA_CHUNK_MASK; continue; put_page: - put_page(head); + folio_put(folio); retry: xas_reset(&xas); }