* [PATCH v2 1/3] arm64: kdump: Provide default size when crashkernel=Y,low is not specified
2022-06-21 12:42 [PATCH v2 0/3] arm64: kdump: Function supplement and performance optimization Zhen Lei
@ 2022-06-21 12:42 ` Zhen Lei
2022-06-21 12:42 ` [PATCH v2 2/3] arm64: kdump: Support crashkernel=X fall back to reserve region above DMA zones Zhen Lei
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Zhen Lei @ 2022-06-21 12:42 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H . Peter Anvin, Eric Biederman, Rob Herring, Frank Rowand,
devicetree, Dave Young, Baoquan He, Vivek Goyal, kexec,
linux-kernel, Catalin Marinas, Will Deacon, linux-arm-kernel,
Jonathan Corbet, linux-doc
Cc: Zhen Lei, Randy Dunlap, Feng Zhou, Kefeng Wang, Chen Zhou,
John Donnelly, Dave Kleikamp
To be consistent with the implementation of x86 and improve cross-platform
user experience. Try to allocate at least 256 MiB low memory automatically
for the case that crashkernel=,high is explicitly specified, while
crashkenrel=,low is omitted.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Acked-by: Baoquan He <bhe@redhat.com>
---
Documentation/admin-guide/kernel-parameters.txt | 8 +-------
arch/arm64/mm/init.c | 12 +++++++++++-
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 2522b11e593f239..65a2c3a22a4b57d 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -843,7 +843,7 @@
available.
It will be ignored if crashkernel=X is specified.
crashkernel=size[KMG],low
- [KNL, X86-64] range under 4G. When crashkernel=X,high
+ [KNL, X86-64, ARM64] range under 4G. When crashkernel=X,high
is passed, kernel could allocate physical memory region
above 4G, that cause second kernel crash on system
that require some amount of low memory, e.g. swiotlb
@@ -857,12 +857,6 @@
It will be ignored when crashkernel=X,high is not used
or memory reserved is below 4G.
- [KNL, ARM64] range in low memory.
- This one lets the user specify a low range in the
- DMA zone for the crash dump kernel.
- It will be ignored when crashkernel=X,high is not used
- or memory reserved is located in the DMA zones.
-
cryptomgr.notests
[KNL] Disable crypto self-tests
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 339ee84e5a61a0b..5390f361208ccf7 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -96,6 +96,14 @@ phys_addr_t __ro_after_init arm64_dma_phys_limit = PHYS_MASK + 1;
#define CRASH_ADDR_LOW_MAX arm64_dma_phys_limit
#define CRASH_ADDR_HIGH_MAX (PHYS_MASK + 1)
+/*
+ * This is an empirical value in x86_64 and taken here directly. Please
+ * refer to the code comment in reserve_crashkernel_low() of x86_64 for more
+ * details.
+ */
+#define DEFAULT_CRASH_KERNEL_LOW_SIZE \
+ max(swiotlb_size_or_default() + (8UL << 20), 256UL << 20)
+
static int __init reserve_crashkernel_low(unsigned long long low_size)
{
unsigned long long low_base;
@@ -147,7 +155,9 @@ static void __init reserve_crashkernel(void)
* is not allowed.
*/
ret = parse_crashkernel_low(cmdline, 0, &crash_low_size, &crash_base);
- if (ret && (ret != -ENOENT))
+ if (ret == -ENOENT)
+ crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE;
+ else if (ret)
return;
crash_max = CRASH_ADDR_HIGH_MAX;
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/3] arm64: kdump: Support crashkernel=X fall back to reserve region above DMA zones
2022-06-21 12:42 [PATCH v2 0/3] arm64: kdump: Function supplement and performance optimization Zhen Lei
2022-06-21 12:42 ` [PATCH v2 1/3] arm64: kdump: Provide default size when crashkernel=Y,low is not specified Zhen Lei
@ 2022-06-21 12:42 ` Zhen Lei
2022-06-21 12:42 ` [PATCH v2 3/3] arm64: kdump: Remove some redundant checks in map_mem() Zhen Lei
2022-06-28 1:58 ` [PATCH v2 0/3] arm64: kdump: Function supplement and performance optimization Leizhen (ThunderTown)
3 siblings, 0 replies; 5+ messages in thread
From: Zhen Lei @ 2022-06-21 12:42 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H . Peter Anvin, Eric Biederman, Rob Herring, Frank Rowand,
devicetree, Dave Young, Baoquan He, Vivek Goyal, kexec,
linux-kernel, Catalin Marinas, Will Deacon, linux-arm-kernel,
Jonathan Corbet, linux-doc
Cc: Zhen Lei, Randy Dunlap, Feng Zhou, Kefeng Wang, Chen Zhou,
John Donnelly, Dave Kleikamp
For crashkernel=X without '@offset', select a region within DMA zones
first, and fall back to reserve region above DMA zones. This allows
users to use the same configuration on multiple platforms.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Acked-by: Baoquan He <bhe@redhat.com>
---
Documentation/admin-guide/kernel-parameters.txt | 2 +-
arch/arm64/mm/init.c | 16 +++++++++++++++-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 65a2c3a22a4b57d..cb6a346419a1fe0 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -823,7 +823,7 @@
memory region [offset, offset + size] for that kernel
image. If '@offset' is omitted, then a suitable offset
is selected automatically.
- [KNL, X86-64] Select a region under 4G first, and
+ [KNL, X86-64, ARM64] Select a region under 4G first, and
fall back to reserve region above 4G when '@offset'
hasn't been specified.
See Documentation/admin-guide/kdump/kdump.rst for further details.
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 5390f361208ccf7..8539598f9e58b4d 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -138,6 +138,7 @@ static void __init reserve_crashkernel(void)
unsigned long long crash_max = CRASH_ADDR_LOW_MAX;
char *cmdline = boot_command_line;
int ret;
+ bool fixed_base;
if (!IS_ENABLED(CONFIG_KEXEC_CORE))
return;
@@ -166,15 +167,28 @@ static void __init reserve_crashkernel(void)
return;
}
+ fixed_base = !!crash_base;
crash_size = PAGE_ALIGN(crash_size);
/* User specifies base address explicitly. */
- if (crash_base)
+ if (fixed_base)
crash_max = crash_base + crash_size;
+retry:
crash_base = memblock_phys_alloc_range(crash_size, CRASH_ALIGN,
crash_base, crash_max);
if (!crash_base) {
+ /*
+ * Attempt to fully allocate low memory failed, fall back
+ * to high memory, the minimum required low memory will be
+ * reserved later.
+ */
+ if (!fixed_base && (crash_max == CRASH_ADDR_LOW_MAX)) {
+ crash_max = CRASH_ADDR_HIGH_MAX;
+ crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE;
+ goto retry;
+ }
+
pr_warn("cannot allocate crashkernel (size:0x%llx)\n",
crash_size);
return;
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 3/3] arm64: kdump: Remove some redundant checks in map_mem()
2022-06-21 12:42 [PATCH v2 0/3] arm64: kdump: Function supplement and performance optimization Zhen Lei
2022-06-21 12:42 ` [PATCH v2 1/3] arm64: kdump: Provide default size when crashkernel=Y,low is not specified Zhen Lei
2022-06-21 12:42 ` [PATCH v2 2/3] arm64: kdump: Support crashkernel=X fall back to reserve region above DMA zones Zhen Lei
@ 2022-06-21 12:42 ` Zhen Lei
2022-06-28 1:58 ` [PATCH v2 0/3] arm64: kdump: Function supplement and performance optimization Leizhen (ThunderTown)
3 siblings, 0 replies; 5+ messages in thread
From: Zhen Lei @ 2022-06-21 12:42 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H . Peter Anvin, Eric Biederman, Rob Herring, Frank Rowand,
devicetree, Dave Young, Baoquan He, Vivek Goyal, kexec,
linux-kernel, Catalin Marinas, Will Deacon, linux-arm-kernel,
Jonathan Corbet, linux-doc
Cc: Zhen Lei, Randy Dunlap, Feng Zhou, Kefeng Wang, Chen Zhou,
John Donnelly, Dave Kleikamp
arm64_memblock_init()
if (!IS_ENABLED(CONFIG_ZONE_DMA/DMA32))
reserve_crashkernel()
//initialize crashk_res when
//"crashkernel=" is correctly specified
paging_init()
map_mem()
As shown in the above pseudo code, the crashk_res.end can only be
initialized to non-zero when both "!IS_ENABLED(CONFIG_ZONE_DMA/DMA32)"
and crash_mem_map are true. So some checks in map_mem() can be adjusted
or optimized.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Acked-by: Baoquan He <bhe@redhat.com>
---
arch/arm64/mm/mmu.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 626ec32873c6c36..6028a5757e4eae2 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -529,12 +529,12 @@ static void __init map_mem(pgd_t *pgdp)
#ifdef CONFIG_KEXEC_CORE
if (crash_mem_map) {
- if (IS_ENABLED(CONFIG_ZONE_DMA) ||
- IS_ENABLED(CONFIG_ZONE_DMA32))
- flags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS;
- else if (crashk_res.end)
+ if (crashk_res.end)
memblock_mark_nomap(crashk_res.start,
resource_size(&crashk_res));
+ else if (IS_ENABLED(CONFIG_ZONE_DMA) ||
+ IS_ENABLED(CONFIG_ZONE_DMA32))
+ flags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS;
}
#endif
@@ -571,16 +571,13 @@ static void __init map_mem(pgd_t *pgdp)
* through /sys/kernel/kexec_crash_size interface.
*/
#ifdef CONFIG_KEXEC_CORE
- if (crash_mem_map &&
- !IS_ENABLED(CONFIG_ZONE_DMA) && !IS_ENABLED(CONFIG_ZONE_DMA32)) {
- if (crashk_res.end) {
- __map_memblock(pgdp, crashk_res.start,
- crashk_res.end + 1,
- PAGE_KERNEL,
- NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS);
- memblock_clear_nomap(crashk_res.start,
- resource_size(&crashk_res));
- }
+ if (crashk_res.end) {
+ __map_memblock(pgdp, crashk_res.start,
+ crashk_res.end + 1,
+ PAGE_KERNEL,
+ NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS);
+ memblock_clear_nomap(crashk_res.start,
+ resource_size(&crashk_res));
}
#endif
}
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/3] arm64: kdump: Function supplement and performance optimization
2022-06-21 12:42 [PATCH v2 0/3] arm64: kdump: Function supplement and performance optimization Zhen Lei
` (2 preceding siblings ...)
2022-06-21 12:42 ` [PATCH v2 3/3] arm64: kdump: Remove some redundant checks in map_mem() Zhen Lei
@ 2022-06-28 1:58 ` Leizhen (ThunderTown)
3 siblings, 0 replies; 5+ messages in thread
From: Leizhen (ThunderTown) @ 2022-06-28 1:58 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H . Peter Anvin, Eric Biederman, Rob Herring, Frank Rowand,
devicetree, Dave Young, Baoquan He, Vivek Goyal, kexec,
linux-kernel, Catalin Marinas, Will Deacon, linux-arm-kernel,
Jonathan Corbet, linux-doc
Cc: Randy Dunlap, Feng Zhou, Kefeng Wang, Chen Zhou, John Donnelly,
Dave Kleikamp
On 2022/6/21 20:42, Zhen Lei wrote:
> v1 --> v2:
> 1. Update the commit message of Patch 1, explicitly indicates that "crashkernel=X,high"
> is specified but "crashkernel=Y,low" is not specified.
> 2. Drop Patch 4-5. Currently, focus on function integrity, performance optimization
> will be considered in later versions.
> 3. Patch 3 is not mandatory, it's just a cleanup now, although it is a must for patch 4-5.
> But to avoid subsequent duplication of effort, I'm glad it was accepted.
Hi Catalin:
Do you have time to review Patch 1-2? Please ignore Patch 3, because now someone has
proposed the following new approach:
https://lore.kernel.org/linux-mm/1656241815-28494-1-git-send-email-guanghuifeng@linux.alibaba.com/T/
>
>
> v1:
> After the basic functions of "support reserving crashkernel above 4G on arm64
> kdump"(see https://lkml.org/lkml/2022/5/6/428) are implemented, we still have
> three features to be improved.
> 1. When crashkernel=X,high is specified but crashkernel=Y,low is not specified,
> the default crash low memory size is provided.
> 2. For crashkernel=X without '@offset', if the low memory fails to be allocated,
> fall back to reserve region from high memory(above DMA zones).
> 3. If crashkernel=X,high is used, page mapping is performed only for the crash
> high memory, and block mapping is still used for other linear address spaces.
> Compared to the previous version:
> (1) For crashkernel=X[@offset], the memory above 4G is not changed to block
> mapping, leave it to the next time.
> (2) The implementation method is modified. Now the implementation is simpler
> and clearer.
>
> Zhen Lei (3):
> arm64: kdump: Provide default size when crashkernel=Y,low is not
> specified
> arm64: kdump: Support crashkernel=X fall back to reserve region above
> DMA zones
> arm64: kdump: Remove some redundant checks in map_mem()
>
> .../admin-guide/kernel-parameters.txt | 10 ++-----
> arch/arm64/mm/init.c | 28 +++++++++++++++++--
> arch/arm64/mm/mmu.c | 25 ++++++++---------
> 3 files changed, 39 insertions(+), 24 deletions(-)
>
--
Regards,
Zhen Lei
^ permalink raw reply [flat|nested] 5+ messages in thread