Add interfaces for ACPI MRRM table
Subsystems (3)
v2 cover Add interfaces for ACPI MRRM table
Memory used to be homogeneous. Then NUMA came along. Later different types of memory (persistent memory, on-package high bandwidth memory, CXL attached memory).
Each type of memory has its own performance characteristics, and users will need to monitor and control access by type.
The MRRM solution is to tag physical address ranges with "region IDs" so that platform firmware[1] can indicate the type of memory for each range (with separate tags available for local vs. remote access to each range). Note that these ranges can include addresses reserved for future hotplugged memory.
The region IDs will be used to provide separate event counts for each region for "perf" and for the "resctrl" file system to monitor and control memory bandwidth in each region.
Users will need to know the address range(s) that are part of each region. This patch series adds
/sys/firmware/acpi/memory_ranges/rangeX
directories to provide user space accessible enumeration.
-Tony
[1] MRRM definition allow for future expansion for the OS to assign these region IDs.
Changes since v1 posted at:
https://lore.kernel.org/all/[email protected]/
1) Target /sys directory for the files moved from /sys/devices/system/memory to /sys/firmware/acpi/memory.
While the old target had a useful sounding name, it is really all about hotplug memory while this enumeration is about different types of memory with hotplug being a non-issue as memory ranges can describe addresses that are reserved for future addition of different types of memory.
2) The ACPICA changes in patch one have been committed to the acpica git repository and will make their way into Linux for the next ACPICA release. Patch included here for convenience.
3) I included a "testing" patch that provides a fake MRRM table so that anyone can compile and run this series to check things out.
Tony Luck (4):
ACPICA: Define MRRM ACPI table
ACPI/MRRM: Create /sys/firmware/acpi/memory_ranges/rangeX ABI
ACPI: Add documentation for exposing MRRM data
acpi_mrrm: fake for testing, do not apply!
include/linux/acpi.h | 6 + include/acpi/actbl1.h | 7 + include/acpi/actbl2.h | 42 ++++ drivers/acpi/acpi_mrrm.c | 185 ++++++++++++++++++ Documentation/ABI/testing/sysfs-firmware-acpi | 16 ++ arch/x86/Kconfig | 1 + drivers/acpi/Kconfig | 3 + drivers/acpi/Makefile | 1 + 8 files changed, 261 insertions(+) create mode 100644 drivers/acpi/acpi_mrrm.c
base-commit: d082ecbc71e9e0bf49883ee4afd435a77a5101b6
Signature · 1 line
2.48.1
PATCH v2 1/4 ACPICA: Define MRRM ACPI table
Patch for reference, this has already been applied to
https://github.com/acpica/acpica and will in due course make its way into Linux when the next ACPICA release is ported over.
--- include/acpi/actbl1.h | 7 +++++++ include/acpi/actbl2.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+)
include/acpi/actbl1.h +7 -0
@@ -110,6 +110,13 @@ struct acpi_whea_header {u64 mask;/* Bitmask required for this register instruction */ }; +/* Larger subtable header (when Length can exceed 255) */ + +struct acpi_subtable_header_16 { +u16 type; +u16 length; +}; +/* https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/acpitabl/ns-acpitabl-aspt_table */ #define ASPT_REVISION_ID 0x01struct acpi_table_aspt {
include/acpi/actbl2.h +42 -0
54 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH v2 2/4 ACPI/MRRM: Create /sys/firmware/acpi/memory_ranges/rangeX ABI
In reply to Tony LuckPerf and resctrl users need an enumeration of which memory addresses are bound to which "region" tag.
Parse the ACPI MRRM table and add /sys entries for each memory range describing base address, length, and which region tags apply for same-socket and cross-socket access.
[Derived from code developed by Fenghua Yu <[email protected]>]
--- include/linux/acpi.h | 6 ++ drivers/acpi/acpi_mrrm.c | 161 +++++++++++++++++++++++++++++++++++++++ arch/x86/Kconfig | 1 + drivers/acpi/Kconfig | 3 + drivers/acpi/Makefile | 1 + 5 files changed, 172 insertions(+) create mode 100644 drivers/acpi/acpi_mrrm.c
include/linux/acpi.h +6 -0
@@ -773,6 +773,12 @@ int acpi_get_local_u64_address(acpi_handle handle, u64 *addr);int acpi_get_local_address (acpi_handle handle,u32 *addr);const char *acpi_get_subsystem_id (acpi_handle handle); +#ifdef CONFIG_ACPI_MRRM +int acpi_mrrm_max_mem_region (void ); +#else +static inline int acpi_mrrm_max_mem_region (void ) {return -ENOENT ; } +#endif +#else /* !CONFIG_ACPI */ #define acpi_disabled 1
drivers/acpi/acpi_mrrm.c new file +161 -0
161 lines not on this page · raw message
arch/x86/Kconfig +1 -0
@@ -36,6 +36,7 @@ config X86_64 select ARCH_HAS_ELFCORE_COMPAT select ZONE_DMA32 select EXECMEM if DYNAMIC_FTRACE + select ACPI_MRRM if ACPI config FORCE_DYNAMIC_FTRACE def_bool y
drivers/acpi/Kconfig +3 -0
@@ -576,6 +576,9 @@ config ACPI_FFH Enable this feature if you want to set up and install the FFH Address Space handler to handle FFH OpRegion in the firmware. +config ACPI_MRRM + bool + source "drivers/acpi/pmic/Kconfig" config ACPI_VIOT
drivers/acpi/Makefile +1 -0
@@ -62,6 +62,7 @@ acpi-$(CONFIG_ACPI_WATCHDOG) += acpi_watchdog.o acpi-$(CONFIG_ACPI_PRMT) += prmt.o acpi-$(CONFIG_ACPI_PCC) += acpi_pcc.o acpi-$(CONFIG_ACPI_FFH) += acpi_ffh.o +acpi-$(CONFIG_ACPI_MRRM) += acpi_mrrm.o # Address translation acpi-$(CONFIG_ACPI_ADXL) += acpi_adxl.o
Signature · 1 line
2.48.1
PATCH v2 3/4 ACPI: Add documentation for exposing MRRM data
In reply to Tony LuckInitial implementation provides enumeration of the address ranges and BIOS assigned region IDs for each range.
--- Documentation/ABI/testing/sysfs-firmware-acpi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
Documentation/ABI/testing/sysfs-firmware-acpi +16 -0
@@ -248,3 +248,19 @@ Description: # cat ff_pwr_btn 7 enabled +What: /sys/firmware/acpi/memory_ranges/rangeX +Date: February 2025 +Contact: Tony Luck <[email protected]> +Description: + On systems with the ACPI MRRM table reports the + parameters for each range. + + base: Starting system physical address. + + length: Length of this range in bytes. + + local_region_id: ID associated with access by agents + local to this range of addresses. + + remote_region_id: ID associated with access by agents + non-local to this range of addresses.
Signature · 1 line
2.48.1
PATCH v2 4/4 acpi_mrrm: fake for testing, do not apply!
In reply to Tony LuckDummy MRRM table for a 2 socket system with memory map:
LocalAccess RemoteAccess
0-3.5G DDR on socket 0 0 1
2G-512G More DDR on socket 0 0 1
512G-1T DDR on socket 1 0 1
1T-2T Reserved for CXL on socket 0 2 3
2T-3T Reserved for CXL on socket 1 2 3
This tags all local DDR access in region 0, remote DDR in region 1, local CXL in region 2, and remote CXL in region 3.
Presented to user like this:
$ cd /sys/firmware/acpi $ grep ^ memory_ranges/*/* memory_ranges/range0/base:0x0 memory_ranges/range0/length:0xe0000000 memory_ranges/range0/local_region_id:0x0 memory_ranges/range0/remote_region_id:0x1 memory_ranges/range1/base:0x100000000 memory_ranges/range1/length:0x7f00000000 memory_ranges/range1/local_region_id:0x0 memory_ranges/range1/remote_region_id:0x1 memory_ranges/range2/base:0x8000000000 memory_ranges/range2/length:0x8000000000 memory_ranges/range2/local_region_id:0x0 memory_ranges/range2/remote_region_id:0x1 memory_ranges/range3/base:0x10000000000 memory_ranges/range3/length:0x100000000000 memory_ranges/range3/local_region_id:0x2 memory_ranges/range3/remote_region_id:0x3 memory_ranges/range4/base:0x200000000000 memory_ranges/range4/length:0x100000000000 memory_ranges/range4/local_region_id:0x2 memory_ranges/range4/remote_region_id:0x3
--- drivers/acpi/acpi_mrrm.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/acpi/acpi_mrrm.c +24 -0
@@ -147,11 +147,35 @@ static __init int add_boot_memory_ranges(void)return ret; } +#define FAKE 1 +#ifdef FAKE +static const u8 fake_mrrm[] = { +0x4D ,0x52 ,0x52 ,0x4D ,0xE0 ,0x00 ,0x00 ,0x00 ,0x01 ,0x3A ,0x49 ,0x4E ,0x54 ,0x45 ,0x4C ,0x00 , +0x49 ,0x4E ,0x54 ,0x45 ,0x4C ,0x20 ,0x49 ,0x44 ,0x02 ,0x00 ,0x00 ,0x00 ,0x49 ,0x4E ,0x54 ,0x4C , +0x12 ,0x12 ,0x24 ,0x20 ,0x04 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,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_table_header *)fake_mrrm); +#else ret =acpi_table_parse (ACPI_SIG_MRRM , acpi_parse_mrrm); +#endif if (ret <0 )return ret;
Signature · 1 line
2.48.1