2018-03-24 17:51:08

by Shea Levy

[permalink] [raw]
Subject: [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.



2018-03-24 17:46:58

by Shea Levy

[permalink] [raw]
Subject: [PATCH 02/16] riscv: Use INITRAMFS_GENERIC_UNLOAD.

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-24 17:47:26

by Shea Levy

[permalink] [raw]
Subject: [PATCH 09/16] m68k: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-24 17:47:34

by Shea Levy

[permalink] [raw]
Subject: [PATCH 15/16] sh: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-24 17:47:37

by Shea Levy

[permalink] [raw]
Subject: [PATCH 16/16] um: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-24 17:48:02

by Shea Levy

[permalink] [raw]
Subject: [PATCH 13/16] parisc: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-24 17:48:13

by Shea Levy

[permalink] [raw]
Subject: [PATCH 14/16] powerpc: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-24 17:48:23

by Shea Levy

[permalink] [raw]
Subject: [PATCH 08/16] m32r: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-24 17:48:34

by Shea Levy

[permalink] [raw]
Subject: [PATCH 11/16] nios2: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-24 17:48:55

by Shea Levy

[permalink] [raw]
Subject: [PATCH 12/16] openrisc: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-24 17:49:46

by Shea Levy

[permalink] [raw]
Subject: [PATCH 05/16] c6x: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-24 17:49:47

by Shea Levy

[permalink] [raw]
Subject: [PATCH 07/16] h8300: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-24 17:49:55

by Shea Levy

[permalink] [raw]
Subject: [PATCH 10/16] microblaze: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-24 17:50:07

by Shea Levy

[permalink] [raw]
Subject: [PATCH 03/16] alpha: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-24 17:50:21

by Shea Levy

[permalink] [raw]
Subject: [PATCH 06/16] frv: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-24 17:50:33

by Shea Levy

[permalink] [raw]
Subject: [PATCH 04/16] arc: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-24 17:51:00

by Shea Levy

[permalink] [raw]
Subject: [PATCH 01/16] initrd: Add generic code path for common initrd unloading logic.

Signed-off-by: Shea Levy <[email protected]>
---
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 <linux/initrd.h>
#include <linux/kexec.h>

+#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


2018-03-25 17:19:29

by Christophe Leroy

[permalink] [raw]
Subject: Re: [PATCH 01/16] initrd: Add generic code path for common initrd unloading logic.

Shea Levy <[email protected]> a écrit :

> Signed-off-by: Shea Levy <[email protected]>
> ---
> 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 <linux/initrd.h>
> #include <linux/kexec.h>
>
> +#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 ?

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



2018-03-25 22:20:36

by Shea Levy

[permalink] [raw]
Subject: [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.


2018-03-25 22:21:49

by Shea Levy

[permalink] [raw]
Subject: Re: [PATCH 01/16] initrd: Add generic code path for common initrd unloading logic.

Hi Christophe,

LEROY Christophe <[email protected]> writes:

> Shea Levy <[email protected]> a écrit :
>
>> Signed-off-by: Shea Levy <[email protected]>
>> ---
>> 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 <linux/initrd.h>
>> #include <linux/kexec.h>
>>
>> +#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


Attachments:
signature.asc (847.00 B)

2018-03-25 22:22:13

by Shea Levy

[permalink] [raw]
Subject: [PATCH v2 15/16] sh: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-25 22:22:52

by Shea Levy

[permalink] [raw]
Subject: [PATCH v2 11/16] nios2: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-25 22:23:02

by Shea Levy

[permalink] [raw]
Subject: [PATCH v2 16/16] um: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-25 22:23:07

by Shea Levy

[permalink] [raw]
Subject: [PATCH v2 09/16] m68k: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-25 22:23:15

by Shea Levy

[permalink] [raw]
Subject: [PATCH v2 07/16] h8300: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-25 22:23:35

by Shea Levy

[permalink] [raw]
Subject: [PATCH v2 06/16] frv: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-25 22:23:35

by Shea Levy

[permalink] [raw]
Subject: [PATCH v2 13/16] parisc: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-25 22:23:43

by Shea Levy

[permalink] [raw]
Subject: [PATCH v2 14/16] powerpc: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-25 22:25:23

by Shea Levy

[permalink] [raw]
Subject: [PATCH v2 12/16] openrisc: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-25 22:25:43

by Shea Levy

[permalink] [raw]
Subject: [PATCH v2 05/16] c6x: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-25 22:25:51

by Shea Levy

[permalink] [raw]
Subject: [PATCH v2 10/16] microblaze: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-25 22:26:06

by Shea Levy

[permalink] [raw]
Subject: [PATCH v2 04/16] arc: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-25 22:26:38

by Shea Levy

[permalink] [raw]
Subject: [PATCH v2 08/16] m32r: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-25 22:26:41

by Shea Levy

[permalink] [raw]
Subject: [PATCH v2 02/16] riscv: Use INITRAMFS_GENERIC_UNLOAD.

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-25 22:27:18

by Shea Levy

[permalink] [raw]
Subject: [PATCH v2 01/16] initrd: Add generic code path for common initrd unloading logic.

Signed-off-by: Shea Levy <[email protected]>
---
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 <linux/initrd.h>
#include <linux/kexec.h>

+#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


2018-03-25 22:27:34

by Shea Levy

[permalink] [raw]
Subject: [PATCH v2 03/16] alpha: Use INITRAMFS_GENERIC_UNLOAD

Signed-off-by: Shea Levy <[email protected]>
---
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


2018-03-26 00:42:34

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH v2 02/16] riscv: Use INITRAMFS_GENERIC_UNLOAD.

On Sun, 25 Mar 2018 15:18:39 PDT (-0700), [email protected] wrote:
> Signed-off-by: Shea Levy <[email protected]>
> ---
> 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 <[email protected]>

if you'd like. If you'd like it merged through my tree then just say
something!

2018-03-26 00:59:54

by Shea Levy

[permalink] [raw]
Subject: Re: [PATCH v2 02/16] riscv: Use INITRAMFS_GENERIC_UNLOAD.

Hi Palmer,

Palmer Dabbelt <[email protected]> writes:

> On Sun, 25 Mar 2018 15:18:39 PDT (-0700), [email protected] wrote:
>> Signed-off-by: Shea Levy <[email protected]>
>> ---
>> 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 <[email protected]>
>
> 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


Attachments:
signature.asc (847.00 B)

2018-03-28 12:08:35

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH 01/16] initrd: Add generic code path for common initrd unloading logic.

> +#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

Given how trivial this is and how many architectures can use it I'd
reverse the polarity and add a CONFIG_HAVE_ARCH_FREE_INITRD_MEM
instead.

2018-03-28 12:25:22

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH 01/16] initrd: Add generic code path for common initrd unloading logic.

On Wed, Mar 28, 2018 at 2:04 PM, Christoph Hellwig <[email protected]> wrote:
>> +#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
>
> Given how trivial this is and how many architectures can use it I'd
> reverse the polarity and add a CONFIG_HAVE_ARCH_FREE_INITRD_MEM
> instead.

And while adding "special" functionality to the generic version, more and more
users of CONFIG_HAVE_ARCH_FREE_INITRD_MEM will be removed.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds