[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250210211223.6139-4-tony.luck@intel.com>
Date: Mon, 10 Feb 2025 13:12:22 -0800
From: Tony Luck <tony.luck@...el.com>
To: Robert Moore <robert.moore@...el.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
Len Brown <lenb@...nel.org>
Cc: linux-acpi@...r.kernel.org,
acpica-devel@...ts.linux.dev,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>,
David Hildenbrand <david@...hat.com>,
Oscar Salvador <osalvador@...e.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Danilo Krummrich <dakr@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org,
Tony Luck <tony.luck@...el.com>
Subject: [PATCH 3/4] ACPI/MRRM: Add "node" symlink to /sys/devices/system/memory/rangeX
Users will likely want to know which node owns each memory range
and which CPUs are local to the range.
Add a symlink to the node directory to provide both pieces of information.
Signed-off-by: Tony Luck <tony.luck@...el.com>
---
drivers/acpi/acpi_mrrm.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/acpi/acpi_mrrm.c b/drivers/acpi/acpi_mrrm.c
index 51ed9064e025..28b484943bbd 100644
--- a/drivers/acpi/acpi_mrrm.c
+++ b/drivers/acpi/acpi_mrrm.c
@@ -119,6 +119,31 @@ static struct attribute *memory_range_attrs[] = {
ATTRIBUTE_GROUPS(memory_range);
+static __init int add_node_link(struct mrrm_mem_range_entry *entry)
+{
+ struct node *node = NULL;
+ int ret = 0;
+ int nid;
+
+ for_each_online_node(nid) {
+ for (int z = 0; z < MAX_NR_ZONES; z++) {
+ struct zone *zone = NODE_DATA(nid)->node_zones + z;
+
+ if (!populated_zone(zone))
+ continue;
+ if (zone_intersects(zone, PHYS_PFN(entry->base), PHYS_PFN(entry->length))) {
+ node = node_devices[zone->node];
+ goto found;
+ }
+ }
+ }
+found:
+ if (node)
+ ret = sysfs_create_link(&entry->dev.kobj, &node->dev.kobj, "node");
+
+ return ret;
+}
+
static __init int add_boot_memory_ranges(void)
{
char name[16];
@@ -140,6 +165,10 @@ static __init int add_boot_memory_ranges(void)
put_device(&entry->dev);
return ret;
}
+
+ ret = add_node_link(entry);
+ if (ret)
+ break;
}
return ret;
--
2.48.1
Powered by blists - more mailing lists