linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] arm64: use generic free_initrd_mem()
@ 2019-09-24 11:18 Mike Rapoport
  2019-09-24 17:18 ` kbuild test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Rapoport @ 2019-09-24 11:18 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Mark Rutland
  Cc: Mike Rapoport, Laura Abbott, linux-kernel, linux-arm-kernel,
	Anshuman Khandual

From: Mike Rapoport <rppt@linux.ibm.com>

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.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---

v2 changes:
* add memblock_free() to the generic free_initrd_mem()
* rebase on the current upstream

 arch/arm64/mm/init.c | 12 ------------
 init/initramfs.c     |  4 ++++
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 45c00a5..87a0e3b 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -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.
  */
diff --git a/init/initramfs.c b/init/initramfs.c
index c47dad0..403c6a0 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -531,6 +531,10 @@ void __weak free_initrd_mem(unsigned long start, unsigned long end)
 {
 	free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM,
 			"initrd");
+
+#ifdef CONFIG_ARCH_KEEP_MEMBLOCK
+	memblock_free(__virt_to_phys(start), end - start);
+#endif
 }
 
 #ifdef CONFIG_KEXEC_CORE
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] arm64: use generic free_initrd_mem()
  2019-09-24 11:18 [PATCH v2] arm64: use generic free_initrd_mem() Mike Rapoport
@ 2019-09-24 17:18 ` kbuild test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kbuild test robot @ 2019-09-24 17:18 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: Mark Rutland, Anshuman Khandual, Catalin Marinas, linux-kernel,
	Mike Rapoport, kbuild-all, Laura Abbott, Will Deacon,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 2208 bytes --]

Hi Mike,

I love your patch! Yet something to improve:

[auto build test ERROR on arm64/for-next/core]
[cannot apply to v5.3 next-20190920]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Mike-Rapoport/arm64-use-generic-free_initrd_mem/20190924-220328
base:   https://kernel.googlesource.com/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: powerpc-allmodconfig (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=powerpc 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   init/initramfs.c: In function 'free_initrd_mem':
>> init/initramfs.c:536:2: error: implicit declaration of function 'memblock_free'; did you mean 'ptlock_free'? [-Werror=implicit-function-declaration]
     memblock_free(__virt_to_phys(start), end - start);
     ^~~~~~~~~~~~~
     ptlock_free
>> init/initramfs.c:536:16: error: implicit declaration of function '__virt_to_phys'; did you mean 'virt_to_phys'? [-Werror=implicit-function-declaration]
     memblock_free(__virt_to_phys(start), end - start);
                   ^~~~~~~~~~~~~~
                   virt_to_phys
   cc1: some warnings being treated as errors

vim +536 init/initramfs.c

   529	
   530	void __weak free_initrd_mem(unsigned long start, unsigned long end)
   531	{
   532		free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM,
   533				"initrd");
   534	
   535	#ifdef CONFIG_ARCH_KEEP_MEMBLOCK
 > 536		memblock_free(__virt_to_phys(start), end - start);
   537	#endif
   538	}
   539	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 62287 bytes --]

[-- Attachment #3: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-24 17:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-24 11:18 [PATCH v2] arm64: use generic free_initrd_mem() Mike Rapoport
2019-09-24 17:18 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).