* [RFC PATCH] reserve_mem: add support for static memory
@ 2026-06-18 22:40 Shyam Saini
2026-06-18 23:02 ` Randy Dunlap
2026-06-23 13:10 ` Pratyush Yadav
0 siblings, 2 replies; 3+ messages in thread
From: Shyam Saini @ 2026-06-18 22:40 UTC (permalink / raw)
To: linux-mm, linux-doc, linux-kernel
Cc: rppt, akpm, kees, tony.luck, gpiccoli, bp, rdunlap, peterz,
feng.tang, dapeng1.mi, elver, enelsonmoore, kuba, lirongqing,
ebiggers
reserve_mem relies on dynamic memory allocation, this limits the
usecase where memory and its address is required to be preserved
across the boots. Eg: ramoops memory reservation on ACPI platforms
So add support to pass a pre-determined static address and reserve
memory at this specified address. This enables use case like ramoops
on ACPI platforms to reliably access ramoops region across the boots.
Also skip parsing of "align" parameter when static address is passed.
Example syntax for static address
reserve_mem=4M@0x1E0000000:oops ramoops.mem_name=oops
Signed-off-by: Shyam Saini <shyamsaini@linux.microsoft.com>
---
.../admin-guide/kernel-parameters.txt | 15 ++++++
mm/memblock.c | 48 +++++++++++++------
2 files changed, 49 insertions(+), 14 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index b5493a7f8f228..7e0baca564b97 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -6563,6 +6563,21 @@ Kernel parameters
reserve_mem=12M:4096:oops ramoops.mem_name=oops
+ reserve_mem= [RAM]
+ Format: nn[KMG]:<@offset>:<label>
+ Reserve physical memory at pre-determined location and label it with
+ a name that other subsystems can use to access it. This is typically
+ used for systems that do not wipe the RAM, and this command
+ line will try to reserve the same physical memory on
+ soft reboots. Note, it is guaranteed to be the same
+ location unless some other early allocation for eg: crashkernel=256M
+ (without static address) is reserved or overlapps this region.
+
+ The format is size:offset:label for example, to request
+ 4 megabytes for ramoops at 0x1E0000000:
+
+ reserve_mem=4M@0x1E0000000:oops ramoops.mem_name=oops
+
reservetop= [X86-32,EARLY]
Format: nn[KMG]
Reserves a hole at the top of the kernel virtual
diff --git a/mm/memblock.c b/mm/memblock.c
index 6349c48154f4b..79f1f806ea364 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -2721,6 +2721,7 @@ static int __init reserve_mem(char *p)
char *name;
char *oldp;
int len;
+ bool addr_is_static = false;
if (!p)
goto err_param;
@@ -2739,16 +2740,27 @@ static int __init reserve_mem(char *p)
if (*p != ':')
goto err_param;
- align = memparse(p+1, &p);
+ /* parse the static memory address */
+ if (*p == '@') {
+ start = memparse(p+1, &p);
+ addr_is_static = true;
+ }
+
if (*p != ':')
goto err_param;
- /*
- * memblock_phys_alloc() doesn't like a zero size align,
- * but it is OK for this command to have it.
- */
- if (align < SMP_CACHE_BYTES)
- align = SMP_CACHE_BYTES;
+ if (!addr_is_static) {
+ align = memparse(p+1, &p);
+ if (*p != ':')
+ goto err_param;
+
+ /*
+ * memblock_phys_alloc() doesn't like a zero size align,
+ * but it is OK for this command to have it.
+ */
+ if (align < SMP_CACHE_BYTES)
+ align = SMP_CACHE_BYTES;
+ }
name = p + 1;
len = strlen(name);
@@ -2772,16 +2784,24 @@ static int __init reserve_mem(char *p)
}
/* Pick previous allocations up from KHO if available */
- if (reserve_mem_kho_revive(name, size, align))
+ if (!addr_is_static && reserve_mem_kho_revive(name, size, align))
return 1;
- /* TODO: Allocation must be outside of scratch region */
- start = memblock_phys_alloc(size, align);
- if (!start) {
- pr_err("reserve_mem: memblock allocation failed\n");
- return -ENOMEM;
- }
+ if (addr_is_static) {
+ if (memblock_reserve(start, size)) {
+ pr_err("reserve_mem: memblock reservation failed\n");
+ return -ENOMEM;
+ }
+
+ } else {
+ /* TODO: Allocation must be outside of scratch region */
+ start = memblock_phys_alloc(size, align);
+ if (!start) {
+ pr_err("reserve_mem: memblock allocation failed\n");
+ return -ENOMEM;
+ }
+ }
reserved_mem_add(start, size, name);
return 1;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] reserve_mem: add support for static memory
2026-06-18 22:40 [RFC PATCH] reserve_mem: add support for static memory Shyam Saini
@ 2026-06-18 23:02 ` Randy Dunlap
2026-06-23 13:10 ` Pratyush Yadav
1 sibling, 0 replies; 3+ messages in thread
From: Randy Dunlap @ 2026-06-18 23:02 UTC (permalink / raw)
To: Shyam Saini, linux-mm, linux-doc, linux-kernel
Cc: rppt, akpm, kees, tony.luck, gpiccoli, bp, peterz, feng.tang,
dapeng1.mi, elver, enelsonmoore, kuba, lirongqing, ebiggers
On 6/18/26 3:40 PM, Shyam Saini wrote:
> reserve_mem relies on dynamic memory allocation, this limits the
> usecase where memory and its address is required to be preserved
> across the boots. Eg: ramoops memory reservation on ACPI platforms
>
> So add support to pass a pre-determined static address and reserve
> memory at this specified address. This enables use case like ramoops
> on ACPI platforms to reliably access ramoops region across the boots.
>
> Also skip parsing of "align" parameter when static address is passed.
>
> Example syntax for static address
> reserve_mem=4M@0x1E0000000:oops ramoops.mem_name=oops
>
> Signed-off-by: Shyam Saini <shyamsaini@linux.microsoft.com>
> ---
> .../admin-guide/kernel-parameters.txt | 15 ++++++
> mm/memblock.c | 48 +++++++++++++------
> 2 files changed, 49 insertions(+), 14 deletions(-)
>
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index b5493a7f8f228..7e0baca564b97 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -6563,6 +6563,21 @@ Kernel parameters
>
> reserve_mem=12M:4096:oops ramoops.mem_name=oops
>
> + reserve_mem= [RAM]
According to this file (kernel-parameters.txt), "RAM" means that this
option applies when "RAM disk support is enabled."
Is that correct here?
My guess is that it's incorrect for the other (existing) "reserve_mem=" also.
> + Format: nn[KMG]:<@offset>:<label>
> + Reserve physical memory at pre-determined location and label it with
Preferably predetermined
> + a name that other subsystems can use to access it. This is typically
> + used for systems that do not wipe the RAM, and this command
> + line will try to reserve the same physical memory on
> + soft reboots. Note, it is guaranteed to be the same
> + location unless some other early allocation for eg: crashkernel=256M
allocation, e.g.: crashkernel=256M
> + (without static address) is reserved or overlapps this region.
overlaps
> +
> + The format is size:offset:label for example, to request
> + 4 megabytes for ramoops at 0x1E0000000:
> +
> + reserve_mem=4M@0x1E0000000:oops ramoops.mem_name=oops
> +
> reservetop= [X86-32,EARLY]
> Format: nn[KMG]
> Reserves a hole at the top of the kernel virtual
> diff --git a/mm/memblock.c b/mm/memblock.c
> index 6349c48154f4b..79f1f806ea364 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -2721,6 +2721,7 @@ static int __init reserve_mem(char *p)
> char *name;
> char *oldp;
> int len;
> + bool addr_is_static = false;
>
> if (!p)
> goto err_param;
> @@ -2739,16 +2740,27 @@ static int __init reserve_mem(char *p)
> if (*p != ':')
> goto err_param;
>
> - align = memparse(p+1, &p);
> + /* parse the static memory address */
> + if (*p == '@') {
> + start = memparse(p+1, &p);
> + addr_is_static = true;
> + }
> +
> if (*p != ':')
> goto err_param;
>
> - /*
> - * memblock_phys_alloc() doesn't like a zero size align,
> - * but it is OK for this command to have it.
> - */
> - if (align < SMP_CACHE_BYTES)
> - align = SMP_CACHE_BYTES;
> + if (!addr_is_static) {
> + align = memparse(p+1, &p);
> + if (*p != ':')
> + goto err_param;
> +
> + /*
> + * memblock_phys_alloc() doesn't like a zero size align,
> + * but it is OK for this command to have it.
> + */
> + if (align < SMP_CACHE_BYTES)
> + align = SMP_CACHE_BYTES;
> + }
>
> name = p + 1;
> len = strlen(name);
> @@ -2772,16 +2784,24 @@ static int __init reserve_mem(char *p)
> }
>
> /* Pick previous allocations up from KHO if available */
> - if (reserve_mem_kho_revive(name, size, align))
> + if (!addr_is_static && reserve_mem_kho_revive(name, size, align))
> return 1;
>
> - /* TODO: Allocation must be outside of scratch region */
> - start = memblock_phys_alloc(size, align);
> - if (!start) {
> - pr_err("reserve_mem: memblock allocation failed\n");
> - return -ENOMEM;
> - }
> + if (addr_is_static) {
> + if (memblock_reserve(start, size)) {
> + pr_err("reserve_mem: memblock reservation failed\n");
> + return -ENOMEM;
> + }
> +
> + } else {
> + /* TODO: Allocation must be outside of scratch region */
> + start = memblock_phys_alloc(size, align);
> + if (!start) {
> + pr_err("reserve_mem: memblock allocation failed\n");
> + return -ENOMEM;
> + }
>
> + }
> reserved_mem_add(start, size, name);
>
> return 1;
__setup() functions return 1 for "yes, I handled this option" (even if there
were errors in it) and 0 for failure ("no idea what this string/option means").
These -ENOMEM, -EINVAL, -EBUSY (in this function) are non-zero so they look like
success and should not be here.
--
~Randy
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] reserve_mem: add support for static memory
2026-06-18 22:40 [RFC PATCH] reserve_mem: add support for static memory Shyam Saini
2026-06-18 23:02 ` Randy Dunlap
@ 2026-06-23 13:10 ` Pratyush Yadav
1 sibling, 0 replies; 3+ messages in thread
From: Pratyush Yadav @ 2026-06-23 13:10 UTC (permalink / raw)
To: Shyam Saini
Cc: linux-mm, linux-doc, linux-kernel, rppt, akpm, kees, tony.luck,
gpiccoli, bp, rdunlap, peterz, feng.tang, dapeng1.mi, elver,
enelsonmoore, kuba, lirongqing, ebiggers
On Thu, Jun 18 2026, Shyam Saini wrote:
> reserve_mem relies on dynamic memory allocation, this limits the
> usecase where memory and its address is required to be preserved
> across the boots. Eg: ramoops memory reservation on ACPI platforms
>
> So add support to pass a pre-determined static address and reserve
> memory at this specified address. This enables use case like ramoops
> on ACPI platforms to reliably access ramoops region across the boots.
Doesn't memmap= do exactly this? How is this different?
I always thought the point of reserve_mem was that you _don't_ have to
provide an explicit address, one is chosen for your machine
automatically.
>
> Also skip parsing of "align" parameter when static address is passed.
>
> Example syntax for static address
> reserve_mem=4M@0x1E0000000:oops ramoops.mem_name=oops
>
> Signed-off-by: Shyam Saini <shyamsaini@linux.microsoft.com>
[...]
--
Regards,
Pratyush Yadav
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-23 13:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-18 22:40 [RFC PATCH] reserve_mem: add support for static memory Shyam Saini
2026-06-18 23:02 ` Randy Dunlap
2026-06-23 13:10 ` Pratyush Yadav
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.