From patchwork Mon Nov 25 21:01:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13885335 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 5BE02D59D7E for ; Mon, 25 Nov 2024 22:38:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6EA86B0089; Mon, 25 Nov 2024 17:38:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B1F706B008C; Mon, 25 Nov 2024 17:38:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 999076B0092; Mon, 25 Nov 2024 17:38:23 -0500 (EST) 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 7D87B6B0089 for ; Mon, 25 Nov 2024 17:38:23 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 437C1C0CDA for ; Mon, 25 Nov 2024 22:38:23 +0000 (UTC) X-FDA: 82826082360.24.F31B303 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf30.hostedemail.com (Postfix) with ESMTP id A0D0780003 for ; Mon, 25 Nov 2024 22:38:14 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=gn4cFZUi; dmarc=none; spf=none (imf30.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=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:in-reply-to:references:references:dkim-signature; bh=T12nlbl/4Y+GQ4Uch7tugY4tn/IhU/zXrrnqkhKCI/8=; b=AaI3a9BFbb6N12wDySq+avIniGvGXcrcPfDUjrgujWB/2oqzL8mQbZLbyEFBRVIW3RUGjh tPw9+vtR+BLoxK4DloUra3qsr7BuzVnSeHQlGxVFpQL2tMrKgciOTASMoVvC2x+KI2cIvY NFUJQ/LXTF++fNkijrRBBTMTR+s8d8A= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=gn4cFZUi; dmarc=none; spf=none (imf30.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=1732574300; a=rsa-sha256; cv=none; b=S+H4VOCbu1ZA6WnQK97gzF7qRvtb7rxIlmQISuH6kVxRetKVuhNTU+URJCG77thsCqdslE 666CmrNc8+5jx0IIp5lUaecDZNFatcu24HFmAv9SPy3h+TRCV1AlKpiwYLWIZ3qWsmGUC+ 9QHuwfJclBEVlB7wYABq3z/YMzdy9bI= 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=T12nlbl/4Y+GQ4Uch7tugY4tn/IhU/zXrrnqkhKCI/8=; b=gn4cFZUiX7oShjsb4J+QpLB0tO yuI9qxl2/UzRhkQLH+5oBQMrMQ0Oetu54JMIc/TYX2UJ90bKCcisNwAAkDhey3akmQm2k58sPBBZb cS5JUUA1BNfjLNmqN2fRzFcF/47vBy35SRWkM1N26VMlpl8SDBCCLLnv3Qm7d4LAuPR1nr+US21Xg mKo0SZubGHmfRPu4cZ/ZQIoB2IrB6tGlSYjnePIKmQd4LQOJyrw5FkQgNteEm4aTU9f+hI5fidfvs QI+mkVwKV1Ly+NjcMI7YWs6Ikktpq9Hjxxp916b+CMOeKLImPoAgxceI4hL5YUlteQRO/v2gWwnzN xehEeC/Q==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tFgDQ-0000000CUEl-1Gf5; Mon, 25 Nov 2024 21:01:52 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, David Hildenbrand Subject: [PATCH v3 13/15] mm/page_alloc: Add __alloc_frozen_pages() Date: Mon, 25 Nov 2024 21:01:45 +0000 Message-ID: <20241125210149.2976098-14-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-Server: rspam03 X-Rspamd-Queue-Id: A0D0780003 X-Stat-Signature: etnp5hyffamyg5htoy9hz1uu5ifbdn1z X-HE-Tag: 1732574294-65971 X-HE-Meta: U2FsdGVkX18jZCrrqnvVu1gOAESSZ3+Lx9F0xPZ2zLGeSeNpeMj0WLcVqZY9qrUMNpx6QvyXleah1Vs+Y6Ad6cZapWrfd9UqTJKNFJpcPTekHqfMvk+yexcC0XvJIRvzyON/pzVcpe1cy/hexWG43C0UTyd7Q9y942KvS5GfeH/NulPVf1UbTXp8KBzqJEhCcsH5WZqE+0ELCmX+tzs7alThZg7Iq2TOdzyTlfU0nbyvcLaukHJ/B4rZAUch+gMfAyACU3WDZJ8utHCnhvMwJNFW7E/qvABwlW64FNBfQGDEgWHeyMadiE1ZnKepcitNty+rl1rTcPR5JeY8EWBDlBtht243fPk/CtkOHrB+N6BMWBvEQmG+UIiEGMI+sE6veAm0givcR8W7WTVYAU6/NiOn2BamEIA/2kzHQWDaBdUpwGfp9Vn7C27QG1HFmu/QuS1v2CV2Ec/eUNZ0Sa1Lc6N3gFW7fp+dYn/tDvP0/MxDi17QuNS7te6vctskkb/XzzngwGpMzY2ZMxLkmdKnuMxUna/jqjNojpZXgViMsT0T0zffFy9Vjbi3DTZW4xdnqrAAyv6xUgAd7fukox71pC+RJjLpEJqKhMsL6D3sDbjWTucsdh0ZlLf3fBQiHeNQGtjog+loPk/HfAzjqwbVSUaeeXx6U9XjciIBime/j4dfCgSbMNCUWJbbI/g10phSf3HPYZeKUVUF5UYP8p06OFcBQwxDQQoVpyh/3Vnu51Y6vvKgG1UagLl7FDAu998cueuPD4wY/aTOr5Io4XasvHkdTEqk/UEySavDwuG30rdhYznZz4wusPVFT8xGESGGwIBfPPd37kXH643ZbBO42NHoqvrQ9AiMvzaksH2NruztYtUTtjKT6RPTzdL2SLpinvlakmKIRplcjq17Ujv8AF8Ii9rLV/X1Cn3YFDHCvXr9CAijIfqP6Qhhxc37T97Dpz/sToxFVSqihEw3A14 uGj1HLEp 4NO0zAhoELt+ACLWUlCNhQq5KnSjsuXl5tMIPfXrYrH4mdzHr4NtmIygofGW/fPAU0yDBHy9VweDmJVDOLHghcFG9Ke6/CW2xjAJH6mm1F7+QTQsBDjf2Y24ijMvATY/qkLAy9A0PNMGDmYi6A00rhar7qVqcJDCX+zyecif7JGh0SpQCLkaqMW+vUagZ1ANQLaDV6Wd/H3bEvc187PsP0qfsEn7PuBTnch+/oZ6EYQBhBD+TN9o3H8jOn1aBlUJJA2WbTM15ShlJDwWBeW8wgfkKamT+eSbJQ2Rv 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: Defer the initialisation of the page refcount to the new __alloc_pages() wrapper and turn the old __alloc_pages() into __alloc_frozen_pages(). Signed-off-by: Matthew Wilcox (Oracle) Acked-by: David Hildenbrand --- mm/internal.h | 4 ++++ mm/page_alloc.c | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 9cc5fdc614cf..55e03f8f41d9 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -740,6 +740,10 @@ extern bool free_pages_prepare(struct page *page, unsigned int order); extern int user_min_free_kbytes; +struct page *__alloc_frozen_pages_noprof(gfp_t, unsigned int order, int nid, + nodemask_t *); +#define __alloc_frozen_pages(...) \ + alloc_hooks(__alloc_frozen_pages_noprof(__VA_ARGS__)) void free_frozen_pages(struct page *page, unsigned int order); void free_unref_folios(struct folio_batch *fbatch); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 35fb45b8b369..67b1cb757def 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4747,8 +4747,8 @@ EXPORT_SYMBOL_GPL(alloc_pages_bulk_noprof); /* * This is the 'heart' of the zoned buddy allocator. */ -struct page *__alloc_pages_noprof(gfp_t gfp, unsigned int order, - int preferred_nid, nodemask_t *nodemask) +struct page *__alloc_frozen_pages_noprof(gfp_t gfp, unsigned int order, + int preferred_nid, nodemask_t *nodemask) { struct page *page; unsigned int alloc_flags = ALLOC_WMARK_LOW; @@ -4804,14 +4804,24 @@ struct page *__alloc_pages_noprof(gfp_t gfp, unsigned int order, free_frozen_pages(page, order); page = NULL; } - if (page) - set_page_refcounted(page); trace_mm_page_alloc(page, order, alloc_gfp, ac.migratetype); kmsan_alloc_page(page, order, alloc_gfp); return page; } +EXPORT_SYMBOL(__alloc_frozen_pages_noprof); + +struct page *__alloc_pages_noprof(gfp_t gfp, unsigned int order, + int preferred_nid, nodemask_t *nodemask) +{ + struct page *page; + + page = __alloc_frozen_pages_noprof(gfp, order, preferred_nid, nodemask); + if (page) + set_page_refcounted(page); + return page; +} EXPORT_SYMBOL(__alloc_pages_noprof); struct folio *__folio_alloc_noprof(gfp_t gfp, unsigned int order, int preferred_nid,