[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241008044355.4325-3-gourry@gourry.net>
Date: Tue, 8 Oct 2024 00:43:54 -0400
From: Gregory Price <gourry@...rry.net>
To: linux-cxl@...r.kernel.org,
x86@...nel.org,
linux-mm@...ck.org,
linux-acpi@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
dave.hansen@...ux.intel.com,
luto@...nel.org,
peterz@...radead.org,
tglx@...utronix.de,
mingo@...hat.com,
bp@...en8.de,
hpa@...or.com,
david@...hat.com,
osalvador@...e.de,
gregkh@...uxfoundation.org,
rafael@...nel.org,
akpm@...ux-foundation.org,
dan.j.williams@...el.com,
Jonathan.Cameron@...wei.com,
alison.schofield@...el.com,
rrichter@....com,
terry.bowman@....com,
lenb@...nel.org,
dave.jiang@...el.com,
ira.weiny@...el.com
Subject: [PATCH 2/3] x86/mm: if memblock size is adjusted, update the cached value
When parsing CFMWS, we need to know the currently registered memory
block size to avoid accidentally adjusting the size upward. Querying
the size causes it to be cached in a static global. Update the static
global if the value is subsequently updated.
Print a warning that this has occurred for debugging purposes if
the memory block size is changed at an unexpected time (post-init).
Signed-off-by: Gregory Price <gourry@...rry.net>
---
arch/x86/mm/init_64.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 6086f99449fa..733dfa899232 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1424,6 +1424,7 @@ void mark_rodata_ro(void)
/* Adjustable memory block size */
static unsigned long set_memory_block_size;
+static unsigned long memory_block_size_probed;
int set_memory_block_size_order(unsigned int order)
{
unsigned long size = 1UL << order;
@@ -1432,6 +1433,19 @@ int set_memory_block_size_order(unsigned int order)
return -EINVAL;
set_memory_block_size = size;
+
+ /*
+ * If the block size has already been probed, we need to change it.
+ * This can happen during ACPI/CFMWS parsing, since it needs to
+ * probe the system for the existing block size to avoid increasing
+ * the block size if lower memory happens to be misaligned
+ */
+ if (memory_block_size_probed) {
+ memory_block_size_probed = size;
+ pr_warn("x86/mm: Memory block size changed: %ldMB\n",
+ size >> 20);
+ }
+
return 0;
}
@@ -1471,7 +1485,6 @@ static unsigned long probe_memory_block_size(void)
return bz;
}
-static unsigned long memory_block_size_probed;
unsigned long memory_block_size_bytes(void)
{
if (!memory_block_size_probed)
--
2.43.0
Powered by blists - more mailing lists