linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] arm64: use generic free_initrd_mem()
@ 2019-09-28  8:02 Mike Rapoport
  2019-09-30  5:24 ` Anshuman Khandual
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Mike Rapoport @ 2019-09-28  8:02 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Mark Rutland
  Cc: Laura Abbott, Anshuman Khandual, linux-arm-kernel, linux-kernel,
	Mike Rapoport

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

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(-)

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..8ec1be4 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -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");
 }
-- 
2.7.4


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

* Re: [PATCH v4] arm64: use generic free_initrd_mem()
  2019-09-28  8:02 [PATCH v4] arm64: use generic free_initrd_mem() Mike Rapoport
@ 2019-09-30  5:24 ` Anshuman Khandual
  2019-10-15  0:46 ` Will Deacon
  2019-10-16 12:55 ` Catalin Marinas
  2 siblings, 0 replies; 6+ messages in thread
From: Anshuman Khandual @ 2019-09-30  5:24 UTC (permalink / raw)
  To: Mike Rapoport, Catalin Marinas, Will Deacon, Mark Rutland
  Cc: Laura Abbott, linux-arm-kernel, linux-kernel, Mike Rapoport


On 09/28/2019 01:32 PM, Mike Rapoport wrote:
> 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.

Thats correct. memblock_free_all() gets called before free_initrd_mem().

> 
> 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.

This improves free_initrd_mem() generic implementation for others to use.

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

Tested-by: Anshuman Khandual <anshuman.khandual@arm.com>	#arm64
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>

> ---
> 
> 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(-)
> 
> 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..8ec1be4 100644
> --- a/init/initramfs.c
> +++ b/init/initramfs.c
> @@ -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");
>  }
> 

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

* Re: [PATCH v4] arm64: use generic free_initrd_mem()
  2019-09-28  8:02 [PATCH v4] arm64: use generic free_initrd_mem() Mike Rapoport
  2019-09-30  5:24 ` Anshuman Khandual
@ 2019-10-15  0:46 ` Will Deacon
  2019-10-15  7:39   ` Mike Rapoport
  2019-10-16 12:55 ` Catalin Marinas
  2 siblings, 1 reply; 6+ messages in thread
From: Will Deacon @ 2019-10-15  0:46 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: Catalin Marinas, Mark Rutland, Laura Abbott, Anshuman Khandual,
	linux-arm-kernel, linux-kernel, Mike Rapoport

On Sat, Sep 28, 2019 at 11:02:26AM +0300, Mike Rapoport wrote:
> 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>
> ---
> 
> v4:
> * memblock_free() aligned area around the initrd

Looks straightforward to me:

Acked-by: Will Deacon <will@kernel.org>

Will

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

* Re: [PATCH v4] arm64: use generic free_initrd_mem()
  2019-10-15  0:46 ` Will Deacon
@ 2019-10-15  7:39   ` Mike Rapoport
  2019-10-15 16:19     ` Will Deacon
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Rapoport @ 2019-10-15  7:39 UTC (permalink / raw)
  To: Will Deacon
  Cc: Catalin Marinas, Mark Rutland, Laura Abbott, Anshuman Khandual,
	linux-arm-kernel, linux-kernel, Mike Rapoport

On October 15, 2019 2:46:59 AM GMT+02:00, Will Deacon <will@kernel.org> wrote:
>On Sat, Sep 28, 2019 at 11:02:26AM +0300, Mike Rapoport wrote:
>> 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>
>> ---
>> 
>> v4:
>> * memblock_free() aligned area around the initrd
>
>Looks straightforward to me:
>
>Acked-by: Will Deacon <will@kernel.org>

 Can it go via arm64 tree?

>Will


-- 
Sincerely yours,
Mike

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

* Re: [PATCH v4] arm64: use generic free_initrd_mem()
  2019-10-15  7:39   ` Mike Rapoport
@ 2019-10-15 16:19     ` Will Deacon
  0 siblings, 0 replies; 6+ messages in thread
From: Will Deacon @ 2019-10-15 16:19 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: Catalin Marinas, Mark Rutland, Laura Abbott, Anshuman Khandual,
	linux-arm-kernel, linux-kernel, Mike Rapoport

On Tue, Oct 15, 2019 at 09:39:41AM +0200, Mike Rapoport wrote:
> On October 15, 2019 2:46:59 AM GMT+02:00, Will Deacon <will@kernel.org> wrote:
> >On Sat, Sep 28, 2019 at 11:02:26AM +0300, Mike Rapoport wrote:
> >> 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>
> >> ---
> >> 
> >> v4:
> >> * memblock_free() aligned area around the initrd
> >
> >Looks straightforward to me:
> >
> >Acked-by: Will Deacon <will@kernel.org>
> 
>  Can it go via arm64 tree?

Yes, I was hoping Catalin would pick it up for 5.5.

Will

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

* Re: [PATCH v4] arm64: use generic free_initrd_mem()
  2019-09-28  8:02 [PATCH v4] arm64: use generic free_initrd_mem() Mike Rapoport
  2019-09-30  5:24 ` Anshuman Khandual
  2019-10-15  0:46 ` Will Deacon
@ 2019-10-16 12:55 ` Catalin Marinas
  2 siblings, 0 replies; 6+ messages in thread
From: Catalin Marinas @ 2019-10-16 12:55 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: Will Deacon, Mark Rutland, Laura Abbott, Anshuman Khandual,
	linux-arm-kernel, linux-kernel, Mike Rapoport

On Sat, Sep 28, 2019 at 11:02:26AM +0300, Mike Rapoport wrote:
> 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>

Queued for 5.5. Thanks.

-- 
Catalin

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

end of thread, other threads:[~2019-10-16 12:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-28  8:02 [PATCH v4] arm64: use generic free_initrd_mem() Mike Rapoport
2019-09-30  5:24 ` Anshuman Khandual
2019-10-15  0:46 ` Will Deacon
2019-10-15  7:39   ` Mike Rapoport
2019-10-15 16:19     ` Will Deacon
2019-10-16 12:55 ` Catalin Marinas

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).