From patchwork Mon Nov 25 21:01:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13885331 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 B6114D59D7E for ; Mon, 25 Nov 2024 22:18:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FAD06B0082; Mon, 25 Nov 2024 17:18:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2AA6D6B0083; Mon, 25 Nov 2024 17:18:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 199276B0088; Mon, 25 Nov 2024 17:18:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EE4766B0082 for ; Mon, 25 Nov 2024 17:18:21 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 92430ADB5B for ; Mon, 25 Nov 2024 22:18:21 +0000 (UTC) X-FDA: 82826031834.19.A3ABB54 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id 9D718A0009 for ; Mon, 25 Nov 2024 22:18:16 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=rh3YdLCY; dmarc=none; spf=none (imf25.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=1732573097; a=rsa-sha256; cv=none; b=Ekaw3TP0xQTfPblbK6I2QLVfW4ONDm8wIIOEdpZTLL77/TF8Wjh9Jk1zd0uFgR+3/Xb6zM 49idzW8cLoFmPy+4qxLwbgzYxVG39tqEBd7ybv/trjNX18GwanpLyEPXY7PzhvViV3CLMU iGtPSLHs7BLgA0TOI1E17bwIkL+ywPU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=rh3YdLCY; dmarc=none; spf=none (imf25.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=1732573097; 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=Te/r5gWiFZvQzzFtah5P/5z7gMYLs5PGvFwPUfYBNaE=; b=RaWIzIyeBRjFosVv0JkmaznVcs586OclrNLnWpCryvq+jwaa6b+1noPkp5GAd3nC6Po3ge XlAzQfI6vb8/BFhT3ZEDtDt/PBdzNrwzoOgNe31tuNut0YJ28MgT1QMWlKUpwdUKtkike7 KdXLPsK2vwVdRx0o8ozwgGKyG7KSn6I= 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=Te/r5gWiFZvQzzFtah5P/5z7gMYLs5PGvFwPUfYBNaE=; b=rh3YdLCYE1/RnqbENJmfPiqoRc 2bBLYof7WE+1GYqJ44vNmR91o3K+4pX2YSS0UlIw+AIxVtQjjetYqnRWEm95eJ2IYdXPbLoiWIKh/ vS/BdzUFcHnKTQckU95rNoRYLZ/1cJ56RecrMoMMSzFofpwh8OAD2qYXQCZNCeFtAXt/cvHvqk+Pt gN37Aa/Lpp39ju/MXLSjYyI/rsKL6P3ORkeYEu3/1jQRjiqL3irrUYsq6t1S1SJ/69zS6ipxN5EKG PVipp/TvMQeFROFZSMjwFR2Ejp30WfckVVinfACjz0rw/r/Rc4Z9HavSfvKCEZYNa/4kXHi+55mgI x6Qkv3UQ==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tFgDP-0000000CUDx-09rg; Mon, 25 Nov 2024 21:01:51 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, David Hildenbrand , William Kucharski , Miaohe Lin , Muchun Song Subject: [PATCH v3 03/15] mm/page_alloc: Export free_frozen_pages() instead of free_unref_page() Date: Mon, 25 Nov 2024 21:01:35 +0000 Message-ID: <20241125210149.2976098-4-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241125210149.2976098-1-willy@infradead.org> References: <20241125210149.2976098-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 9D718A0009 X-Rspamd-Server: rspam11 X-Stat-Signature: 9djqx1nziyrjoknu1b11jgz8r59pw855 X-HE-Tag: 1732573096-492302 X-HE-Meta: U2FsdGVkX1+lbIoxk98LiCrs5bHGxWRhLglFhUCMZCNNKhd/GkQw+90evMPkkxi/MjgZNEP4se+XrwGY5UF1320Eq2bkWwypr+r2Xxq/OH+pO9fmEBZoIbKTlKdhR2bPnyJ4QFHnFF4LowkT6XgLAOOMdu53VvapOtVgW53S/B+8E++AP7Z0GEzoUnLMDRt71VLxsKEB4mfAWReWPsLo/kTUKej3NS5E8us1DZss3xAWiLfQdexkEfMd4wINt2C1bjRY6LVDblC+WLPk0gC+JsK6vNng/nI3nSon5W/y+W6EUb5FO+M5QCWU0WJ8ZpSbl/2M387A/uJG0K98eA/fG2AkybWn7moMcmDm/twi1lhbIQVO2GGAjMgkXFjYv0o4G38LwJdxmLwLj1GitpdtansvBiKFGD0VJEJI6iJdvkh7/iWxORryD4re+N7X4P6bHr8pHWRizx4LrXHdD/3Smlpn/eKul2XxqURksnVGu56iiMg4Df76QQiTv04z0U9tveFCsTbxFAbcLIXkb5J2lXNcm4k+wqfiUkluo1AC9TfOHwWXd4/V0uOuvaoG1ikQS22LoVsERsinx2DY3INHT/v442s03VIHZxWAEwNufsY8NH4ll7kovb0S64i/4CkPNBRLnYtsGLugIlTBZSfCebov+KY36sm44iJrXfzroU6KeM8aB07BYGAaG4GdPjwO6WZ3V4wUQJN3cFTV/x8ReFKj0Ix3GQ2dJ52TrcHdcNRyN76mHXViTtAsmcvzu1hreoKX0l5vOxyaTz0fdiCv0Xe91fT8yW58KV/kklC3M0aujSrr/5rUxz5SclL5avc4Mdy5sdRf4VDpD7hB1BJctKFh3lDknIQcHLMYF+zQwVJJ6xNjtMqZr9NSmdFT99WvZNofqtBtUZ0HxR9HikaGgCUAUfrxjmqdkK0t5dIfkCKcUB525hLTubsD6tRGlava7bw+LfnJ4n5IV8W1FCq OHw/0r7u LREHz9Gt3lBjCkbNr1uYAest2l4jkK7QVenmNOPcbRjYr1E/y2nQUX4bfentNBM8wsUuidF+q8MGFfQTZa8eGUb39p691AyVOKgfdr9+TFg486AEClItkJCttuohLA14G8NBf6c8E3CqyTlR4hE4ZTsfMFK1+qp7q0mrUFQUtuWmz1m8QbnBeH6BNn15v1yZ0kt4MgH+WW/tLvsF79Lmh9jMXVA7jZT6uVdMK/BEW31xneHPy3cFjEeTur1hXmSaGkmP+vufZJhfsLnLwIA/vqmScmmrGhk4EQgFAc9xWZH7BT0BQ1k9ikS41YtvA9tyUmconeHfSs3KzoG0k1KDukF4e6/2hU6yirfln38LrPuCQq4xQk1QffPjXl/m6PG/fpOqF 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: We already have the concept of "frozen pages" (eg page_ref_freeze()), so let's not complicate things by also having the concept of "unref pages". Reviewed-by: David Hildenbrand Reviewed-by: William Kucharski Reviewed-by: Miaohe Lin Reviewed-by: Muchun Song Signed-off-by: Matthew Wilcox (Oracle) --- mm/internal.h | 2 +- mm/page_alloc.c | 18 +++++++++--------- mm/page_frag_cache.c | 6 +++--- mm/swap.c | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index cb8d8e8e3ffa..ca400c70199c 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -741,7 +741,7 @@ extern bool free_pages_prepare(struct page *page, unsigned int order); extern int user_min_free_kbytes; -void free_unref_page(struct page *page, unsigned int order); +void free_frozen_pages(struct page *page, unsigned int order); void free_unref_folios(struct folio_batch *fbatch); extern void zone_pcp_reset(struct zone *zone); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c40a0c29a89c..adac485e3254 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2626,9 +2626,9 @@ static int nr_pcp_high(struct per_cpu_pages *pcp, struct zone *zone, return high; } -static void free_unref_page_commit(struct zone *zone, struct per_cpu_pages *pcp, - struct page *page, int migratetype, - unsigned int order) +static void free_frozen_page_commit(struct zone *zone, + struct per_cpu_pages *pcp, struct page *page, int migratetype, + unsigned int order) { int high, batch; int pindex; @@ -2677,7 +2677,7 @@ static void free_unref_page_commit(struct zone *zone, struct per_cpu_pages *pcp, /* * Free a pcp page */ -void free_unref_page(struct page *page, unsigned int order) +void free_frozen_pages(struct page *page, unsigned int order) { unsigned long __maybe_unused UP_flags; struct per_cpu_pages *pcp; @@ -2713,7 +2713,7 @@ void free_unref_page(struct page *page, unsigned int order) pcp_trylock_prepare(UP_flags); pcp = pcp_spin_trylock(zone->per_cpu_pageset); if (pcp) { - free_unref_page_commit(zone, pcp, page, migratetype, order); + free_frozen_page_commit(zone, pcp, page, migratetype, order); pcp_spin_unlock(pcp); } else { free_one_page(zone, page, pfn, order, FPI_NONE); @@ -2777,7 +2777,7 @@ void free_unref_folios(struct folio_batch *folios) /* * Free isolated pages directly to the - * allocator, see comment in free_unref_page. + * allocator, see comment in free_frozen_pages. */ if (is_migrate_isolate(migratetype)) { free_one_page(zone, &folio->page, pfn, @@ -2808,7 +2808,7 @@ void free_unref_folios(struct folio_batch *folios) migratetype = MIGRATE_MOVABLE; trace_mm_page_free_batched(&folio->page); - free_unref_page_commit(zone, pcp, &folio->page, migratetype, + free_frozen_page_commit(zone, pcp, &folio->page, migratetype, order); } @@ -4871,11 +4871,11 @@ void __free_pages(struct page *page, unsigned int order) struct alloc_tag *tag = pgalloc_tag_get(page); if (put_page_testzero(page)) - free_unref_page(page, order); + free_frozen_pages(page, order); else if (!head) { pgalloc_tag_sub_pages(tag, (1 << order) - 1); while (order-- > 0) - free_unref_page(page + (1 << order), order); + free_frozen_pages(page + (1 << order), order); } } EXPORT_SYMBOL(__free_pages); diff --git a/mm/page_frag_cache.c b/mm/page_frag_cache.c index 3f7a203d35c6..d2423f30577e 100644 --- a/mm/page_frag_cache.c +++ b/mm/page_frag_cache.c @@ -86,7 +86,7 @@ void __page_frag_cache_drain(struct page *page, unsigned int count) VM_BUG_ON_PAGE(page_ref_count(page) == 0, page); if (page_ref_sub_and_test(page, count)) - free_unref_page(page, compound_order(page)); + free_frozen_pages(page, compound_order(page)); } EXPORT_SYMBOL(__page_frag_cache_drain); @@ -138,7 +138,7 @@ void *__page_frag_alloc_align(struct page_frag_cache *nc, goto refill; if (unlikely(encoded_page_decode_pfmemalloc(encoded_page))) { - free_unref_page(page, + free_frozen_pages(page, encoded_page_decode_order(encoded_page)); goto refill; } @@ -166,6 +166,6 @@ void page_frag_free(void *addr) struct page *page = virt_to_head_page(addr); if (unlikely(put_page_testzero(page))) - free_unref_page(page, compound_order(page)); + free_frozen_pages(page, compound_order(page)); } EXPORT_SYMBOL(page_frag_free); diff --git a/mm/swap.c b/mm/swap.c index 10decd9dffa1..3a01acfd5a89 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -109,7 +109,7 @@ void __folio_put(struct folio *folio) page_cache_release(folio); folio_unqueue_deferred_split(folio); mem_cgroup_uncharge(folio); - free_unref_page(&folio->page, folio_order(folio)); + free_frozen_pages(&folio->page, folio_order(folio)); } EXPORT_SYMBOL(__folio_put);