From patchwork Wed Jan 29 22:41:42 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: 13954210 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 91C01C02190 for ; Wed, 29 Jan 2025 22:43:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 36E1928009E; Wed, 29 Jan 2025 17:42:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F4D828008C; Wed, 29 Jan 2025 17:42:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1BF3F28009E; Wed, 29 Jan 2025 17:42:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E34A528008C for ; Wed, 29 Jan 2025 17:42:40 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9B113452FC for ; Wed, 29 Jan 2025 22:42:40 +0000 (UTC) X-FDA: 83061965280.19.44363C0 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) by imf27.hostedemail.com (Postfix) with ESMTP id D3FD24000C for ; Wed, 29 Jan 2025 22:42:38 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=TC+lBrtt; spf=pass (imf27.hostedemail.com: domain of 33a6aZwQKCOgPfNVQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--fvdl.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=33a6aZwQKCOgPfNVQYYQVO.MYWVSXeh-WWUfKMU.YbQ@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=1738190558; 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=0+3HUxZiz+RKIQ9jlH4So8o0RBu4XPrYVAv2fom3TWtoIurWtWKpp003I4M0oJHxJZIrsR v+okUVWymzecVpSaxM5bRguGYdhU+QMPvQCKswJcZxUJS3O8xw4PIILeEZrEhf20QEICQS BGohx+qvn7C6CJNNVFN8X3eiX4xCU/s= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=TC+lBrtt; spf=pass (imf27.hostedemail.com: domain of 33a6aZwQKCOgPfNVQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--fvdl.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=33a6aZwQKCOgPfNVQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--fvdl.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738190558; a=rsa-sha256; cv=none; b=suYo8cjVUWtifGHUg7ZN5EA1h3qnOb1EprSJ7nJpe9pkRVTgVMZHlvBKx3fXko5YihC4hL 7JSDgy6uY3kfs3eRD2AtsM2f9BPEm8lpwoMPGtBg4UHVrhHiD2/MgNdVJGl+Bw7Pl2wL7d dgEpryGK+Sr2aB/RSy0p1Xmuwsvm1os= Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-21655569152so3146505ad.2 for ; Wed, 29 Jan 2025 14:42:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738190557; x=1738795357; 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=TC+lBrttueQ29DYCYA2ZtP3k76+o/YWTWXvqsqAomPjYS6am2VVA+3BgMvybRIQRM9 9B2sTPxyp3+5GghtFjJ3qwsdFWtSwQgJtu00aMn3Sg/f4Iw8mrzWyjgFLQYsOTDyAQhh SQqsaGqZwEhBSLTXS2Mfa6I1wkEA0OTQ+CXuCjfEyJtPt7hb1rGHFWmgnW6hTGu0B0Nw jK0gp5nWICOESj6P11/1TPfdBd3oqKFYrWSLyArMcD8jU7pIcYHB7OLjwv3Sjwwa2TQI xjp/rxI/jdz5QrQFAeZS/JN0EVug+1mkjq/FoAcAAJP7sw4v3yE9v6iycaYVn4F5AuLL 9MbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738190557; x=1738795357; 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=vx2ahHMdjF6E2YaCALeDCIHS1BBYRUT9hBPpewKRnnkaI7yacPfCeznBB2F3k971gg sy+zxuVTJBNhjr7K/CTSfMwhHZUwyPurp7UDF+WbuEQnXd3Rr2NIEPIFMkx+zOJLXnPU bZOgIr9DtKsznT6loF6JjfnYOCD6PQvl0lV6l1RbDHzbeq2KT97crRId9W7cCxw6tav2 s3k4B5gbFNEGxt/aBSfNTP4vu5EnMynCwj0Nxx7qLiLT6Ju3080DXMpt0+WxkpgrLBBe ZiDg8udWaK0iclgKNBdUzI//vB01q2H5cRR2eF+HzjSnFAuUd2lmdYZQPedo3cyrAu7r a3/w== X-Forwarded-Encrypted: i=1; AJvYcCVP+nq46qc/Ml2hxcymbS8+YIE8ZXqER/1IOgAWGKMP+7GO5Z3x5kvW8zrbC2KyNKka3o4/pltGVA==@kvack.org X-Gm-Message-State: AOJu0YxadLw4OKX5prmkd4SuwlwbZbq2cNkxJS0veUK3DZEehTgh/vP+ oDdk0XK2et/UduSKPNJaifLkikn4o4+stFjT/XB/oqpWnPE2fqwhEKU7tVwfKa2AjGZjQg== X-Google-Smtp-Source: AGHT+IG77o+oLUYvd4dsteZDfBQBaEerJ11jO3U7DjFTw9ASxdHAtRSoV+qn91gtydr1b6v63zVD5abu X-Received: from plbmf13.prod.google.com ([2002:a17:902:fc8d:b0:215:5a53:ee06]) (user=fvdl job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:d551:b0:216:5556:8b46 with SMTP id d9443c01a7336-21dd7e0728fmr78854645ad.49.1738190557688; Wed, 29 Jan 2025 14:42:37 -0800 (PST) Date: Wed, 29 Jan 2025 22:41:42 +0000 In-Reply-To: <20250129224157.2046079-1-fvdl@google.com> Mime-Version: 1.0 References: <20250129224157.2046079-1-fvdl@google.com> X-Mailer: git-send-email 2.48.1.262.g85cc9f2d1e-goog Message-ID: <20250129224157.2046079-14-fvdl@google.com> Subject: [PATCH v2 13/28] 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, usamaarif642@gmail.com, joao.m.martins@oracle.com, roman.gushchin@linux.dev, Frank van der Linden X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D3FD24000C X-Stat-Signature: 8ghdrfwrzdjmbwjkp5okymew8os1k6pg X-Rspam-User: X-HE-Tag: 1738190558-888313 X-HE-Meta: U2FsdGVkX1865/8zy31jqxf1+xBSzVwfZlLNMxWMl7FLz7ISlHtuqJ6jzC03hVqc/VFoO7RwvDP5LoiFjhm499T83VtzXxu+akE/BOuhNtHESBYsC+5PisWkMsuRjlMh2aVQidopPrFqxdx1Luo/xLJx+OhlMqzzsWssWGPQUdOA1u2tkwBqb8f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8DSMsqt6ktdxSj36X0Zdp/+BHIJoIH7f7/IygwO7sVYPwsslOe2rrVxPYMWdxKBliFNgzKsvLSbPFRjYzHGpMmHwKS/ekPutPWe7gbgyattg24RS5Wdx9ccgkx0wjsny18XVGhUkJxDdjmQ2gIp5zm2dDRMSdQKYyrNeV/AuIXqEe2+NrREz0dcnleVxyWgcWoIi06O7QyWYJHSqY8+42qMf9kO8Vez2gpmJL0lXsC/VOSFkWqSRnoc6iW4aGt6o25NCqUfzX69qDjNDN9plaFk1IGgkbbawyWJ+xmgMeUwuo15ri3RayWQd54d5Nw4ef9xXwXp9TSxrjWRS/u4k= 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) {}