init: provide a generic free_initmem implementation
authorMike Rapoport <rppt@linux.ibm.com>
Tue, 14 May 2019 00:18:40 +0000 (17:18 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 14 May 2019 16:47:47 +0000 (09:47 -0700)
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>
12 files changed:
arch/alpha/mm/init.c
arch/arc/mm/init.c
arch/c6x/mm/init.c
arch/h8300/mm/init.c
arch/microblaze/mm/init.c
arch/nds32/mm/init.c
arch/nios2/mm/init.c
arch/openrisc/mm/init.c
arch/sh/mm/init.c
arch/unicore32/mm/init.c
arch/xtensa/mm/init.c
init/main.c

index 97f4940f11e3be7b284bb9d8a1a1132d8ccec0f6..e2cbec3789e8c870ca159094f669daa30632c2a1 100644 (file)
@@ -285,9 +285,3 @@ mem_init(void)
        memblock_free_all();
        mem_init_print_info(NULL);
 }
-
-void
-free_initmem(void)
-{
-       free_initmem_default(-1);
-}
index c357a3bd15328448d7e844cff9b37e2838731e39..02b7a3b20d7c847dd4b4803cd4b5418f2e79c629 100644 (file)
@@ -206,11 +206,3 @@ void __init mem_init(void)
        memblock_free_all();
        mem_init_print_info(NULL);
 }
-
-/*
- * free_initmem: Free all the __init memory.
- */
-void __ref free_initmem(void)
-{
-       free_initmem_default(-1);
-}
index 6fd43ec53507163de0afcec3276d60657c798150..573242b160e1abf0d9fd6b0223c0f1b44fe3d933 100644 (file)
@@ -68,8 +68,3 @@ void __init mem_init(void)
 
        mem_init_print_info(NULL);
 }
-
-void __init free_initmem(void)
-{
-       free_initmem_default(-1);
-}
index ea635c9025fe7dea04810b1b5c7f045fabc5c0f2..1eab16b1a0bcfbf688294855f72eb7e1668fef90 100644 (file)
@@ -102,9 +102,3 @@ void __init mem_init(void)
 
        mem_init_print_info(NULL);
 }
-
-void
-free_initmem(void)
-{
-       free_initmem_default(-1);
-}
index b675bc666e68c15524da0732ce79fdddbafd04ba..a015a951c8b78bece064bb3cc5c03a5123fa5b2d 100644 (file)
@@ -186,11 +186,6 @@ void __init setup_memory(void)
        paging_init();
 }
 
-void free_initmem(void)
-{
-       free_initmem_default(-1);
-}
-
 void __init mem_init(void)
 {
        high_memory = (void *)__va(memory_start + lowmem_size - 1);
index 9a7065c1fb839eedb285d02027103ff0ba19817f..1a4ab1b7525fcd94aecc26e485944737ac5a3414 100644 (file)
@@ -252,11 +252,6 @@ void __init mem_init(void)
        return;
 }
 
-void free_initmem(void)
-{
-       free_initmem_default(-1);
-}
-
 void __set_fixmap(enum fixed_addresses idx,
                               phys_addr_t phys, pgprot_t flags)
 {
index 60736a72588364602196600251e471fc22a73d13..2c609c2516b29c1a83f402abb2010e28fa62bdd3 100644 (file)
@@ -82,11 +82,6 @@ void __init mmu_init(void)
        flush_tlb_all();
 }
 
-void __ref free_initmem(void)
-{
-       free_initmem_default(-1);
-}
-
 #define __page_aligned(order) __aligned(PAGE_SIZE << (order))
 pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned(PGD_ORDER);
 pte_t invalid_pte_table[PTRS_PER_PTE] __page_aligned(PTE_ORDER);
index 08df7f0b1d9648f41dbddbecdc21b5ede77c0d31..abe87e54e231cf73bf4d30581c6f34e5e0dcc896 100644 (file)
@@ -223,8 +223,3 @@ void __init mem_init(void)
        mem_init_done = 1;
        return;
 }
-
-void free_initmem(void)
-{
-       free_initmem_default(-1);
-}
index 3e68d98af1bd6a56b88f8244eac6ee8c2b0e06ba..aeb9f45c7a398279e4d0c644cc786ed9cf51934c 100644 (file)
@@ -403,11 +403,6 @@ void __init mem_init(void)
        mem_init_done = 1;
 }
 
-void free_initmem(void)
-{
-       free_initmem_default(-1);
-}
-
 #ifdef CONFIG_MEMORY_HOTPLUG
 int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
                bool want_memblock)
index 6e352de80038dcbe205fbf07d81db354f4801e54..b4442f3060ce0d946144e278c6122c68736723b3 100644 (file)
@@ -287,8 +287,3 @@ void __init mem_init(void)
                sysctl_overcommit_memory = OVERCOMMIT_ALWAYS;
        }
 }
-
-void free_initmem(void)
-{
-       free_initmem_default(-1);
-}
index d4986109968415a8f82ee258d6dad4d0b33b31f1..b51746f2b80bf925b9f131384e42e2419bd6ac14 100644 (file)
@@ -216,11 +216,6 @@ void free_initrd_mem(unsigned long start, unsigned long end)
 }
 #endif
 
-void free_initmem(void)
-{
-       free_initmem_default(-1);
-}
-
 static void __init parse_memmap_one(char *p)
 {
        char *oldp;
index 33c87e91dc37aa778389244687bfea3cfb5d12ef..26234570a32455d6751ecdfe2ad5ecb549ce9a05 100644 (file)
@@ -1074,6 +1074,11 @@ static inline void mark_readonly(void)
 }
 #endif
 
+void __weak free_initmem(void)
+{
+       free_initmem_default(-1);
+}
+
 static int __ref kernel_init(void *unused)
 {
        int ret;