From: Ma Wupeng mawupeng1@huawei.com
Fix memory reliable related issues.
Ma Wupeng (3): mm: mem_reliable: Fix reliable page counter mismatch problem mm: mem_reliable: Update reliable page counter to zero if underflows efi: Disable mirror feature during crashkernel
drivers/firmware/efi/efi.c | 6 ++++++ include/linux/mem_reliable.h | 15 +++++++++++++-- mm/memory.c | 1 + 3 files changed, 20 insertions(+), 2 deletions(-)
From: Ma Wupeng mawupeng1@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I77BDW CVE: NA
--------------------------------
During copy_present_pte, rss counter is increased but the corresponding reliable page counter is not updated. This will lead to reliable page counter mismatch. Fix this by adding reliable page counter.
Fixes: d81e9624de21 ("proc: Count reliable memory usage of reliable tasks")
Signed-off-by: Ma Wupeng mawupeng1@huawei.com Reviewed-by: Kefeng Wang wangkefeng.wang@huawei.com Reviewed-by: Nanyong Sun sunnanyong@huawei.com --- mm/memory.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/mm/memory.c b/mm/memory.c index 5941a4f4ea4b..5893c178251a 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -887,6 +887,7 @@ copy_present_pte(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, get_page(page); page_dup_rmap(page, false); rss[mm_counter(page)]++; + reliable_page_counter(page, dst_vma->vm_mm, 1); }
/*
From: Ma Wupeng mawupeng1@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I77BDW CVE: NA
--------------------------------
Since reliable page counter is used for debug purpose only, There is no real function problem by doing this.
Signed-off-by: Ma Wupeng mawupeng1@huawei.com Reviewed-by: Kefeng Wang wangkefeng.wang@huawei.com Reviewed-by: Nanyong Sun sunnanyong@huawei.com --- include/linux/mem_reliable.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/include/linux/mem_reliable.h b/include/linux/mem_reliable.h index 79228a1b2f0b..dc1344b843b0 100644 --- a/include/linux/mem_reliable.h +++ b/include/linux/mem_reliable.h @@ -132,8 +132,19 @@ static inline bool reliable_allow_fb_enabled(void) static inline void reliable_page_counter(struct page *page, struct mm_struct *mm, int val) { - if (page_reliable(page)) - atomic_long_add(val, &mm->reliable_nr_page); + if (!page_reliable(page)) + return; + + atomic_long_add(val, &mm->reliable_nr_page); + + /* + * Update reliable page counter to zero if underflows. + * + * Since reliable page counter is used for debug purpose only, + * there is no real function problem by doing this. + */ + if (unlikely(atomic_long_read(&mm->reliable_nr_page) < 0)) + atomic_long_set(&mm->reliable_nr_page, 0); }
static inline void reliable_clear_page_counter(struct mm_struct *mm)
From: Ma Wupeng mawupeng1@huawei.com
hulk inclusion category: cleanup bugzilla: https://gitee.com/openeuler/kernel/issues/I6WKXZ CVE: NA
--------------------------------
If system have no mirrored memory or use crashkernel.high while kernelcore=mirror is enabled in cmdline, during crashkernel, there will be limited mirrored memory and this usually lead to OOM.
To solve this problem, disable mirror feature during crashkernel.
Signed-off-by: Ma Wupeng mawupeng1@huawei.com Reviewed-by: Kefeng Wang wangkefeng.wang@huawei.com --- drivers/firmware/efi/efi.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index c406de00883a..97a0916d6502 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -31,6 +31,7 @@ #include <linux/ucs2_string.h> #include <linux/memblock.h> #include <linux/security.h> +#include <linux/crash_dump.h>
#include <asm/early_ioremap.h>
@@ -446,6 +447,11 @@ void __init efi_find_mirror(void) if (!mirrored_kernelcore) return;
+ if (is_kdump_kernel()) { + mirrored_kernelcore = false; + return; + } + for_each_efi_memory_desc(md) { unsigned long long start = md->phys_addr; unsigned long long size = md->num_pages << EFI_PAGE_SHIFT;
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/1191 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/D...
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://gitee.com/openeuler/kernel/pulls/1191 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/D...