provide a generic free_initmem implementation
Subsystems (12)
cover provide a generic free_initmem implementation
Hi,
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 changlog entries from his patches :)
[1] https://lore.kernel.org/lkml/[email protected]/
Mike Rapoport (4):
init: provide a generic free_initmem implementation
hexagon: switch over to generic free_initmem()
init: free_initmem: poison freed init memory
riscv: switch over to generic free_initmem()
arch/alpha/mm/init.c | 6 ------ arch/arc/mm/init.c | 8 -------- arch/c6x/mm/init.c | 5 ----- arch/h8300/mm/init.c | 6 ------ arch/hexagon/mm/init.c | 10 ---------- arch/microblaze/mm/init.c | 5 ----- arch/nds32/mm/init.c | 5 ----- arch/nios2/mm/init.c | 5 ----- arch/openrisc/mm/init.c | 5 ----- arch/riscv/mm/init.c | 5 ----- arch/sh/mm/init.c | 5 ----- arch/sparc/mm/init_32.c | 5 ----- arch/unicore32/mm/init.c | 5 ----- arch/xtensa/mm/init.c | 5 ----- init/main.c | 5 +++++ 15 files changed, 5 insertions(+), 80 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/4 init: provide a generic free_initmem implementation
For most architectures free_initmem just a wrapper for the same free_initmem_default(-1) call.
Provide that as a generic implementation marked __weak.
--- arch/alpha/mm/init.c | 6 ------ arch/arc/mm/init.c | 8 -------- arch/c6x/mm/init.c | 5 ----- arch/h8300/mm/init.c | 6 ------ arch/microblaze/mm/init.c | 5 ----- arch/nds32/mm/init.c | 5 ----- arch/nios2/mm/init.c | 5 ----- arch/openrisc/mm/init.c | 5 ----- arch/sh/mm/init.c | 5 ----- arch/unicore32/mm/init.c | 5 ----- arch/xtensa/mm/init.c | 5 ----- init/main.c | 5 +++++ 12 files changed, 5 insertions(+), 60 deletions(-)
arch/alpha/mm/init.c +0 -6
@@ -286,12 +286,6 @@ mem_init(void)mem_init_print_info (NULL ); } -void -free_initmem (void ) -{ -free_initmem_default (-1 ); -} -#ifdef CONFIG_BLK_DEV_INITRD void free_initrd_mem (unsigned long start,unsigned long end)
arch/arc/mm/init.c +0 -8
@@ -207,14 +207,6 @@ void __init mem_init(void)mem_init_print_info (NULL ); } -/* -* free_initmem: Free all the __init memory. -*/ -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) {
arch/c6x/mm/init.c +0 -5
@@ -73,8 +73,3 @@ 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 ); -}
arch/h8300/mm/init.c +0 -6
@@ -108,9 +108,3 @@ 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 ); -}
arch/microblaze/mm/init.c +0 -5
@@ -193,11 +193,6 @@ void free_initrd_mem(unsigned long start, unsigned long end) }#endif -void free_initmem (void ) -{ -free_initmem_default (-1 ); -} -void __init mem_init (void ) { high_memory = (void *)__va (memory_start + lowmem_size -1 );
arch/nds32/mm/init.c +0 -5
@@ -244,11 +244,6 @@ void __init mem_init(void)return ; } -void free_initmem (void ) -{ -free_initmem_default (-1 ); -} -#ifdef CONFIG_BLK_DEV_INITRD void free_initrd_mem (unsigned long start,unsigned long end) {
arch/nios2/mm/init.c +0 -5
@@ -89,11 +89,6 @@ void __init free_initrd_mem(unsigned long start, unsigned long end) }#endif -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);
arch/openrisc/mm/init.c +0 -5
@@ -227,8 +227,3 @@ 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 ); -}
arch/sh/mm/init.c +0 -5
@@ -405,11 +405,6 @@ void __init mem_init(void) mem_init_done =1 ; } -void free_initmem (void ) -{ -free_initmem_default (-1 ); -} -#ifdef CONFIG_BLK_DEV_INITRD void free_initrd_mem (unsigned long start,unsigned long end) {
arch/unicore32/mm/init.c +0 -5
@@ -312,11 +312,6 @@ void __init mem_init(void) } } -void free_initmem (void ) -{ -free_initmem_default (-1 ); -} -#ifdef CONFIG_BLK_DEV_INITRD static int keep_initrd;
arch/xtensa/mm/init.c +0 -5
@@ -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;
init/main.c +5 -0
@@ -1047,6 +1047,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;
Signature · 1 line
2.7.4
PATCH 2/4 hexagon: switch over to generic free_initmem()
In reply to Mike Rapoporthexagon implementation of free_initmem() is currently empty and marked with comment
* Todo: free pages between __init_begin and __init_end; possibly
* some devtree related stuff as well.
Switch it to the generic implementation.
--- arch/hexagon/mm/init.c | 10 ---------- 1 file changed, 10 deletions(-)
arch/hexagon/mm/init.c +0 -10
@@ -85,16 +85,6 @@ void __init mem_init(void) }/* -* free_initmem - frees memory used by stuff declared with __init -* -* Todo: free pages between __init_begin and __init_end; possibly -* some devtree related stuff as well. -*/ -void __ref free_initmem (void ) -{ -} - -/* * free_initrd_mem - frees... initrd memory. * @start - start of init memory * @end - end of init memory
Signature · 1 line
2.7.4
PATCH 3/4 init: free_initmem: poison freed init memory
In reply to Mike RapoportVarious architectures including x86 poison the freed init memory. Do the same in the generic free_initmem implementation and switch sparc32 architecture that is identical to the generic code over to it now.
--- arch/sparc/mm/init_32.c | 5 ----- init/main.c | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-)
arch/sparc/mm/init_32.c +0 -5
@@ -294,11 +294,6 @@ void __init mem_init(void)mem_init_print_info (NULL ); } -void free_initmem (void ) -{ -free_initmem_default (POISON_FREE_INITMEM ); -} -#ifdef CONFIG_BLK_DEV_INITRD void free_initrd_mem (unsigned long start,unsigned long end) {
init/main.c +1 -1
@@ -1049,7 +1049,7 @@ static inline void mark_readonly(void)void __weak free_initmem (void ) { -free_initmem_default (-1 ); +free_initmem_default (POISON_FREE_INITMEM ); }static int __ref kernel_init (void *unused)
Signature · 1 line
2.7.4
PATCH 4/4 riscv: switch over to generic free_initmem()
In reply to Mike RapoportThe riscv version of free_initmem() differs from the generic one only in that it sets the freed memory to zero.
Make ricsv use the generic version and poison the freed memory.
--- arch/riscv/mm/init.c | 5 ----- 1 file changed, 5 deletions(-)
arch/riscv/mm/init.c +0 -5
@@ -60,11 +60,6 @@ void __init mem_init(void)mem_init_print_info (NULL ); } -void free_initmem (void ) -{ -free_initmem_default (0 ); -} -#ifdef CONFIG_BLK_DEV_INITRD void free_initrd_mem (unsigned long start,unsigned long end) {
Signature · 1 line
2.7.4
This look fine to me, but I'm a little worried that as-is this will just create conflicts with my series..
Quoted 2 lines · Christoph Hellwig
This look fine to me, but I'm a little worried that as-is this will just create conflicts with my series..
I'll rebase on top of your patches once they are in. Or I can send both series as a single set.
Preferences?
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH 4/4] riscv: switch over to generic free_initmem()
In reply to Mike RapoportQuoted 16 lines · On Thu, 14 Feb 2019 07:59:37 PST (-0800), [email protected] wrote:
The riscv version of
free_initmem()differs from the generic one only in that it sets the freed memory to zero.Make ricsv use the generic version and poison the freed memory.
Signed-off-by Mike Rapoport <[email protected]>--- arch/riscv/mm/init.c | 5 ----- 1 file changed, 5 deletions(-)arch/riscv/mm/init.c +0
-0@@ -60,11 +60,6 @@ void __init mem_init(void)mem_init_print_info (NULL );
arch/riscv/mm/init.c void __init mem_init(void) · line 65
Quoted 10 lines
arch/riscv/mm/init.c +0
-5} -void free_initmem (void ) -{ -free_initmem_default (0 ); -} -#ifdef CONFIG_BLK_DEV_INITRD void free_initrd_mem (unsigned long start,unsigned long end) {
I'm going to assume this goes in with the rest of the patch set, thanks!
Quoted 7 lines · Mike Rapoport
Quoted 2 lines · Christoph Hellwig
This look fine to me, but I'm a little worried that as-is this will just create conflicts with my series..
I'll rebase on top of your patches once they are in. Or I can send both series as a single set.
Preferences?
So far there wasn't really much a reason to rebase my series, hope this gets picked up either by Andrew or Al (not sure what the right place is). I think for now just rebase your series on top, we can then figure out how to proceed.
Re: [PATCH 4/4] riscv: switch over to generic free_initmem()
In reply to Palmer DabbeltHi Mike,
Quoted 8 lines · Palmer Dabbelt
Quoted 6 lines · On Thu, 14 Feb 2019 07:59:37 PST (-0800), [email protected] wrote:
The riscv version of
free_initmem()differs from the generic one only in that it sets the freed memory to zero.Make ricsv use the generic version and poison the freed memory.
Signed-off-by Mike Rapoport <[email protected]>
Just for clarity, does same change applicable in below places -
arch/openrisc/mm/init.c#L231
arch/alpha/mm/init.c#L290
arch/arc/mm/init.c#L213
arch/m68k/mm/init.c#L109
arch/nds32/mm/init.c#L247
arch/nios2/mm/init.c#L92
arch/openrisc/mm/init.c#L231
Quoted 25 lines
Quoted 10 lines
--- arch/riscv/mm/init.c | 5 ----- 1 file changed, 5 deletions(-)arch/riscv/mm/init.c +0
-0@@ -60,11 +60,6 @@ void __init mem_init(void)mem_init_print_info (NULL );arch/riscv/mm/init.c void __init mem_init(void) · line 65
Quoted 10 lines
arch/riscv/mm/init.c +0
-5} -void free_initmem (void ) -{ -free_initmem_default (0 ); -} -#ifdef CONFIG_BLK_DEV_INITRD void free_initrd_mem (unsigned long start,unsigned long end) {Reviewed-by Palmer Dabbelt <[email protected]>I'm going to assume this goes in with the rest of the patch set, thanks!
Re: [PATCH 4/4] riscv: switch over to generic free_initmem()
Quoted 15 lines · Souptick Joarder
Hi Mike,
Quoted 8 lines · Palmer Dabbelt
Quoted 6 lines · On Thu, 14 Feb 2019 07:59:37 PST (-0800), [email protected] wrote:
The riscv version of
free_initmem()differs from the generic one only in that it sets the freed memory to zero.Make ricsv use the generic version and poison the freed memory.
Signed-off-by Mike Rapoport <[email protected]>Just for clarity, does same change applicable in below places -
Quoted 7 lines
arch/openrisc/mm/init.c#L231
arch/alpha/mm/init.c#L290
arch/arc/mm/init.c#L213
arch/m68k/mm/init.c#L109
arch/nds32/mm/init.c#L247
arch/nios2/mm/init.c#L92
arch/openrisc/mm/init.c#L231
Please ignore this query. just saw the other patches. Sorry for the noise.
Quoted 27 lines
Quoted 27 lines
Quoted 12 lines
--- arch/riscv/mm/init.c | 5 ----- 1 file changed, 5 deletions(-)arch/riscv/mm/init.c +0
-0@@ -60,11 +60,6 @@ void __init mem_init(void)mem_init_print_info (NULL );arch/riscv/mm/init.c void __init mem_init(void) · line 65
Quoted 10 lines
arch/riscv/mm/init.c +0
-5} -void free_initmem (void ) -{ -free_initmem_default (0 ); -} -#ifdef CONFIG_BLK_DEV_INITRD void free_initrd_mem (unsigned long start,unsigned long end) {Reviewed-by Palmer Dabbelt <[email protected]>I'm going to assume this goes in with the rest of the patch set, thanks!