未验证 提交 f949d7e7 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!880 LoongArch: kdump: Add high memory reservation

Merge Pull Request from: @Hongchen_Zhang 
 
kdump function test failed on 3C5000+7A2000 dual-bridge machine,
we fix it as following:
reserve high memory for the capture kernel to avoid kdump operation
failure on 3C5000 machines with old firmware.

after apply this patch,the following test case passed:
1) add crashkernel=512M in commandline 
2) systemctl start kdump
3) echo c >/proc/sysrq-trigger
4) after reboot, vmcore file created in /var/crash directory
 
 
Link:https://gitee.com/openeuler/kernel/pulls/880 

Reviewed-by: Jialin Zhang <zhangjialin11@huawei.com> 
Reviewed-by: Guo Dongtai <guodongtai@kylinos.cn> 
Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com> 
...@@ -306,13 +306,49 @@ static void __init arch_parse_crashkernel(void) ...@@ -306,13 +306,49 @@ static void __init arch_parse_crashkernel(void)
* memory area used by the previous production kernel should be reserved to * memory area used by the previous production kernel should be reserved to
* avoid destroy to the captured data. * avoid destroy to the captured data.
*/ */
static void reserve_oldmem_region(void) static void reserve_oldmem_region(int node, unsigned long s0, unsigned long e0)
{ {
#ifdef CONFIG_CRASH_DUMP #ifdef CONFIG_CRASH_DUMP
unsigned long s1, e1;
if (!is_kdump_kernel()) if (!is_kdump_kernel())
return; return;
memblock_cap_memory_range(crashmem_start, crashmem_size); if ((e0 - s0) > (SZ_1G >> PAGE_SHIFT))
e0 = e0 - (SZ_512M >> PAGE_SHIFT);
/* crashmem_start is crashk_res reserved by primary production kernel */
s1 = PFN_UP(crashmem_start);
e1 = PFN_DOWN(crashmem_start + crashmem_size);
if (s1 == 0)
return;
if (node == 0) {
memblock_reserve(PFN_PHYS(s0), (s1 - s0) << PAGE_SHIFT);
memblock_reserve(PFN_PHYS(e1), (e0 - e1) << PAGE_SHIFT);
} else {
memblock_reserve(PFN_PHYS(s0), (e0 - s0) << PAGE_SHIFT);
}
#endif
}
/* Traditionally, LoongArch's contiguous low memory is 256M, so crashkernel=X@Y is
* unable to be large enough in some cases. Thus, if the total memory of a node
* is more than 1GB, we reserve the top 512MB for the capture kernel
*/
static void reserve_crashm_region(int node, unsigned long s0, unsigned long e0)
{
#ifdef CONFIG_KEXEC
if (crashk_res.start == crashk_res.end)
return;
if ((e0 - s0) <= (SZ_1G >> PAGE_SHIFT))
return;
s0 = e0 - (SZ_512M >> PAGE_SHIFT);
memblock_reserve(PFN_PHYS(s0), (e0 - s0) << PAGE_SHIFT);
#endif #endif
} }
...@@ -356,9 +392,16 @@ static void __init check_kernel_sections_mem(void) ...@@ -356,9 +392,16 @@ static void __init check_kernel_sections_mem(void)
*/ */
static void __init arch_mem_init(char **cmdline_p) static void __init arch_mem_init(char **cmdline_p)
{ {
unsigned int node;
unsigned long start_pfn, end_pfn;
arch_reserve_vmcore(); arch_reserve_vmcore();
arch_parse_crashkernel(); arch_parse_crashkernel();
reserve_oldmem_region(); for_each_online_node(node) {
get_pfn_range_for_nid(node, &start_pfn, &end_pfn);
reserve_crashm_region(node, start_pfn, end_pfn);
reserve_oldmem_region(node, start_pfn, end_pfn);
}
if (usermem) if (usermem)
pr_info("User-defined physical RAM map overwrite\n"); pr_info("User-defined physical RAM map overwrite\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册