From: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, kernel-dev@igalia.com,
kernel@gpiccoli.net, gpiccoli@igalia.com,
Andrew Morton <akpm@linux-foundation.org>,
Mike Rapoport <rppt@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH 1/2] mm/memblock: Print out errors on reserve_mem parser
Date: Tue, 17 Feb 2026 16:45:06 -0300 [thread overview]
Message-ID: <20260217195816.861684-2-gpiccoli@igalia.com> (raw)
In-Reply-To: <20260217195816.861684-1-gpiccoli@igalia.com>
The parsing of kernel parameter "reserve_mem=" is subject to
multiple failures, like duplicate naming, malformed expression
or even lack of available memory. Right now, all of these fail
silently. Let's add some messages so the kernel log can provide
useful information in case of failures.
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
---
mm/memblock.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/mm/memblock.c b/mm/memblock.c
index b3ddfdec7a80..2d2646f7a120 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -2642,23 +2642,25 @@ static int __init reserve_mem(char *p)
int len;
if (!p)
- return -EINVAL;
+ goto err_param;
/* Check if there's room for more reserved memory */
- if (reserved_mem_count >= RESERVE_MEM_MAX_ENTRIES)
+ if (reserved_mem_count >= RESERVE_MEM_MAX_ENTRIES) {
+ pr_err("reserve_mem: no more room for reserved memory\n");
return -EBUSY;
+ }
oldp = p;
size = memparse(p, &p);
if (!size || p == oldp)
- return -EINVAL;
+ goto err_param;
if (*p != ':')
- return -EINVAL;
+ goto err_param;
align = memparse(p+1, &p);
if (*p != ':')
- return -EINVAL;
+ goto err_param;
/*
* memblock_phys_alloc() doesn't like a zero size align,
@@ -2672,7 +2674,7 @@ static int __init reserve_mem(char *p)
/* name needs to have length but not too big */
if (!len || len >= RESERVE_MEM_NAME_SIZE)
- return -EINVAL;
+ goto err_param;
/* Make sure that name has text */
for (p = name; *p; p++) {
@@ -2680,11 +2682,13 @@ static int __init reserve_mem(char *p)
break;
}
if (!*p)
- return -EINVAL;
+ goto err_param;
/* Make sure the name is not already used */
- if (reserve_mem_find_by_name(name, &start, &tmp))
+ if (reserve_mem_find_by_name(name, &start, &tmp)) {
+ pr_err("reserve_mem: name \"%s\" was already used\n", name);
return -EBUSY;
+ }
/* Pick previous allocations up from KHO if available */
if (reserve_mem_kho_revive(name, size, align))
@@ -2692,12 +2696,18 @@ static int __init reserve_mem(char *p)
/* TODO: Allocation must be outside of scratch region */
start = memblock_phys_alloc(size, align);
- if (!start)
+ if (!start) {
+ pr_err("reserve_mem: memblock allocation failed\n");
return -ENOMEM;
+ }
reserved_mem_add(start, size, name);
return 1;
+err_param:
+ pr_err("reserve_mem: empty or malformed parameter\n");
+ return -EINVAL;
+
}
__setup("reserve_mem=", reserve_mem);
--
2.50.1
next prev parent reply other threads:[~2026-02-17 19:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-17 19:45 [PATCH 0/2] Some small improvements to reserve_mem Guilherme G. Piccoli
2026-02-17 19:45 ` Guilherme G. Piccoli [this message]
2026-02-17 19:45 ` [PATCH 2/2] mm/memblock: Add reserve_mem debugfs info Guilherme G. Piccoli
2026-02-18 0:15 ` kernel test robot
2026-02-18 0:26 ` kernel test robot
2026-02-21 8:52 ` Mike Rapoport
2026-02-21 8:29 ` [PATCH 0/2] Some small improvements to reserve_mem Mike Rapoport
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=20260217195816.861684-2-gpiccoli@igalia.com \
--to=gpiccoli@igalia.com \
--cc=akpm@linux-foundation.org \
--cc=kernel-dev@igalia.com \
--cc=kernel@gpiccoli.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox