* [PATCH v3 1/1] mm: numa_memblks: introduce numa_add_reserved_memblk
@ 2025-05-08 2:27 Yuquan Wang
2025-05-08 4:09 ` Alison Schofield
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Yuquan Wang @ 2025-05-08 2:27 UTC (permalink / raw)
To: Jonathan.Cameron, dan.j.williams, rppt, rafael, lenb, akpm,
alison.schofield, rrichter, bfaccini, haibo1.xu, david,
chenhuacai
Cc: linux-cxl, linux-acpi, linux-kernel, linux-mm, chenbaozi,
loongarch, Yuquan Wang
acpi_parse_cfmws() currently adds empty CFMWS ranges to numa_meminfo
with the expectation that numa_cleanup_meminfo moves them to
numa_reserved_meminfo. There is no need for that indirection when it is
known in advance that these unpopulated ranges are meant for
numa_reserved_meminfo in support of future hotplug / CXL provisioning.
Introduce and use numa_add_reserved_memblk() to add the empty CFMWS
ranges directly.
Signed-off-by: Yuquan Wang <wangyuquan1236@phytium.com.cn>
---
Changes in v3 (Thanks to Dan & huacai):
- The previous version failed to build on loongarch, now this issue is resolved.
drivers/acpi/numa/srat.c | 2 +-
include/linux/numa_memblks.h | 1 +
mm/numa_memblks.c | 22 ++++++++++++++++++++++
3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
index 0a725e46d017..751774f0b4e5 100644
--- a/drivers/acpi/numa/srat.c
+++ b/drivers/acpi/numa/srat.c
@@ -453,7 +453,7 @@ static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
return -EINVAL;
}
- if (numa_add_memblk(node, start, end) < 0) {
+ if (numa_add_reserved_memblk(node, start, end) < 0) {
/* CXL driver must handle the NUMA_NO_NODE case */
pr_warn("ACPI NUMA: Failed to add memblk for CFMWS node %d [mem %#llx-%#llx]\n",
node, start, end);
diff --git a/include/linux/numa_memblks.h b/include/linux/numa_memblks.h
index dd85613cdd86..991076cba7c5 100644
--- a/include/linux/numa_memblks.h
+++ b/include/linux/numa_memblks.h
@@ -22,6 +22,7 @@ struct numa_meminfo {
};
int __init numa_add_memblk(int nodeid, u64 start, u64 end);
+int __init numa_add_reserved_memblk(int nid, u64 start, u64 end);
void __init numa_remove_memblk_from(int idx, struct numa_meminfo *mi);
int __init numa_cleanup_meminfo(struct numa_meminfo *mi);
diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c
index ff4054f4334d..541a99c4071a 100644
--- a/mm/numa_memblks.c
+++ b/mm/numa_memblks.c
@@ -200,6 +200,28 @@ int __init numa_add_memblk(int nid, u64 start, u64 end)
return numa_add_memblk_to(nid, start, end, &numa_meminfo);
}
+/**
+ * numa_add_reserved_memblk - Add one numa_memblk to numa_reserved_meminfo
+ * @nid: NUMA node ID of the new memblk
+ * @start: Start address of the new memblk
+ * @end: End address of the new memblk
+ *
+ * Add a new memblk to the numa_reserved_meminfo.
+ *
+ * Usage Case: numa_cleanup_meminfo() reconciles all numa_memblk instances
+ * against memblock_type information and moves any that intersect reserved
+ * ranges to numa_reserved_meminfo. However, when that information is known
+ * ahead of time, we use numa_add_reserved_memblk() to add the numa_memblk
+ * to numa_reserved_meminfo directly.
+ *
+ * RETURNS:
+ * 0 on success, -errno on failure.
+ */
+int __init numa_add_reserved_memblk(int nid, u64 start, u64 end)
+{
+ return numa_add_memblk_to(nid, start, end, &numa_reserved_meminfo);
+}
+
/**
* numa_cleanup_meminfo - Cleanup a numa_meminfo
* @mi: numa_meminfo to clean up
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/1] mm: numa_memblks: introduce numa_add_reserved_memblk
2025-05-08 2:27 [PATCH v3 1/1] mm: numa_memblks: introduce numa_add_reserved_memblk Yuquan Wang
@ 2025-05-08 4:09 ` Alison Schofield
2025-05-08 9:45 ` Jonathan Cameron
2025-05-09 0:42 ` Andrew Morton
2025-06-03 13:06 ` Guenter Roeck
2 siblings, 1 reply; 6+ messages in thread
From: Alison Schofield @ 2025-05-08 4:09 UTC (permalink / raw)
To: Yuquan Wang
Cc: Jonathan.Cameron, dan.j.williams, rppt, rafael, lenb, akpm,
rrichter, bfaccini, haibo1.xu, david, chenhuacai, linux-cxl,
linux-acpi, linux-kernel, linux-mm, chenbaozi, loongarch
On Thu, May 08, 2025 at 10:27:19AM +0800, Yuquan Wang wrote:
> acpi_parse_cfmws() currently adds empty CFMWS ranges to numa_meminfo
> with the expectation that numa_cleanup_meminfo moves them to
> numa_reserved_meminfo. There is no need for that indirection when it is
> known in advance that these unpopulated ranges are meant for
> numa_reserved_meminfo in support of future hotplug / CXL provisioning.
>
> Introduce and use numa_add_reserved_memblk() to add the empty CFMWS
> ranges directly.
>
> Signed-off-by: Yuquan Wang <wangyuquan1236@phytium.com.cn>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/1] mm: numa_memblks: introduce numa_add_reserved_memblk
2025-05-08 4:09 ` Alison Schofield
@ 2025-05-08 9:45 ` Jonathan Cameron
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2025-05-08 9:45 UTC (permalink / raw)
To: Alison Schofield
Cc: Yuquan Wang, dan.j.williams, rppt, rafael, lenb, akpm, rrichter,
bfaccini, haibo1.xu, david, chenhuacai, linux-cxl, linux-acpi,
linux-kernel, linux-mm, chenbaozi, loongarch
On Wed, 7 May 2025 21:09:07 -0700
Alison Schofield <alison.schofield@intel.com> wrote:
> On Thu, May 08, 2025 at 10:27:19AM +0800, Yuquan Wang wrote:
> > acpi_parse_cfmws() currently adds empty CFMWS ranges to numa_meminfo
> > with the expectation that numa_cleanup_meminfo moves them to
> > numa_reserved_meminfo. There is no need for that indirection when it is
> > known in advance that these unpopulated ranges are meant for
> > numa_reserved_meminfo in support of future hotplug / CXL provisioning.
> >
> > Introduce and use numa_add_reserved_memblk() to add the empty CFMWS
> > ranges directly.
> >
> > Signed-off-by: Yuquan Wang <wangyuquan1236@phytium.com.cn>
>
> Reviewed-by: Alison Schofield <alison.schofield@intel.com>
>
>
>
Yuquan - I'm guessing this is a misunderstanding of process.
The patch submitter should pick up tags on previous versions.
If any are not picked up in the tag block there should be a clear
explanation of why!
Jonathan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/1] mm: numa_memblks: introduce numa_add_reserved_memblk
2025-05-08 2:27 [PATCH v3 1/1] mm: numa_memblks: introduce numa_add_reserved_memblk Yuquan Wang
2025-05-08 4:09 ` Alison Schofield
@ 2025-05-09 0:42 ` Andrew Morton
2025-06-03 13:06 ` Guenter Roeck
2 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2025-05-09 0:42 UTC (permalink / raw)
To: Yuquan Wang
Cc: Jonathan.Cameron, dan.j.williams, rppt, rafael, lenb,
alison.schofield, rrichter, bfaccini, haibo1.xu, david,
chenhuacai, linux-cxl, linux-acpi, linux-kernel, linux-mm,
chenbaozi, loongarch
On Thu, 8 May 2025 10:27:19 +0800 Yuquan Wang <wangyuquan1236@phytium.com.cn> wrote:
> acpi_parse_cfmws() currently adds empty CFMWS ranges to numa_meminfo
> with the expectation that numa_cleanup_meminfo moves them to
> numa_reserved_meminfo. There is no need for that indirection when it is
> known in advance that these unpopulated ranges are meant for
> numa_reserved_meminfo in support of future hotplug / CXL provisioning.
>
> Introduce and use numa_add_reserved_memblk() to add the empty CFMWS
> ranges directly.
>
> ...
>
> drivers/acpi/numa/srat.c | 2 +-
> include/linux/numa_memblks.h | 1 +
> mm/numa_memblks.c | 22 ++++++++++++++++++++++
I'm not sure which tree this best belongs to so I'll add it to mm-git.
If it later pops up in another tree, I'll drop it again.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/1] mm: numa_memblks: introduce numa_add_reserved_memblk
2025-05-08 2:27 [PATCH v3 1/1] mm: numa_memblks: introduce numa_add_reserved_memblk Yuquan Wang
2025-05-08 4:09 ` Alison Schofield
2025-05-09 0:42 ` Andrew Morton
@ 2025-06-03 13:06 ` Guenter Roeck
2025-06-03 13:30 ` Xi Ruoyao
2 siblings, 1 reply; 6+ messages in thread
From: Guenter Roeck @ 2025-06-03 13:06 UTC (permalink / raw)
To: Yuquan Wang
Cc: Jonathan.Cameron, dan.j.williams, rppt, rafael, lenb, akpm,
alison.schofield, rrichter, bfaccini, haibo1.xu, david,
chenhuacai, linux-cxl, linux-acpi, linux-kernel, linux-mm,
chenbaozi, loongarch
Hi,
On Thu, May 08, 2025 at 10:27:19AM +0800, Yuquan Wang wrote:
> acpi_parse_cfmws() currently adds empty CFMWS ranges to numa_meminfo
> with the expectation that numa_cleanup_meminfo moves them to
> numa_reserved_meminfo. There is no need for that indirection when it is
> known in advance that these unpopulated ranges are meant for
> numa_reserved_meminfo in support of future hotplug / CXL provisioning.
>
> Introduce and use numa_add_reserved_memblk() to add the empty CFMWS
> ranges directly.
>
> Signed-off-by: Yuquan Wang <wangyuquan1236@phytium.com.cn>
Just on case this has not been reported yet:
Building loongarch:defconfig ... failed
--------------
Error log:
drivers/acpi/numa/srat.c: In function 'acpi_parse_cfmws':
drivers/acpi/numa/srat.c:467:13: error: implicit declaration of function 'numa_add_reserved_memblk'
Guenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/1] mm: numa_memblks: introduce numa_add_reserved_memblk
2025-06-03 13:06 ` Guenter Roeck
@ 2025-06-03 13:30 ` Xi Ruoyao
0 siblings, 0 replies; 6+ messages in thread
From: Xi Ruoyao @ 2025-06-03 13:30 UTC (permalink / raw)
To: Guenter Roeck, Yuquan Wang
Cc: Jonathan.Cameron, dan.j.williams, rppt, rafael, lenb, akpm,
alison.schofield, rrichter, bfaccini, haibo1.xu, david,
chenhuacai, linux-cxl, linux-acpi, linux-kernel, linux-mm,
chenbaozi, loongarch
On Tue, 2025-06-03 at 06:06 -0700, Guenter Roeck wrote:
> Hi,
>
> On Thu, May 08, 2025 at 10:27:19AM +0800, Yuquan Wang wrote:
> > acpi_parse_cfmws() currently adds empty CFMWS ranges to numa_meminfo
> > with the expectation that numa_cleanup_meminfo moves them to
> > numa_reserved_meminfo. There is no need for that indirection when it
> > is
> > known in advance that these unpopulated ranges are meant for
> > numa_reserved_meminfo in support of future hotplug / CXL
> > provisioning.
> >
> > Introduce and use numa_add_reserved_memblk() to add the empty CFMWS
> > ranges directly.
> >
> > Signed-off-by: Yuquan Wang <wangyuquan1236@phytium.com.cn>
>
> Just on case this has not been reported yet:
>
> Building loongarch:defconfig ... failed
> --------------
> Error log:
> drivers/acpi/numa/srat.c: In function 'acpi_parse_cfmws':
> drivers/acpi/numa/srat.c:467:13: error: implicit declaration of
> function 'numa_add_reserved_memblk'
The fix is queued at
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson.git/commit/?h=loongarch-next&id=a24f2fb70cb62180486ad4d74f809ff35ddd1cf9
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-06-03 13:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-08 2:27 [PATCH v3 1/1] mm: numa_memblks: introduce numa_add_reserved_memblk Yuquan Wang
2025-05-08 4:09 ` Alison Schofield
2025-05-08 9:45 ` Jonathan Cameron
2025-05-09 0:42 ` Andrew Morton
2025-06-03 13:06 ` Guenter Roeck
2025-06-03 13:30 ` Xi Ruoyao
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).