[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220607093805.1354256-6-mawupeng1@huawei.com>
Date: Tue, 7 Jun 2022 17:38:04 +0800
From: Wupeng Ma <mawupeng1@...wei.com>
To: <corbet@....net>, <will@...nel.org>, <ardb@...nel.org>,
<catalin.marinas@....com>
CC: <tglx@...utronix.de>, <mingo@...hat.com>, <bp@...en8.de>,
<dave.hansen@...ux.intel.com>, <x86@...nel.org>, <hpa@...or.com>,
<dvhart@...radead.org>, <andy@...radead.org>, <rppt@...nel.org>,
<akpm@...ux-foundation.org>, <paul.walmsley@...ive.com>,
<palmer@...belt.com>, <aou@...s.berkeley.edu>,
<paulmck@...nel.org>, <keescook@...omium.org>,
<songmuchun@...edance.com>, <rdunlap@...radead.org>,
<damien.lemoal@...nsource.wdc.com>, <swboyd@...omium.org>,
<wei.liu@...nel.org>, <robin.murphy@....com>, <david@...hat.com>,
<mawupeng1@...wei.com>, <anshuman.khandual@....com>,
<thunder.leizhen@...wei.com>, <wangkefeng.wang@...wei.com>,
<gpiccoli@...lia.com>, <chenhuacai@...nel.org>,
<geert@...ux-m68k.org>, <chenzhou10@...wei.com>,
<vijayb@...ux.microsoft.com>, <linux-doc@...r.kernel.org>,
<linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-efi@...r.kernel.org>, <platform-driver-x86@...r.kernel.org>,
<linux-mm@...ck.org>, <linux-riscv@...ts.infradead.org>
Subject: [PATCH v3 5/6] mm: Add mirror flag back on initrd memory
From: Ma Wupeng <mawupeng1@...wei.com>
Initrd memory will be removed and then added in arm64_memblock_init() and this
will cause it to lose all of its memblock flags. The lost of MEMBLOCK_MIRROR
flag will lead to error log printed by find_zone_movable_pfns_for_nodes if
the lower 4G range has some non-mirrored memory.
In order to solve this problem, the lost MEMBLOCK_MIRROR flag will be
reinstalled if the origin memblock has this flag.
Signed-off-by: Ma Wupeng <mawupeng1@...wei.com>
---
arch/arm64/mm/init.c | 9 +++++++++
include/linux/memblock.h | 1 +
mm/memblock.c | 20 ++++++++++++++++++++
3 files changed, 30 insertions(+)
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 339ee84e5a61..11641f924d08 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -350,9 +350,18 @@ void __init arm64_memblock_init(void)
"initrd not fully accessible via the linear mapping -- please check your bootloader ...\n")) {
phys_initrd_size = 0;
} else {
+ int flags, ret;
+
+ ret = memblock_get_flags(base, &flags);
+ if (ret)
+ flags = 0;
+
memblock_remove(base, size); /* clear MEMBLOCK_ flags */
memblock_add(base, size);
memblock_reserve(base, size);
+
+ if (flags & MEMBLOCK_MIRROR)
+ memblock_mark_mirror(base, size);
}
}
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 50ad19662a32..3d6a382ac9c8 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -487,6 +487,7 @@ bool memblock_is_map_memory(phys_addr_t addr);
bool memblock_is_region_memory(phys_addr_t base, phys_addr_t size);
bool memblock_is_reserved(phys_addr_t addr);
bool memblock_is_region_reserved(phys_addr_t base, phys_addr_t size);
+int memblock_get_flags(phys_addr_t base, int *flags);
void memblock_dump_all(void);
diff --git a/mm/memblock.c b/mm/memblock.c
index b1d2a0009733..0c5b5699af6e 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -1796,6 +1796,26 @@ int __init_memblock memblock_search_pfn_nid(unsigned long pfn,
return memblock_get_region_node(&type->regions[mid]);
}
+/**
+ * memblock_get_flags - get a single memblock flags
+ * @base: base of memeblock to get
+ *
+ * Get the flags of memeblock with base: @base
+ *
+ * Return:
+ * 0 if ok, non-zero if fail
+ */
+int __init_memblock memblock_get_flags(phys_addr_t base, int *flags)
+{
+ int idx = memblock_search(&memblock.memory, base);
+
+ if (idx == -1)
+ return -EINVAL;
+
+ *flags = memblock.memory.regions[idx].flags;
+ return 0;
+}
+
/**
* memblock_is_region_memory - check if a region is a subset of memory
* @base: base of region to check
--
2.25.1
Powered by blists - more mailing lists