arm64: use generic free_initrd_mem()
PATCH v4 1/1 arm64: use generic free_initrd_mem()
From: Mike Rapoport <[email protected]>
arm64 calls memblock_free() for the initrd area in its implementation of free_initrd_mem(), but this call has no actual effect that late in the boot process. By the time initrd is freed, all the reserved memory is managed by the page allocator and the memblock.reserved is unused, so the only purpose of the memblock_free() call is to keep track of initrd memory for debugging and accounting.
Without the memblock_free() call the only difference between arm64 and the generic versions of free_initrd_mem() is the memory poisoning.
Move memblock_free() call to the generic code, enable it there for the architectures that define ARCH_KEEP_MEMBLOCK and use the generic implementation of free_initrd_mem() on arm64.
---
v4:
* memblock_free() aligned area around the initrd
v3:
* fix powerpc build
v2:
* add memblock_free() to the generic free_initrd_mem()
* rebase on the current upstream
arch/arm64/mm/init.c | 12 ------------ init/initramfs.c | 8 ++++++++ 2 files changed, 8 insertions(+), 12 deletions(-)
arch/arm64/mm/init.c +0 -12
@@ -580,18 +580,6 @@ void free_initmem(void)unmap_kernel_range ((u64 )__init_begin, (u64)(__init_end - __init_begin)); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem (unsigned long start,unsigned long end) -{ -unsigned long aligned_start, aligned_end; - - aligned_start =__virt_to_phys (start) &PAGE_MASK ; - aligned_end =PAGE_ALIGN (__virt_to_phys (end)); -memblock_free (aligned_start, aligned_end - aligned_start); -free_reserved_area ((void *)start, (void *)end,0 ,"initrd" ); -} -#endif -/* * Dump out memory limit information on panic. */
init/initramfs.c +8 -0
@@ -10,6 +10,7 @@#include <linux/syscalls.h> #include <linux/utime.h> #include <linux/file.h> +#include <linux/memblock.h> static ssize_t __init xwrite (int fd,const char *p,size_t count) {
@@ -529,6 +530,13 @@ extern unsigned long __initramfs_size;void __weak free_initrd_mem (unsigned long start,unsigned long end) { +#ifdef CONFIG_ARCH_KEEP_MEMBLOCK +unsigned long aligned_start =ALIGN_DOWN (start,PAGE_SIZE ); +unsigned long aligned_end =ALIGN (end,PAGE_SIZE ); + +memblock_free (__pa (aligned_start), aligned_end - aligned_start); +#endif +free_reserved_area ((void *)start, (void *)end,POISON_FREE_INITMEM ,"initrd" ); }
Signature · 1 line
2.7.4
Quoted 8 lines · Mike Rapoport
From: Mike Rapoport <[email protected]>
arm64 calls
memblock_free()for the initrd area in its implementation offree_initrd_mem(), but this call has no actual effect that late in the boot process. By the time initrd is freed, all the reserved memory is managed by the page allocator and the memblock.reserved is unused, so the only purpose of thememblock_free()call is to keep track of initrd memory for debugging and accounting.
Thats correct. memblock_free_all() gets called before free_initrd_mem().
Quoted 7 lines
Without the
memblock_free()call the only difference between arm64 and the generic versions offree_initrd_mem()is the memory poisoning.Move
memblock_free()call to the generic code, enable it there for the architectures that defineARCH_KEEP_MEMBLOCKand use the generic implementation offree_initrd_mem()on arm64.
This improves free_initrd_mem() generic implementation for others to use.
Quoted 2 lines
Signed-off-by Mike Rapoport <[email protected]>
Quoted 57 lines
---
v4:
*memblock_free()aligned area around the initrdv3:
* fix powerpc buildv2:
* addmemblock_free()to the genericfree_initrd_mem()
* rebase on the current upstreamarch/arm64/mm/init.c | 12 ------------ init/initramfs.c | 8 ++++++++ 2 files changed, 8 insertions(+), 12 deletions(-)arch/arm64/mm/init.c +0
-12@@ -580,18 +580,6 @@ void free_initmem(void)unmap_kernel_range ((u64 )__init_begin, (u64)(__init_end - __init_begin)); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem (unsigned long start,unsigned long end) -{ -unsigned long aligned_start, aligned_end; - - aligned_start =__virt_to_phys (start) &PAGE_MASK ; - aligned_end =PAGE_ALIGN (__virt_to_phys (end)); -memblock_free (aligned_start, aligned_end - aligned_start); -free_reserved_area ((void *)start, (void *)end,0 ,"initrd" ); -} -#endif -/* * Dump out memory limit information on panic. */ init/initramfs.c +1
-0@@ -10,6 +10,7 @@#include <linux/syscalls.h> #include <linux/utime.h> #include <linux/file.h> +#include <linux/memblock.h> static ssize_t __init xwrite (int fd,const char *p,size_t count) {@@ -529,6 +530,13 @@ extern unsigned long __initramfs_size;void __weak free_initrd_mem (unsigned long start,unsigned long end) {
init/initramfs.c extern unsigned long __initramfs_size; · line 542
Quoted 10 lines
init/initramfs.c +7
-0+#ifdef CONFIG_ARCH_KEEP_MEMBLOCK +unsigned long aligned_start =ALIGN_DOWN (start,PAGE_SIZE ); +unsigned long aligned_end =ALIGN (end,PAGE_SIZE ); + +memblock_free (__pa (aligned_start), aligned_end - aligned_start); +#endif +free_reserved_area ((void *)start, (void *)end,POISON_FREE_INITMEM ,"initrd" ); }
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 16 lines · Mike Rapoport
From: Mike Rapoport <[email protected]>
arm64 calls
memblock_free()for the initrd area in its implementation offree_initrd_mem(), but this call has no actual effect that late in the boot process. By the time initrd is freed, all the reserved memory is managed by the page allocator and the memblock.reserved is unused, so the only purpose of thememblock_free()call is to keep track of initrd memory for debugging and accounting.Without the
memblock_free()call the only difference between arm64 and the generic versions offree_initrd_mem()is the memory poisoning.Move
memblock_free()call to the generic code, enable it there for the architectures that defineARCH_KEEP_MEMBLOCKand use the generic implementation offree_initrd_mem()on arm64.
Quoted 5 lines
Signed-off-by Mike Rapoport <[email protected]>---
v4:
*memblock_free()aligned area around the initrd
Looks straightforward to me:
Will
Quoted 27 lines · Will Deacon
Quoted 3 lines · Mike Rapoport
From: Mike Rapoport <[email protected]>
arm64 calls
memblock_free()for the initrd area in its implementationof
Quoted 1 line
free_initrd_mem(), but this call has no actual effect that late inthe boot
Quoted 1 line
process. By the time initrd is freed, all the reserved memory is
managed by
Quoted 1 line
the page allocator and the memblock.reserved is unused, so the only
purpose
Quoted 1 line
of the
memblock_free()call is to keep track of initrd memory fordebugging
Quoted 3 lines
and accounting.
Without the
memblock_free()call the only difference between arm64and the
Quoted 4 lines
generic versions of
free_initrd_mem()is the memory poisoning.Move
memblock_free()call to the generic code, enable it there for the architectures that defineARCH_KEEP_MEMBLOCKand use thegeneric
Quoted 5 lines
implementation of
free_initrd_mem()on arm64.Signed-off-by Mike Rapoport <[email protected]>---
Quoted 6 lines
Quoted 2 lines
v4:
*memblock_free()aligned area around the initrdLooks straightforward to me:
Acked-by Will Deacon <[email protected]>
Can it go via arm64 tree?
Quoted 1 line
Will
Signature · 2 lines
Sincerely yours, Mike
Will Deacon
maintainerQuoted 28 lines · Mike Rapoport
Quoted 27 lines · Will Deacon
Quoted 3 lines · Mike Rapoport
From: Mike Rapoport <[email protected]>
arm64 calls
memblock_free()for the initrd area in its implementationof
Quoted 1 line
free_initrd_mem(), but this call has no actual effect that late inthe boot
Quoted 1 line
process. By the time initrd is freed, all the reserved memory is
managed by
Quoted 1 line
the page allocator and the memblock.reserved is unused, so the only
purpose
Quoted 1 line
of the
memblock_free()call is to keep track of initrd memory fordebugging
Quoted 3 lines
and accounting.
Without the
memblock_free()call the only difference between arm64and the
Quoted 4 lines
generic versions of
free_initrd_mem()is the memory poisoning.Move
memblock_free()call to the generic code, enable it there for the architectures that defineARCH_KEEP_MEMBLOCKand use thegeneric
Quoted 5 lines
implementation of
free_initrd_mem()on arm64.Signed-off-by Mike Rapoport <[email protected]>---
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
v4:
*memblock_free()aligned area around the initrdLooks straightforward to me:
Acked-by Will Deacon <[email protected]>Can it go via arm64 tree?
Yes, I was hoping Catalin would pick it up for 5.5.
Will
Quoted 9 lines · Mike Rapoport
From: Mike Rapoport <[email protected]>
arm64 calls
memblock_free()for the initrd area in its implementation offree_initrd_mem(), but this call has no actual effect that late in the boot process. By the time initrd is freed, all the reserved memory is managed by the page allocator and the memblock.reserved is unused, so the only purpose of thememblock_free()call is to keep track of initrd memory for debugging and accounting.
Quoted 8 lines
Without the
memblock_free()call the only difference between arm64 and the generic versions offree_initrd_mem()is the memory poisoning.Move
memblock_free()call to the generic code, enable it there for the architectures that defineARCH_KEEP_MEMBLOCKand use the generic implementation offree_initrd_mem()on arm64.Signed-off-by Mike Rapoport <[email protected]>
Queued for 5.5. Thanks.
Signature · 1 line
Catalin