[PATCH OLK-5.10 0/2] kmemleak: Fix kmemleak false warnings
This series fixes kmemleak false warnings when reserving crash kernel memory. Patch 1 moves kmemleak_ignore_phys() to reserve_crashkernel_high() where memory is actually tracked by kmemleak. Patch 2 ensures kmemleak_ignore_phys() is only called when new memory is allocated, not when crash_base is pre-set via cmdline. ZhangPeng (2): arm64: kdump: fix kmemleak unknown object warning arm64: kdump: fix kmemleak unknown object warning when crash base is set kernel/crash_core.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) -- 2.33.0
From: ZhangPeng <zhangpeng362@huawei.com> hulk inclusion category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/13312 -------------------------------- In reserve_crashkernel(), only memblock_find_in_range() and memblock_reserve() are called. kmemleak_alloc_phys() is not called, so the kmemleak object is not created. Therefore, there is no need to call kmemleak_ignore_phys(). To fix the kmemleak unknown object warning, remove kmemleak_ignore_phys() from reserve_crashkernel(). In reserve_crashkernel_high(), memblock_phys_alloc_range() is called. kmemleak_alloc_phys() creates an object of kmemleak, so kmemleak_ignore_phys() needs to be called. Fixes: 951001072323 ("arm64: kdump: Skip kmemleak scan reserved memory for kdump") Signed-off-by: ZhangPeng <zhangpeng362@huawei.com> Signed-off-by: Qi Xi <xiqi2@huawei.com> --- kernel/crash_core.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 368d8d1dd03c..a0ea5fe6fa60 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -415,6 +415,12 @@ void __init reserve_crashkernel_high(void) crash_high_mem_reserved = true; } + /* + * The crashkernel memory will be removed from the kernel linear + * map. Inform kmemleak so that it won't try to access it. + */ + kmemleak_ignore_phys(crash_base); + /* Mark the memory range that requires page-level mappings */ crashk_res.start = crash_base; crashk_res.end = crash_base + crash_size - 1; @@ -557,14 +563,6 @@ void __init reserve_crashkernel(void) (unsigned long)(crash_base >> 20), (unsigned long)(total_mem >> 20)); -#ifdef CONFIG_ARM64 - /* - * The crashkernel memory will be removed from the kernel linear - * map. Inform kmemleak so that it won't try to access it. - */ - kmemleak_ignore_phys(crash_base); -#endif - crashk_res.start = crash_base; crashk_res.end = crash_base + crash_size - 1; } -- 2.33.0
From: ZhangPeng <zhangpeng362@huawei.com> hulk inclusion category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/13312 -------------------------------- When crash_base is set via kernel command line, reserve_crashkernel_high() does not allocate new memory and thus no kmemleak object is created. However, kmemleak_ignore_phys() was called unconditionally, leading to unnecessary kmemleak warnings. Move kmemleak_ignore_phys() inside the allocation branch where it's actually needed, ensuring it's only called when new memory is allocated and tracked by kmemleak. Fixes: 951001072323 ("arm64: kdump: Skip kmemleak scan reserved memory for kdump") Signed-off-by: ZhangPeng <zhangpeng362@huawei.com> Signed-off-by: Qi Xi <xiqi2@huawei.com> --- kernel/crash_core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/crash_core.c b/kernel/crash_core.c index a0ea5fe6fa60..79c0692a8899 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -413,13 +413,13 @@ void __init reserve_crashkernel_high(void) return; crash_high_mem_reserved = true; - } - /* - * The crashkernel memory will be removed from the kernel linear - * map. Inform kmemleak so that it won't try to access it. - */ - kmemleak_ignore_phys(crash_base); + /* + * The crashkernel memory will be removed from the kernel linear + * map. Inform kmemleak so that it won't try to access it. + */ + kmemleak_ignore_phys(crash_base); + } /* Mark the memory range that requires page-level mappings */ crashk_res.start = crash_base; -- 2.33.0
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://atomgit.com/openeuler/kernel/merge_requests/20103 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/NS7... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://atomgit.com/openeuler/kernel/merge_requests/20103 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/NS7...
participants (2)
-
patchwork bot -
Qi Xi