Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

init: provide a generic free_initmem implementation

Patch series "provide a generic free_initmem implementation", v2.

Many architectures implement free_initmem() in exactly the same or very
similar way: they wrap the call to free_initmem_default() with sometimes
different 'poison' parameter.

These patches switch those architectures to use a generic implementation
that does free_initmem_default(POISON_FREE_INITMEM).

This was inspired by Christoph's patches for free_initrd_mem [1] and I
shamelessly copied changelog entries from his patches :)

[1] https://lore.kernel.org/lkml/20190213174621.29297-1-hch@lst.de/

This patch (of 2):

For most architectures free_initmem just a wrapper for the same
free_initmem_default(-1) call. Provide that as a generic implementation
marked __weak.

Link: http://lkml.kernel.org/r/1550515285-17446-2-git-send-email-rppt@linux.ibm.com
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Palmer Dabbelt <palmer@sifive.com>
Cc: Richard Kuo <rkuo@codeaurora.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Mike Rapoport and committed by
Linus Torvalds
997aef68 f94f7434

+5 -60
-6
arch/alpha/mm/init.c
··· 285 285 memblock_free_all(); 286 286 mem_init_print_info(NULL); 287 287 } 288 - 289 - void 290 - free_initmem(void) 291 - { 292 - free_initmem_default(-1); 293 - }
-8
arch/arc/mm/init.c
··· 206 206 memblock_free_all(); 207 207 mem_init_print_info(NULL); 208 208 } 209 - 210 - /* 211 - * free_initmem: Free all the __init memory. 212 - */ 213 - void __ref free_initmem(void) 214 - { 215 - free_initmem_default(-1); 216 - }
-5
arch/c6x/mm/init.c
··· 68 68 69 69 mem_init_print_info(NULL); 70 70 } 71 - 72 - void __init free_initmem(void) 73 - { 74 - free_initmem_default(-1); 75 - }
-6
arch/h8300/mm/init.c
··· 102 102 103 103 mem_init_print_info(NULL); 104 104 } 105 - 106 - void 107 - free_initmem(void) 108 - { 109 - free_initmem_default(-1); 110 - }
-5
arch/microblaze/mm/init.c
··· 186 186 paging_init(); 187 187 } 188 188 189 - void free_initmem(void) 190 - { 191 - free_initmem_default(-1); 192 - } 193 - 194 189 void __init mem_init(void) 195 190 { 196 191 high_memory = (void *)__va(memory_start + lowmem_size - 1);
-5
arch/nds32/mm/init.c
··· 252 252 return; 253 253 } 254 254 255 - void free_initmem(void) 256 - { 257 - free_initmem_default(-1); 258 - } 259 - 260 255 void __set_fixmap(enum fixed_addresses idx, 261 256 phys_addr_t phys, pgprot_t flags) 262 257 {
-5
arch/nios2/mm/init.c
··· 82 82 flush_tlb_all(); 83 83 } 84 84 85 - void __ref free_initmem(void) 86 - { 87 - free_initmem_default(-1); 88 - } 89 - 90 85 #define __page_aligned(order) __aligned(PAGE_SIZE << (order)) 91 86 pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned(PGD_ORDER); 92 87 pte_t invalid_pte_table[PTRS_PER_PTE] __page_aligned(PTE_ORDER);
-5
arch/openrisc/mm/init.c
··· 223 223 mem_init_done = 1; 224 224 return; 225 225 } 226 - 227 - void free_initmem(void) 228 - { 229 - free_initmem_default(-1); 230 - }
-5
arch/sh/mm/init.c
··· 403 403 mem_init_done = 1; 404 404 } 405 405 406 - void free_initmem(void) 407 - { 408 - free_initmem_default(-1); 409 - } 410 - 411 406 #ifdef CONFIG_MEMORY_HOTPLUG 412 407 int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, 413 408 bool want_memblock)
-5
arch/unicore32/mm/init.c
··· 287 287 sysctl_overcommit_memory = OVERCOMMIT_ALWAYS; 288 288 } 289 289 } 290 - 291 - void free_initmem(void) 292 - { 293 - free_initmem_default(-1); 294 - }
-5
arch/xtensa/mm/init.c
··· 216 216 } 217 217 #endif 218 218 219 - void free_initmem(void) 220 - { 221 - free_initmem_default(-1); 222 - } 223 - 224 219 static void __init parse_memmap_one(char *p) 225 220 { 226 221 char *oldp;
+5
init/main.c
··· 1074 1074 } 1075 1075 #endif 1076 1076 1077 + void __weak free_initmem(void) 1078 + { 1079 + free_initmem_default(-1); 1080 + } 1081 + 1077 1082 static int __ref kernel_init(void *unused) 1078 1083 { 1079 1084 int ret;