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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 85F35C433ED for ; Wed, 5 May 2021 17:31:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2C2B16105A for ; Wed, 5 May 2021 17:31:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C2B16105A 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 C08F06B006C; Wed, 5 May 2021 13:30:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BB7936B0071; Wed, 5 May 2021 13:30:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA7EB6B0072; Wed, 5 May 2021 13:30:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0246.hostedemail.com [216.40.44.246]) by kanga.kvack.org (Postfix) with ESMTP id 8EA356B006C for ; Wed, 5 May 2021 13:30:59 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 4BC61181AC553 for ; Wed, 5 May 2021 17:30:59 +0000 (UTC) X-FDA: 78107867838.06.4AE537B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP id 0A49FA0009F5 for ; Wed, 5 May 2021 17:30:51 +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=Av+BBOZUAh68SU/Va2q2cjv/1CjK/OveGHjToGYH/sA=; b=CAhWDKDx3yaZWJa35M23tD+lyu hmnqg3FWgFypWHnHGXbtRsbNfwwMFBsEOR/Ia8sjH8WdFRgIp4dbulaQePJRXCjYinBib8vdqlMGk Mjm449KWodW2lo9JTmys2AGZADpeTzgg6MGh28a9izlEcmPG2AGDUeFNvvJaeTBUeLcKpJ4eTtKYl nWIRDq2K07Nl3JGewOy1BM6J3qCMy187DbWBUWjGuX+grtj9gmOnpwUJr26rrIhJYByEbh6T6vqz/ 5JH/EPLSMuU4OtMxfC4gq+WMu41SHQZXDWUO6ell1IaTOHfmipJcFkhFmaInJQKrfEmD4Ej9T3Jjx /XgTs/ew==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1leKvk-000ceS-O0; Wed, 05 May 2021 17:04:11 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org Subject: [PATCH v9 79/96] mm/filemap: Convert mapping_get_entry to return a folio Date: Wed, 5 May 2021 16:06:11 +0100 Message-Id: <20210505150628.111735-80-willy@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210505150628.111735-1-willy@infradead.org> References: <20210505150628.111735-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 0A49FA0009F5 X-Stat-Signature: mtnafiira8i1k5nbum3rkobrazeqp1kc Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=CAhWDKDx; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none Received-SPF: none (infradead.org>: No applicable sender policy available) receiver=imf15; identity=mailfrom; envelope-from=""; helo=casper.infradead.org; client-ip=90.155.50.34 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620235851-24252 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: The pagecache only contains folios, so indicate that this is definitely not a tail page. Shrinks mapping_get_entry() by 56 bytes, but grows pagecache_get_page() by 21 bytes as gcc makes slightly different hot/cold code decisions. A net reduction of 35 bytes of text. Signed-off-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 062610ae95d8..b3714dddb045 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1732,34 +1732,33 @@ EXPORT_SYMBOL(page_cache_prev_miss); * @mapping: the address_space to search * @index: The page cache index. * - * Looks up the page cache slot at @mapping & @index. If there is a - * page cache page, the head page is returned with an increased refcount= . + * Looks up the page cache entry at @mapping & @index. If it is a folio= , + * it is returned with an increased refcount. If it is a shadow entry + * of a previously evicted folio, or a swap entry from shmem/tmpfs, + * it is returned without further action. * - * If the slot holds a shadow entry of a previously evicted page, or a - * swap entry from shmem/tmpfs, it is returned. - * - * Return: The head page or shadow entry, %NULL if nothing is found. + * Return: The folio, swap or shadow entry, %NULL if nothing is found. */ -static struct page *mapping_get_entry(struct address_space *mapping, +static struct folio *mapping_get_entry(struct address_space *mapping, pgoff_t index) { XA_STATE(xas, &mapping->i_pages, index); - struct page *page; + struct folio *folio; =20 rcu_read_lock(); repeat: xas_reset(&xas); - page =3D xas_load(&xas); - if (xas_retry(&xas, page)) + folio =3D xas_load(&xas); + if (xas_retry(&xas, folio)) goto repeat; /* * A shadow entry of a recently evicted page, or a swap entry from * shmem/tmpfs. Return it without attempting to raise page count. */ - if (!page || xa_is_value(page)) + if (!folio || xa_is_value(folio)) goto out; =20 - if (!page_cache_get_speculative(page)) + if (!page_cache_get_speculative(&folio->page)) goto repeat; =20 /* @@ -1767,14 +1766,14 @@ static struct page *mapping_get_entry(struct addr= ess_space *mapping, * This is part of the lockless pagecache protocol. See * include/linux/pagemap.h for details. */ - if (unlikely(page !=3D xas_reload(&xas))) { - put_page(page); + if (unlikely(folio !=3D xas_reload(&xas))) { + folio_put(folio); goto repeat; } out: rcu_read_unlock(); =20 - return page; + return folio; } =20 /** @@ -1814,10 +1813,12 @@ static struct page *mapping_get_entry(struct addr= ess_space *mapping, struct page *pagecache_get_page(struct address_space *mapping, pgoff_t i= ndex, int fgp_flags, gfp_t gfp_mask) { + struct folio *folio; struct page *page; =20 repeat: - page =3D mapping_get_entry(mapping, index); + folio =3D mapping_get_entry(mapping, index); + page =3D &folio->page; if (xa_is_value(page)) { if (fgp_flags & FGP_ENTRY) return page; --=20 2.30.2