From patchwork Mon Nov 25 21:01:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13885315 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 F2C08D59D73 for ; Mon, 25 Nov 2024 21:38:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 48DAA6B0088; Mon, 25 Nov 2024 16:38:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 43D826B0089; Mon, 25 Nov 2024 16:38:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32C136B008C; Mon, 25 Nov 2024 16:38:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 150B26B0088 for ; Mon, 25 Nov 2024 16:38:21 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id BE588160EB8 for ; Mon, 25 Nov 2024 21:38:20 +0000 (UTC) X-FDA: 82825931076.18.B69AA50 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf16.hostedemail.com (Postfix) with ESMTP id 311BB180008 for ; Mon, 25 Nov 2024 21:38:14 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=dWz7GKjP; dmarc=none; spf=none (imf16.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=1732570696; a=rsa-sha256; cv=none; b=LvMjI+imfWA6Mk4nnaoIKc/zavhNhdDMR6aa3oscnXDyvFmet/R/cUOp02vty5BaGpOTho 21lwqCo7tBtTumCCL5aW37X91ia2z7u+D7NERL5I87QG5AOyTfZy4DPP5RxGSrZndrVrNd WUwYkuQJlTblCMJs2lIuCh+4VnIff00= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=dWz7GKjP; dmarc=none; spf=none (imf16.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=1732570696; 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=NyXU/7JDZr5zMHu3c4Kg/pLLdo4wbKi9H/MK7sGHG5A=; b=33TR+Qd7zZRrHOxvRvsgZe3dqQTjcLe8xOAVyskRwXuzmPLvkZTGVYpfdzlFh547kof2K8 rw0oWENueC8+jNRXnb+uc521xps/d/QXbduQ/QxRoFLzfRi9XVNboB+HHCTc0DA/5PMXt1 kXzFLeeHOFhBNVhSYRAnYRVNktvd+j8= 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=NyXU/7JDZr5zMHu3c4Kg/pLLdo4wbKi9H/MK7sGHG5A=; b=dWz7GKjPNNF60Zr5rRZ6rKmXei xDze31MLuYvVQw4Gq6EPpGbHRnZMcDI7Jp2hLW7xior2/api14rZJhyAAQNV9mY1B9IMF0jPH7w98 OXnTv5Sx/pbM5kC6rc4Ublrq0k4JV9h3KvM1M9L0d1UPsLuqGEx8cW0eilIKB3UxUab5SPDKoutVU 4YMREb3330dMOXEz0xslJK6dK+PKDImV9/GK0d1zJz09jmhr9h2XZnm2uQf886zh8e86kVipL0mZV vmKDn3PnLhLlxeN+NahL3FTRPC813aR2cAu0L5C9f2+rYJ/WDrCMVkxJAdr1gfwuTqmLNHy+b5IR/ 5F/rXB0A==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tFgDP-0000000CUE1-1GLR; 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 Subject: [PATCH v3 05/15] mm/page_alloc: Move set_page_refcounted() to callers of prep_new_page() Date: Mon, 25 Nov 2024 21:01:37 +0000 Message-ID: <20241125210149.2976098-6-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-Rspamd-Queue-Id: 311BB180008 X-Stat-Signature: kmqh8415x3fpsc6kedckfr614agogy7x X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1732570694-967033 X-HE-Meta: U2FsdGVkX1+odoMNWUPcE79Pw9YlNDYBVSoXUgPJhkgO0c7EH2+C1L8mNfOiZ4h5+0W/qDCx0w4s336e1ci4vP+86hkrlwYSd/FEfE+r5sYK/hhvZQb9NieqslGU8T8b5ymp4BeY4BLvTvD+DXZxCNUES+0jrCh1f+Ik0TgxZ5SdJhMsXQwBr/JWvmo6iBnxX7w0wJ5xM6iiER+Qf63SPElHstgM0nEN8RFUqp+WnDwCMxpVkaejgq6DVWNEzNp1iJQULIvX2P6qGZGlzSxFnEKvf4Vx6YzhD4YRhGWom+Wm/zMpeRoMKpUyH7IYLAmI4qX8zZoGYq7vNNB8JdFACqHJB/CbgwQgq533MSwr28G6YGVMakPYVIUAJJ7TmUPJsC6N8c972EKIxVxwwSs/FhtYHP4lRZMSqujuDqy7gZuqFEPKJl1euix6hgaiKzQqD1jdf5LwvZMry+ybymHyMwnCQ/fUJGq02PeZ/dd8v94f0T0NBBTCbW4U5Op7z8eujmovH17qUBScxnowD37l8HJcjkRsUhfiKIlXLiDUAKVdHCsZKeK2I7RtuM62LFeF+9PJf0snbujv4XS8v102LIZtce0BBwEDd5zZ9YDPThc7MfvgRktZ4xNazcNIj/x055xFsyAdviJohA6v3BlQtvgLx6HZ2GAEqXilQj6Bl8EMYw5/rjBr+K8ZbuJp3iy6eFuG2OQhnQguoInyWiQgrLjGUap8MzUmDLOUIkIBYfk7YCFywmZBoPHTbj638o5cogg5wg/c9AETiJ9oqS+KKT86I2RbZTFPK5CYY3f9a16TOOS02chgy2NK0WPIrQ4PoYDa0JM8hulbC+hmswCJRu9Iu1T0x0y/35NlGIBPciFXvBNJj+AhxQlVJFyDa685ebZ9weBn1Ednp4MZnkVTkDE+r4/xdq6VDOEAjlCZOpl4Qlipugpw0uqly8hkOdau2WkxXB7PHfnBFyZB+4y wJGzCfF2 2yu/p7kA79Cap7h9Glx3URlaNvDtDgKsaRsBpF0xFBYdIZgCrikhqES8LXRL3BLIM0vOA0DO6RJXU0R8D2HO6aJlu4eIBGlgpROSmxqgku4r5ZinVhRKKClyGDW5qDa5nhfXjCjRMZQC/q0381xzIOXWVYmvL6/9al2cnMqyBCdel/B/eNbhngXMrMUA9DrYoqy2N5X0DXW6XKxaFOpSKPQLCuZPZZ8fIQZbBkoFZhKkFyKAmiBjRUA0m9Sdsobeh60SVtNjEYwHFeas4sqJbYqd0ZeXPCDdGPSLa 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: In preparation for allocating frozen pages, stop initialising the page refcount in prep_new_page(). Signed-off-by: Matthew Wilcox (Oracle) Acked-by: David Hildenbrand --- mm/page_alloc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e3a4aaf437f9..c2b46cdc7ffd 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1561,7 +1561,6 @@ static void prep_new_page(struct page *page, unsigned int order, gfp_t gfp_flags unsigned int alloc_flags) { post_alloc_hook(page, order, gfp_flags); - set_page_refcounted(page); if (order && (gfp_flags & __GFP_COMP)) prep_compound_page(page, order); @@ -3508,6 +3507,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags, gfp_mask, alloc_flags, ac->migratetype); if (page) { prep_new_page(page, order, gfp_mask, alloc_flags); + set_page_refcounted(page); /* * If this is a high-order atomic allocation then check @@ -3732,8 +3732,10 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, count_vm_event(COMPACTSTALL); /* Prep a captured page if available */ - if (page) + if (page) { prep_new_page(page, order, gfp_mask, alloc_flags); + set_page_refcounted(page); + } /* Try get a page from the freelist if available */ if (!page) @@ -4712,6 +4714,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid, nr_account++; prep_new_page(page, 0, gfp, 0); + set_page_refcounted(page); if (page_list) list_add(&page->lru, page_list); else @@ -6534,6 +6537,7 @@ int alloc_contig_range_noprof(unsigned long start, unsigned long end, check_new_pages(head, order); prep_new_page(head, order, gfp_mask, 0); + set_page_refcounted(head); } else { ret = -EINVAL; WARN(true, "PFN range: requested [%lu, %lu), allocated [%lu, %lu)\n",