From patchwork Mon Nov 25 21:01:32 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: 13885336 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 E435ED59D7E for ; Mon, 25 Nov 2024 22:38:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 729AD6B008C; Mon, 25 Nov 2024 17:38:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B0DA6B0092; Mon, 25 Nov 2024 17:38:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5792C6B0093; Mon, 25 Nov 2024 17:38:26 -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 3D0676B008C for ; Mon, 25 Nov 2024 17:38:26 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E5F8980C86 for ; Mon, 25 Nov 2024 22:38:25 +0000 (UTC) X-FDA: 82826082486.30.E65833A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id D754F140018 for ; Mon, 25 Nov 2024 22:38:21 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=SKoyoFPa; spf=none (imf23.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=1732574300; 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:references:dkim-signature; bh=3jS0qRH8pAWI1Mb9A6hMA4gm0ghfWwgfeyuh5iltG0g=; b=AzqILk5a1yTiK83YZEIcIkQdcIoHhg2MM3PsDQxEalJWofS8jt4YrHFaFvX8yk3XI+BM3F aZ8LAJqVJ+n1MirV4XwJIN+Y9bWaKhh9TjsBSdbBsCgOIm9PgScfUzIOeqyINYt3o9lFTD VKTx52HC5rluaRk32ZI3uHR3WTyWgTY= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=SKoyoFPa; spf=none (imf23.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=1732574300; a=rsa-sha256; cv=none; b=O3lJretFuIZA6LsF8D1mo+9mAqgHZPEWYGqf3i8TnuS9ZOzCn6Uxc6ShNfhOIKaND8lxNa /dzfZ0qqu6cE02Hlks5HZglPO3+N2282/VlOhnJcnNHk5lCQYsBOMCti7TBNvF4jlU2o66 Y33Ub+v1SdyGbIa91FQATu0I0mpKz18= 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: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=3jS0qRH8pAWI1Mb9A6hMA4gm0ghfWwgfeyuh5iltG0g=; b=SKoyoFPahzDKn6QJIW95jdptSt E3xOINaS22XNiWhrE9Fa7zFVG4EFBRkOibFOcIhnqTCgiIlO6VNifi6l1jD2PDi+UE/xKx8cv7v1g u5GhIqhzNhmKT0r2Y0utmWmNjSocOwI4cGq635XRL3YEJQMg5RPeYgkPlNBe+XZnyqGbB4mR492v+ QGUG4zPuwYyeq4tE4oZeoZPmWPpBlnKzYzYYiEey//qR88as4GStmBw53n1+Rto4OTv5gB4gEWhHd qmR5Gkdd17OGCraK4nIv1TzQJVS9BYglA2WjOqk6w5K83zkT6utwNhGYz84cIi9punHKbo3japqoV ObVeCAlQ==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tFgDO-0000000CUDq-2yPI; Mon, 25 Nov 2024 21:01:50 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, David Hildenbrand Subject: [PATCH v3 00/15] Allocate and free frozen pages Date: Mon, 25 Nov 2024 21:01:32 +0000 Message-ID: <20241125210149.2976098-1-willy@infradead.org> X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D754F140018 X-Stat-Signature: dnbi7ewgj7d55ypsksh31d6xxkc6retr X-Rspam-User: X-HE-Tag: 1732574301-586957 X-HE-Meta: U2FsdGVkX1+H8RC5QGdZmZZghBgug7JKYCbk1Xd2UlKjDg38D6d45N2Xkn9wmteWFWtU5uoRsXNIJkbLD0YwiOEJFJzhvWtTFDpe6pYHORY1NO9/PV6V8YzFxeSR1Fkq1mDmUAQ8wytY07jw32/P5JbBClPtSkeA10YnC38XqWiyoJxo4s5msQ6miJQZsfxqFLZts4duYJAc5BX5IxGGODl7vYcgK8SKrjUqCFOmhJvgmCrBh5SBu9uk/y0VL8LjvqlbKsFGK6nOGKr/9AQms+kBi7tSznIgrsV45vG4uxJwta/1Jam6b/bHlvzw6XOwEroh6Dap6EQx4vuCJHl2LXycP2X/TJm7B+AFaJrDjmA/HUWYNTRJg9iXbM/QCvLu5p9EF3el1nEaHH1hue6z7qVzPJKJJauVNhT47cH4D1lg285onSUOdQsENGBsveQ6Ow10rk2kxH71DXGISKAn0y3/UQF43YSSW7kjABlH54nzPBThNy8/skwecLgWzeDKBfeNP2xJTjqVovmoB+AHcGPSCBQwo7yf54ERZrfADwPhm82gDwOX0HHcaoqiTnDkUNzwbRkQQEdVlFlUPeZQj33+Ag3WLw+H69fob1zYabgtqpw4usdf93Anv1MtggtxlIMhOKq7sP5XXMN0JVAFYSrxRVg2qS5UVdREGk1tcND2QHeQSpi8d00IyA8MkIvjX2IxsFHHSVrvXEp/ie4MpC3OaduugMULTM6y0ayj5GWt1eJb5RSEzxWUBycD2p04Gebav2HoCmTNkIlm1wUH3ACQsWeBhqSqcuLigV0zRioT57VuOSlGfv1Y+lNwh1LVQd3t3jahxwVjjNxZsCsh5M4zIZoGm4DJmub8G9xXJfvNwpJPPZx5pQxJYJNdX98vmuhQP/PEAu1clybvWF2rmDoeyx0ngbCnPCYyus0/PZwgU9XH31NQj+7wxT1ZK/0bwVdQ0Sx8Az95LAXtELh A1oVAejs BgeDqbgASufnAIBXlLkpKhpvLI3moz9WPA3JbhWJWJWWRUtjmSvtviEFk5U2n6+Ima5FHLGnApgUBwZgRhaj9sqfD93bNIKNUPECagVJIrJUM4Omhbq1Rj2BFgd2Owa4pTYiyAYiupR9L3c5zXPtbUx8wxuDVG5Q2P3Oui/6nUiF1SaYrfGyQg+Ra0x3iB9GA3kcq8zxjqZNAoHXt0WAwfoDmdzGQTYkZ/4MNInpiIBc6gGA/WoNv9ODuGNw4uJIXrxTH 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: Slab does not need to use the page refcount at all, and it can avoid an atomic operation on page free. Hugetlb wants to delay setting the refcount until it has assembled a complete gigantic page. We already have the ability to freeze a page (safely reduce its reference count to 0), so this patchset adds APIs to allocate and free pages which are in a frozen state. This patchset is also a step towards the Glorious Future in which struct page doesn't have a refcount; the users which need a refcount will have one in their per-allocation memdesc. v3: - Rebase to next-20241114 - Drop patch for free_the_page() as it no longer exists; instead rename free_unref_page() to free_frozen_pages() - Add patch to make alloc_pages_mpol() static - Drop slab patch since slab is gone - There are now many more callers of post_alloc_hook() and prep_new_page() than there used to be, but I reviewed the changes and believe they are all changed in the appropriate commit. - Adapt to _noprof v2: https://lore.kernel.org/linux-mm/20220809171854.3725722-1-willy@infradead.org/ Matthew Wilcox (Oracle) (15): mm/page_alloc: Cache page_zone() result in free_unref_page() mm: Make alloc_pages_mpol() static mm/page_alloc: Export free_frozen_pages() instead of free_unref_page() mm/page_alloc: Move set_page_refcounted() to callers of post_alloc_hook() mm/page_alloc: Move set_page_refcounted() to callers of prep_new_page() mm/page_alloc: Move set_page_refcounted() to callers of get_page_from_freelist() mm/page_alloc: Move set_page_refcounted() to callers of __alloc_pages_cpuset_fallback() mm/page_alloc: Move set_page_refcounted() to callers of __alloc_pages_may_oom() mm/page_alloc: Move set_page_refcounted() to callers of __alloc_pages_direct_compact() mm/page_alloc: Move set_page_refcounted() to callers of __alloc_pages_direct_reclaim() mm/page_alloc: Move set_page_refcounted() to callers of __alloc_pages_slowpath() mm/page_alloc: Move set_page_refcounted() to end of __alloc_pages() mm/page_alloc: Add __alloc_frozen_pages() mm/mempolicy: Add alloc_frozen_pages() slab: Allocate frozen pages include/linux/gfp.h | 8 ------- mm/compaction.c | 2 ++ mm/internal.h | 21 +++++++++++++++--- mm/mempolicy.c | 53 ++++++++++++++++++++++++++++---------------- mm/page_alloc.c | 45 ++++++++++++++++++++++++------------- mm/page_frag_cache.c | 6 ++--- mm/slub.c | 6 ++--- mm/swap.c | 2 +- 8 files changed, 90 insertions(+), 53 deletions(-)