From patchwork Mon Aug 21 20:44:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13359797 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 56CE7EE49A6 for ; Mon, 21 Aug 2023 20:44:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B316E940011; Mon, 21 Aug 2023 16:44:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE1E4940010; Mon, 21 Aug 2023 16:44:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A997940011; Mon, 21 Aug 2023 16:44:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8664B8E0012 for ; Mon, 21 Aug 2023 16:44:39 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5ACB11C9A64 for ; Mon, 21 Aug 2023 20:44:39 +0000 (UTC) X-FDA: 81149290278.07.FFAF006 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf17.hostedemail.com (Postfix) with ESMTP id AF8D140010 for ; Mon, 21 Aug 2023 20:44:37 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=rzJR+ALE; spf=none (imf17.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692650677; 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=R60f4MZlgl3FiJgLjXWtZXeM99QHm1vtfudYO1B8YHk=; b=KrjqQjUa31x2y6PkVJuxBysiff9OmyQ4a+IRnPfZs18NJ7mrO79Y6L0CS12v2oxbLNTGGZ ETw7S+gGSqWri5+RBGTIjEKrsIcrQomUepNOV5RslZ/LbKEPcUp8LV5/uhSM5e5VsarvKC ofJeGkmjFzhi/AgEvo/Z6ZTVnMKdUGU= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=rzJR+ALE; spf=none (imf17.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692650677; a=rsa-sha256; cv=none; b=paTW5ph3rCE1loiun7gkcVZNbIJ0OLuPuRb48bVRSqkOyU1JFeKESXReTz7ncdmY69dkMk Cc+YAKYmxywp+Vi72wolK68DDyxMoWHf1F2RqYL+p+1sxk3uY90+oTtrvZoa+ANNzWPwTA e70mwI2lCwj9sCGtbcJDAbqMGfi0sd4= 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=R60f4MZlgl3FiJgLjXWtZXeM99QHm1vtfudYO1B8YHk=; b=rzJR+ALEuWNqK9HrcFfa8MzDG/ /cTXZSUZqPrUIkirOzoygnEazjDTrCAdZl+jsxjLjiS8BjfWrpHcucFTaJlBhX/QbsHZ8dRnzUqP/ oLtAzcQQGv58zaD8LnjUXJZTBJ+vM9y82DUozXRCXVK6QbJ6ue+HqKSk/mZpOQSzdVQ88X2K25n9b awISxEAZ+9IUkRF3s1UKwSIzwilgwGFpmnBBRe6f5X9NHnmqlnpbd2iLaP4dcLZ5Dw4olzWomrOWe dbu3siwyIqVwOHqWvvxUBtF0cvvifgE+ZFikoNkWEC09VzXHCtEjK07Htq5t8bS9FInuFGrmpSYLm 9o43L/Vg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qYBlE-00CL06-9Z; Mon, 21 Aug 2023 20:44:28 +0000 From: "Matthew Wilcox (Oracle)" To: Mateusz Guzik , linux-kernel@vger.kernel.org, dennis@kernel.org, tj@kernel.org, cl@linux.com, akpm@linux-foundation.org, shakeelb@google.com, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 2/7] mm: Convert free_unref_page_list() to use folios Date: Mon, 21 Aug 2023 21:44:20 +0100 Message-Id: <20230821204425.2940496-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230821204425.2940496-1-willy@infradead.org> References: <20230821204425.2940496-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: AF8D140010 X-Rspam-User: X-Stat-Signature: qwaxo1yihs5hxfpfnpzdhhqpjj16jae4 X-Rspamd-Server: rspam01 X-HE-Tag: 1692650677-840138 X-HE-Meta: U2FsdGVkX188aCuYDG9CI5nrebNQMUHdMPD9p5h//S2TCTGCIeWjV03S6QQ/IKkQaBw3B6ROlwd8NauC0RG+4mcp4G0qzI/Oy9IoGrguKwHtxtE92VJ8yrz/q6duftayhAoqNLgLg70Iq0Qev6oqSrYIL+g3zMkWheJUbsR0KEz1swo/ymMHPOBmrWv1UayQK1SVhUh5abx5UWvjA6g5kct+RFxakm61Gbr71XO32VOaKxeqqAfAWGROKxIrULX4OZwN64E9vyKUgbzn5CQYHmeKHNB5DB1Ax2jdTTUhqkjzU/hVaH6A+02kijgEr8J/a0anKLZfs74wB29hfaiAbCR/l3ZssIORXwm7G8LJtCIy+X3oUbCUrwS/EmpwutixCMjkFWlXMeMmlI3wCrxXpLgRub/Ba/jdXKyjl5800l3RZJmCogqZDo4XwBHjw0zhznMv6gISTilXi88CQrFTp7ChpFuCYgvtBjM01VNtbKaYvNnG8XB2wsZCcuvlCNoZ9n2X1FBqMIXVGLdocHgvEqzA0vYTuLIHkMqf4Wua5JnwWEeRmyDhuvZZXI7scw43sYoHjC3jIUQLFBr+UB0KWJ0UNpghggTRi2hhmaRPJfKKtpcGSQIwc3WgwgTIiQyUkg96kwgT7PYoZnn20AI9EUPuqMH06tnNdw/BtDNkTCg1F+wqzD+MVBFD3IWANGfLz8XAhMSrNaIszyJMIJG33dSZweWClJhcPbwsh9QelFDEaJ/W7ZIjJPA0Pd1G6h61+KEP0lr+yP0c5evPafLuxmAA4pNHgpIC7XwApn94pboBsIJIUkV3Dn/d9AizXz2YwOA/YI3jp5vQfpDE65pBhUxHyNigs7c8rDgv8iV++Rll9SzdwDgf3hOeDG/Q6H0Y2FMJcrgwntuo+/6I0kplivb1ZEEFhZqACuBr+39gC8yRKJ1u5SqSkS/+Za5+sd8RdxjiOT8sy4RGZ4VDpPi i516XEaE /5cmJA53xm0bOznSrg/AsqIKMjhVr2XC8lfs+brbLbOfuPlcWcf9YAI0JCoQYiHoS1yJp6MWxS2B0edgq04n1siwCgC7QUgnBETjOPXEELszhKjhELDolHZD4DZu3zreAwcSA3kgY1yytsYq77nyRf4Oc3OwM2UzaAD+Y+bfeEhDTy1KOqc6lKlPoGA00fpg8+4C5emxqNtUYweUQ7d4fXAeF4xeKdwhEzTzc 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: Most of its callees are not yet ready to accept a folio, but we know all of the pages passed in are actually folios because they're linked through ->lru. Signed-off-by: Matthew Wilcox (Oracle) --- mm/page_alloc.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 81b1c7e3a28b..2f2185929fcb 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2498,17 +2498,17 @@ void free_unref_page(struct page *page, unsigned int order) void free_unref_page_list(struct list_head *list) { unsigned long __maybe_unused UP_flags; - struct page *page, *next; + struct folio *folio, *next; struct per_cpu_pages *pcp = NULL; struct zone *locked_zone = NULL; int batch_count = 0; int migratetype; /* Prepare pages for freeing */ - list_for_each_entry_safe(page, next, list, lru) { - unsigned long pfn = page_to_pfn(page); - if (!free_unref_page_prepare(page, pfn, 0)) { - list_del(&page->lru); + list_for_each_entry_safe(folio, next, list, lru) { + unsigned long pfn = folio_pfn(folio); + if (!free_unref_page_prepare(&folio->page, pfn, 0)) { + list_del(&folio->lru); continue; } @@ -2516,24 +2516,25 @@ void free_unref_page_list(struct list_head *list) * Free isolated pages directly to the allocator, see * comment in free_unref_page. */ - migratetype = get_pcppage_migratetype(page); + migratetype = get_pcppage_migratetype(&folio->page); if (unlikely(is_migrate_isolate(migratetype))) { - list_del(&page->lru); - free_one_page(page_zone(page), page, pfn, 0, migratetype, FPI_NONE); + list_del(&folio->lru); + free_one_page(folio_zone(folio), &folio->page, pfn, + 0, migratetype, FPI_NONE); continue; } } - list_for_each_entry_safe(page, next, list, lru) { - struct zone *zone = page_zone(page); + list_for_each_entry_safe(folio, next, list, lru) { + struct zone *zone = folio_zone(folio); - list_del(&page->lru); - migratetype = get_pcppage_migratetype(page); + list_del(&folio->lru); + migratetype = get_pcppage_migratetype(&folio->page); /* * Either different zone requiring a different pcp lock or * excessive lock hold times when freeing a large list of - * pages. + * folios. */ if (zone != locked_zone || batch_count == SWAP_CLUSTER_MAX) { if (pcp) { @@ -2544,15 +2545,16 @@ void free_unref_page_list(struct list_head *list) batch_count = 0; /* - * trylock is necessary as pages may be getting freed + * trylock is necessary as folios may be getting freed * from IRQ or SoftIRQ context after an IO completion. */ pcp_trylock_prepare(UP_flags); pcp = pcp_spin_trylock(zone->per_cpu_pageset); if (unlikely(!pcp)) { pcp_trylock_finish(UP_flags); - free_one_page(zone, page, page_to_pfn(page), - 0, migratetype, FPI_NONE); + free_one_page(zone, &folio->page, + folio_pfn(folio), 0, + migratetype, FPI_NONE); locked_zone = NULL; continue; } @@ -2566,8 +2568,8 @@ void free_unref_page_list(struct list_head *list) if (unlikely(migratetype >= MIGRATE_PCPTYPES)) migratetype = MIGRATE_MOVABLE; - trace_mm_page_free_batched(page); - free_unref_page_commit(zone, pcp, page, migratetype, 0); + trace_mm_page_free_batched(&folio->page); + free_unref_page_commit(zone, pcp, &folio->page, migratetype, 0); batch_count++; }