2022-02-28 11:10:33

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v2 0/4] MIPS: Modify mem= and memmap= parameter

In the current code, the kernel command-line parameter mem= and memmap=
can not work well on MIPS, this patchset refactors the related code to
fix them.

For kdump on MIPS, if the users want to limit the memory region for the
capture kernel to avoid corrupting the memory image of the panic kernel,
use the parameter memmap=limit@base is the proper way, I will submit a
patch to use memmap=limit@base for kexec-tools after this patchset is
applied.

v2: Add some new patches to support memmap=limit@base

Tiezhu Yang (4):
MIPS: Refactor early_parse_mem() to fix mem= parameter
memblock: Introduce memblock_mem_range_remove_map()
MIPS: Refactor early_parse_memmap() to fix memmap= parameter
MIPS: Remove not used variable usermem

arch/mips/kernel/setup.c | 71 ++++++++++++------------------------------------
include/linux/memblock.h | 1 +
mm/memblock.c | 9 ++++--
3 files changed, 25 insertions(+), 56 deletions(-)

--
2.1.0


2022-02-28 11:14:26

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v2 2/4] memblock: Introduce memblock_mem_range_remove_map()

This is preparation for supporting memmap=limit@base parameter,
no functionality change.

Signed-off-by: Tiezhu Yang <[email protected]>
---
include/linux/memblock.h | 1 +
mm/memblock.c | 9 +++++++--
2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 50ad196..e558d2c 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -482,6 +482,7 @@ phys_addr_t memblock_end_of_DRAM(void);
void memblock_enforce_memory_limit(phys_addr_t memory_limit);
void memblock_cap_memory_range(phys_addr_t base, phys_addr_t size);
void memblock_mem_limit_remove_map(phys_addr_t limit);
+void memblock_mem_range_remove_map(phys_addr_t base, phys_addr_t limit);
bool memblock_is_memory(phys_addr_t addr);
bool memblock_is_map_memory(phys_addr_t addr);
bool memblock_is_region_memory(phys_addr_t base, phys_addr_t size);
diff --git a/mm/memblock.c b/mm/memblock.c
index 1018e50..2476d15d 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -1723,7 +1723,7 @@ void __init memblock_cap_memory_range(phys_addr_t base, phys_addr_t size)
base + size, PHYS_ADDR_MAX);
}

-void __init memblock_mem_limit_remove_map(phys_addr_t limit)
+void __init memblock_mem_range_remove_map(phys_addr_t base, phys_addr_t limit)
{
phys_addr_t max_addr;

@@ -1736,7 +1736,12 @@ void __init memblock_mem_limit_remove_map(phys_addr_t limit)
if (max_addr == PHYS_ADDR_MAX)
return;

- memblock_cap_memory_range(0, max_addr);
+ memblock_cap_memory_range(base, max_addr);
+}
+
+void __init memblock_mem_limit_remove_map(phys_addr_t limit)
+{
+ memblock_mem_range_remove_map(0, limit);
}

static int __init_memblock memblock_search(struct memblock_type *type, phys_addr_t addr)
--
2.1.0

2022-02-28 11:28:27

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v2 4/4] MIPS: Remove not used variable usermem

Now, the variable usermem is not used any more, just remove it.

Signed-off-by: Tiezhu Yang <[email protected]>
---
arch/mips/kernel/setup.c | 5 -----
1 file changed, 5 deletions(-)

diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index e3b1f2e..a65d0b28 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -338,7 +338,6 @@ static void __init bootmem_init(void)

#endif /* CONFIG_SGI_IP27 */

-static int usermem __initdata;
static phys_addr_t memory_limit;
static phys_addr_t memory_base;

@@ -596,10 +595,6 @@ static void __init arch_mem_init(char **cmdline_p)
*cmdline_p = command_line;

parse_early_param();
-
- if (usermem)
- pr_info("User-defined physical RAM map overwrite\n");
-
check_kernel_sections_mem();

early_init_fdt_reserve_self();
--
2.1.0