From patchwork Wed Apr 2 21:06:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 14036486 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 3C835C36018 for ; Wed, 2 Apr 2025 21:06:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4719F280005; Wed, 2 Apr 2025 17:06:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 15A77280003; Wed, 2 Apr 2025 17:06:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9BBE280005; Wed, 2 Apr 2025 17:06:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C1E5A280003 for ; Wed, 2 Apr 2025 17:06:17 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3399A1CA109 for ; Wed, 2 Apr 2025 21:06:19 +0000 (UTC) X-FDA: 83290336878.21.ECDB07A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf20.hostedemail.com (Postfix) with ESMTP id 2A50B1C0004 for ; Wed, 2 Apr 2025 21:06:16 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=nBSfKrRq; dmarc=none; spf=none (imf20.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743627977; a=rsa-sha256; cv=none; b=utKGNf6186WmEir9n0SEaHNHiti0FKEEjRZnbrH1JUgOgwLMpsQJJyOmDTrt1xQEqWTB+8 fuRIOzp3BDlxYlO3wEWrU1m8wwa1nHagoYswijzGYSNezMatnZnqd/yqd/vVhfDRoakOXE 4e0Y01nIGipeQEn+XatYVMqo+IXMxMk= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=nBSfKrRq; dmarc=none; spf=none (imf20.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743627977; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=aeknInBgahlhrSIfl6BQ35gr/87Ob6URDMcFA+uZRVc=; b=qJYV2+Rg7Rn6mGZDZPQkmq0rUZcqZeCTiemccLqmC5giVAtrV5XOpZ4DOyn1sp5ulwIeow PqaDoqHoQVQBMOfusFxy8qwNnoTynkHL/fHlcbv5QWMlovSHQ+MjYBsy9IZPnYrRNpAN/t jmYJSihGQl+d0jCOzDTDpXf1gK7ubV0= 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=aeknInBgahlhrSIfl6BQ35gr/87Ob6URDMcFA+uZRVc=; b=nBSfKrRqW/CJy3iB/seVe8R54U +FqjMUO1A2E5UsJHgEobOCJKv8F4ginlYFU32AmXi8dkxt8+ZAk5qVue8Po3xbpMs7I5CgTjot4ET HRFdKNOe4U6hdXq3YJV0i7kABBZ33AzFc0U3jG8OI4JpjdW6GAMP1ZSbzySZ59j2iXxTMe1NRzeT0 DvzfmWWAzubo8osUsE8Qa5ePrdQkxxW+ZcwWUWlWjQkfh8VThs1TFLgKwRRP69BuC+Fkqa5WnhN1g mKRhfj7AbphkJe1aFphKbHrpKB68GWHNXMCgU/W+LSEmJf8UEUaHfG08+C43bt7c9jeZAIPPa3WDE 6YPPBgnw==; Received: from willy by casper.infradead.org with local (Exim 4.98.1 #2 (Red Hat Linux)) id 1u05Hr-0000000AFqW-0qhe; Wed, 02 Apr 2025 21:06:15 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 6/8] filemap: Convert __readahead_batch() to use a folio Date: Wed, 2 Apr 2025 22:06:08 +0100 Message-ID: <20250402210612.2444135-7-willy@infradead.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402210612.2444135-1-willy@infradead.org> References: <20250402210612.2444135-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2A50B1C0004 X-Stat-Signature: g81s19r6qpsphh548zz3h31qipgor38q X-Rspam-User: X-HE-Tag: 1743627976-914929 X-HE-Meta: U2FsdGVkX1/jcn2Uka5xW83xztJjz4XboSJJI4ghvDoBMWF/vI/vNZQ9g6PK13D4Q+coEVl83v0ju7rojpuMLBTRzTWhAV4tFuCE0ZASPMTt3LFzJISFZ27YaR/BoAu6Gc1Jv/whr6tWRghP/fHBCUhzzvHU0BUDanPmLrty8nZM98GjD0g0eH7r6uUubmty1XiSwrE9FV3YxgRp6ImCWZFJVgiFSQUB++EP4jEzFgW2qRcK9vNk3DoXsZk1CqeP4cOmsSJSInw3yUXCiaCsaKnXXpFBda0LcjPYE2od3WRuqVga1hCFAHulWfzS2zMNYCzKMMc5Y8kekRc8hZj2iTKP38WCvxvN4kqRNFMR1zi/u5ocuMaLfbVoHQsa7BqkAuVsiC09CnFmje5SwRGZ5e6H8zTaXZ/SaAe6izQ9S55/Z9K69MBCXUBVObeFaqheI3AKtCkcM9PJNe+Y9hRlYJM+qMsMyWoPQvDAgvwq8Q05BGPiokZo1jKdvZbx1TZ8wwsRGQCQh3Eh1KR4NxGu5qGLortr0Mq+NmvVxo1Z5Jmiycn5KV53xESObBBYx3cJ8jbT/MgpfNwGCt9Grxpow3KND7Zo4SUO8INngPxfrHtUOGHPCZmJ8HEuK89u/+F1cGD41un7BqzJM0wi1gBRX/ECo8cn5N9NeQrKbK3qc5fsuHJRSL5py78ymYyYZh3vjjAabKde0fiMtiTbuOk6OZW3ORZTKiIxqmVpl5Fd18EoRE6mY6HBLfM6j2EZf6rwPlaGtivNPi9i5xpTSyhYJljCKpFqojW85xYeFVdU1EfcD26wokcFxkNdRCGazervU20CsN0eLNrhK7QPl8j5nISb4j9C1Xxj8yN7XPBf3vUDqhYi7jWHpDP6E6MtIY+vwyjvSSJuKabkVGzv89Xu54VrMvYm9j8XnpmpqdgCcONHdsvtH1pdo2bC+X8tfzrPEb/8HVjF1i2buNwarGY HUKzU0fK MCT/vKX39aNBCNyV1qxTdTPqj7F5XJtikOqaASheF9KUcEIjGd8PxnbEBoQhqHKt1kh6iSgiFvL8Pi08rsidV9otpk/9y1FZJw5ZjZWXGxAQVl9x3TNUh2Kgaao0IAULvgsL0Jhlfjp0Mg7WWhqHlwvUg8gxIFPgAfLlg/yOfq1P+tdSTj2qlp8zEoz4BLgpalhRy7tE+XSDGVkMhQiWyweDWDznPf1N3tEYlEJ/YanGhAkurOJVCVBJVyo+Eb5UIPSCpFIh0wWcwDz9LcEfGIdedkYv2SnsozLus 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: List-Subscribe: List-Unsubscribe: Extract folios from i_mapping, not pages. Removes a hidden call to compound_head(), a use of thp_nr_pages() and an unnecessary assertion that we didn't find a tail page in the page cache. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 0ddd4bd8cdf8..c5c9b3770d75 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -1424,7 +1424,7 @@ static inline unsigned int __readahead_batch(struct readahead_control *rac, { unsigned int i = 0; XA_STATE(xas, &rac->mapping->i_pages, 0); - struct page *page; + struct folio *folio; BUG_ON(rac->_batch_count > rac->_nr_pages); rac->_nr_pages -= rac->_batch_count; @@ -1433,13 +1433,12 @@ static inline unsigned int __readahead_batch(struct readahead_control *rac, xas_set(&xas, rac->_index); rcu_read_lock(); - xas_for_each(&xas, page, rac->_index + rac->_nr_pages - 1) { - if (xas_retry(&xas, page)) + xas_for_each(&xas, folio, rac->_index + rac->_nr_pages - 1) { + if (xas_retry(&xas, folio)) continue; - VM_BUG_ON_PAGE(!PageLocked(page), page); - VM_BUG_ON_PAGE(PageTail(page), page); - array[i++] = page; - rac->_batch_count += thp_nr_pages(page); + VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); + array[i++] = folio_page(folio, 0); + rac->_batch_count += folio_nr_pages(folio); if (i == array_sz) break; }