2019-01-14 13:02:19

by David Hildenbrand

[permalink] [raw]
Subject: [PATCH v2 7/9] arm64: kdump: No need to mark crashkernel pages manually PG_reserved

The crashkernel is reserved via memblock_reserve(). memblock_free_all()
will call free_low_memory_core_early(), which will go over all reserved
memblocks, marking the pages as PG_reserved.

So manually marking pages as PG_reserved is not necessary, they are
already in the desired state (otherwise they would have been handed over
to the buddy as free pages and bad things would happen).

Cc: Catalin Marinas <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: James Morse <[email protected]>
Cc: Bhupesh Sharma <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Dave Kleikamp <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Mike Rapoport <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Stefan Agner <[email protected]>
Cc: Laura Abbott <[email protected]>
Cc: Greg Hackmann <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Kristina Martsenko <[email protected]>
Cc: CHANDAN VN <[email protected]>
Cc: AKASHI Takahiro <[email protected]>
Cc: Logan Gunthorpe <[email protected]>
Reviewed-by: Matthias Brugger <[email protected]>
Signed-off-by: David Hildenbrand <[email protected]>
---
arch/arm64/kernel/machine_kexec.c | 2 +-
arch/arm64/mm/init.c | 27 ---------------------------
2 files changed, 1 insertion(+), 28 deletions(-)

diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c
index 6f0587b5e941..66b5d697d943 100644
--- a/arch/arm64/kernel/machine_kexec.c
+++ b/arch/arm64/kernel/machine_kexec.c
@@ -321,7 +321,7 @@ void crash_post_resume(void)
* but does not hold any data of loaded kernel image.
*
* Note that all the pages in crash dump kernel memory have been initially
- * marked as Reserved in kexec_reserve_crashkres_pages().
+ * marked as Reserved as memory was allocated via memblock_reserve().
*
* In hibernation, the pages which are Reserved and yet "nosave" are excluded
* from the hibernation iamge. crash_is_nosave() does thich check for crash
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 7205a9085b4d..c38976b70069 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -118,35 +118,10 @@ static void __init reserve_crashkernel(void)
crashk_res.start = crash_base;
crashk_res.end = crash_base + crash_size - 1;
}
-
-static void __init kexec_reserve_crashkres_pages(void)
-{
-#ifdef CONFIG_HIBERNATION
- phys_addr_t addr;
- struct page *page;
-
- if (!crashk_res.end)
- return;
-
- /*
- * To reduce the size of hibernation image, all the pages are
- * marked as Reserved initially.
- */
- for (addr = crashk_res.start; addr < (crashk_res.end + 1);
- addr += PAGE_SIZE) {
- page = phys_to_page(addr);
- SetPageReserved(page);
- }
-#endif
-}
#else
static void __init reserve_crashkernel(void)
{
}
-
-static void __init kexec_reserve_crashkres_pages(void)
-{
-}
#endif /* CONFIG_KEXEC_CORE */

#ifdef CONFIG_CRASH_DUMP
@@ -586,8 +561,6 @@ void __init mem_init(void)
/* this will put all unused low memory onto the freelists */
memblock_free_all();

- kexec_reserve_crashkres_pages();
-
mem_init_print_info(NULL);

/*
--
2.17.2



2019-01-14 15:55:34

by Bhupesh Sharma

[permalink] [raw]
Subject: Re: [PATCH v2 7/9] arm64: kdump: No need to mark crashkernel pages manually PG_reserved

Hi David,

On Mon, Jan 14, 2019 at 6:30 PM David Hildenbrand <[email protected]> wrote:
>
> The crashkernel is reserved via memblock_reserve(). memblock_free_all()
> will call free_low_memory_core_early(), which will go over all reserved
> memblocks, marking the pages as PG_reserved.
>
> So manually marking pages as PG_reserved is not necessary, they are
> already in the desired state (otherwise they would have been handed over
> to the buddy as free pages and bad things would happen).
>
> Cc: Catalin Marinas <[email protected]>
> Cc: Will Deacon <[email protected]>
> Cc: James Morse <[email protected]>
> Cc: Bhupesh Sharma <[email protected]>
> Cc: David Hildenbrand <[email protected]>
> Cc: Mark Rutland <[email protected]>
> Cc: Dave Kleikamp <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Mike Rapoport <[email protected]>
> Cc: Michal Hocko <[email protected]>
> Cc: Florian Fainelli <[email protected]>
> Cc: Stefan Agner <[email protected]>
> Cc: Laura Abbott <[email protected]>
> Cc: Greg Hackmann <[email protected]>
> Cc: Johannes Weiner <[email protected]>
> Cc: Kristina Martsenko <[email protected]>
> Cc: CHANDAN VN <[email protected]>
> Cc: AKASHI Takahiro <[email protected]>
> Cc: Logan Gunthorpe <[email protected]>
> Reviewed-by: Matthias Brugger <[email protected]>
> Signed-off-by: David Hildenbrand <[email protected]>
> ---
> arch/arm64/kernel/machine_kexec.c | 2 +-
> arch/arm64/mm/init.c | 27 ---------------------------
> 2 files changed, 1 insertion(+), 28 deletions(-)
>
> diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c
> index 6f0587b5e941..66b5d697d943 100644
> --- a/arch/arm64/kernel/machine_kexec.c
> +++ b/arch/arm64/kernel/machine_kexec.c
> @@ -321,7 +321,7 @@ void crash_post_resume(void)
> * but does not hold any data of loaded kernel image.
> *
> * Note that all the pages in crash dump kernel memory have been initially
> - * marked as Reserved in kexec_reserve_crashkres_pages().
> + * marked as Reserved as memory was allocated via memblock_reserve().
> *
> * In hibernation, the pages which are Reserved and yet "nosave" are excluded
> * from the hibernation iamge. crash_is_nosave() does thich check for crash
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index 7205a9085b4d..c38976b70069 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -118,35 +118,10 @@ static void __init reserve_crashkernel(void)
> crashk_res.start = crash_base;
> crashk_res.end = crash_base + crash_size - 1;
> }
> -
> -static void __init kexec_reserve_crashkres_pages(void)
> -{
> -#ifdef CONFIG_HIBERNATION
> - phys_addr_t addr;
> - struct page *page;
> -
> - if (!crashk_res.end)
> - return;
> -
> - /*
> - * To reduce the size of hibernation image, all the pages are
> - * marked as Reserved initially.
> - */
> - for (addr = crashk_res.start; addr < (crashk_res.end + 1);
> - addr += PAGE_SIZE) {
> - page = phys_to_page(addr);
> - SetPageReserved(page);
> - }
> -#endif
> -}
> #else
> static void __init reserve_crashkernel(void)
> {
> }
> -
> -static void __init kexec_reserve_crashkres_pages(void)
> -{
> -}
> #endif /* CONFIG_KEXEC_CORE */
>
> #ifdef CONFIG_CRASH_DUMP
> @@ -586,8 +561,6 @@ void __init mem_init(void)
> /* this will put all unused low memory onto the freelists */
> memblock_free_all();
>
> - kexec_reserve_crashkres_pages();
> -
> mem_init_print_info(NULL);
>
> /*
> --
> 2.17.2

LGTM, so:
Reviewed-by: Bhupesh Sharma <[email protected]>

2019-01-25 16:28:59

by Catalin Marinas

[permalink] [raw]
Subject: Re: [PATCH v2 7/9] arm64: kdump: No need to mark crashkernel pages manually PG_reserved

On Mon, Jan 14, 2019 at 01:59:01PM +0100, David Hildenbrand wrote:
> The crashkernel is reserved via memblock_reserve(). memblock_free_all()
> will call free_low_memory_core_early(), which will go over all reserved
> memblocks, marking the pages as PG_reserved.
>
> So manually marking pages as PG_reserved is not necessary, they are
> already in the desired state (otherwise they would have been handed over
> to the buddy as free pages and bad things would happen).
>
> Cc: Catalin Marinas <[email protected]>
> Cc: Will Deacon <[email protected]>
> Cc: James Morse <[email protected]>
> Cc: Bhupesh Sharma <[email protected]>
> Cc: David Hildenbrand <[email protected]>
> Cc: Mark Rutland <[email protected]>
> Cc: Dave Kleikamp <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Mike Rapoport <[email protected]>
> Cc: Michal Hocko <[email protected]>
> Cc: Florian Fainelli <[email protected]>
> Cc: Stefan Agner <[email protected]>
> Cc: Laura Abbott <[email protected]>
> Cc: Greg Hackmann <[email protected]>
> Cc: Johannes Weiner <[email protected]>
> Cc: Kristina Martsenko <[email protected]>
> Cc: CHANDAN VN <[email protected]>
> Cc: AKASHI Takahiro <[email protected]>
> Cc: Logan Gunthorpe <[email protected]>
> Reviewed-by: Matthias Brugger <[email protected]>
> Signed-off-by: David Hildenbrand <[email protected]>

Acked-by: Catalin Marinas <[email protected]>