From patchwork Sat Feb 17 02:25:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13561211 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 56E95C48260 for ; Sat, 17 Feb 2024 02:26:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA78F6B00A0; Fri, 16 Feb 2024 21:25:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CABD6B00A5; Fri, 16 Feb 2024 21:25:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E0A06B00A1; Fri, 16 Feb 2024 21:25:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1BD626B00A5 for ; Fri, 16 Feb 2024 21:25:55 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EAE9414012F for ; Sat, 17 Feb 2024 02:25:54 +0000 (UTC) X-FDA: 81799705428.09.BE4878C Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id 7F9A8180021 for ; Sat, 17 Feb 2024 02:25:53 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lPd5VdaU; spf=none (imf24.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=1708136753; 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=mlFgA+f7ZWhuxah7PZlx2X3QOGE0MGG8XgVHVNnzo5M=; b=ZzBo+SFKOg4pGWCQ8/24EAk/AsdQrIhDn4Bp35mdIMbtXAunSEfPGqvC6j/uZ9KuA4xomw b60+jOHijOnMVi40SRowZCYxhriC0fO0JhlXWbRG/Op7JxYggtrlgWcRKBbtLLi7r+Q8og TXmdRVbldhS2nNAhuzjUTUvMQDPBZig= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708136753; a=rsa-sha256; cv=none; b=e74milBUQ54clwpnvzpNCA11hhu/Lh9a+Me5SI10K4ADXrlhXBZDyXyk9BIhpjZb7OTrFc dWRVZljbM0lR5Lbgk8X4aUhEAjRzql0i3qgdA2Y9BTTiX+THneYLlOjHgQ0ipGt4Ss6Qk/ tJGyMcNg5iEBJVubi41EJxx30slK/7I= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lPd5VdaU; spf=none (imf24.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none 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=mlFgA+f7ZWhuxah7PZlx2X3QOGE0MGG8XgVHVNnzo5M=; b=lPd5VdaUaYfPQgDi+6DMFBDc+0 PmhjdIEG/r1n8vOV5rfv7vP//GosH9K/WIjysAHl8ydjEU5MKAt1vxCkqqwU3KY5HpPM7IKDe210D 9KIgHIjE8TSciUAxmYGNy8BUzN4ACbHLgeL5MoKTbLSzh3Bd16Lg98KeEcBknTUkoEkuwPXCA07/A rpuRNsOJNLQDbauT1v0NDCGky1tRbIkH8QNY2Vl6O9Ek/gVmvHRU7bilwdke+R2waXYBG0iAH61kl vDmjgKAd2QOuxJKmxpbYN0Avfy/fjemJwxXOpvFnicEMoMbg+7fiOLHibTO5yyg3bBgvmTmbhv4qE YcIz7JYQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbAOi-00000006HD9-1cgP; Sat, 17 Feb 2024 02:25:48 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Ryan Roberts Subject: [PATCH v2 02/18] mm: Convert free_unref_page_list() to use folios Date: Sat, 17 Feb 2024 02:25:28 +0000 Message-ID: <20240217022546.1496101-3-willy@infradead.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240217022546.1496101-1-willy@infradead.org> References: <20240217022546.1496101-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7F9A8180021 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: be3kk4913hb4t66y7fdgtdety8nji4eh X-HE-Tag: 1708136753-85791 X-HE-Meta: U2FsdGVkX1/vsaHgUjleIje/IL/rk7Ora6yx4YWbQjnaWwEhGwYCtElKcQq9Zd8SQMkm6XhyvkCb9fucWqTLEmOZ4r8kn6+ZJGR30kGJuGdt+whsjl63cmHPoqXAERD0H96ycjTy7WUXGQr3jttWDgMJU6/dRioVR2+krboHulrmQNukqBXdDrSmbI8fogQwyvlLpsSKa6bdk1YgBXrn/F4MOrB6PJkT+GzcfG4ZGucYiyNnhnOow6wnef38Fgd0qvtJwHVI++sTR7KEeN8I0aAu1OnCeTiuHxjJmjSgdDq3uDsLa8GVLznvL4F5utFjGvaa/MnreJcopB4/mrrl+jAWImSJfK4JUM1w+iauYvzK8gLQnlfeEAWe5cXNe1GLvuPm8XvyMBIMD+jPQ8IeNR0nRC61MmXjNpbgpPvqkeBPP27plCcu8jjeyKVdq7leLDCpzPVPWfGqFBMfawtQmz3MiiGMGQVPPOMBTG2Qbswqw3o74BEsq8drXrqddDQULwlB6BukebI6hQyhSRkxr8j02ornEfOEhidOJBc6UH6EAKDlZC+k0S5lDVedN4OZRoEDsWclf40RSXofMFWNxIbm8bvISwTDZdBTR9os1NKhhyGKW/zn3DLYdlnxbAuovZX0LSBoyI3eh6W9CG1MNTKuaH8IfT/ipxOD+xMPpeSho6xNjPwcucS1npgxmlHj33Eis7rgi//oURc7yH4wFYoVDxhLjCJKlh+EImH96iZRE0Cd3KdWl9LKZ1BDJ+y7FBpdPRB3mfHM/Zn+NCwj1milLuWVBcumiPa7isFCRcA827hGsvbGs4DkqDX8ofMvuiS2E8tfcTzVGqWIJkW1KPXXU9k9maLHGy726w51l4hfMGPmhY58TR56nPjOnPLovqnVxMjB4c0YqZbXxgXx0rxnGDRac8cV 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: 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) Reviewed-by: Ryan Roberts --- 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 7ae4b74c9e5c..a8292c7a0391 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2556,17 +2556,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; } @@ -2574,24 +2574,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) { @@ -2602,15 +2603,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; } @@ -2624,8 +2626,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++; }