diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 858dd038499d..ce9e964d7bfb 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2533,6 +2533,12 @@ memblock=debug [KNL] Enable memblock debug messages. + android12_only.will_be_removed_soon.memblock_nomap_remove= [KNL] + Setting this to true through kernel command line will + call memblock_remove on the regions marked with no-map + property thereby saving memory by removing page structs + for those regions. By default this is set to false. + load_ramdisk= [RAM] [Deprecated] lockd.nlm_grace_period=P [NFS] Assign grace period. diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 74d2bd7a6550..01e14ac13571 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -1181,6 +1181,9 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, if (memblock_is_region_reserved(base, size)) return -EBUSY; + if (memblock_is_nomap_remove()) + return memblock_remove(base, size); + return memblock_mark_nomap(base, size); } return memblock_reserve(base, size); diff --git a/include/linux/memblock.h b/include/linux/memblock.h index ff08bb433c16..3d2351b43d3b 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -487,6 +487,7 @@ bool memblock_is_map_memory(phys_addr_t addr); bool memblock_is_region_memory(phys_addr_t base, phys_addr_t size); bool memblock_is_reserved(phys_addr_t addr); bool memblock_is_region_reserved(phys_addr_t base, phys_addr_t size); +bool memblock_is_nomap_remove(void); void memblock_dump_all(void); diff --git a/mm/memblock.c b/mm/memblock.c index e0c166463ab4..3b559ce0869b 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -152,6 +152,7 @@ static __refdata struct memblock_type *memblock_memory = &memblock.memory; } while (0) static int memblock_debug __initdata_memblock; +static bool memblock_nomap_remove __initdata_memblock; static bool system_has_some_mirror __initdata_memblock = false; static int memblock_can_resize __initdata_memblock; static int memblock_memory_in_slab __initdata_memblock = 0; @@ -1904,6 +1905,18 @@ static int __init early_memblock(char *p) } early_param("memblock", early_memblock); +static int __init early_memblock_nomap(char *str) +{ + kstrtobool(str, &memblock_nomap_remove); + return 0; +} +early_param("android12_only.will_be_removed_soon.memblock_nomap_remove", early_memblock_nomap); + +bool __init memblock_is_nomap_remove(void) +{ + return memblock_nomap_remove; +} + static void __init __free_pages_memory(unsigned long start, unsigned long end) { int order;