Skip to content

Commit 899ee4a

Browse files
rpptctmarinas
authored andcommitted
arm64: use generic free_initrd_mem()
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. Tested-by: Anshuman Khandual <anshuman.khandual@arm.com> #arm64 Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Acked-by: Will Deacon <will@kernel.org> Signed-off-by: Mike Rapoport <rppt@linux.ibm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent ce87de4 commit 899ee4a

2 files changed

Lines changed: 8 additions & 12 deletions

File tree

‎arch/arm64/mm/init.c‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -580,18 +580,6 @@ void free_initmem(void)
580580
unmap_kernel_range((u64)__init_begin, (u64)(__init_end - __init_begin));
581581
}
582582

583-
#ifdef CONFIG_BLK_DEV_INITRD
584-
void __init free_initrd_mem(unsigned long start, unsigned long end)
585-
{
586-
unsigned long aligned_start, aligned_end;
587-
588-
aligned_start = __virt_to_phys(start) & PAGE_MASK;
589-
aligned_end = PAGE_ALIGN(__virt_to_phys(end));
590-
memblock_free(aligned_start, aligned_end - aligned_start);
591-
free_reserved_area((void *)start, (void *)end, 0, "initrd");
592-
}
593-
#endif
594-
595583
/*
596584
* Dump out memory limit information on panic.
597585
*/

‎init/initramfs.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/syscalls.h>
1111
#include <linux/utime.h>
1212
#include <linux/file.h>
13+
#include <linux/memblock.h>
1314

1415
static ssize_t __init xwrite(int fd, const char *p, size_t count)
1516
{
@@ -529,6 +530,13 @@ extern unsigned long __initramfs_size;
529530

530531
void __weak free_initrd_mem(unsigned long start, unsigned long end)
531532
{
533+
#ifdef CONFIG_ARCH_KEEP_MEMBLOCK
534+
unsigned long aligned_start = ALIGN_DOWN(start, PAGE_SIZE);
535+
unsigned long aligned_end = ALIGN(end, PAGE_SIZE);
536+
537+
memblock_free(__pa(aligned_start), aligned_end - aligned_start);
538+
#endif
539+
532540
free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM,
533541
"initrd");
534542
}

0 commit comments

Comments
 (0)