From: Mike Rapoport <rppt@kernel.org>
To: Zhen Ni <zhen.ni@easystack.cn>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>,
Rich Felker <dalias@libc.org>,
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
"David S. Miller" <davem@davemloft.net>,
Andreas Larsson <andreas@gaisler.com>,
Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org,
sparclinux@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] mm/memblock: Introduce memblock_alloc_node_or_panic() helper
Date: Thu, 4 Jun 2026 08:44:17 +0300 [thread overview]
Message-ID: <aiEQscLI2LkNSj2v@kernel.org> (raw)
In-Reply-To: <20260604034139.2827148-1-zhen.ni@easystack.cn>
On Thu, Jun 04, 2026 at 11:41:39AM +0800, Zhen Ni wrote:
> During early boot, several subsystems allocate memory from specific
> NUMA nodes using memblock_alloc_node(). When allocation fails, the
> typical requirement is to panic immediately.
>
> Introduce memblock_alloc_node_or_panic() to automatically panic on
> allocation failure. This reduces repetitive error checking, improves code
> consistency across subsystems, and enhances code readability.
memblock_alloc_or_panic() made sense because it's the most used memblock
API.
Adding panic() versions for a handful of uses is unnecessary churn.
A better patch would be to update panic() messages to convey more useful
information.
> Signed-off-by: Zhen Ni <zhen.ni@easystack.cn>
> ---
> arch/sh/mm/numa.c | 10 ++++------
> arch/sparc/kernel/setup_64.c | 16 ++++++----------
> arch/x86/coco/sev/core.c | 5 ++---
> include/linux/memblock.h | 6 ++++++
> mm/memblock.c | 22 ++++++++++++++++++++++
> mm/mm_init.c | 11 ++++-------
> mm/sparse.c | 13 +++++--------
> 7 files changed, 49 insertions(+), 34 deletions(-)
>
> diff --git a/arch/sh/mm/numa.c b/arch/sh/mm/numa.c
> index 9bc212b5e762..32b01697b27f 100644
> --- a/arch/sh/mm/numa.c
> +++ b/arch/sh/mm/numa.c
> @@ -38,12 +38,10 @@ void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)
> __add_active_range(nid, start_pfn, end_pfn);
>
> /* Node-local pgdat */
> - NODE_DATA(nid) = memblock_alloc_node(sizeof(struct pglist_data),
> - SMP_CACHE_BYTES, nid);
> - if (!NODE_DATA(nid))
> - panic("%s: Failed to allocate %zu bytes align=0x%x nid=%d\n",
> - __func__, sizeof(struct pglist_data), SMP_CACHE_BYTES,
> - nid);
> + NODE_DATA(nid) = memblock_alloc_node_or_panic(
> + sizeof(struct pglist_data),
> + SMP_CACHE_BYTES,
> + nid);
Please don't touch this, the entire file is going away after rc1.
>
> NODE_DATA(nid)->node_start_pfn = start_pfn;
> NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn;
--
Sincerely yours,
Mike.
prev parent reply other threads:[~2026-06-04 5:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 3:41 [PATCH] mm/memblock: Introduce memblock_alloc_node_or_panic() helper Zhen Ni
2026-06-04 5:44 ` Mike Rapoport [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aiEQscLI2LkNSj2v@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=andreas@gaisler.com \
--cc=bp@alien8.de \
--cc=dalias@libc.org \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=david@kernel.org \
--cc=glaubitz@physik.fu-berlin.de \
--cc=hpa@zytor.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-sh@vger.kernel.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=sparclinux@vger.kernel.org \
--cc=surenb@google.com \
--cc=tglx@kernel.org \
--cc=vbabka@kernel.org \
--cc=x86@kernel.org \
--cc=ysato@users.sourceforge.jp \
--cc=zhen.ni@easystack.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.