+ mm-disable-kernelcore=mirror-when-no-mirror-memory.patch added to mm-unstable branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: mm: disable kernelcore=mirror when no mirror memory
has been added to the -mm mm-unstable branch.  Its filename is
     mm-disable-kernelcore=mirror-when-no-mirror-memory.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-disable-kernelcore=mirror-when-no-mirror-memory.patch

This patch will later appear in the mm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Ma Wupeng <mawupeng1@xxxxxxxxxx>
Subject: mm: disable kernelcore=mirror when no mirror memory
Date: Wed, 2 Aug 2023 15:23:28 +0800

For system with kernelcore=mirror enabled while no mirrored memory is
reported by efi.  This could lead to kernel OOM during startup since all
memory beside zone DMA are in the movable zone and this prevents the
kernel to use it.

Zone DMA/DMA32 initialization is independent of mirrored memory and their
max pfn is set in zone_sizes_init().  Since kernel can fallback to zone
DMA/DMA32 if there is no memory in zone Normal, these zones are seen as
mirrored memory no mather their memory attributes are.

To solve this problem, disable kernelcore=mirror when there is no real
mirrored memory exists.

Link: https://lkml.kernel.org/r/20230802072328.2107981-1-mawupeng1@xxxxxxxxxx
Signed-off-by: Ma Wupeng <mawupeng1@xxxxxxxxxx>
Suggested-by: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx>
Suggested-by: Mike Rapoport <rppt@xxxxxxxxxx>
Reviewed-by: Mike Rapoport (IBM) <rppt@xxxxxxxxxx>
Reviewed-by: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx>
Cc: Levi Yun <ppbuk5246@xxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 mm/internal.h |    1 +
 mm/memblock.c |    5 +++++
 mm/mm_init.c  |    5 +++++
 3 files changed, 11 insertions(+)

--- a/mm/internal.h~mm-disable-kernelcore=mirror-when-no-mirror-memory
+++ a/mm/internal.h
@@ -1022,6 +1022,7 @@ static inline bool gup_must_unshare(stru
 }
 
 extern bool mirrored_kernelcore;
+extern bool memblock_has_mirror(void);
 
 static inline bool vma_soft_dirty_enabled(struct vm_area_struct *vma)
 {
--- a/mm/memblock.c~mm-disable-kernelcore=mirror-when-no-mirror-memory
+++ a/mm/memblock.c
@@ -161,6 +161,11 @@ static int memblock_can_resize __initdat
 static int memblock_memory_in_slab __initdata_memblock;
 static int memblock_reserved_in_slab __initdata_memblock;
 
+bool __init_memblock memblock_has_mirror(void)
+{
+	return system_has_some_mirror;
+}
+
 static enum memblock_flags __init_memblock choose_memblock_flags(void)
 {
 	return system_has_some_mirror ? MEMBLOCK_MIRROR : MEMBLOCK_NONE;
--- a/mm/mm_init.c~mm-disable-kernelcore=mirror-when-no-mirror-memory
+++ a/mm/mm_init.c
@@ -376,6 +376,11 @@ static void __init find_zone_movable_pfn
 	if (mirrored_kernelcore) {
 		bool mem_below_4gb_not_mirrored = false;
 
+		if (!memblock_has_mirror()) {
+			pr_warn("The system has no mirror memory, ignore kernelcore=mirror.\n");
+			goto out;
+		}
+
 		for_each_mem_region(r) {
 			if (memblock_is_mirror(r))
 				continue;
_

Patches currently in -mm which might be from mawupeng1@xxxxxxxxxx are

swap-cleanup-duplicated-warn_on-in-add_to_avail_list.patch
swap-stop-add-to-avail-list-is-swap-is-full.patch
doc-update-params-of-memhp_default_state=.patch
mm-disable-kernelcore=mirror-when-no-mirror-memory.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux