From patchwork Mon Jan 27 23:21:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank van der Linden X-Patchwork-Id: 13951854 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 30DAEC0218A for ; Mon, 27 Jan 2025 23:23:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 639FC2801C2; Mon, 27 Jan 2025 18:22:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E94828013A; Mon, 27 Jan 2025 18:22:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 416052801C2; Mon, 27 Jan 2025 18:22:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 20CAE28013A for ; Mon, 27 Jan 2025 18:22:48 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CEF6916059D for ; Mon, 27 Jan 2025 23:22:47 +0000 (UTC) X-FDA: 83054808774.25.AA253F6 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) by imf03.hostedemail.com (Postfix) with ESMTP id 03AC52000B for ; Mon, 27 Jan 2025 23:22:45 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Nd5oV5Ug; spf=pass (imf03.hostedemail.com: domain of 3RBWYZwQKCBMyEw4z77z4x.v75416DG-553Etv3.7Az@flex--fvdl.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=3RBWYZwQKCBMyEw4z77z4x.v75416DG-553Etv3.7Az@flex--fvdl.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738020166; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xLt9HBc0qt/kG8opRR3xwjjIGa13UKxYV2/Ut2PpccA=; b=1jgveIqoZpCmKybYxOEf9K7cv6MMu4TFVp/TMV/C5zr1XGTCtpVzpd1ZfRvD4UzrzFHCG6 t3KAWKeppYzgzW/LarRum2PEkoQKnr9zYEtHx5UJE9ltbAjlnGYdp9yvUO+r3J3Lmjrril /7rqW/r5p+IYiHcFxvDfx70JwLqnHw8= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Nd5oV5Ug; spf=pass (imf03.hostedemail.com: domain of 3RBWYZwQKCBMyEw4z77z4x.v75416DG-553Etv3.7Az@flex--fvdl.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=3RBWYZwQKCBMyEw4z77z4x.v75416DG-553Etv3.7Az@flex--fvdl.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738020166; a=rsa-sha256; cv=none; b=teQVpZe2A0+pKYssHN4DQ6/ha3N6AuO0PzDC3qEB14zbSASyzjFysiL44U/0nWfXDGZ/i0 ntOsHSCrviXd5msvXvoGYXzGlr2fJAL68CdriKVci7VB93XdefznR0ifOQtANbdGgSia0Q eetBamlVJbFnp1jT+rdCDjKxbzdvvGo= Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2166e907b5eso89141995ad.3 for ; Mon, 27 Jan 2025 15:22:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738020165; x=1738624965; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xLt9HBc0qt/kG8opRR3xwjjIGa13UKxYV2/Ut2PpccA=; b=Nd5oV5Ug/DMDySpKK4Q804lcxelUJyV+uAuEauP5KVWya8GggFpz0fUnmxTiq3bMmK fid8yfrYw5/RGjW6p1uYPoWcs9wnna2upaf8doLKoxbbiILZNwQ0l3xen7Ba5uMY5dKJ bPUwsGCnB2VEytx0GnWs1reYRtbD9xVMrm/+Q0SJhLd6+6vbpDNBtpSQxL2ThCawqkUe V+sAqqhd2TKHZv0sLzvLAOxeXf/bpv9hQdWKtxgrx1EzO8h3WzPsSJwS8VFnJaQ992s/ KInv5u/pBY1slxpV6cMgMU/SpWIa8sYZ8qSCPl1bbBNBNQ4wjCoW6eyQrBRadv+R9sN0 F9zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738020165; x=1738624965; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xLt9HBc0qt/kG8opRR3xwjjIGa13UKxYV2/Ut2PpccA=; b=a+X1Dkn1QQZciEOnYPrq8qWrJe9J6uIOPbmOHZtvXfD99xVoesRKuVxG1SwGdqQgpF UB9AnXPz69ZzTw/GCKHmE38PLMaS4twDxoflFMDLNyEsRY5eZ9wDK61s4d/8BoY05t/v 6rlY8DMlsnW6ov2cXZ3AYXKTyst+Aov2n6ZxXlyB9d4OQP8NylaC7ciV/LJO7e4rWXRd 19QyXL0QXAN+DeTUspazbaT/QQzU0wb7zXN3C28gwBsggU7N/BaBwDRhR4XIQ7rvkQvm gGuYXcZxli5PyGmBMdSsfPHkpgwkzoYAOQ0unflH0TZauYR96UwHG5msT3tFLB4/0WPf G45A== X-Forwarded-Encrypted: i=1; AJvYcCXCIe6jGfzgyfM2qNKqFfz7jlxP66aNve4BdGkl6HBW2AFqUYYJ6l69jKLmyuvJPp5IrhlCL/b9+w==@kvack.org X-Gm-Message-State: AOJu0YwJYJ/1XFde1fj+kvWXq/RrADE7ohbQDqwouW3TLJGC2/rI9PwB Qb3Q1YkEnD0DfMzP/Oia1Dzzlcpq2ETWTxmCMk0G1a+rvn9rdXb6AQT3ZgOzfyIFMVATXA== X-Google-Smtp-Source: AGHT+IEy4AliGB/BJZg6HxqjwcmwX1utwC6DXZQSuAJ7MG3sxG6Hj9E074OSH8KEZyMN9lWrc3wMyVEV X-Received: from pgqw8.prod.google.com ([2002:a65:6948:0:b0:ac2:39d0:bdd7]) (user=fvdl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:7896:b0:1cf:27bf:8e03 with SMTP id adf61e73a8af0-1eb21585e4cmr64832659637.26.1738020164830; Mon, 27 Jan 2025 15:22:44 -0800 (PST) Date: Mon, 27 Jan 2025 23:21:53 +0000 In-Reply-To: <20250127232207.3888640-1-fvdl@google.com> Mime-Version: 1.0 References: <20250127232207.3888640-1-fvdl@google.com> X-Mailer: git-send-email 2.48.1.262.g85cc9f2d1e-goog Message-ID: <20250127232207.3888640-14-fvdl@google.com> Subject: [PATCH 13/27] mm: define __init_reserved_page_zone function From: Frank van der Linden To: akpm@linux-foundation.org, muchun.song@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: yuzhao@google.com, usama.arif@bytedance.com, joao.m.martins@oracle.com, roman.gushchin@linux.dev, Frank van der Linden X-Rspamd-Queue-Id: 03AC52000B X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: bsodgdtpywb1ipca7pj3rnkixoami3w9 X-HE-Tag: 1738020165-939344 X-HE-Meta: U2FsdGVkX1+41bIOiFN6U7UgzIruUmNplM+y91jXHT6u8nmYWW4Rm6qRcZET6fsgMWNlk2ohfQsUs9MalAKk6nzQpiGCB/O7WYjHUS8BNyqet+PsI1onqiZlxlOKXa6V7GEe1uKsCaCcwuB2eDQ4FLOvbeL9z0LAMg5ksA1CrQ0DQKoG3FM5ntfii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jdJyJiFtpTS9NE2nMCFwsMmvU7nG0sJKSrBap6UBOyQIB6bCS8GT38tdOQfVnlTbJMOB0QD452Jh675MdfJSftpfmnEJO2E3rqG24vawe/pGyCcN49yHqMubFofAd7HhtpCwj/5THMwQzRGWyHpocnw2PGukxfZ6VyH+gLPHsJGYDVMleqf6sVFv7EelJEtL/2PTYuD+MgqABf6wZ/ttux91oDpbQYE2usNkblWnvbnYjDhpBYWgP0DDivyfKcVjpSNfSf8KWtiox8jEXh91vd2VQ28J4DqygkWSNmQcx5TzKCxj4TaV8Q3T47LlCM06efPwJWtTrRxdeMPwR2Os= 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: Sometimes page structs must be unconditionally initialized as reserved, regardless of DEFERRED_STRUCT_PAGE_INIT. Define a function, __init_reserved_page_zone, containing code that already did all of the work in init_reserved_page, and make it available for use. Signed-off-by: Frank van der Linden --- mm/internal.h | 1 + mm/mm_init.c | 38 +++++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 109ef30fee11..57662141930e 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1448,6 +1448,7 @@ static inline bool pte_needs_soft_dirty_wp(struct vm_area_struct *vma, pte_t pte void __meminit __init_single_page(struct page *page, unsigned long pfn, unsigned long zone, int nid); +void __meminit __init_reserved_page_zone(unsigned long pfn, int nid); /* shrinker related functions */ unsigned long shrink_slab(gfp_t gfp_mask, int nid, struct mem_cgroup *memcg, diff --git a/mm/mm_init.c b/mm/mm_init.c index 9f1e41c3dde6..925ed6564572 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -650,6 +650,28 @@ static inline void fixup_hashdist(void) static inline void fixup_hashdist(void) {} #endif /* CONFIG_NUMA */ +/* + * Initialize a reserved page unconditionally, finding its zone first. + */ +void __meminit __init_reserved_page_zone(unsigned long pfn, int nid) +{ + pg_data_t *pgdat; + int zid; + + pgdat = NODE_DATA(nid); + + for (zid = 0; zid < MAX_NR_ZONES; zid++) { + struct zone *zone = &pgdat->node_zones[zid]; + + if (zone_spans_pfn(zone, pfn)) + break; + } + __init_single_page(pfn_to_page(pfn), pfn, zid, nid); + + if (pageblock_aligned(pfn)) + set_pageblock_migratetype(pfn_to_page(pfn), MIGRATE_MOVABLE); +} + #ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT static inline void pgdat_set_deferred_range(pg_data_t *pgdat) { @@ -708,24 +730,10 @@ defer_init(int nid, unsigned long pfn, unsigned long end_pfn) static void __meminit init_reserved_page(unsigned long pfn, int nid) { - pg_data_t *pgdat; - int zid; - if (early_page_initialised(pfn, nid)) return; - pgdat = NODE_DATA(nid); - - for (zid = 0; zid < MAX_NR_ZONES; zid++) { - struct zone *zone = &pgdat->node_zones[zid]; - - if (zone_spans_pfn(zone, pfn)) - break; - } - __init_single_page(pfn_to_page(pfn), pfn, zid, nid); - - if (pageblock_aligned(pfn)) - set_pageblock_migratetype(pfn_to_page(pfn), MIGRATE_MOVABLE); + __init_reserved_page_zone(pfn, nid); } #else static inline void pgdat_set_deferred_range(pg_data_t *pgdat) {}