Re: [PATCH] Extract initrd free logic from arch-specific code.
Hi Ingo, Ingo Molnar writes: > * Shea Levy wrote: > >> Now only those architectures that have custom initrd free requirements >> need to define free_initrd_mem. >> >> Signed-off-by: Shea Levy > > Please put the Kconfig symbol name this patch introduces both into the title, > so > that people know what to grep for. > >> --- >> arch/alpha/mm/init.c | 8 >> arch/arc/mm/init.c| 7 --- >> arch/arm/Kconfig | 1 + >> arch/arm64/Kconfig| 1 + >> arch/blackfin/Kconfig | 1 + >> arch/c6x/mm/init.c| 7 --- >> arch/cris/Kconfig | 1 + >> arch/frv/mm/init.c| 11 --- >> arch/h8300/mm/init.c | 7 --- >> arch/hexagon/Kconfig | 1 + >> arch/ia64/Kconfig | 1 + >> arch/m32r/Kconfig | 1 + >> arch/m32r/mm/init.c | 11 --- >> arch/m68k/mm/init.c | 7 --- >> arch/metag/Kconfig| 1 + >> arch/microblaze/mm/init.c | 7 --- >> arch/mips/Kconfig | 1 + >> arch/mn10300/Kconfig | 1 + >> arch/nios2/mm/init.c | 7 --- >> arch/openrisc/mm/init.c | 7 --- >> arch/parisc/mm/init.c | 7 --- >> arch/powerpc/mm/mem.c | 7 --- >> arch/riscv/mm/init.c | 6 -- >> arch/s390/Kconfig | 1 + >> arch/score/Kconfig| 1 + >> arch/sh/mm/init.c | 7 --- >> arch/sparc/Kconfig| 1 + >> arch/tile/Kconfig | 1 + >> arch/um/kernel/mem.c | 7 --- >> arch/unicore32/Kconfig| 1 + >> arch/x86/Kconfig | 1 + >> arch/xtensa/Kconfig | 1 + >> init/initramfs.c | 7 +++ >> usr/Kconfig | 4 >> 34 files changed, 28 insertions(+), 113 deletions(-) > > Please also put it into Documentation/features/. > I switched this patch series (the latest revision v6 was just posted) to using weak symbols instead of Kconfig. Does it still warrant documentation? > >> diff --git a/usr/Kconfig b/usr/Kconfig >> index 43658b8a975e..7a94f6df39bf 100644 >> --- a/usr/Kconfig >> +++ b/usr/Kconfig >> @@ -233,3 +233,7 @@ config INITRAMFS_COMPRESSION >> default ".lzma" if RD_LZMA >> default ".bz2" if RD_BZIP2 >> default "" >> + >> +config HAVE_ARCH_FREE_INITRD_MEM >> +bool >> +default n > > Help text would be nice, to tell arch maintainers what the purpose of this > switch > is. > > Also, a nit, I think this should be named "ARCH_HAS_FREE_INITRD_MEM", which > is the > dominant pattern: > > triton:~/tip> git grep 'select.*ARCH' arch/x86/Kconfig* | cut -f2 | cut -d_ > -f1-2 | sort | uniq -c | sort -n > ... > 2 select ARCH_USES > 2 select ARCH_WANTS > 3 select ARCH_MIGHT > 3 select ARCH_WANT > 4 select ARCH_SUPPORTS > 4 select ARCH_USE > 16 select HAVE_ARCH > 23 select ARCH_HAS > > It also reads nicely in English: > > "arch has free_initrd_mem()" > > While the other makes little sense: > > "have arch free_initrd_mem()" > > ? > > Thanks, > > Ingo Thanks, Shea signature.asc Description: PGP signature
Re: [PATCH v4 14/16] powerpc: Use generic free_initrd_mem.
Hi Michael, Michael Ellerman writes: > Shea Levy writes: > >> Joe Perches writes: >> >>> On Wed, 2018-03-28 at 16:36 -0400, Shea Levy wrote: >>>> Signed-off-by: Shea Levy >>> >>> Most people seem to want some form of commit message >>> and not just your sign-off. >>> >> >> Ah, if the subject is insufficient I can add some more detail. > > Yeah please do. > > Seeing this patch in isolation, with no change log, I might think it's > safe for me to just apply it. > > But that would break the build because I don't have patch 1. > > So for starters you need to explain that part, eg something like: > > A previous patch in the series added a weak definition of > free_initrd_mem() in init/initramfs.c. > > The powerpc implementation is identical, so it can be removed allowing > the generic version to be used. > > > Then you could also tell me if you did/didn't build/boot test it. Thanks for the feedback, can you let me know if the recently posted v6 fits the bill? > > cheers Thanks, Shea signature.asc Description: PGP signature
[PATCH v6 14/16] powerpc: Switch to generic free_initrd_mem.
The first patch in this series added a weakly-defined generic implementation, which is functionally identical to the architecture-specific one removed here. Series boot-tested on RISC-V (which now uses the generic implementation) and x86_64 (which doesn't). Signed-off-by: Shea Levy --- arch/powerpc/mm/mem.c | 7 --- 1 file changed, 7 deletions(-) diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index fe8c61149fb8..e85b2a3cd264 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -404,13 +404,6 @@ void free_initmem(void) free_initmem_default(POISON_FREE_INITMEM); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - /* * This is called when a page has been modified by the kernel. * It just marks the page as not i-cache clean. We do the i-cache -- 2.16.2
[PATCH v5 14/16] powerpc: Switch to generic free_initrd_mem.
The generic implementation is functionally identical. Signed-off-by: Shea Levy --- arch/powerpc/mm/mem.c | 7 --- 1 file changed, 7 deletions(-) diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index fe8c61149fb8..e85b2a3cd264 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -404,13 +404,6 @@ void free_initmem(void) free_initmem_default(POISON_FREE_INITMEM); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - /* * This is called when a page has been modified by the kernel. * It just marks the page as not i-cache clean. We do the i-cache -- 2.16.2
Re: [PATCH] Extract initrd free logic from arch-specific code.
Hi Rob, Rob Landley writes: > On 03/28/2018 10:26 AM, Shea Levy wrote: >> Now only those architectures that have custom initrd free requirements >> need to define free_initrd_mem. > ... >> --- a/arch/arc/mm/init.c >> +++ b/arch/arc/mm/init.c >> @@ -229,10 +229,3 @@ void __ref free_initmem(void) >> { >> free_initmem_default(-1); >> } >> - >> -#ifdef CONFIG_BLK_DEV_INITRD >> -void __init free_initrd_mem(unsigned long start, unsigned long end) >> -{ >> -free_reserved_area((void *)start, (void *)end, -1, "initrd"); >> -} >> -#endif >> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig >> index 3f972e83909b..19d1c5594e2d 100644 >> --- a/arch/arm/Kconfig >> +++ b/arch/arm/Kconfig >> @@ -47,6 +47,7 @@ config ARM >> select HARDIRQS_SW_RESEND >> select HAVE_ARCH_AUDITSYSCALL if (AEABI && !OABI_COMPAT) >> select HAVE_ARCH_BITREVERSE if (CPU_32v7M || CPU_32v7) && !CPU_32v6 >> +select HAVE_ARCH_FREE_INITRD_MEM >> select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU >> select HAVE_ARCH_KGDB if !CPU_ENDIAN_BE32 && MMU >> select HAVE_ARCH_MMAP_RND_BITS if MMU > > Isn't this why weak symbols were invented? > This approach was suggested by Christoph Hellwig upthread, and seems to have some precedent elsewhere (e.g. strncasecmp), but I agree weak symbols seem appropriate here. I'm happy to implement either approach! > > Confused, > > Rob Thanks, Shea signature.asc Description: PGP signature
[PATCH] Extract initrd free logic from arch-specific code.
Now only those architectures that have custom initrd free requirements need to define free_initrd_mem. Signed-off-by: Shea Levy --- arch/alpha/mm/init.c | 8 arch/arc/mm/init.c| 7 --- arch/arm/Kconfig | 1 + arch/arm64/Kconfig| 1 + arch/blackfin/Kconfig | 1 + arch/c6x/mm/init.c| 7 --- arch/cris/Kconfig | 1 + arch/frv/mm/init.c| 11 --- arch/h8300/mm/init.c | 7 --- arch/hexagon/Kconfig | 1 + arch/ia64/Kconfig | 1 + arch/m32r/Kconfig | 1 + arch/m32r/mm/init.c | 11 --- arch/m68k/mm/init.c | 7 --- arch/metag/Kconfig| 1 + arch/microblaze/mm/init.c | 7 --- arch/mips/Kconfig | 1 + arch/mn10300/Kconfig | 1 + arch/nios2/mm/init.c | 7 --- arch/openrisc/mm/init.c | 7 --- arch/parisc/mm/init.c | 7 --- arch/powerpc/mm/mem.c | 7 --- arch/riscv/mm/init.c | 6 -- arch/s390/Kconfig | 1 + arch/score/Kconfig| 1 + arch/sh/mm/init.c | 7 --- arch/sparc/Kconfig| 1 + arch/tile/Kconfig | 1 + arch/um/kernel/mem.c | 7 --- arch/unicore32/Kconfig| 1 + arch/x86/Kconfig | 1 + arch/xtensa/Kconfig | 1 + init/initramfs.c | 7 +++ usr/Kconfig | 4 34 files changed, 28 insertions(+), 113 deletions(-) diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c index 9d74520298ab..55f7c8efa962 100644 --- a/arch/alpha/mm/init.c +++ b/arch/alpha/mm/init.c @@ -291,11 +291,3 @@ free_initmem(void) { free_initmem_default(-1); } - -#ifdef CONFIG_BLK_DEV_INITRD -void -free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c index ba145065c579..7bcf23ab1756 100644 --- a/arch/arc/mm/init.c +++ b/arch/arc/mm/init.c @@ -229,10 +229,3 @@ void __ref free_initmem(void) { free_initmem_default(-1); } - -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 3f972e83909b..19d1c5594e2d 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -47,6 +47,7 @@ config ARM select HARDIRQS_SW_RESEND select HAVE_ARCH_AUDITSYSCALL if (AEABI && !OABI_COMPAT) select HAVE_ARCH_BITREVERSE if (CPU_32v7M || CPU_32v7) && !CPU_32v6 + select HAVE_ARCH_FREE_INITRD_MEM select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU select HAVE_ARCH_KGDB if !CPU_ENDIAN_BE32 && MMU select HAVE_ARCH_MMAP_RND_BITS if MMU diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index cb03e93f03cf..de93620870af 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -85,6 +85,7 @@ config ARM64 select HAVE_ALIGNED_STRUCT_PAGE if SLUB select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_BITREVERSE + select HAVE_ARCH_FREE_INITRD_MEM select HAVE_ARCH_HUGE_VMAP select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_KASAN if !(ARM64_16K_PAGES && ARM64_VA_BITS_48) diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig index d9c2866ba618..6c6dae9fe894 100644 --- a/arch/blackfin/Kconfig +++ b/arch/blackfin/Kconfig @@ -15,6 +15,7 @@ config BLACKFIN def_bool y select HAVE_ARCH_KGDB select HAVE_ARCH_TRACEHOOK + select HAVE_ARCH_FREE_INITRD_MEM select HAVE_DYNAMIC_FTRACE select HAVE_FTRACE_MCOUNT_RECORD select HAVE_FUNCTION_GRAPH_TRACER diff --git a/arch/c6x/mm/init.c b/arch/c6x/mm/init.c index 4cc72b0d1c1d..a11cb657182a 100644 --- a/arch/c6x/mm/init.c +++ b/arch/c6x/mm/init.c @@ -66,13 +66,6 @@ void __init mem_init(void) mem_init_print_info(NULL); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - void __init free_initmem(void) { free_initmem_default(-1); diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig index cd5a0865c97f..5425f77e5664 100644 --- a/arch/cris/Kconfig +++ b/arch/cris/Kconfig @@ -76,6 +76,7 @@ config CRIS select HAVE_DEBUG_BUGVERBOSE if ETRAX_ARCH_V32 select HAVE_NMI select DMA_DIRECT_OPS if PCI + select HAVE_ARCH_FREE_INITRD_MEM config HZ int diff --git a/arch/frv/mm/init.c b/arch/frv/mm/init.c index cf464100e838..345edc4dc462 100644 --- a/arch/frv/mm/init.c +++ b/arch/frv/mm/init.c @@ -131,14 +131,3 @@ void free_initmem(void) free_initmem_default(-1); #endif } /* end free_initmem() */ - -/*
Re: [PATCH v4 14/16] powerpc: Use generic free_initrd_mem.
Joe Perches writes: > On Wed, 2018-03-28 at 16:36 -0400, Shea Levy wrote: >> Signed-off-by: Shea Levy > > Most people seem to want some form of commit message > and not just your sign-off. > Ah, if the subject is insufficient I can add some more detail. > > And btw: > > It seems you used get_maintainer to determine who to > send these patches to. > > I suggest you add --nogit and --nogit-fallback to the > get_maintainer command line you use to avoid sending > these patches to people like me that have done drive-by > cleanup work on these files. Whoops, thanks for the tip and sorry for the noise! signature.asc Description: PGP signature
[PATCH v4 14/16] powerpc: Use generic free_initrd_mem.
Signed-off-by: Shea Levy --- arch/powerpc/mm/mem.c | 7 --- 1 file changed, 7 deletions(-) diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index fe8c61149fb8..e85b2a3cd264 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -404,13 +404,6 @@ void free_initmem(void) free_initmem_default(POISON_FREE_INITMEM); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - /* * This is called when a page has been modified by the kernel. * It just marks the page as not i-cache clean. We do the i-cache -- 2.16.2
Re: [PATCH v2 02/16] riscv: Use INITRAMFS_GENERIC_UNLOAD.
Hi Palmer, Palmer Dabbelt writes: > On Sun, 25 Mar 2018 15:18:39 PDT (-0700), s...@shealevy.com wrote: >> Signed-off-by: Shea Levy >> --- >> arch/riscv/Kconfig | 1 + >> arch/riscv/mm/init.c | 6 -- >> 2 files changed, 1 insertion(+), 6 deletions(-) >> >> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig >> index c22ebe08e902..ab1b4cee84fc 100644 >> --- a/arch/riscv/Kconfig >> +++ b/arch/riscv/Kconfig >> @@ -37,6 +37,7 @@ config RISCV >> select THREAD_INFO_IN_TASK >> select RISCV_TIMER >> select GENERIC_IRQ_MULTI_HANDLER >> +select INITRAMFS_GENERIC_UNLOAD >> >> config MMU >> def_bool y >> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c >> index c77df8142be2..36f83fe8a726 100644 >> --- a/arch/riscv/mm/init.c >> +++ b/arch/riscv/mm/init.c >> @@ -62,9 +62,3 @@ void free_initmem(void) >> { >> free_initmem_default(0); >> } >> - >> -#ifdef CONFIG_BLK_DEV_INITRD >> -void free_initrd_mem(unsigned long start, unsigned long end) >> -{ >> -} >> -#endif /* CONFIG_BLK_DEV_INITRD */ > > I haven't looked through the rest of the patch set, but this is a pretty > trivial change so feel free to add a > > Reviewed-By: Palmer Dabbelt > > if you'd like. If you'd like it merged through my tree then just say > something! I'm not sure how these cross-cutting changes go, if you can take the series through your tree that'd be great! Thanks, Shea signature.asc Description: PGP signature
Re: [PATCH 01/16] initrd: Add generic code path for common initrd unloading logic.
Hi Christophe, LEROY Christophe writes: > Shea Levy a écrit : > >> Signed-off-by: Shea Levy >> --- >> init/initramfs.c | 7 +++ >> usr/Kconfig | 4 >> 2 files changed, 11 insertions(+) >> >> diff --git a/init/initramfs.c b/init/initramfs.c >> index 7e99a0038942..de5ce873eb5a 100644 >> --- a/init/initramfs.c >> +++ b/init/initramfs.c >> @@ -526,6 +526,13 @@ extern unsigned long __initramfs_size; >> #include >> #include >> >> +#ifdef CONFIG_INITRAMFS_GENERIC_UNLOAD >> +void free_initrd_mem(unsigned long start, unsigned long end) >> +{ >> + free_reserved_area((void *)start, (void *)end, -1, "initrd"); >> +} >> +#endif > > In powerpc this was an __init function. Why not also put the generic > one in __init section ? > v2 series sent, thanks! > > Christophe > > >> + >> static void __init free_initrd(void) >> { >> #ifdef CONFIG_KEXEC_CORE >> diff --git a/usr/Kconfig b/usr/Kconfig >> index 43658b8a975e..fd79d4d6fa26 100644 >> --- a/usr/Kconfig >> +++ b/usr/Kconfig >> @@ -233,3 +233,7 @@ config INITRAMFS_COMPRESSION >> default ".lzma" if RD_LZMA >> default ".bz2" if RD_BZIP2 >> default "" >> + >> +# Arches can select this for a generic initrd unloading codepath >> +config INITRAMFS_GENERIC_UNLOAD >> +bool >> -- >> 2.16.2 signature.asc Description: PGP signature
[PATCH v2 16/16] um: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/um/Kconfig.common | 1 + arch/um/kernel/mem.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common index c68add8df3ae..1cb8a023938b 100644 --- a/arch/um/Kconfig.common +++ b/arch/um/Kconfig.common @@ -13,6 +13,7 @@ config UML select GENERIC_CLOCKEVENTS select HAVE_GCC_PLUGINS select TTY # Needed for line.c + select INITRAMFS_GENERIC_UNLOAD config MMU bool diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index 3c0e470ea646..2d26eec92126 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c @@ -170,13 +170,6 @@ void free_initmem(void) { } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - /* Allocate and free page tables. */ pgd_t *pgd_alloc(struct mm_struct *mm) -- 2.16.2
[PATCH v2 15/16] sh: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/sh/Kconfig | 1 + arch/sh/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 97fe29316476..b6f80dad2152 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -50,6 +50,7 @@ config SUPERH select HAVE_ARCH_AUDITSYSCALL select HAVE_FUTEX_CMPXCHG if FUTEX select HAVE_NMI + select INITRAMFS_GENERIC_UNLOAD help The SuperH is a RISC processor targeted for use in embedded systems and consumer electronics; it was also used in the Sega Dreamcast diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index ce0bbaa7e404..7451459d0725 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c @@ -477,13 +477,6 @@ void free_initmem(void) free_initmem_default(-1); } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - #ifdef CONFIG_MEMORY_HOTPLUG int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, bool want_memblock) -- 2.16.2
[PATCH v2 14/16] powerpc: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/powerpc/Kconfig | 1 + arch/powerpc/mm/mem.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 73ce5dd07642..8cf384068e79 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -223,6 +223,7 @@ config PPC select HAVE_SYSCALL_TRACEPOINTS select HAVE_VIRT_CPU_ACCOUNTING select HAVE_IRQ_TIME_ACCOUNTING + select INITRAMFS_GENERIC_UNLOAD select IRQ_DOMAIN select IRQ_FORCED_THREADING select MODULES_USE_ELF_RELA diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index fe8c61149fb8..e85b2a3cd264 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -404,13 +404,6 @@ void free_initmem(void) free_initmem_default(POISON_FREE_INITMEM); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - /* * This is called when a page has been modified by the kernel. * It just marks the page as not i-cache clean. We do the i-cache -- 2.16.2
[PATCH v2 13/16] parisc: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/parisc/Kconfig | 1 + arch/parisc/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index 9792d8cf4f56..7410c2094987 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -51,6 +51,7 @@ config PARISC select GENERIC_CLOCKEVENTS select ARCH_NO_COHERENT_DMA_MMAP select CPU_NO_EFFICIENT_FFS + select INITRAMFS_GENERIC_UNLOAD help The PA-RISC microprocessor is designed by Hewlett-Packard and used diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c index cab32ee824d2..3643399230f3 100644 --- a/arch/parisc/mm/init.c +++ b/arch/parisc/mm/init.c @@ -932,10 +932,3 @@ void flush_tlb_all(void) spin_unlock(&sid_lock); } #endif - -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif -- 2.16.2
[PATCH v2 12/16] openrisc: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/openrisc/Kconfig | 1 + arch/openrisc/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig index dfb6a79ba7ff..0f8d2132baa5 100644 --- a/arch/openrisc/Kconfig +++ b/arch/openrisc/Kconfig @@ -36,6 +36,7 @@ config OPENRISC select OMPIC if SMP select ARCH_WANT_FRAME_POINTERS select GENERIC_IRQ_MULTI_HANDLER + select INITRAMFS_GENERIC_UNLOAD config CPU_BIG_ENDIAN def_bool y diff --git a/arch/openrisc/mm/init.c b/arch/openrisc/mm/init.c index 6972d5d6f23f..c1a3dcf9ad40 100644 --- a/arch/openrisc/mm/init.c +++ b/arch/openrisc/mm/init.c @@ -222,13 +222,6 @@ void __init mem_init(void) return; } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - void free_initmem(void) { free_initmem_default(-1); -- 2.16.2
[PATCH v2 11/16] nios2: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/nios2/Kconfig | 1 + arch/nios2/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig index 3d4ec88f1db1..d3b72d5c8967 100644 --- a/arch/nios2/Kconfig +++ b/arch/nios2/Kconfig @@ -19,6 +19,7 @@ config NIOS2 select SPARSE_IRQ select USB_ARCH_HAS_HCD if USB_SUPPORT select CPU_NO_EFFICIENT_FFS + select INITRAMFS_GENERIC_UNLOAD config GENERIC_CSUM def_bool y diff --git a/arch/nios2/mm/init.c b/arch/nios2/mm/init.c index c92fe4234009..3df75ff8c768 100644 --- a/arch/nios2/mm/init.c +++ b/arch/nios2/mm/init.c @@ -82,13 +82,6 @@ void __init mmu_init(void) flush_tlb_all(); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - void __ref free_initmem(void) { free_initmem_default(-1); -- 2.16.2
[PATCH v2 10/16] microblaze: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/microblaze/Kconfig | 1 + arch/microblaze/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index 3817a3e2146c..ef23e8410b4b 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig @@ -36,6 +36,7 @@ config MICROBLAZE select TRACING_SUPPORT select VIRT_TO_BUS select CPU_NO_EFFICIENT_FFS + select INITRAMFS_GENERIC_UNLOAD # Endianness selection choice diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c index df6de7ccdc2e..ea058dfda222 100644 --- a/arch/microblaze/mm/init.c +++ b/arch/microblaze/mm/init.c @@ -187,13 +187,6 @@ void __init setup_memory(void) paging_init(); } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - void free_initmem(void) { free_initmem_default(-1); -- 2.16.2
[PATCH v2 09/16] m68k: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/m68k/Kconfig | 1 + arch/m68k/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index 785612b576f7..47913a68529e 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -24,6 +24,7 @@ config M68K select MODULES_USE_ELF_RELA select OLD_SIGSUSPEND3 select OLD_SIGACTION + select INITRAMFS_GENERIC_UNLOAD config CPU_BIG_ENDIAN def_bool y diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c index e85acd131fa8..e20bef09258c 100644 --- a/arch/m68k/mm/init.c +++ b/arch/m68k/mm/init.c @@ -172,10 +172,3 @@ void __init mem_init(void) mem_init_print_info(NULL); print_memmap(); } - -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif -- 2.16.2
[PATCH v2 08/16] m32r: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/m32r/Kconfig | 1 + arch/m32r/mm/init.c | 11 --- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index dd84ee194579..010a2b999181 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig @@ -21,6 +21,7 @@ config M32R select CPU_NO_EFFICIENT_FFS select DMA_DIRECT_OPS select ARCH_NO_COHERENT_DMA_MMAP if !MMU + select INITRAMFS_GENERIC_UNLOAD config SBUS bool diff --git a/arch/m32r/mm/init.c b/arch/m32r/mm/init.c index 93abc8c3a46e..e2b5f09209ee 100644 --- a/arch/m32r/mm/init.c +++ b/arch/m32r/mm/init.c @@ -139,14 +139,3 @@ void free_initmem(void) { free_initmem_default(-1); } - -#ifdef CONFIG_BLK_DEV_INITRD -/*==* - * free_initrd_mem() : - * orig : arch/sh/mm/init.c - *==*/ -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif -- 2.16.2
[PATCH v2 07/16] h8300: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/h8300/Kconfig | 1 + arch/h8300/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig index 091d6d04b5e5..58c9b6b1df16 100644 --- a/arch/h8300/Kconfig +++ b/arch/h8300/Kconfig @@ -24,6 +24,7 @@ config H8300 select HAVE_ARCH_HASH select CPU_NO_EFFICIENT_FFS select DMA_DIRECT_OPS + select INITRAMFS_GENERIC_UNLOAD config CPU_BIG_ENDIAN def_bool y diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c index 015287ac8ce8..37574332b202 100644 --- a/arch/h8300/mm/init.c +++ b/arch/h8300/mm/init.c @@ -102,13 +102,6 @@ void __init mem_init(void) } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - void free_initmem(void) { -- 2.16.2
[PATCH v2 06/16] frv: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/frv/Kconfig | 1 + arch/frv/mm/init.c | 11 --- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig index af369b05fed5..5c104b800cb1 100644 --- a/arch/frv/Kconfig +++ b/arch/frv/Kconfig @@ -17,6 +17,7 @@ config FRV select OLD_SIGACTION select HAVE_DEBUG_STACKOVERFLOW select ARCH_NO_COHERENT_DMA_MMAP + select INITRAMFS_GENERIC_UNLOAD config CPU_BIG_ENDIAN def_bool y diff --git a/arch/frv/mm/init.c b/arch/frv/mm/init.c index cf464100e838..345edc4dc462 100644 --- a/arch/frv/mm/init.c +++ b/arch/frv/mm/init.c @@ -131,14 +131,3 @@ void free_initmem(void) free_initmem_default(-1); #endif } /* end free_initmem() */ - -/*/ -/* - * free the initial ramdisk memory - */ -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} /* end free_initrd_mem() */ -#endif -- 2.16.2
[PATCH v2 05/16] c6x: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/c6x/Kconfig | 1 + arch/c6x/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/c6x/Kconfig b/arch/c6x/Kconfig index c6b4dd1418b4..857f95f9a6a4 100644 --- a/arch/c6x/Kconfig +++ b/arch/c6x/Kconfig @@ -19,6 +19,7 @@ config C6X select GENERIC_CLOCKEVENTS select MODULES_USE_ELF_RELA select ARCH_NO_COHERENT_DMA_MMAP + select INITRAMFS_GENERIC_UNLOAD config MMU def_bool n diff --git a/arch/c6x/mm/init.c b/arch/c6x/mm/init.c index 4cc72b0d1c1d..a11cb657182a 100644 --- a/arch/c6x/mm/init.c +++ b/arch/c6x/mm/init.c @@ -66,13 +66,6 @@ void __init mem_init(void) mem_init_print_info(NULL); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - void __init free_initmem(void) { free_initmem_default(-1); -- 2.16.2
[PATCH v2 04/16] arc: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/arc/Kconfig | 1 + arch/arc/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index d76bf4a83740..2844ce5b910c 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -44,6 +44,7 @@ config ARC select HAVE_GENERIC_DMA_COHERENT select HAVE_KERNEL_GZIP select HAVE_KERNEL_LZMA + select INITRAMFS_GENERIC_UNLOAD config MIGHT_HAVE_PCI bool diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c index ba145065c579..7bcf23ab1756 100644 --- a/arch/arc/mm/init.c +++ b/arch/arc/mm/init.c @@ -229,10 +229,3 @@ void __ref free_initmem(void) { free_initmem_default(-1); } - -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif -- 2.16.2
[PATCH v2 03/16] alpha: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/alpha/Kconfig | 1 + arch/alpha/mm/init.c | 8 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index e96adcbcab41..238d743ae8f2 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -27,6 +27,7 @@ config ALPHA select ODD_RT_SIGACTION select OLD_SIGSUSPEND select CPU_NO_EFFICIENT_FFS if !ALPHA_EV67 + select INITRAMFS_GENERIC_UNLOAD help The Alpha is a 64-bit general-purpose processor designed and marketed by the Digital Equipment Corporation of blessed memory, diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c index 9d74520298ab..55f7c8efa962 100644 --- a/arch/alpha/mm/init.c +++ b/arch/alpha/mm/init.c @@ -291,11 +291,3 @@ free_initmem(void) { free_initmem_default(-1); } - -#ifdef CONFIG_BLK_DEV_INITRD -void -free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif -- 2.16.2
[PATCH v2 02/16] riscv: Use INITRAMFS_GENERIC_UNLOAD.
Signed-off-by: Shea Levy --- arch/riscv/Kconfig | 1 + arch/riscv/mm/init.c | 6 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index c22ebe08e902..ab1b4cee84fc 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -37,6 +37,7 @@ config RISCV select THREAD_INFO_IN_TASK select RISCV_TIMER select GENERIC_IRQ_MULTI_HANDLER + select INITRAMFS_GENERIC_UNLOAD config MMU def_bool y diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index c77df8142be2..36f83fe8a726 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -62,9 +62,3 @@ void free_initmem(void) { free_initmem_default(0); } - -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ -} -#endif /* CONFIG_BLK_DEV_INITRD */ -- 2.16.2
[PATCH v2 01/16] initrd: Add generic code path for common initrd unloading logic.
Signed-off-by: Shea Levy --- init/initramfs.c | 7 +++ usr/Kconfig | 4 2 files changed, 11 insertions(+) diff --git a/init/initramfs.c b/init/initramfs.c index 7e99a0038942..5f2e3dba4822 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -526,6 +526,13 @@ extern unsigned long __initramfs_size; #include #include +#ifdef CONFIG_INITRAMFS_GENERIC_UNLOAD +void __init free_initrd_mem(unsigned long start, unsigned long end) +{ + free_reserved_area((void *)start, (void *)end, -1, "initrd"); +} +#endif + static void __init free_initrd(void) { #ifdef CONFIG_KEXEC_CORE diff --git a/usr/Kconfig b/usr/Kconfig index 43658b8a975e..fd79d4d6fa26 100644 --- a/usr/Kconfig +++ b/usr/Kconfig @@ -233,3 +233,7 @@ config INITRAMFS_COMPRESSION default ".lzma" if RD_LZMA default ".bz2" if RD_BZIP2 default "" + +# Arches can select this for a generic initrd unloading codepath +config INITRAMFS_GENERIC_UNLOAD + bool -- 2.16.2
[PATCH v2 00/16] Generic infrastructure for unloading initramfs
This patch series extracts out code for unloading the initramfs that was identical across 14 architectures, and moves those architectures to the common code path. Additionally, RISC-V is newly moved to the common code path. In addition to reducing duplication, this allows us to bring future improvements (such as generalizing existing "keep initrd" command line options) to multiple architectures at once. v2: Mark generic free_initrd_mem __init.
[PATCH 04/16] arc: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/arc/Kconfig | 1 + arch/arc/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index d76bf4a83740..2844ce5b910c 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -44,6 +44,7 @@ config ARC select HAVE_GENERIC_DMA_COHERENT select HAVE_KERNEL_GZIP select HAVE_KERNEL_LZMA + select INITRAMFS_GENERIC_UNLOAD config MIGHT_HAVE_PCI bool diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c index ba145065c579..7bcf23ab1756 100644 --- a/arch/arc/mm/init.c +++ b/arch/arc/mm/init.c @@ -229,10 +229,3 @@ void __ref free_initmem(void) { free_initmem_default(-1); } - -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif -- 2.16.2
[PATCH 14/16] powerpc: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/powerpc/Kconfig | 1 + arch/powerpc/mm/mem.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 73ce5dd07642..8cf384068e79 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -223,6 +223,7 @@ config PPC select HAVE_SYSCALL_TRACEPOINTS select HAVE_VIRT_CPU_ACCOUNTING select HAVE_IRQ_TIME_ACCOUNTING + select INITRAMFS_GENERIC_UNLOAD select IRQ_DOMAIN select IRQ_FORCED_THREADING select MODULES_USE_ELF_RELA diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index fe8c61149fb8..e85b2a3cd264 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -404,13 +404,6 @@ void free_initmem(void) free_initmem_default(POISON_FREE_INITMEM); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - /* * This is called when a page has been modified by the kernel. * It just marks the page as not i-cache clean. We do the i-cache -- 2.16.2
[PATCH 06/16] frv: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/frv/Kconfig | 1 + arch/frv/mm/init.c | 11 --- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig index af369b05fed5..5c104b800cb1 100644 --- a/arch/frv/Kconfig +++ b/arch/frv/Kconfig @@ -17,6 +17,7 @@ config FRV select OLD_SIGACTION select HAVE_DEBUG_STACKOVERFLOW select ARCH_NO_COHERENT_DMA_MMAP + select INITRAMFS_GENERIC_UNLOAD config CPU_BIG_ENDIAN def_bool y diff --git a/arch/frv/mm/init.c b/arch/frv/mm/init.c index cf464100e838..345edc4dc462 100644 --- a/arch/frv/mm/init.c +++ b/arch/frv/mm/init.c @@ -131,14 +131,3 @@ void free_initmem(void) free_initmem_default(-1); #endif } /* end free_initmem() */ - -/*/ -/* - * free the initial ramdisk memory - */ -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} /* end free_initrd_mem() */ -#endif -- 2.16.2
[PATCH 10/16] microblaze: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/microblaze/Kconfig | 1 + arch/microblaze/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index 3817a3e2146c..ef23e8410b4b 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig @@ -36,6 +36,7 @@ config MICROBLAZE select TRACING_SUPPORT select VIRT_TO_BUS select CPU_NO_EFFICIENT_FFS + select INITRAMFS_GENERIC_UNLOAD # Endianness selection choice diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c index df6de7ccdc2e..ea058dfda222 100644 --- a/arch/microblaze/mm/init.c +++ b/arch/microblaze/mm/init.c @@ -187,13 +187,6 @@ void __init setup_memory(void) paging_init(); } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - void free_initmem(void) { free_initmem_default(-1); -- 2.16.2
[PATCH 08/16] m32r: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/m32r/Kconfig | 1 + arch/m32r/mm/init.c | 11 --- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index dd84ee194579..010a2b999181 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig @@ -21,6 +21,7 @@ config M32R select CPU_NO_EFFICIENT_FFS select DMA_DIRECT_OPS select ARCH_NO_COHERENT_DMA_MMAP if !MMU + select INITRAMFS_GENERIC_UNLOAD config SBUS bool diff --git a/arch/m32r/mm/init.c b/arch/m32r/mm/init.c index 93abc8c3a46e..e2b5f09209ee 100644 --- a/arch/m32r/mm/init.c +++ b/arch/m32r/mm/init.c @@ -139,14 +139,3 @@ void free_initmem(void) { free_initmem_default(-1); } - -#ifdef CONFIG_BLK_DEV_INITRD -/*==* - * free_initrd_mem() : - * orig : arch/sh/mm/init.c - *==*/ -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif -- 2.16.2
[PATCH 01/16] initrd: Add generic code path for common initrd unloading logic.
Signed-off-by: Shea Levy --- init/initramfs.c | 7 +++ usr/Kconfig | 4 2 files changed, 11 insertions(+) diff --git a/init/initramfs.c b/init/initramfs.c index 7e99a0038942..de5ce873eb5a 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -526,6 +526,13 @@ extern unsigned long __initramfs_size; #include #include +#ifdef CONFIG_INITRAMFS_GENERIC_UNLOAD +void free_initrd_mem(unsigned long start, unsigned long end) +{ + free_reserved_area((void *)start, (void *)end, -1, "initrd"); +} +#endif + static void __init free_initrd(void) { #ifdef CONFIG_KEXEC_CORE diff --git a/usr/Kconfig b/usr/Kconfig index 43658b8a975e..fd79d4d6fa26 100644 --- a/usr/Kconfig +++ b/usr/Kconfig @@ -233,3 +233,7 @@ config INITRAMFS_COMPRESSION default ".lzma" if RD_LZMA default ".bz2" if RD_BZIP2 default "" + +# Arches can select this for a generic initrd unloading codepath +config INITRAMFS_GENERIC_UNLOAD + bool -- 2.16.2
[PATCH 05/16] c6x: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/c6x/Kconfig | 1 + arch/c6x/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/c6x/Kconfig b/arch/c6x/Kconfig index c6b4dd1418b4..857f95f9a6a4 100644 --- a/arch/c6x/Kconfig +++ b/arch/c6x/Kconfig @@ -19,6 +19,7 @@ config C6X select GENERIC_CLOCKEVENTS select MODULES_USE_ELF_RELA select ARCH_NO_COHERENT_DMA_MMAP + select INITRAMFS_GENERIC_UNLOAD config MMU def_bool n diff --git a/arch/c6x/mm/init.c b/arch/c6x/mm/init.c index 4cc72b0d1c1d..a11cb657182a 100644 --- a/arch/c6x/mm/init.c +++ b/arch/c6x/mm/init.c @@ -66,13 +66,6 @@ void __init mem_init(void) mem_init_print_info(NULL); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - void __init free_initmem(void) { free_initmem_default(-1); -- 2.16.2
[PATCH 11/16] nios2: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/nios2/Kconfig | 1 + arch/nios2/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig index 3d4ec88f1db1..d3b72d5c8967 100644 --- a/arch/nios2/Kconfig +++ b/arch/nios2/Kconfig @@ -19,6 +19,7 @@ config NIOS2 select SPARSE_IRQ select USB_ARCH_HAS_HCD if USB_SUPPORT select CPU_NO_EFFICIENT_FFS + select INITRAMFS_GENERIC_UNLOAD config GENERIC_CSUM def_bool y diff --git a/arch/nios2/mm/init.c b/arch/nios2/mm/init.c index c92fe4234009..3df75ff8c768 100644 --- a/arch/nios2/mm/init.c +++ b/arch/nios2/mm/init.c @@ -82,13 +82,6 @@ void __init mmu_init(void) flush_tlb_all(); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - void __ref free_initmem(void) { free_initmem_default(-1); -- 2.16.2
[PATCH 16/16] um: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/um/Kconfig.common | 1 + arch/um/kernel/mem.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common index c68add8df3ae..1cb8a023938b 100644 --- a/arch/um/Kconfig.common +++ b/arch/um/Kconfig.common @@ -13,6 +13,7 @@ config UML select GENERIC_CLOCKEVENTS select HAVE_GCC_PLUGINS select TTY # Needed for line.c + select INITRAMFS_GENERIC_UNLOAD config MMU bool diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index 3c0e470ea646..2d26eec92126 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c @@ -170,13 +170,6 @@ void free_initmem(void) { } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - /* Allocate and free page tables. */ pgd_t *pgd_alloc(struct mm_struct *mm) -- 2.16.2
[PATCH 03/16] alpha: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/alpha/Kconfig | 1 + arch/alpha/mm/init.c | 8 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index e96adcbcab41..238d743ae8f2 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -27,6 +27,7 @@ config ALPHA select ODD_RT_SIGACTION select OLD_SIGSUSPEND select CPU_NO_EFFICIENT_FFS if !ALPHA_EV67 + select INITRAMFS_GENERIC_UNLOAD help The Alpha is a 64-bit general-purpose processor designed and marketed by the Digital Equipment Corporation of blessed memory, diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c index 9d74520298ab..55f7c8efa962 100644 --- a/arch/alpha/mm/init.c +++ b/arch/alpha/mm/init.c @@ -291,11 +291,3 @@ free_initmem(void) { free_initmem_default(-1); } - -#ifdef CONFIG_BLK_DEV_INITRD -void -free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif -- 2.16.2
[PATCH 09/16] m68k: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/m68k/Kconfig | 1 + arch/m68k/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index 785612b576f7..47913a68529e 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -24,6 +24,7 @@ config M68K select MODULES_USE_ELF_RELA select OLD_SIGSUSPEND3 select OLD_SIGACTION + select INITRAMFS_GENERIC_UNLOAD config CPU_BIG_ENDIAN def_bool y diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c index e85acd131fa8..e20bef09258c 100644 --- a/arch/m68k/mm/init.c +++ b/arch/m68k/mm/init.c @@ -172,10 +172,3 @@ void __init mem_init(void) mem_init_print_info(NULL); print_memmap(); } - -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif -- 2.16.2
[PATCH 00/16] Generic infrastructure for unloading initramfs
This patch series extracts out code for unloading the initramfs that was identical across 14 architectures, and moves those architectures to the common code path. Additionally, RISC-V is newly moved to the common code path. In addition to reducing duplication, this allows us to bring future improvements (such as generalizing existing "keep initrd" command line options) to multiple architectures at once.
[PATCH 15/16] sh: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/sh/Kconfig | 1 + arch/sh/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 97fe29316476..b6f80dad2152 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -50,6 +50,7 @@ config SUPERH select HAVE_ARCH_AUDITSYSCALL select HAVE_FUTEX_CMPXCHG if FUTEX select HAVE_NMI + select INITRAMFS_GENERIC_UNLOAD help The SuperH is a RISC processor targeted for use in embedded systems and consumer electronics; it was also used in the Sega Dreamcast diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index ce0bbaa7e404..7451459d0725 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c @@ -477,13 +477,6 @@ void free_initmem(void) free_initmem_default(-1); } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - #ifdef CONFIG_MEMORY_HOTPLUG int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, bool want_memblock) -- 2.16.2
[PATCH 13/16] parisc: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/parisc/Kconfig | 1 + arch/parisc/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index 9792d8cf4f56..7410c2094987 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -51,6 +51,7 @@ config PARISC select GENERIC_CLOCKEVENTS select ARCH_NO_COHERENT_DMA_MMAP select CPU_NO_EFFICIENT_FFS + select INITRAMFS_GENERIC_UNLOAD help The PA-RISC microprocessor is designed by Hewlett-Packard and used diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c index cab32ee824d2..3643399230f3 100644 --- a/arch/parisc/mm/init.c +++ b/arch/parisc/mm/init.c @@ -932,10 +932,3 @@ void flush_tlb_all(void) spin_unlock(&sid_lock); } #endif - -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif -- 2.16.2
[PATCH 12/16] openrisc: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/openrisc/Kconfig | 1 + arch/openrisc/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig index dfb6a79ba7ff..0f8d2132baa5 100644 --- a/arch/openrisc/Kconfig +++ b/arch/openrisc/Kconfig @@ -36,6 +36,7 @@ config OPENRISC select OMPIC if SMP select ARCH_WANT_FRAME_POINTERS select GENERIC_IRQ_MULTI_HANDLER + select INITRAMFS_GENERIC_UNLOAD config CPU_BIG_ENDIAN def_bool y diff --git a/arch/openrisc/mm/init.c b/arch/openrisc/mm/init.c index 6972d5d6f23f..c1a3dcf9ad40 100644 --- a/arch/openrisc/mm/init.c +++ b/arch/openrisc/mm/init.c @@ -222,13 +222,6 @@ void __init mem_init(void) return; } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - void free_initmem(void) { free_initmem_default(-1); -- 2.16.2
[PATCH 02/16] riscv: Use INITRAMFS_GENERIC_UNLOAD.
Signed-off-by: Shea Levy --- arch/riscv/Kconfig | 1 + arch/riscv/mm/init.c | 6 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index c22ebe08e902..ab1b4cee84fc 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -37,6 +37,7 @@ config RISCV select THREAD_INFO_IN_TASK select RISCV_TIMER select GENERIC_IRQ_MULTI_HANDLER + select INITRAMFS_GENERIC_UNLOAD config MMU def_bool y diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index c77df8142be2..36f83fe8a726 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -62,9 +62,3 @@ void free_initmem(void) { free_initmem_default(0); } - -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ -} -#endif /* CONFIG_BLK_DEV_INITRD */ -- 2.16.2
[PATCH 07/16] h8300: Use INITRAMFS_GENERIC_UNLOAD
Signed-off-by: Shea Levy --- arch/h8300/Kconfig | 1 + arch/h8300/mm/init.c | 7 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig index 091d6d04b5e5..58c9b6b1df16 100644 --- a/arch/h8300/Kconfig +++ b/arch/h8300/Kconfig @@ -24,6 +24,7 @@ config H8300 select HAVE_ARCH_HASH select CPU_NO_EFFICIENT_FFS select DMA_DIRECT_OPS + select INITRAMFS_GENERIC_UNLOAD config CPU_BIG_ENDIAN def_bool y diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c index 015287ac8ce8..37574332b202 100644 --- a/arch/h8300/mm/init.c +++ b/arch/h8300/mm/init.c @@ -102,13 +102,6 @@ void __init mem_init(void) } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - void free_initmem(void) { -- 2.16.2