Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp145155pxv; Thu, 15 Jul 2021 00:49:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8hDAm3Tg2QlVdwYebPJyFIru9iV5hfSe1nQA9cBoPqCJ85NbY/HXYrH30uyhsn4SQ5vG7 X-Received: by 2002:a17:907:7709:: with SMTP id kw9mr4088849ejc.68.1626335355275; Thu, 15 Jul 2021 00:49:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626335355; cv=none; d=google.com; s=arc-20160816; b=XGwwXb0nJ1q9khQS5I0Phgepi6At9PkF/YaWIIYr1Xz8YZaSpEaUb4lhcSyX4pfEwC FvBX0uwKszPaAZc7+V5wUrrtNmB6IwipNmrSStIq5YSnl6pAkjmi8117qYOTqXtW9YlK +zaHv5s+NlWiNXaqfUOrTbjhG7bLhAy6dogFGIco4oYNYvZHeD35RJy4Y909wTiGVjiU UtLjFkaH6K4t3LWJJ/h0P91seWbjMaKaH/rN7TZtZJwd6l7nmZH2/YcqD0NUw1xOJrt7 zkbVpJIs0Yz+pdYDBSxMqdhnX4por+cPJy6GUgscPwDErcAMvwa6GBVSIgVXjfcz37bs lvqQ== 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=s4e8Kh2qWqpIIoiU7QzGdSi1p21qS0jMzL9s/9ihZxo=; b=xfxsX+0D2zpyMXWAPiIEv1r5KH2FImPKzSOX1JHjTzEiis2PSyq7jndnkTZfnsXlhE AeCzEUSvs9dV2FVjdlucnI4Jo5Ox1vIeRfh5YVEIJ+vhFGWb2bCt0lWY63GrGSUvUe2w FH0SNprDMnVersliq3TMwsT+3Vgrw4et8bqxHMKzn2DlOhYZaNkp4D44aRSmxa44iU0H TkiDAyUx0tU3UQ9GcFBjY0BLS5ZhSRtWNZ2NLmHEfArPNj70B7e/F/pnhYUDUMXsEWRH fgFSRh0jh5pRCmb8gS03khlih73ViPbd5ddiBrFsipCFy8m5olyuVFsvUPoHzrSH+HdS LE5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=BRDZ5j6D; 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 y18si5317850edw.21.2021.07.15.00.48.52; Thu, 15 Jul 2021 00:49:15 -0700 (PDT) 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=BRDZ5j6D; 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 S238012AbhGOEut (ORCPT + 99 others); Thu, 15 Jul 2021 00:50:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232058AbhGOEup (ORCPT ); Thu, 15 Jul 2021 00:50:45 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24F5CC06175F; Wed, 14 Jul 2021 21:47:53 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 index) { XA_STATE(xas, &mapping->i_pages, index); - struct page *page; + struct folio *folio; rcu_read_lock(); repeat: xas_reset(&xas); - page = xas_load(&xas); - if (xas_retry(&xas, page)) + folio = 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; - if (!page_cache_get_speculative(page)) + if (!folio_try_get_rcu(folio)) goto repeat; - /* - * 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 != xas_reload(&xas))) { - put_page(page); + if (unlikely(folio != xas_reload(&xas))) { + folio_put(folio); goto repeat; } out: rcu_read_unlock(); - return page; + return folio; } /** -- 2.30.2