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=-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,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 7000AC07E96 for ; Thu, 15 Jul 2021 04:47:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2239E61360 for ; Thu, 15 Jul 2021 04:47:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2239E61360 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 6B5948D005D; Thu, 15 Jul 2021 00:47:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 665F38D004B; Thu, 15 Jul 2021 00:47:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52DF78D005D; Thu, 15 Jul 2021 00:47:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0152.hostedemail.com [216.40.44.152]) by kanga.kvack.org (Postfix) with ESMTP id 2FD928D004B for ; Thu, 15 Jul 2021 00:47:54 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 17B57184B4336 for ; Thu, 15 Jul 2021 04:47:53 +0000 (UTC) X-FDA: 78363589626.35.BB78F0E Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id C2CB89000702 for ; Thu, 15 Jul 2021 04:47:52 +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=s4e8Kh2qWqpIIoiU7QzGdSi1p21qS0jMzL9s/9ihZxo=; b=BRDZ5j6Da8EHAij1YI9iH7W4bY nlylSxN3DJeOKKUL8gdufs+7uKHb3dGVCxEha/8hlarEKk/3FGz3kn5wxQpwjM5Rb80CGloZa7zW5 oqBgPe8Jmqf8KRJOomhAwLIG3mLcYZ54e+7//Es5PK4T7Cf1+6EMUcm6gcghXKlb/j+Jl44fl7HsJ 0olxlTwHC5zr4uk8BjJM3Eq4dyh2W9oK4zS0UiAJVu1dS72Sd7swwdVqF1t8FT4EOZHBmXa6l62xL E6t1Jq7pUdkVIgLkJEdWv+PTZnMC0Vy1cvQN17mjeTkU9pf35qc46mP90pPjtnahppQ+/7aiRQeiF 5GW2voAg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3tGh-002yae-SG; Thu, 15 Jul 2021 04:46:49 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig Subject: [PATCH v14 087/138] mm/filemap: Convert mapping_get_entry to return a folio Date: Thu, 15 Jul 2021 04:36:13 +0100 Message-Id: <20210715033704.692967-88-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715033704.692967-1-willy@infradead.org> References: <20210715033704.692967-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C2CB89000702 X-Stat-Signature: ghaokbm86ougyxwp4egncinr76fstt37 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=BRDZ5j6D; spf=none (imf23.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-HE-Tag: 1626324472-751654 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) Reviewed-by: Christoph Hellwig --- mm/filemap.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 4e34383fd894..85a457c7b7a7 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1755,49 +1755,42 @@ 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, - pgoff_t index) +static void *mapping_get_entry(struct address_space *mapping, pgoff_t in= dex) { 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 (!folio_try_get_rcu(folio)) goto repeat; =20 - /* - * Has the page moved or been split? - * 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 /** --=20 2.30.2