* [PATCH v8 0/3] memory,x86,acpi: hotplug memory alignment advisement
@ 2025-01-27 15:34 Gregory Price
2025-01-27 15:34 ` [PATCH v8 1/3] memory: implement memory_block_advise/probe_max_size Gregory Price
` (4 more replies)
0 siblings, 5 replies; 13+ messages in thread
From: Gregory Price @ 2025-01-27 15:34 UTC (permalink / raw)
To: linux-mm, linux-acpi
Cc: kernel-team, x86, linux-kernel, dave.hansen, luto, peterz, tglx,
mingo, bp, hpa, rafael, lenb, david, osalvador, gregkh, akpm,
dan.j.williams, Jonathan.Cameron, alison.schofield, rrichter,
rppt, gourry, bfaccini, haibo1.xu, dave.jiang, Ira Weiny, Fan Ni
v8: nits and tag pickups
When physical address regions are not aligned to memory block size,
the misaligned portion is lost (stranded capacity).
Block size (min/max/selected) is architecture defined. Most architectures
tend to use the minimum block size or some simplistic heurist. On x86,
memory block size increases up to 2GB, and is otherwise fitted to the
alignment of non-hotplug (i.e. not special purpose memory).
CXL exposes its memory for management through the ACPI CEDT (CXL Early
Detection Table) in a field called the CXL Fixed Memory Window. Per
the CXL specification, this memory must be aligned to at least 256MB.
When a CFMW aligns on a size less than the block size, this causes a
loss of up to 2GB per CFMW on x86. It is not uncommon for CFMW to be
allocated per-device - though this behavior is BIOS defined.
This patch set provides 3 things:
1) implement advise/query functions in driverse/base/memory.c to
report/query architecture agnostic hotplug block alignment advice.
2) update x86 memblock size logic to consider the hotplug advice
3) add code in acpi/numa/srat.c to report CFMW alignment advice
The advisement interfaces are design to be called during arch_init
code prior to allocator and smp_init. start_kernel will call these
through setup_arch() (via acpi and mm/init_64.c on x86), which occurs
prior to mm_core_init and smp_init - so no need for atomics.
There's an attempt to signal callers to advise() that query has already
occurred, but this is predicated on the notion that query actually
occurs (which presently only happens on the x86 arch). This is to
assist debugging future users. Otherwise, the advise() call has
been marked __init to help static discovery of bad call times.
Once query is called the first time, it will always return the same value.
Interfaces return -EBUSY and 0 respectively on systems without hotplug.
Suggested-by: Ira Weiny <ira.weiny@intel.com>
Suggested-by: David Hildenbrand <david@redhat.com>
Suggested-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Gregory Price <gourry@gourry.net>
Tested-by: Fan Ni <fan.ni@samsung.com>
Gregory Price (3):
memory: implement memory_block_advise/probe_max_size
x86: probe memory block size advisement value during mm init
acpi,srat: give memory block size advice based on CFMWS alignment
arch/x86/mm/init_64.c | 15 ++++++++----
drivers/acpi/numa/srat.c | 12 ++++++++-
drivers/base/memory.c | 53 ++++++++++++++++++++++++++++++++++++++++
include/linux/memory.h | 10 ++++++++
4 files changed, 84 insertions(+), 6 deletions(-)
--
2.48.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v8 1/3] memory: implement memory_block_advise/probe_max_size
2025-01-27 15:34 [PATCH v8 0/3] memory,x86,acpi: hotplug memory alignment advisement Gregory Price
@ 2025-01-27 15:34 ` Gregory Price
2025-04-01 18:50 ` Oscar Salvador
2025-01-27 15:34 ` [PATCH v8 2/3] x86: probe memory block size advisement value during mm init Gregory Price
` (3 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Gregory Price @ 2025-01-27 15:34 UTC (permalink / raw)
To: linux-mm, linux-acpi
Cc: kernel-team, x86, linux-kernel, dave.hansen, luto, peterz, tglx,
mingo, bp, hpa, rafael, lenb, david, osalvador, gregkh, akpm,
dan.j.williams, Jonathan.Cameron, alison.schofield, rrichter,
rppt, gourry, bfaccini, haibo1.xu, dave.jiang, Ira Weiny, Fan Ni
Hotplug memory sources may have opinions on what the memblock size
should be - usually for alignment purposes. For example, CXL memory
extents can be 256MB with a matching alignment. If this size/alignment
is smaller than the block size, it can result in stranded capacity.
Implement memory_block_advise_max_size for use prior to allocator init,
for software to advise the system on the max block size.
Implement memory_block_probe_max_size for use by arch init code to
calculate the best block size. Use of advice is architecture defined.
The probe value can never change after first probe. Calls to advise
after probe will return -EBUSY to aid debugging.
On systems without hotplug, always return -ENODEV and 0 respectively.
Suggested-by: Ira Weiny <ira.weiny@intel.com>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Fan Ni <fan.ni@samsung.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Gregory Price <gourry@gourry.net>
---
drivers/base/memory.c | 51 ++++++++++++++++++++++++++++++++++++++++++
include/linux/memory.h | 10 +++++++++
2 files changed, 61 insertions(+)
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 348c5dbbfa68..69feacbac3da 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -110,6 +110,57 @@ static void memory_block_release(struct device *dev)
kfree(mem);
}
+
+/* Max block size to be set by memory_block_advise_max_size */
+static unsigned long memory_block_advised_size;
+static bool memory_block_advised_size_queried;
+
+/**
+ * memory_block_advise_max_size() - advise memory hotplug on the max suggested
+ * block size, usually for alignment.
+ * @size: suggestion for maximum block size. must be aligned on power of 2.
+ *
+ * Early boot software (pre-allocator init) may advise archs on the max block
+ * size. This value can only decrease after initialization, as the intent is
+ * to identify the largest supported alignment for all sources.
+ *
+ * Use of this value is arch-defined, as is min/max block size.
+ *
+ * Return: 0 on success
+ * -EINVAL if size is 0 or not pow2 aligned
+ * -EBUSY if value has already been probed
+ */
+int __init memory_block_advise_max_size(unsigned long size)
+{
+ if (!size || !is_power_of_2(size))
+ return -EINVAL;
+
+ if (memory_block_advised_size_queried)
+ return -EBUSY;
+
+ if (memory_block_advised_size)
+ memory_block_advised_size = min(memory_block_advised_size, size);
+ else
+ memory_block_advised_size = size;
+
+ return 0;
+}
+
+/**
+ * memory_block_advised_max_size() - query advised max hotplug block size.
+ *
+ * After the first call, the value can never change. Callers looking for the
+ * actual block size should use memory_block_size_bytes. This interface is
+ * intended for use by arch-init when initializing the hotplug block size.
+ *
+ * Return: advised size in bytes, or 0 if never set.
+ */
+unsigned long memory_block_advised_max_size(void)
+{
+ memory_block_advised_size_queried = true;
+ return memory_block_advised_size;
+}
+
unsigned long __weak memory_block_size_bytes(void)
{
return MIN_MEMORY_BLOCK_SIZE;
diff --git a/include/linux/memory.h b/include/linux/memory.h
index c0afee5d126e..8202d0efbf46 100644
--- a/include/linux/memory.h
+++ b/include/linux/memory.h
@@ -149,6 +149,14 @@ static inline int hotplug_memory_notifier(notifier_fn_t fn, int pri)
{
return 0;
}
+static inline int memory_block_advise_max_size(unsigned long size)
+{
+ return -ENODEV;
+}
+static inline unsigned long memory_block_advised_max_size(void)
+{
+ return 0;
+}
#else /* CONFIG_MEMORY_HOTPLUG */
extern int register_memory_notifier(struct notifier_block *nb);
extern void unregister_memory_notifier(struct notifier_block *nb);
@@ -181,6 +189,8 @@ int walk_dynamic_memory_groups(int nid, walk_memory_groups_func_t func,
void memory_block_add_nid(struct memory_block *mem, int nid,
enum meminit_context context);
#endif /* CONFIG_NUMA */
+int memory_block_advise_max_size(unsigned long size);
+unsigned long memory_block_advised_max_size(void);
#endif /* CONFIG_MEMORY_HOTPLUG */
/*
--
2.48.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v8 2/3] x86: probe memory block size advisement value during mm init
2025-01-27 15:34 [PATCH v8 0/3] memory,x86,acpi: hotplug memory alignment advisement Gregory Price
2025-01-27 15:34 ` [PATCH v8 1/3] memory: implement memory_block_advise/probe_max_size Gregory Price
@ 2025-01-27 15:34 ` Gregory Price
2025-04-01 18:51 ` Oscar Salvador
2025-01-27 15:34 ` [PATCH v8 3/3] acpi,srat: give memory block size advice based on CFMWS alignment Gregory Price
` (2 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Gregory Price @ 2025-01-27 15:34 UTC (permalink / raw)
To: linux-mm, linux-acpi
Cc: kernel-team, x86, linux-kernel, dave.hansen, luto, peterz, tglx,
mingo, bp, hpa, rafael, lenb, david, osalvador, gregkh, akpm,
dan.j.williams, Jonathan.Cameron, alison.schofield, rrichter,
rppt, gourry, bfaccini, haibo1.xu, dave.jiang, Fan Ni, Ira Weiny
Systems with hotplug may provide an advisement value on what the
memblock size should be. Probe this value when the rest of the
configuration values are considered.
The new heuristic is as follows
1) set_memory_block_size_order value if already set (cmdline param)
2) minimum block size if memory is less than large block limit
3) if no hotplug advice: Max block size if system is bare-metal,
otherwise use end of memory alignment.
4) if hotplug advice: lesser of advice and end of memory alignment.
Convert to cpu_feature_enabled() while at it.[1]
[1] https://lore.kernel.org/all/20241031103401.GBZyNdGQ-ZyXKyzC_z@fat_crate.local/
Suggested-by: Borislav Petkov <bp@alien8.de>
Suggested-by: David Hildenbrand <david@redhat.com>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Fan Ni <fan.ni@samsung.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Gregory Price <gourry@gourry.net>
---
arch/x86/mm/init_64.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 01ea7c6df303..58ace82874eb 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1462,16 +1462,21 @@ static unsigned long probe_memory_block_size(void)
}
/*
- * Use max block size to minimize overhead on bare metal, where
- * alignment for memory hotplug isn't a concern.
+ * When hotplug alignment is not a concern, maximize blocksize
+ * to minimize overhead. Otherwise, align to the lesser of advice
+ * alignment and end of memory alignment.
*/
- if (!boot_cpu_has(X86_FEATURE_HYPERVISOR)) {
+ bz = memory_block_advised_max_size();
+ if (!bz) {
bz = MAX_BLOCK_SIZE;
- goto done;
+ if (!cpu_feature_enabled(X86_FEATURE_HYPERVISOR))
+ goto done;
+ } else {
+ bz = max(min(bz, MAX_BLOCK_SIZE), MIN_MEMORY_BLOCK_SIZE);
}
/* Find the largest allowed block size that aligns to memory end */
- for (bz = MAX_BLOCK_SIZE; bz > MIN_MEMORY_BLOCK_SIZE; bz >>= 1) {
+ for (; bz > MIN_MEMORY_BLOCK_SIZE; bz >>= 1) {
if (IS_ALIGNED(boot_mem_end, bz))
break;
}
--
2.48.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v8 3/3] acpi,srat: give memory block size advice based on CFMWS alignment
2025-01-27 15:34 [PATCH v8 0/3] memory,x86,acpi: hotplug memory alignment advisement Gregory Price
2025-01-27 15:34 ` [PATCH v8 1/3] memory: implement memory_block_advise/probe_max_size Gregory Price
2025-01-27 15:34 ` [PATCH v8 2/3] x86: probe memory block size advisement value during mm init Gregory Price
@ 2025-01-27 15:34 ` Gregory Price
2025-04-01 18:52 ` Oscar Salvador
2025-04-01 18:33 ` [PATCH v8 0/3] memory,x86,acpi: hotplug memory alignment advisement Gregory Price
2025-04-01 18:53 ` Oscar Salvador
4 siblings, 1 reply; 13+ messages in thread
From: Gregory Price @ 2025-01-27 15:34 UTC (permalink / raw)
To: linux-mm, linux-acpi
Cc: kernel-team, x86, linux-kernel, dave.hansen, luto, peterz, tglx,
mingo, bp, hpa, rafael, lenb, david, osalvador, gregkh, akpm,
dan.j.williams, Jonathan.Cameron, alison.schofield, rrichter,
rppt, gourry, bfaccini, haibo1.xu, dave.jiang, Fan Ni,
Rafael J. Wysocki, Ira Weiny
Capacity is stranded when CFMWS regions are not aligned to block size.
On x86, block size increases with capacity (2G blocks @ 64G capacity).
Use CFMWS base/size to report memory block size alignment advice.
Suggested-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Fan Ni <fan.ni@samsung.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Gregory Price <gourry@gourry.net>
---
drivers/acpi/numa/srat.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
index 59fffe34c9d0..1501a9bb3936 100644
--- a/drivers/acpi/numa/srat.c
+++ b/drivers/acpi/numa/srat.c
@@ -14,6 +14,7 @@
#include <linux/errno.h>
#include <linux/acpi.h>
#include <linux/memblock.h>
+#include <linux/memory.h>
#include <linux/numa.h>
#include <linux/nodemask.h>
#include <linux/topology.h>
@@ -425,13 +426,23 @@ static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
{
struct acpi_cedt_cfmws *cfmws;
int *fake_pxm = arg;
- u64 start, end;
+ u64 start, end, align;
int node;
+ int err;
cfmws = (struct acpi_cedt_cfmws *)header;
start = cfmws->base_hpa;
end = cfmws->base_hpa + cfmws->window_size;
+ /* Align memblock size to CFMW regions if possible */
+ align = 1UL << __ffs(start | end);
+ if (align >= SZ_256M) {
+ err = memory_block_advise_max_size(align);
+ if (err)
+ pr_warn("CFMWS: memblock size advise failed (%d)\n", err);
+ } else
+ pr_err("CFMWS: [BIOS BUG] base/size alignment violates spec\n");
+
/*
* The SRAT may have already described NUMA details for all,
* or a portion of, this CFMWS HPA range. Extend the memblks
--
2.48.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v8 0/3] memory,x86,acpi: hotplug memory alignment advisement
2025-01-27 15:34 [PATCH v8 0/3] memory,x86,acpi: hotplug memory alignment advisement Gregory Price
` (2 preceding siblings ...)
2025-01-27 15:34 ` [PATCH v8 3/3] acpi,srat: give memory block size advice based on CFMWS alignment Gregory Price
@ 2025-04-01 18:33 ` Gregory Price
2025-04-01 18:53 ` Oscar Salvador
4 siblings, 0 replies; 13+ messages in thread
From: Gregory Price @ 2025-04-01 18:33 UTC (permalink / raw)
To: linux-mm, linux-acpi
Cc: kernel-team, x86, linux-kernel, dave.hansen, luto, peterz, tglx,
mingo, bp, hpa, rafael, lenb, david, osalvador, gregkh, akpm,
dan.j.williams, Jonathan.Cameron, alison.schofield, rrichter,
rppt, bfaccini, haibo1.xu, dave.jiang, Ira Weiny, Fan Ni
On Mon, Jan 27, 2025 at 10:34:02AM -0500, Gregory Price wrote:
> v8: nits and tag pickups
>
I apparently already cleaned up the remaining nits. So this has been
stable. Just did a rebase on mm-unstable and it was clean, so this
should pluck cleanly.
Andrew, do you think this should go through mm or another subsystem?
~Gregory
> When physical address regions are not aligned to memory block size,
> the misaligned portion is lost (stranded capacity).
>
> Block size (min/max/selected) is architecture defined. Most architectures
> tend to use the minimum block size or some simplistic heurist. On x86,
> memory block size increases up to 2GB, and is otherwise fitted to the
> alignment of non-hotplug (i.e. not special purpose memory).
>
> CXL exposes its memory for management through the ACPI CEDT (CXL Early
> Detection Table) in a field called the CXL Fixed Memory Window. Per
> the CXL specification, this memory must be aligned to at least 256MB.
>
> When a CFMW aligns on a size less than the block size, this causes a
> loss of up to 2GB per CFMW on x86. It is not uncommon for CFMW to be
> allocated per-device - though this behavior is BIOS defined.
>
> This patch set provides 3 things:
> 1) implement advise/query functions in driverse/base/memory.c to
> report/query architecture agnostic hotplug block alignment advice.
> 2) update x86 memblock size logic to consider the hotplug advice
> 3) add code in acpi/numa/srat.c to report CFMW alignment advice
>
> The advisement interfaces are design to be called during arch_init
> code prior to allocator and smp_init. start_kernel will call these
> through setup_arch() (via acpi and mm/init_64.c on x86), which occurs
> prior to mm_core_init and smp_init - so no need for atomics.
>
> There's an attempt to signal callers to advise() that query has already
> occurred, but this is predicated on the notion that query actually
> occurs (which presently only happens on the x86 arch). This is to
> assist debugging future users. Otherwise, the advise() call has
> been marked __init to help static discovery of bad call times.
>
> Once query is called the first time, it will always return the same value.
>
> Interfaces return -EBUSY and 0 respectively on systems without hotplug.
>
> Suggested-by: Ira Weiny <ira.weiny@intel.com>
> Suggested-by: David Hildenbrand <david@redhat.com>
> Suggested-by: Dan Williams <dan.j.williams@intel.com>
> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> Acked-by: David Hildenbrand <david@redhat.com>
> Acked-by: Dan Williams <dan.j.williams@intel.com>
> Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
> Signed-off-by: Gregory Price <gourry@gourry.net>
> Tested-by: Fan Ni <fan.ni@samsung.com>
>
> Gregory Price (3):
> memory: implement memory_block_advise/probe_max_size
> x86: probe memory block size advisement value during mm init
> acpi,srat: give memory block size advice based on CFMWS alignment
>
> arch/x86/mm/init_64.c | 15 ++++++++----
> drivers/acpi/numa/srat.c | 12 ++++++++-
> drivers/base/memory.c | 53 ++++++++++++++++++++++++++++++++++++++++
> include/linux/memory.h | 10 ++++++++
> 4 files changed, 84 insertions(+), 6 deletions(-)
>
> --
> 2.48.1
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v8 1/3] memory: implement memory_block_advise/probe_max_size
2025-01-27 15:34 ` [PATCH v8 1/3] memory: implement memory_block_advise/probe_max_size Gregory Price
@ 2025-04-01 18:50 ` Oscar Salvador
0 siblings, 0 replies; 13+ messages in thread
From: Oscar Salvador @ 2025-04-01 18:50 UTC (permalink / raw)
To: Gregory Price
Cc: linux-mm, linux-acpi, kernel-team, x86, linux-kernel, dave.hansen,
luto, peterz, tglx, mingo, bp, hpa, rafael, lenb, david, gregkh,
akpm, dan.j.williams, Jonathan.Cameron, alison.schofield,
rrichter, rppt, bfaccini, haibo1.xu, dave.jiang, Ira Weiny,
Fan Ni
On Mon, Jan 27, 2025 at 10:34:03AM -0500, Gregory Price wrote:
> Hotplug memory sources may have opinions on what the memblock size
> should be - usually for alignment purposes. For example, CXL memory
> extents can be 256MB with a matching alignment. If this size/alignment
> is smaller than the block size, it can result in stranded capacity.
>
> Implement memory_block_advise_max_size for use prior to allocator init,
> for software to advise the system on the max block size.
>
> Implement memory_block_probe_max_size for use by arch init code to
> calculate the best block size. Use of advice is architecture defined.
>
> The probe value can never change after first probe. Calls to advise
> after probe will return -EBUSY to aid debugging.
>
> On systems without hotplug, always return -ENODEV and 0 respectively.
>
> Suggested-by: Ira Weiny <ira.weiny@intel.com>
> Acked-by: David Hildenbrand <david@redhat.com>
> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> Acked-by: Dan Williams <dan.j.williams@intel.com>
> Tested-by: Fan Ni <fan.ni@samsung.com>
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> Signed-off-by: Gregory Price <gourry@gourry.net>
Acked-by: Oscar Salvador <osalvador@suse.de>
--
Oscar Salvador
SUSE Labs
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v8 2/3] x86: probe memory block size advisement value during mm init
2025-01-27 15:34 ` [PATCH v8 2/3] x86: probe memory block size advisement value during mm init Gregory Price
@ 2025-04-01 18:51 ` Oscar Salvador
0 siblings, 0 replies; 13+ messages in thread
From: Oscar Salvador @ 2025-04-01 18:51 UTC (permalink / raw)
To: Gregory Price
Cc: linux-mm, linux-acpi, kernel-team, x86, linux-kernel, dave.hansen,
luto, peterz, tglx, mingo, bp, hpa, rafael, lenb, david, gregkh,
akpm, dan.j.williams, Jonathan.Cameron, alison.schofield,
rrichter, rppt, bfaccini, haibo1.xu, dave.jiang, Fan Ni,
Ira Weiny
On Mon, Jan 27, 2025 at 10:34:04AM -0500, Gregory Price wrote:
> Systems with hotplug may provide an advisement value on what the
> memblock size should be. Probe this value when the rest of the
> configuration values are considered.
>
> The new heuristic is as follows
>
> 1) set_memory_block_size_order value if already set (cmdline param)
> 2) minimum block size if memory is less than large block limit
> 3) if no hotplug advice: Max block size if system is bare-metal,
> otherwise use end of memory alignment.
> 4) if hotplug advice: lesser of advice and end of memory alignment.
>
> Convert to cpu_feature_enabled() while at it.[1]
>
> [1] https://lore.kernel.org/all/20241031103401.GBZyNdGQ-ZyXKyzC_z@fat_crate.local/
>
> Suggested-by: Borislav Petkov <bp@alien8.de>
> Suggested-by: David Hildenbrand <david@redhat.com>
> Acked-by: David Hildenbrand <david@redhat.com>
> Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> Acked-by: Dan Williams <dan.j.williams@intel.com>
> Tested-by: Fan Ni <fan.ni@samsung.com>
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> Signed-off-by: Gregory Price <gourry@gourry.net>
Acked-by: Oscar Salvador <osalvador@suse.de>
--
Oscar Salvador
SUSE Labs
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v8 3/3] acpi,srat: give memory block size advice based on CFMWS alignment
2025-01-27 15:34 ` [PATCH v8 3/3] acpi,srat: give memory block size advice based on CFMWS alignment Gregory Price
@ 2025-04-01 18:52 ` Oscar Salvador
0 siblings, 0 replies; 13+ messages in thread
From: Oscar Salvador @ 2025-04-01 18:52 UTC (permalink / raw)
To: Gregory Price
Cc: linux-mm, linux-acpi, kernel-team, x86, linux-kernel, dave.hansen,
luto, peterz, tglx, mingo, bp, hpa, rafael, lenb, david, gregkh,
akpm, dan.j.williams, Jonathan.Cameron, alison.schofield,
rrichter, rppt, bfaccini, haibo1.xu, dave.jiang, Fan Ni,
Rafael J. Wysocki, Ira Weiny
On Mon, Jan 27, 2025 at 10:34:05AM -0500, Gregory Price wrote:
> Capacity is stranded when CFMWS regions are not aligned to block size.
> On x86, block size increases with capacity (2G blocks @ 64G capacity).
>
> Use CFMWS base/size to report memory block size alignment advice.
>
> Suggested-by: Dan Williams <dan.j.williams@intel.com>
> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> Acked-by: David Hildenbrand <david@redhat.com>
> Acked-by: Dan Williams <dan.j.williams@intel.com>
> Tested-by: Fan Ni <fan.ni@samsung.com>
> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> Signed-off-by: Gregory Price <gourry@gourry.net>
Acked-by: Oscar Salvador <osalvador@suse.de>
--
Oscar Salvador
SUSE Labs
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v8 0/3] memory,x86,acpi: hotplug memory alignment advisement
2025-01-27 15:34 [PATCH v8 0/3] memory,x86,acpi: hotplug memory alignment advisement Gregory Price
` (3 preceding siblings ...)
2025-04-01 18:33 ` [PATCH v8 0/3] memory,x86,acpi: hotplug memory alignment advisement Gregory Price
@ 2025-04-01 18:53 ` Oscar Salvador
2025-04-01 19:08 ` David Hildenbrand
2025-04-01 19:44 ` Dan Williams
4 siblings, 2 replies; 13+ messages in thread
From: Oscar Salvador @ 2025-04-01 18:53 UTC (permalink / raw)
To: Gregory Price
Cc: linux-mm, linux-acpi, kernel-team, x86, linux-kernel, dave.hansen,
luto, peterz, tglx, mingo, bp, hpa, rafael, lenb, david, gregkh,
akpm, dan.j.williams, Jonathan.Cameron, alison.schofield,
rrichter, rppt, bfaccini, haibo1.xu, dave.jiang, Ira Weiny,
Fan Ni
On Mon, Jan 27, 2025 at 10:34:02AM -0500, Gregory Price wrote:
> v8: nits and tag pickups
>
> When physical address regions are not aligned to memory block size,
> the misaligned portion is lost (stranded capacity).
>
> Block size (min/max/selected) is architecture defined. Most architectures
> tend to use the minimum block size or some simplistic heurist. On x86,
> memory block size increases up to 2GB, and is otherwise fitted to the
> alignment of non-hotplug (i.e. not special purpose memory).
I wonder if something like this could help us in improving the
ridiculous situation of having 16MB memory-block size on powerpc.
--
Oscar Salvador
SUSE Labs
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v8 0/3] memory,x86,acpi: hotplug memory alignment advisement
2025-04-01 18:53 ` Oscar Salvador
@ 2025-04-01 19:08 ` David Hildenbrand
2025-04-02 9:39 ` Mike Rapoport
2025-04-01 19:44 ` Dan Williams
1 sibling, 1 reply; 13+ messages in thread
From: David Hildenbrand @ 2025-04-01 19:08 UTC (permalink / raw)
To: Oscar Salvador, Gregory Price
Cc: linux-mm, linux-acpi, kernel-team, x86, linux-kernel, dave.hansen,
luto, peterz, tglx, mingo, bp, hpa, rafael, lenb, gregkh, akpm,
dan.j.williams, Jonathan.Cameron, alison.schofield, rrichter,
rppt, bfaccini, haibo1.xu, dave.jiang, Ira Weiny, Fan Ni
On 01.04.25 20:53, Oscar Salvador wrote:
> On Mon, Jan 27, 2025 at 10:34:02AM -0500, Gregory Price wrote:
>> v8: nits and tag pickups
>>
>> When physical address regions are not aligned to memory block size,
>> the misaligned portion is lost (stranded capacity).
>>
>> Block size (min/max/selected) is architecture defined. Most architectures
>> tend to use the minimum block size or some simplistic heurist. On x86,
>> memory block size increases up to 2GB, and is otherwise fitted to the
>> alignment of non-hotplug (i.e. not special purpose memory).
>
> I wonder if something like this could help us in improving the
> ridiculous situation of having 16MB memory-block size on powerpc.
They have this granularity because ... they want to add/remove memory in
16MiB on some powerpc dlpar machines :(
probe_memory_block_size() can query the hypervisor on the actual
hot(un)plug size. IIRC, QEMU sets it to 256 MiB.
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v8 0/3] memory,x86,acpi: hotplug memory alignment advisement
2025-04-01 18:53 ` Oscar Salvador
2025-04-01 19:08 ` David Hildenbrand
@ 2025-04-01 19:44 ` Dan Williams
1 sibling, 0 replies; 13+ messages in thread
From: Dan Williams @ 2025-04-01 19:44 UTC (permalink / raw)
To: Oscar Salvador, Gregory Price
Cc: linux-mm, linux-acpi, kernel-team, x86, linux-kernel, dave.hansen,
luto, peterz, tglx, mingo, bp, hpa, rafael, lenb, david, gregkh,
akpm, dan.j.williams, Jonathan.Cameron, alison.schofield,
rrichter, rppt, bfaccini, haibo1.xu, dave.jiang, Ira Weiny,
Fan Ni
Oscar Salvador wrote:
> On Mon, Jan 27, 2025 at 10:34:02AM -0500, Gregory Price wrote:
> > v8: nits and tag pickups
> >
> > When physical address regions are not aligned to memory block size,
> > the misaligned portion is lost (stranded capacity).
> >
> > Block size (min/max/selected) is architecture defined. Most architectures
> > tend to use the minimum block size or some simplistic heurist. On x86,
> > memory block size increases up to 2GB, and is otherwise fitted to the
> > alignment of non-hotplug (i.e. not special purpose memory).
>
> I wonder if something like this could help us in improving the
> ridiculous situation of having 16MB memory-block size on powerpc.
It's only ridiculous due to what it does to /sys/.../memory,
right?
If you permit me a bit of hand-waving, it would be lovely to deprecate
/sys/.../memory in favor of a new (fd based?) ABI for memory-hotplug
policy management and have something like a fuse "compatfs" mounted at
/sys/.../memory/ for maintaining legacy compatibility for userspace that
still depends on twiddling with individual blocks in sysfs.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v8 0/3] memory,x86,acpi: hotplug memory alignment advisement
2025-04-01 19:08 ` David Hildenbrand
@ 2025-04-02 9:39 ` Mike Rapoport
2025-04-02 10:07 ` David Hildenbrand
0 siblings, 1 reply; 13+ messages in thread
From: Mike Rapoport @ 2025-04-02 9:39 UTC (permalink / raw)
To: David Hildenbrand
Cc: Oscar Salvador, Gregory Price, linux-mm, linux-acpi, kernel-team,
x86, linux-kernel, dave.hansen, luto, peterz, tglx, mingo, bp,
hpa, rafael, lenb, gregkh, akpm, dan.j.williams, Jonathan.Cameron,
alison.schofield, rrichter, bfaccini, haibo1.xu, dave.jiang,
Ira Weiny, Fan Ni
On Tue, Apr 01, 2025 at 09:08:31PM +0200, David Hildenbrand wrote:
> On 01.04.25 20:53, Oscar Salvador wrote:
> > On Mon, Jan 27, 2025 at 10:34:02AM -0500, Gregory Price wrote:
> > > v8: nits and tag pickups
> > >
> > > When physical address regions are not aligned to memory block size,
> > > the misaligned portion is lost (stranded capacity).
> > >
> > > Block size (min/max/selected) is architecture defined. Most architectures
> > > tend to use the minimum block size or some simplistic heurist. On x86,
> > > memory block size increases up to 2GB, and is otherwise fitted to the
> > > alignment of non-hotplug (i.e. not special purpose memory).
> >
> > I wonder if something like this could help us in improving the
> > ridiculous situation of having 16MB memory-block size on powerpc.
>
> They have this granularity because ... they want to add/remove memory in
> 16MiB on some powerpc dlpar machines :(
I'm not sure they do it today, there's a comment in near define of that 16M
in arch/powerpc/mm/init_64.c:
/*
* Outside hotplug the kernel uses this value to map the kernel direct map
* with radix. To be compatible with older kernels, let's keep this value
* as 16M which is also SECTION_SIZE with SPARSEMEM. We can ideally map
* things with 1GB size in the case where we don't support hotplug.
*/
and their SECTION_SIZE didn't change since 2005.
Quite possible that they'll be fine with increasing their
DEFAULT_MEMORY_BLOCK_SIZE.
> probe_memory_block_size() can query the hypervisor on the actual hot(un)plug
> size. IIRC, QEMU sets it to 256 MiB.
>
> --
> Cheers,
>
> David / dhildenb
>
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v8 0/3] memory,x86,acpi: hotplug memory alignment advisement
2025-04-02 9:39 ` Mike Rapoport
@ 2025-04-02 10:07 ` David Hildenbrand
0 siblings, 0 replies; 13+ messages in thread
From: David Hildenbrand @ 2025-04-02 10:07 UTC (permalink / raw)
To: Mike Rapoport
Cc: Oscar Salvador, Gregory Price, linux-mm, linux-acpi, kernel-team,
x86, linux-kernel, dave.hansen, luto, peterz, tglx, mingo, bp,
hpa, rafael, lenb, gregkh, akpm, dan.j.williams, Jonathan.Cameron,
alison.schofield, rrichter, bfaccini, haibo1.xu, dave.jiang,
Ira Weiny, Fan Ni
On 02.04.25 11:39, Mike Rapoport wrote:
> On Tue, Apr 01, 2025 at 09:08:31PM +0200, David Hildenbrand wrote:
>> On 01.04.25 20:53, Oscar Salvador wrote:
>>> On Mon, Jan 27, 2025 at 10:34:02AM -0500, Gregory Price wrote:
>>>> v8: nits and tag pickups
>>>>
>>>> When physical address regions are not aligned to memory block size,
>>>> the misaligned portion is lost (stranded capacity).
>>>>
>>>> Block size (min/max/selected) is architecture defined. Most architectures
>>>> tend to use the minimum block size or some simplistic heurist. On x86,
>>>> memory block size increases up to 2GB, and is otherwise fitted to the
>>>> alignment of non-hotplug (i.e. not special purpose memory).
>>>
>>> I wonder if something like this could help us in improving the
>>> ridiculous situation of having 16MB memory-block size on powerpc.
>>
>> They have this granularity because ... they want to add/remove memory in
>> 16MiB on some powerpc dlpar machines :(
>
> I'm not sure they do it today, there's a comment in near define of that 16M
> in arch/powerpc/mm/init_64.c:
>
> /*
> * Outside hotplug the kernel uses this value to map the kernel direct map
> * with radix. To be compatible with older kernels, let's keep this value
> * as 16M which is also SECTION_SIZE with SPARSEMEM. We can ideally map
> * things with 1GB size in the case where we don't support hotplug.
> */
> > and their SECTION_SIZE didn't change since 2005.
> Quite possible that they'll be fine with increasing their
> DEFAULT_MEMORY_BLOCK_SIZE.
At least modern PowerVM on Power10 seems to support LMBs of 128 MiB.
"Based on this data, Power10 initially only supported LMB sizes of 128MB
and 256MB." The default usually seems to be 256 MiB.
In reality, the expectation is that the hypervisor will always
communicate the LMB such that the memory block size will be set to that.
Assuming we'd increase DEFAULT_MEMORY_BLOCK_SIZE to 128MiB, we might
also be able to increase SECTION_SIZE to 128 MiB I assume.
Not sure about older PowerVM / systems.
[1]
https://community.ibm.com/community/user/power/blogs/pete-heyrman1/2024/03/06/power10-lmb-sizes
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-04-02 10:07 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-27 15:34 [PATCH v8 0/3] memory,x86,acpi: hotplug memory alignment advisement Gregory Price
2025-01-27 15:34 ` [PATCH v8 1/3] memory: implement memory_block_advise/probe_max_size Gregory Price
2025-04-01 18:50 ` Oscar Salvador
2025-01-27 15:34 ` [PATCH v8 2/3] x86: probe memory block size advisement value during mm init Gregory Price
2025-04-01 18:51 ` Oscar Salvador
2025-01-27 15:34 ` [PATCH v8 3/3] acpi,srat: give memory block size advice based on CFMWS alignment Gregory Price
2025-04-01 18:52 ` Oscar Salvador
2025-04-01 18:33 ` [PATCH v8 0/3] memory,x86,acpi: hotplug memory alignment advisement Gregory Price
2025-04-01 18:53 ` Oscar Salvador
2025-04-01 19:08 ` David Hildenbrand
2025-04-02 9:39 ` Mike Rapoport
2025-04-02 10:07 ` David Hildenbrand
2025-04-01 19:44 ` Dan Williams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).