surface heterogeneous memory performance information
Subsystems (5)
v2 cover surface heterogeneous memory performance information
==== Quick Summary ====
Platforms in the very near future will have multiple types of memory attached to a single CPU. These disparate memory ranges will have some characteristics in common, such as CPU cache coherence, but they can have wide ranges of performance both in terms of latency and bandwidth.
For example, consider a system that contains persistent memory, standard DDR memory and High Bandwidth Memory (HBM), all attached to the same CPU. There could potentially be an order of magnitude or more difference in performance between the slowest and fastest memory attached to that CPU.
With the current Linux code NUMA nodes are CPU-centric, so all the memory attached to a given CPU will be lumped into the same NUMA node. This makes it very difficult for userspace applications to understand the performance of different memory ranges on a given CPU.
We solve this issue by providing userspace with performance information on individual memory ranges. This performance information is exposed via sysfs:
# grep . mem_tgt2/* mem_tgt2/local_init/* 2>/dev/null mem_tgt2/firmware_id:1 mem_tgt2/is_cached:0 mem_tgt2/is_enabled:1 mem_tgt2/is_isolated:0 mem_tgt2/phys_addr_base:0x0 mem_tgt2/phys_length_bytes:0x800000000 mem_tgt2/local_init/read_bw_MBps:30720 mem_tgt2/local_init/read_lat_nsec:100 mem_tgt2/local_init/write_bw_MBps:30720 mem_tgt2/local_init/write_lat_nsec:100
This allows applications to easily find the memory that they want to use. We expect that the existing NUMA APIs will be enhanced to use this new information so that applications can continue to use them to select their desired memory.
This series is built upon acpica-1705:
https://github.com/zetalog/linux/commits/acpica-1705
And you can find a working tree here:
https://git.kernel.org/pub/scm/linux/kernel/git/zwisler/linux.git/log/?h=hmem_sysfs
==== Lots of Details ====
This patch set is only concerned with CPU-addressable memory types, not on-device memory like what we have with Jerome Glisse's HMM series:
https://lwn.net/Articles/726691/
This patch set works by enabling the new Heterogeneous Memory Attribute Table (HMAT) table, newly defined in ACPI 6.2. One major conceptual change in ACPI 6.2 related to this work is that proximity domains no longer need to contain a processor. We can now have memory-only proximity domains, which means that we can now have memory-only Linux NUMA nodes.
Here is an example configuration where we have a single processor, one range of regular memory and one range of HBM:
+---------------+ +----------------+
| Processor | | Memory |
| prox domain 0 +---+ prox domain 1 |
| NUMA node 1 | | NUMA node 2 |
+-------+-------+ +----------------+
|
+-------+----------+
| HBM |
| prox domain 2 |
| NUMA node 0 |
+------------------+This gives us one initiator (the processor) and two targets (the two memory ranges). Each of these three has its own ACPI proximity domain and associated Linux NUMA node. Note also that while there is a 1:1 mapping from each proximity domain to each NUMA node, the numbers don't necessarily match up. Additionally we can have extra NUMA nodes that don't map back to ACPI proximity domains.
The above configuration could also have the processor and one of the two memory ranges sharing a proximity domain and NUMA node, but for the purposes of the HMAT the two memory ranges will always need to be separated.
The overall goal of this series and of the HMAT is to allow users to identify memory using its performance characteristics. This can broadly be done in one of two ways:
Option 1: Provide the user with a way to map between proximity domains and NUMA nodes and a way to access the HMAT directly (probably via /sys/firmware/acpi/tables). Then, through possibly a library and a daemon, provide an API so that applications can either request information about memory ranges, or request memory allocations that meet a given set of performance characteristics.
Option 2: Provide the user with HMAT performance data directly in sysfs, allowing applications to directly access it without the need for the library and daemon.
The kernel work for option 1 is started by patches 1-3. These just surface the minimal amount of information in sysfs to allow userspace to map between proximity domains and NUMA nodes so that the raw data in the HMAT table can be understood.
Patches 4 and 5 enable option 2, adding performance information from the HMAT to sysfs. The second option is complicated by the amount of HMAT data that could be present in very large systems, so in this series we only surface performance information for local (initiator,target) pairings. The changelog for patch 5 discusses this in detail.
The naming collision between Jerome's "Heterogeneous Memory Management (HMM)" and this "Heterogeneous Memory (HMEM)" series is unfortunate, but I was trying to stick with the word "Heterogeneous" because of the naming of the ACPI 6.2 Heterogeneous Memory Attribute Table table. Suggestions for better naming are welcome.
==== Next steps ====
There is still a lot of work to be done on this series, but the overall goal of this RFC is to gather feedback on which of the two options we should pursue, or whether some third option is preferred. After that is done and we have a solid direction we can add support for ACPI hot add, test more complex configurations, etc.
So, for applications that need to differentiate between memory ranges based on their performance, what option would work best for you? Is the local (initiator,target) performance provided by patch 5 enough, or do you require performance information for all possible (initiator,target) pairings?
If option 1 looks best, do we have ideas on what the userspace API would look like?
What other things should we consider, or what needs do you have that aren't being addressed?
---
Changes from previous RFC (https://lwn.net/Articles/724562/):
- Allow multiple initiators to be local to a given memory target, as long as they all have the same performance characteristics. (Dan Williams)
- A few small fixes to the ACPI parsing to allow for configurations I hadn't previously considered.
Ross Zwisler (5):
acpi: add missing include in acpi_numa.h
acpi: HMAT support in acpi_parse_entries_array()
hmem: add heterogeneous memory sysfs support
sysfs: add sysfs_add_group_link()
hmem: add performance attributes
MAINTAINERS | 5 + drivers/acpi/Kconfig | 1 + drivers/acpi/Makefile | 1 + drivers/acpi/hmem/Kconfig | 7 + drivers/acpi/hmem/Makefile | 2 + drivers/acpi/hmem/core.c | 835 ++++++++++++++++++++++++++++++++++++ drivers/acpi/hmem/hmem.h | 64 +++ drivers/acpi/hmem/initiator.c | 61 +++ drivers/acpi/hmem/perf_attributes.c | 56 +++ drivers/acpi/hmem/target.c | 97 +++++ drivers/acpi/numa.c | 2 +- drivers/acpi/tables.c | 52 ++- fs/sysfs/group.c | 30 +- include/acpi/acpi_numa.h | 1 + include/linux/sysfs.h | 2 + 15 files changed, 1197 insertions(+), 19 deletions(-) create mode 100644 drivers/acpi/hmem/Kconfig create mode 100644 drivers/acpi/hmem/Makefile create mode 100644 drivers/acpi/hmem/core.c create mode 100644 drivers/acpi/hmem/hmem.h create mode 100644 drivers/acpi/hmem/initiator.c create mode 100644 drivers/acpi/hmem/perf_attributes.c create mode 100644 drivers/acpi/hmem/target.c
Signature · 1 line
2.9.4
RFC v2 1/5 acpi: add missing include in acpi_numa.h
Right now if a file includes acpi_numa.h and they don't happen to include linux/numa.h before it, they get the following warning:
./include/acpi/acpi_numa.h:9:5: warning: "MAX_NUMNODES" is not defined [-Wundef]
#if MAX_NUMNODES > 256
^~~~~~~~~~~~--- include/acpi/acpi_numa.h | 1 + 1 file changed, 1 insertion(+)
include/acpi/acpi_numa.h +1 -0
@@ -3,6 +3,7 @@#ifdef CONFIG_ACPI_NUMA #include <linux/kernel.h> +#include <linux/numa.h> /* Proximity bitmap length */ #if MAX_NUMNODES >256
Signature · 6 lines
2.9.4 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [RFC v2 1/5] acpi: add missing include in acpi_numa.h
Quoted 8 lines · Ross Zwisler
Right now if a file includes
acpi_numa.hand they don't happen to includelinux/numa.hbefore it, they get the following warning:
./include/acpi/acpi_numa.h:9:5: warning: "MAX_NUMNODES" is not defined [-Wundef]#if MAX_NUMNODES > 256 ^~~~~~~~~~~~Signed-off-by Ross Zwisler <ross.zwisler(a)linux.intel.com>
Quoted 23 lines
--- include/acpi/acpi_numa.h | 1 + 1 file changed, 1 insertion(+)include/acpi/acpi_numa.h +1
-1@@ -3,6 +3,7 @@#ifdef CONFIG_ACPI_NUMA #include <linux/kernel.h> +#include <linux/numa.h> /* Proximity bitmap length */ #if MAX_NUMNODES >256 --2.9.4
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC v2 2/5 acpi: HMAT support in acpi_parse_entries_array()
In reply to Ross ZwislerThe current implementation of acpi_parse_entries_array() assumes that each subtable has a standard ACPI subtable entry of type struct acpi_sutbable_header. This standard subtable header has a one byte length followed by a one byte type.
The HMAT subtables have to allow for a longer length so they have subtable headers of type struct acpi_hmat_structure which has a 2 byte type and a 4 byte length.
Enhance the subtable parsing in acpi_parse_entries_array() so that it can handle these new HMAT subtables.
--- drivers/acpi/numa.c | 2 +- drivers/acpi/tables.c | 52 ++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 12 deletions(-)
drivers/acpi/numa.c +1 -1
@@ -443,7 +443,7 @@ int __init acpi_numa_init(void)* So go over all cpu entries in SRAT to get apicid to node mapping. */ -/* SRAT: Static Resource Affinity Table */ +/* SRAT: System Resource Affinity Table */ if (!acpi_table_parse (ACPI_SIG_SRAT , acpi_parse_srat)) {struct acpi_subtable_proc srat_proc[3 ];
drivers/acpi/tables.c +41 -11
92 lines not on this page · raw message
Signature · 6 lines
2.9.4 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Rafael J. Wysocki
maintainerRe: [RFC v2 2/5] acpi: HMAT support in acpi_parse_entries_array()
Quoted 23 lines · Ross Zwisler
The current implementation of
acpi_parse_entries_array()assumes that each subtable has a standard ACPI subtable entry of type structacpi_sutbable_header. This standard subtable header has a one byte length followed by a one byte type.The HMAT subtables have to allow for a longer length so they have subtable headers of type struct
acpi_hmat_structurewhich has a 2 byte type and a 4 byte length.Enhance the subtable parsing in
acpi_parse_entries_array()so that it can handle these new HMAT subtables.Signed-off-by Ross Zwisler <ross.zwisler(a)linux.intel.com>--- drivers/acpi/numa.c | 2 +- drivers/acpi/tables.c | 52 ++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 12 deletions(-)drivers/acpi/numa.c +0
-0
drivers/acpi/numa.c int __init acpi_numa_init(void) · line 449
Quoted 8 lines
drivers/acpi/numa.c +1
-1@@ -443,7 +443,7 @@ int __init acpi_numa_init(void)* So go over all cpu entries in SRAT to get apicid to node mapping. */ -/* SRAT: Static Resource Affinity Table */ +/* SRAT: System Resource Affinity Table */ if (!acpi_table_parse (ACPI_SIG_SRAT , acpi_parse_srat)) {struct acpi_subtable_proc srat_proc[3 ];
This change is unrelated to the rest of the patch.
Maybe send it separately?
Quoted 6 lines
drivers/acpi/tables.c +0
-0@@ -218,6 +218,33 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) }
drivers/acpi/tables.c void acpi_table_print_madt_entry(struct acpi_subtable_header *header) · line 228
Quoted 10 lines
drivers/acpi/tables.c +8
-0} +static unsigned long __init +acpi_get_entry_type (char *id,void *entry) +{ +if (!strncmp (id,ACPI_SIG_HMAT ,4 )) +return ((struct acpi_hmat_structure *)entry)->type; +else +return ((struct acpi_subtable_header *)entry)->type; +}
I slightly prefer to use ? : in similar situations.
Quoted 75 lines
drivers/acpi/tables.c +32
-9+ +static unsigned long __init +acpi_get_entry_length (char *id,void *entry) +{ +if (!strncmp (id,ACPI_SIG_HMAT ,4 )) +return ((struct acpi_hmat_structure *)entry)->length; +else +return ((struct acpi_subtable_header *)entry)->length; +} + +static unsigned long __init +acpi_get_subtable_header_length (char *id) +{ +if (!strncmp (id,ACPI_SIG_HMAT ,4 )) +return sizeof (struct acpi_hmat_structure ); +else +return sizeof (struct acpi_subtable_header ); +} +/** * acpi_parse_entries_array - for each proc_num find a suitable subtable * @@ -242,10 +269,10 @@ acpi_parse_entries_array(char *id, unsigned long table_size, struct acpi_subtable_proc *proc, int proc_num, unsigned int max_entries) { - struct acpi_subtable_header *entry; -unsigned long table_end; + unsigned long table_end, subtable_header_length;int count =0 ;int errs =0 ; +void *entry;int i;if (acpi_disabled)@@ -263,19 +290,23 @@ acpi_parse_entries_array(char *id, unsigned long table_size, } table_end = (unsigned long )table_header + table_header->length; + subtable_header_length =acpi_get_subtable_header_length (id);/* Parse all entries looking for a match. */ - entry = (struct acpi_subtable_header *) - ((unsigned long )table_header + table_size); + entry = (void *)table_header + table_size; + +while (((unsigned long )entry) + subtable_header_length < table_end) { +unsigned long entry_type, entry_length; -while (((unsigned long )entry) +sizeof (struct acpi_subtable_header ) < - table_end) {if (max_entries && count >= max_entries)break ; + entry_type =acpi_get_entry_type (id, entry); + entry_length =acpi_get_entry_length (id, entry); +for (i =0 ; i < proc_num; i++) { -if (entry->type != proc[i].id) +if (entry_type != proc[i].id)continue ;if (!proc[i].handler || (!errs && proc[i].handler (entry, table_end))) {@@ -290,16 +321,15 @@ acpi_parse_entries_array(char *id, unsigned long table_size, count++;/* -* If entry->length is 0, break from this loop to avoid +* If entry_length is 0, break from this loop to avoid * infinite loop. */ -if (entry->length ==0 ) { +if (entry_length ==0 ) {pr_err ("[%4.4s:0x%02x] Invalid zero length\n" , id, proc->id);
drivers/acpi/tables.c acpi_parse_entries_array(char *id, unsigned long table_size,
Quoted 10 lines
drivers/acpi/tables.c +1
-3return -EINVAL ; } - entry = (struct acpi_subtable_header *) - ((unsigned long )entry + entry->length); + entry += entry_length; }if (max_entries && count > max_entries) { --
The rest is fine by me.
Thanks,
Rafael
Re: [RFC v2 2/5] acpi: HMAT support in acpi_parse_entries_array()
Quoted 36 lines · Rafael J. Wysocki
Quoted 23 lines · Ross Zwisler
The current implementation of
acpi_parse_entries_array()assumes that each subtable has a standard ACPI subtable entry of type structacpi_sutbable_header. This standard subtable header has a one byte length followed by a one byte type.The HMAT subtables have to allow for a longer length so they have subtable headers of type struct
acpi_hmat_structurewhich has a 2 byte type and a 4 byte length.Enhance the subtable parsing in
acpi_parse_entries_array()so that it can handle these new HMAT subtables.Signed-off-by Ross Zwisler <[email protected]>--- drivers/acpi/numa.c | 2 +- drivers/acpi/tables.c | 52 ++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 12 deletions(-)drivers/acpi/numa.c +0
-0drivers/acpi/numa.c int __init acpi_numa_init(void) · line 449
Quoted 8 lines
drivers/acpi/numa.c +1
-1@@ -443,7 +443,7 @@ int __init acpi_numa_init(void)* So go over all cpu entries in SRAT to get apicid to node mapping. */ -/* SRAT: Static Resource Affinity Table */ +/* SRAT: System Resource Affinity Table */ if (!acpi_table_parse (ACPI_SIG_SRAT , acpi_parse_srat)) {struct acpi_subtable_proc srat_proc[3 ];This change is unrelated to the rest of the patch.
Quoted 1 line
Maybe send it separately?
Sure, will do.
Quoted 8 lines
Quoted 8 lines
drivers/acpi/tables.c +0
-0@@ -218,6 +218,33 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) } }
Quoted 10 lines
drivers/acpi/tables.c void acpi_table_print_madt_entry(struct acpi_subtable_header *header) · line 228
Quoted 8 lines
drivers/acpi/tables.c +8
-0+static unsigned long __init +acpi_get_entry_type (char *id,void *entry) +{ +if (!strncmp (id,ACPI_SIG_HMAT ,4 )) +return ((struct acpi_hmat_structure *)entry)->type; +else +return ((struct acpi_subtable_header *)entry)->type; +}I slightly prefer to use ? : in similar situations.
Hmm..that becomes rather long, and seems complex for the already hard to read ?: operator? Let's see, this:
if (!strncmp(id, ACPI_SIG_HMAT, 4)) return ((struct acpi_hmat_structure *)entry)->type; else return ((struct acpi_subtable_header *)entry)->type;
becomes
return strncmp(id, ACPI_SIG_HMAT, 4)) ? ((struct acpi_subtable_header *)entry)->type : ((struct acpi_hmat_structure *)entry)->type;
Hmm...we only save one line, and I personally find that a lot harder to read, but that being said if you feel strongly about it I'll make the change.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Rafael J. Wysocki
maintainerRe: [RFC v2 2/5] acpi: HMAT support in acpi_parse_entries_array()
Quoted 20 lines · Ross Zwisler
Quoted 19 lines · Rafael J. Wysocki
Quoted 17 lines · Ross Zwisler
The current implementation of
acpi_parse_entries_array()assumes that each subtable has a standard ACPI subtable entry of type structacpi_sutbable_header. This standard subtable header has a one byte length followed by a one byte type.The HMAT subtables have to allow for a longer length so they have subtable headers of type struct
acpi_hmat_structurewhich has a 2 byte type and a 4 byte length.Enhance the subtable parsing in
acpi_parse_entries_array()so that it can handle these new HMAT subtables.Signed-off-by Ross Zwisler <[email protected]>--- drivers/acpi/numa.c | 2 +- drivers/acpi/tables.c | 52 ++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 12 deletions(-)
[cut]
Quoted 27 lines
Quoted 8 lines
Quoted 8 lines
drivers/acpi/tables.c +0
-0@@ -218,6 +218,33 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) } }Quoted 10 lines
drivers/acpi/tables.c void acpi_table_print_madt_entry(struct acpi_subtable_header *header) · line 228
Quoted 8 lines
drivers/acpi/tables.c +8
-0+static unsigned long __init +acpi_get_entry_type (char *id,void *entry) +{ +if (!strncmp (id,ACPI_SIG_HMAT ,4 )) +return ((struct acpi_hmat_structure *)entry)->type; +else +return ((struct acpi_subtable_header *)entry)->type; +}I slightly prefer to use ? : in similar situations.
Hmm..that becomes rather long, and seems complex for the already hard to read ?: operator? Let's see, this:
if (!strncmp(id, ACPI_SIG_HMAT, 4)) return ((struct acpi_hmat_structure *)entry)->type; else return ((struct acpi_subtable_header *)entry)->type;
Quoted 8 lines
becomes
return strncmp(id, ACPI_SIG_HMAT, 4)) ? ((struct acpi_subtable_header *)entry)->type : ((struct acpi_hmat_structure *)entry)->type;Hmm...we only save one line, and I personally find that a lot harder to read, but that being said if you feel strongly about it I'll make the change.
Well, I said "slightly". :-)
Thanks,
Rafael
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
RFC v2 3/5 hmem: add heterogeneous memory sysfs support
In reply to Ross ZwislerAdd a new sysfs subsystem, /sys/devices/system/hmem, which surfaces information about memory initiators and memory targets to the user. These initiators and targets are described by the ACPI SRAT and HMAT tables.
A "memory initiator" in this case is any device such as a CPU or a separate memory I/O device that can initiate a memory request. A "memory target" is a CPU-accessible physical address range.
The key piece of information surfaced by this patch is the mapping between the ACPI table "proximity domain" numbers, held in the "firmware_id" attribute, and Linux NUMA node numbers.
Initiators are found at /sys/devices/system/hmem/mem_initX, and the attributes for a given initiator look like this:
# tree mem_init0/ mem_init0/ ├── cpu0 -> ../../cpu/cpu0 ├── firmware_id ├── is_enabled ├── node0 -> ../../node/node0 ├── power │ ├── async │ ... ├── subsystem -> ../../../../bus/hmem └── uevent
Where "mem_init0" on my system represents the CPU acting as a memory initiator at NUMA node 0.
Targets are found at /sys/devices/system/hmem/mem_tgtX, and the attributes for a given target look like this:
# tree mem_tgt2/ mem_tgt2/ ├── firmware_id ├── is_cached ├── is_enabled ├── is_isolated ├── node2 -> ../../node/node2 ├── phys_addr_base ├── phys_length_bytes ├── power │ ├── async │ ... ├── subsystem -> ../../../../bus/hmem └── uevent
--- MAINTAINERS | 5 + drivers/acpi/Kconfig | 1 + drivers/acpi/Makefile | 1 + drivers/acpi/hmem/Kconfig | 7 + drivers/acpi/hmem/Makefile | 2 + drivers/acpi/hmem/core.c | 569 ++++++++++++++++++++++++++++++++++++++++++ drivers/acpi/hmem/hmem.h | 47 ++++ drivers/acpi/hmem/initiator.c | 61 +++++ drivers/acpi/hmem/target.c | 97 +++++++ 9 files changed, 790 insertions(+) create mode 100644 drivers/acpi/hmem/Kconfig create mode 100644 drivers/acpi/hmem/Makefile create mode 100644 drivers/acpi/hmem/core.c create mode 100644 drivers/acpi/hmem/hmem.h create mode 100644 drivers/acpi/hmem/initiator.c create mode 100644 drivers/acpi/hmem/target.c
MAINTAINERS +5 -0
@@ -6085,6 +6085,11 @@ S: Supported F: drivers/scsi/hisi_sas/ F: Documentation/devicetree/bindings/scsi/hisilicon-sas.txt +HMEM (ACPI HETEROGENEOUS MEMORY SUPPORT) +M: Ross Zwisler <[email protected]> +S: Supported +F: drivers/acpi/hmem/ + HOST AP DRIVER M: Jouni Malinen <[email protected]> L: [email protected]
drivers/acpi/Kconfig +1 -0
@@ -460,6 +460,7 @@ config ACPI_REDUCED_HARDWARE_ONLY If you are unsure what to do, do not enable this option. source "drivers/acpi/nfit/Kconfig" +source "drivers/acpi/hmem/Kconfig" source "drivers/acpi/apei/Kconfig" source "drivers/acpi/dptf/Kconfig"
drivers/acpi/Makefile +1 -0
@@ -72,6 +72,7 @@ obj-$(CONFIG_ACPI_PROCESSOR) += processor.o obj-$(CONFIG_ACPI) += container.o obj-$(CONFIG_ACPI_THERMAL) += thermal.o obj-$(CONFIG_ACPI_NFIT) += nfit/ +obj-$(CONFIG_ACPI_HMEM) += hmem/ obj-$(CONFIG_ACPI) += acpi_memhotplug.o obj-$(CONFIG_ACPI_HOTPLUG_IOAPIC) += ioapic.o obj-$(CONFIG_ACPI_BATTERY) += battery.o
drivers/acpi/hmem/Kconfig new file +7 -0
@@ -0,0 +1,7 @@ +config ACPI_HMEM + bool "ACPI Heterogeneous Memory Support" + depends on ACPI_NUMA + depends on SYSFS + help + Exports a sysfs representation of the ACPI Heterogeneous Memory + Attributes Table (HMAT).
drivers/acpi/hmem/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_ACPI_HMEM) := hmem.o +hmem-y := core.o initiator.o target.o
drivers/acpi/hmem/core.c new file +569 -0
569 lines not on this page · raw message
drivers/acpi/hmem/hmem.h new file +47 -0
47 lines not on this page · raw message
drivers/acpi/hmem/initiator.c new file +61 -0
61 lines not on this page · raw message
drivers/acpi/hmem/target.c new file +97 -0
97 lines not on this page · raw message
Signature · 6 lines
2.9.4 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [RFC v2 3/5] hmem: add heterogeneous memory sysfs support
On 07/06/2017 02:52 PM, Ross Zwisler wrote:
[...]
drivers/acpi/Makefile obj-$(CONFIG_ACPI_PROCESSOR) += processor.o · line 78
Quoted 12 lines
drivers/acpi/Makefile +1
-0@@ -72,6 +72,7 @@ obj-$(CONFIG_ACPI_PROCESSOR) += processor.o obj-$(CONFIG_ACPI) += container.o obj-$(CONFIG_ACPI_THERMAL) += thermal.o obj-$(CONFIG_ACPI_NFIT) += nfit/ +obj-$(CONFIG_ACPI_HMEM) += hmem/ obj-$(CONFIG_ACPI) += acpi_memhotplug.o obj-$(CONFIG_ACPI_HOTPLUG_IOAPIC) += ioapic.o obj-$(CONFIG_ACPI_BATTERY) += battery.o
Hi Ross,
Following are a series of suggestions, intended to clarify naming just enough so that, when Jerome's HMM patchset lands, we'll be able to tell the difference between the two types of Heterogeneous Memory.
drivers/acpi/hmem/Kconfig line 2
Quoted 8 lines
drivers/acpi/hmem/Kconfig new file +2
-0@@ -0,0 +1,7 @@ +config ACPI_HMEM + bool "ACPI Heterogeneous Memory Support"
How about:
bool "ACPI Heterogeneous Memory Attribute Table Support"
The idea here, and throughout, is that this type of Heterogeneous Memory support is all about "the Heterogeneous Memory that you found via ACPI's Heterogeneous Memory Attribute Table".
That's different from "the Heterogeneous Memory that you found when you installed a PCIe device that supports HMM". Or, at least it is different, until the day that someone decides to burn in support for an HMM device, into the ACPI tables. Seems unlikely, though. :) And even so, I think it would still work.
Quoted 19 lines
drivers/acpi/hmem/Kconfig new file +5
-0+ depends on ACPI_NUMA + depends on SYSFS + help + Exports a sysfs representation of the ACPI Heterogeneous Memory + Attributes Table (HMAT).drivers/acpi/hmem/Makefile new file +2
-0@@ -0,0 +1,2 @@ +obj-$(CONFIG_ACPI_HMEM) := hmem.o +hmem-y := core.o initiator.o target.odrivers/acpi/hmem/core.c new file +0
-0
drivers/acpi/hmem/core.c line 2
Quoted 2 lines
drivers/acpi/hmem/core.c new file +2
-0@@ -0,0 +1,569 @@ +/* +* Heterogeneous memory representation in sysfs
Heterogeneous memory, as discovered via ACPI's Heterogeneous Memory Attribute Table: representation in sysfs
Quoted 14 lines
drivers/acpi/hmem/core.c new file +14
-0+* +* Copyright (c) 2017, Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +*/ + +#include <acpi/acpi_numa.h>
[...]
drivers/acpi/hmem/hmem.h line 2
Quoted 8 lines
drivers/acpi/hmem/hmem.h new file +2
-0@@ -0,0 +1,47 @@ +/* +* Heterogeneous memory representation in sysfs
Heterogeneous memory, as discovered via ACPI's Heterogeneous Memory Attribute Table: representation in sysfs
Quoted 51 lines
drivers/acpi/hmem/hmem.h new file +45
-0+* +* Copyright (c) 2017, Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +*/ + +#ifndef _ACPI_HMEM_H_ +#define _ACPI_HMEM_H_ + +struct memory_initiator { +struct list_head list; +struct device dev; + +/* only one of the following three will be set */ +struct acpi_srat_cpu_affinity *cpu; +struct acpi_srat_x2apic_cpu_affinity *x2apic; +struct acpi_srat_gicc_affinity *gicc; + +int pxm; +bool is_registered; +}; +#define to_memory_initiator (d) container_of((d), struct memory_initiator, dev) + +struct memory_target { +struct list_head list; +struct device dev; +struct acpi_srat_mem_affinity *ma; +struct acpi_hmat_address_range *spa; +struct memory_initiator *local_init; + +bool is_cached; +bool is_registered; +}; +#define to_memory_target (d) container_of((d), struct memory_target, dev) + +extern const struct attribute_group *memory_initiator_attribute_groups[]; +extern const struct attribute_group *memory_target_attribute_groups[]; +#endif /* _ACPI_HMEM_H_ */ drivers/acpi/hmem/initiator.c new file +0
-0
drivers/acpi/hmem/initiator.c line 2
Quoted 2 lines
drivers/acpi/hmem/initiator.c new file +2
-0@@ -0,0 +1,61 @@ +/* +* Heterogeneous memory initiator sysfs attributes
HMAT (Heterogeneous Memory Attribute Table)-based memory: initiator sysfs attributes
Quoted 65 lines
drivers/acpi/hmem/initiator.c new file +59
-0+* +* Copyright (c) 2017, Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +*/ + +#include <acpi/acpi_numa.h> +#include <linux/acpi.h> +#include <linux/device.h> +#include <linux/sysfs.h> +#include "hmem.h" + +static ssize_t firmware_id_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct memory_initiator *init =to_memory_initiator (dev); + +return sprintf (buf,"%d\n" , init->pxm); +} +static DEVICE_ATTR_RO (firmware_id); + +static ssize_t is_enabled_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct memory_initiator *init =to_memory_initiator (dev); +int is_enabled; + +if (init->cpu) + is_enabled = !!(init->cpu->flags &ACPI_SRAT_CPU_ENABLED ); +else if (init->x2apic) + is_enabled = !!(init->x2apic->flags &ACPI_SRAT_CPU_ENABLED ); +else + is_enabled = !!(init->gicc->flags &ACPI_SRAT_GICC_ENABLED ); + +return sprintf (buf,"%d\n" , is_enabled); +} +static DEVICE_ATTR_RO (is_enabled); + +static struct attribute *memory_initiator_attributes[] = { + &dev_attr_firmware_id.attr, + &dev_attr_is_enabled.attr, +NULL , +}; + +static struct attribute_group memory_initiator_attribute_group = { + .attrs = memory_initiator_attributes, +}; + +const struct attribute_group *memory_initiator_attribute_groups[] = { + &memory_initiator_attribute_group, +NULL , +};drivers/acpi/hmem/target.c new file +0
-0
drivers/acpi/hmem/target.c line 2
Quoted 2 lines
drivers/acpi/hmem/target.c new file +2
-0@@ -0,0 +1,97 @@ +/* +* Heterogeneous memory target sysfs attributes
HMAT (Heterogeneous Memory Attribute Table)-based memory: target sysfs attributes
So, maybe those will help.
thanks
john h
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [RFC v2 3/5] hmem: add heterogeneous memory sysfs support
Quoted 17 lines · John Hubbard
On 07/06/2017 02:52 PM, Ross Zwisler wrote:
[...]drivers/acpi/Makefile obj-$(CONFIG_ACPI_PROCESSOR) += processor.o · line 78
Quoted 12 lines
drivers/acpi/Makefile +1
-0@@ -72,6 +72,7 @@ obj-$(CONFIG_ACPI_PROCESSOR) += processor.o obj-$(CONFIG_ACPI) += container.o obj-$(CONFIG_ACPI_THERMAL) += thermal.o obj-$(CONFIG_ACPI_NFIT) += nfit/ +obj-$(CONFIG_ACPI_HMEM) += hmem/ obj-$(CONFIG_ACPI) += acpi_memhotplug.o obj-$(CONFIG_ACPI_HOTPLUG_IOAPIC) += ioapic.o obj-$(CONFIG_ACPI_BATTERY) += battery.oHi Ross,
Quoted 3 lines
Following are a series of suggestions, intended to clarify naming just enough so that, when Jerome's HMM patchset lands, we'll be able to tell the difference between the two types of Heterogeneous Memory.
Sure, these all seem sane to me, thanks. I'll fix this up in v3.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
RFC v2 4/5 sysfs: add sysfs_add_group_link()
In reply to Ross ZwislerThe current __compat_only_sysfs_link_entry_to_kobj() code allows us to create symbolic links in sysfs to groups or attributes. Something like:
/sys/.../entry1/groupA -> /sys/.../entry2/groupA
This patch extends this functionality with a new sysfs_add_group_link() call that allows the link to have a different name than the group or attribute, so:
/sys/.../entry1/link_name -> /sys/.../entry2/groupA
__compat_only_sysfs_link_entry_to_kobj() now just calls sysfs_add_group_link(), passing in the same name for both the group/attribute and for the link name.
This is needed by the ACPI HMAT enabling work because we want to have a group of performance attributes that live in a memory target. This group represents the performance between a memory target and its local inititator. In the target the attribute group is named "local_init":
# tree mem_tgt2/local_init/ mem_tgt2/local_init/ ├── mem_init0 -> ../../mem_init0 ├── mem_tgt2 -> ../../mem_tgt2 ├── read_bw_MBps ├── read_lat_nsec ├── write_bw_MBps └── write_lat_nsec
We then want to link to this attribute group from the initiator, but change the name of the link to "mem_tgtX" since we're now looking at it from the initiator's perspective, and because a given initiator can have multiple local memory targets:
# ls -l mem_init0/mem_tgt2 lrwxrwxrwx. 1 root root 0 Jul 5 14:38 mem_init0/mem_tgt2 -> ../mem_tgt2/local_init
--- fs/sysfs/group.c | 30 +++++++++++++++++++++++------- include/linux/sysfs.h | 2 ++ 2 files changed, 25 insertions(+), 7 deletions(-)
fs/sysfs/group.c +23 -7
@@ -367,15 +367,15 @@ void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name,EXPORT_SYMBOL_GPL (sysfs_remove_link_from_group);/** -* __compat_only_sysfs_link_entry_to_kobj - add a symlink to a kobject pointing -* to a group or an attribute +* sysfs_add_group_link - add a symlink to a kobject pointing to a group or +* an attribute * @kobj: The kobject containing the group. * @target_kobj: The target kobject. * @target_name: The name of the target group or attribute. +* @link_name: The name of the link to the target group or attribute. */ -int __compat_only_sysfs_link_entry_to_kobj (struct kobject *kobj, -struct kobject *target_kobj, -const char *target_name) +int sysfs_add_group_link (struct kobject *kobj,struct kobject *target_kobj, +const char *target_name,const char *link_name) {struct kernfs_node *target;struct kernfs_node *entry;
@@ -400,12 +400,28 @@ int __compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,return -ENOENT ; } - link =kernfs_create_link (kobj->sd, target_name, entry); + link =kernfs_create_link (kobj->sd, link_name, entry);if (IS_ERR (link) &&PTR_ERR (link) == -EEXIST ) -sysfs_warn_dup (kobj->sd, target_name); +sysfs_warn_dup (kobj->sd, link_name);kernfs_put (entry);kernfs_put (target);return IS_ERR (link) ?PTR_ERR (link) :0 ; } +EXPORT_SYMBOL_GPL (sysfs_add_group_link); + +/** +* __compat_only_sysfs_link_entry_to_kobj - add a symlink to a kobject pointing +* to a group or an attribute +* @kobj: The kobject containing the group. +* @target_kobj: The target kobject. +* @target_name: The name of the target group or attribute. +*/ +int __compat_only_sysfs_link_entry_to_kobj (struct kobject *kobj, +struct kobject *target_kobj, +const char *target_name) +{ +return sysfs_add_group_link (kobj, target_kobj, target_name, + target_name); +}EXPORT_SYMBOL_GPL (__compat_only_sysfs_link_entry_to_kobj);
include/linux/sysfs.h +2 -0
@@ -278,6 +278,8 @@ int sysfs_add_link_to_group(struct kobject *kobj, const char *group_name, struct kobject *target, const char *link_name);void sysfs_remove_link_from_group (struct kobject *kobj,const char *group_name,const char *link_name); +int sysfs_add_group_link (struct kobject *kobj,struct kobject *target_kobj, +const char *target_name,const char *link_name);int __compat_only_sysfs_link_entry_to_kobj (struct kobject *kobj,struct kobject *target_kobj,const char *target_name);
Signature · 6 lines
2.9.4 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
RFC v2 5/5 hmem: add performance attributes
In reply to Ross ZwislerAdd performance information found in the HMAT to the sysfs representation. This information lives as an attribute group named "local_init" in the memory target:
# tree mem_tgt2/ mem_tgt2/ ├── firmware_id ├── is_cached ├── is_enabled ├── is_isolated ├── local_init │ ├── mem_init0 -> ../../mem_init0 │ ├── mem_init1 -> ../../mem_init1 │ ├── mem_tgt2 -> ../../mem_tgt2 │ ├── read_bw_MBps │ ├── read_lat_nsec │ ├── write_bw_MBps │ └── write_lat_nsec ├── node2 -> ../../node/node2 ├── phys_addr_base ├── phys_length_bytes ├── power │ ├── async │ ... ├── subsystem -> ../../../../bus/hmem └── uevent
This attribute group surfaces latency and bandwidth performance for a memory target and its local initiators. For example:
# grep . mem_tgt2/local_init/* 2>/dev/null mem_tgt2/local_init/read_bw_MBps:30720 mem_tgt2/local_init/read_lat_nsec:100 mem_tgt2/local_init/write_bw_MBps:30720 mem_tgt2/local_init/write_lat_nsec:100
The local initiators have a symlink to the performance information which lives in the target's attribute group:
# ls -l mem_init0/mem_tgt2 lrwxrwxrwx. 1 root root 0 Jul 5 14:38 mem_init0/mem_tgt2 -> ../mem_tgt2/local_init
We create performance attribute groups only for local (initiator,target) pairings, where the the first local initiator for a given target is defined by the "Processor Proximity Domain" field in the HMAT's Memory Subsystem Address Range Structure table. After we have one local initiator we scan the performance data to link to any other "local" initiators with the same local performance to a given memory target.
A given target only has one set of local performance values, so each target will have at most one "local_init" attribute group, though that group can contain links to multiple initiators that all have local performance. A given memory initiator may have multiple local memory targets, so multiple "mem_tgtX" links may exist for a given initiator.
If a given memory target is cached we give performance numbers only for the media itself, and rely on the "is_cached" attribute to represent the fact that there is a caching layer.
The fact that we only expose a subset of the performance information presented in the HMAT via sysfs as a compromise, driven by fact that those usages will be the highest performing and because to represent all possible paths could cause an unmanageable explosion of sysfs entries.
If we dump everything from the HMAT into sysfs we end up with O(num_targets * num_initiators * num_caching_levels) attributes. Each of these attributes only takes up 2 bytes in a System Locality Latency and Bandwidth Information Structure, but if we have to create a directory entry for each it becomes much more expensive.
For example, very large systems today can have on the order of thousands of NUMA nodes. Say we have a system which used to have 1,000 NUMA nodes that each had both a CPU and local memory. The HMAT allows us to separate the CPUs and memory into separate NUMA nodes, so we can end up with 1,000 CPU initiator NUMA nodes and 1,000 memory target NUMA nodes. If we represented the performance information for each possible CPU/memory pair in sysfs we would end up with 1,000,000 attribute groups.
This is a lot to pass in a set of packed data tables, but I think we'll break sysfs if we try to create millions of attributes, regardless of how we nest them in a directory hierarchy.
By only representing performance information for local (initiator,target) pairings, we reduce the number of sysfs entries to O(num_targets).
--- drivers/acpi/hmem/Makefile | 2 +- drivers/acpi/hmem/core.c | 268 +++++++++++++++++++++++++++++++++++- drivers/acpi/hmem/hmem.h | 17 +++ drivers/acpi/hmem/perf_attributes.c | 56 ++++++++ 4 files changed, 341 insertions(+), 2 deletions(-) create mode 100644 drivers/acpi/hmem/perf_attributes.c
drivers/acpi/hmem/Makefile +1 -1
@@ -1,2 +1,2 @@ obj-$(CONFIG_ACPI_HMEM) := hmem.o -hmem-y := core.o initiator.o target.o +hmem-y := core.o initiator.o target.o perf_attributes.o
drivers/acpi/hmem/core.c +267 -1
321 lines not on this page · raw message
drivers/acpi/hmem/hmem.h +17 -0
@@ -16,6 +16,11 @@ #ifndef _ACPI_HMEM_H_ #define _ACPI_HMEM_H_ +enum hmem_attr_type { + LATENCY, + BANDWIDTH, +}; + struct memory_initiator { struct list_head list; struct device dev;
@@ -39,9 +44,21 @@ struct memory_target {bool is_cached;bool is_registered; + bool has_perf_attributes; };#define to_memory_target (d) container_of((d), struct memory_target, dev) +struct memory_locality { +struct list_head list; +struct acpi_hmat_locality *hmat_loc; +}; +extern const struct attribute_group *memory_initiator_attribute_groups[];extern const struct attribute_group *memory_target_attribute_groups[]; +extern struct attribute *performance_attributes[]; + +extern struct list_head locality_list; + +int hmem_local_attribute (struct device *tgt_dev,int direction, +enum hmem_attr_type type);#endif /* _ACPI_HMEM_H_ */
drivers/acpi/hmem/perf_attributes.c new file +56 -0
56 lines not on this page · raw message
Signature · 6 lines
2.9.4 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
On Thu, Jul 06, 2017 at 03:52:28PM -0600, Ross Zwisler wrote:
[...]
Quoted 9 lines
==== Next steps ====
There is still a lot of work to be done on this series, but the overall goal of this RFC is to gather feedback on which of the two options we should pursue, or whether some third option is preferred. After that is done and we have a solid direction we can add support for ACPI hot add, test more complex configurations, etc.
Quoted 5 lines
So, for applications that need to differentiate between memory ranges based on their performance, what option would work best for you? Is the local (initiator,target) performance provided by patch 5 enough, or do you require performance information for all possible (initiator,target) pairings?
Am i right in assuming that HBM or any faster memory will be relatively small (1GB - 8GB maybe 16GB ?) and of fix amount (ie size will depend on the exact CPU model you have) ?
If so i am wondering if we should not restrict NUMA placement policy for such node to vma only. Forbid any policy that would prefer those node globally at thread/process level. This would avoid wide thread policy to exhaust this smaller pool of memory.
Drawback of doing so would be that existing applications would not benefit from it. So workload where is acceptable to exhaust such memory wouldn't benefit until their application are updated.
This is definitly not something impacting this patchset. I am just thinking about this at large and i believe that NUMA might need to evolve slightly to better handle memory hierarchy.
Cheers,
Jérôme
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 9 lines · Jerome Glisse
Quoted 5 lines
So, for applications that need to differentiate between memory ranges based on their performance, what option would work best for you? Is the local (initiator,target) performance provided by patch 5 enough, or do you require performance information for all possible (initiator,target) pairings?
Am i right in assuming that HBM or any faster memory will be relatively small (1GB - 8GB maybe 16GB ?) and of fix amount (ie size will depend on the exact CPU model you have) ?
For HBM, that's certainly consistent with the Xeon Phi MCDRAM.
But, please remember that this patch set is for fast memory *and* slow memory (vs. plain DRAM).
Quoted 4 lines
If so i am wondering if we should not restrict NUMA placement policy for such node to vma only. Forbid any policy that would prefer those node globally at thread/process level. This would avoid wide thread policy to exhaust this smaller pool of memory.
You would like to take the NUMA APIs and bifurcate them? Make some of them able to work on this memory, and others not? So, set_mempolicy() would work if you passed it one of these "special" nodes with MPOL_F_ADDR, but would fail otherwise?
Quoted 3 lines
Drawback of doing so would be that existing applications would not benefit from it. So workload where is acceptable to exhaust such memory wouldn't benefit until their application are updated.
I think the guys running 40-year-old fortran binaries might not be so keen on this restriction. I bet there are a pretty substantial number of folks out there that would love to get new hardware and just do:
numactl --membind=fast-node ./old-binary
If I were working for a hardware company, I'd sure like to just be able to sell somebody some fancy new hardware and have their existing software "just work" with a minimal wrapper.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
On 07/06/2017 02:52 PM, Ross Zwisler wrote:
[...]
Quoted 7 lines
The naming collision between Jerome's "Heterogeneous Memory Management (HMM)" and this "Heterogeneous Memory (HMEM)" series is unfortunate, but I was trying to stick with the word "Heterogeneous" because of the naming of the ACPI 6.2 Heterogeneous Memory Attribute Table table. Suggestions for better naming are welcome.
Hi Ross,
Say, most of the places (file names, function and variable names, and even print statements) where this patchset uses hmem or HMEM, it really seems to mean, the Heterogeneous Memory Attribute Table. That's not *always* true, but given that it's a pretty severe naming conflict, how about just changing:
hmem --> hmat
HMEM --> HMAT
...everywhere? Then you still have Heterogeneous Memory in the name, but there is enough lexical distance (is that a thing? haha) between HMM and HMAT to keep us all sane. :)
With or without the above suggestion, there are a few places (Kconfig, comments, prints) where we can more easily make it clear that HMM != HMEM (or HMAT), so for those I can just comment on them separately in the individual patches.
thanks,
john h
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 24 lines · John Hubbard
On 07/06/2017 02:52 PM, Ross Zwisler wrote:
[...]Quoted 7 lines
The naming collision between Jerome's "Heterogeneous Memory Management (HMM)" and this "Heterogeneous Memory (HMEM)" series is unfortunate, but I was trying to stick with the word "Heterogeneous" because of the naming of the ACPI 6.2 Heterogeneous Memory Attribute Table table. Suggestions for better naming are welcome.
Hi Ross,
Say, most of the places (file names, function and variable names, and even print statements) where this patchset uses hmem or HMEM, it really seems to mean, the Heterogeneous Memory Attribute Table. That's not *always* true, but given that it's a pretty severe naming conflict, how about just changing:
hmem --> hmat
HMEM --> HMAT...everywhere? Then you still have Heterogeneous Memory in the name, but there is enough lexical distance (is that a thing? haha) between HMM and HMAT to keep us all sane. :)
Quoted 6 lines
With or without the above suggestion, there are a few places (
Kconfig, comments, prints) where we can more easily make it clear that HMM != HMEM (or HMAT), so for those I can just comment on them separately in the individual patches.thanks,
john h
Hi John,
Sure, that change makes sense to me. I had initially tried to make this enabling more generic so that other, non-ACPI systems could use the same sysfs representation even if they got their performance numbers from some other source, but while implementing it pretty quickly became very tightly tied to the ACPI HMAT.
- Ross
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 21 lines · Ross Zwisler
==== Quick Summary ====
Platforms in the very near future will have multiple types of memory attached to a single CPU. These disparate memory ranges will have some characteristics in common, such as CPU cache coherence, but they can have wide ranges of performance both in terms of latency and bandwidth.
For example, consider a system that contains persistent memory, standard DDR memory and High Bandwidth Memory (HBM), all attached to the same CPU. There could potentially be an order of magnitude or more difference in performance between the slowest and fastest memory attached to that CPU.
With the current Linux code NUMA nodes are CPU-centric, so all the memory attached to a given CPU will be lumped into the same NUMA node. This makes it very difficult for userspace applications to understand the performance of different memory ranges on a given CPU.
We solve this issue by providing userspace with performance information on individual memory ranges. This performance information is exposed via sysfs:
Quoted 5 lines
# grep . mem_tgt2/* mem_tgt2/local_init/* 2>/dev/null mem_tgt2/firmware_id:1 mem_tgt2/is_cached:0 mem_tgt2/is_enabled:1 mem_tgt2/is_isolated:0
Could you please explain these charactersitics, are they in the patches to follow?
Quoted 7 lines
mem_tgt2/phys_addr_base:0x0
mem_tgt2/phys_length_bytes:0x800000000
mem_tgt2/local_init/read_bw_MBps:30720
mem_tgt2/local_init/read_lat_nsec:100
mem_tgt2/local_init/write_bw_MBps:30720
mem_tgt2/local_init/write_lat_nsec:100
How to these numbers compare to normal system memory?
Quoted 41 lines
This allows applications to easily find the memory that they want to use. We expect that the existing NUMA APIs will be enhanced to use this new information so that applications can continue to use them to select their desired memory.
This series is built upon acpica-1705:
https://github.com/zetalog/linux/commits/acpica-1705
And you can find a working tree here:
https://git.kernel.org/pub/scm/linux/kernel/git/zwisler/linux.git/log/?h=hmem_sysfs
==== Lots of Details ====
This patch set is only concerned with CPU-addressable memory types, not on-device memory like what we have with Jerome Glisse's HMM series:
https://lwn.net/Articles/726691/
This patch set works by enabling the new Heterogeneous Memory Attribute Table (HMAT) table, newly defined in ACPI 6.2. One major conceptual change in ACPI 6.2 related to this work is that proximity domains no longer need to contain a processor. We can now have memory-only proximity domains, which means that we can now have memory-only Linux NUMA nodes.
Here is an example configuration where we have a single processor, one range of regular memory and one range of HBM:
+---------------+ +----------------+ | Processor | | Memory | | prox domain 0 +---+ prox domain 1 | | NUMA node 1 | | NUMA node 2 | +-------+-------+ +----------------+ | +-------+----------+ | HBM | | prox domain 2 | | NUMA node 0 | +------------------+
Quoted 6 lines
This gives us one initiator (the processor) and two targets (the two memory ranges). Each of these three has its own ACPI proximity domain and associated Linux NUMA node. Note also that while there is a 1:1 mapping from each proximity domain to each NUMA node, the numbers don't necessarily match up. Additionally we can have extra NUMA nodes that don't map back to ACPI proximity domains.
Could you expand on proximity domains, are they the same as node distance or is this ACPI terminology for something more?
Quoted 32 lines
The above configuration could also have the processor and one of the two memory ranges sharing a proximity domain and NUMA node, but for the purposes of the HMAT the two memory ranges will always need to be separated.
The overall goal of this series and of the HMAT is to allow users to identify memory using its performance characteristics. This can broadly be done in one of two ways:
Option 1: Provide the user with a way to map between proximity domains and NUMA nodes and a way to access the HMAT directly (probably via
/sys/firmware/acpi/tables). Then, through possibly a library and a daemon, provide an API so that applications can either request information about memory ranges, or request memory allocations that meet a given set of performance characteristics.Option 2: Provide the user with HMAT performance data directly in sysfs, allowing applications to directly access it without the need for the library and daemon.
The kernel work for option 1 is started by patches 1-3. These just surface the minimal amount of information in sysfs to allow userspace to map between proximity domains and NUMA nodes so that the raw data in the HMAT table can be understood.
Patches 4 and 5 enable option 2, adding performance information from the HMAT to sysfs. The second option is complicated by the amount of HMAT data that could be present in very large systems, so in this series we only surface performance information for local (initiator,target) pairings. The changelog for patch 5 discusses this in detail.
Quoted 6 lines
The naming collision between Jerome's "Heterogeneous Memory Management (HMM)" and this "Heterogeneous Memory (HMEM)" series is unfortunate, but I was trying to stick with the word "Heterogeneous" because of the naming of the ACPI 6.2 Heterogeneous Memory Attribute Table table. Suggestions for better naming are welcome.
Balbir Singh.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 3 lines · Balbir Singh
Quoted 2 lines · Ross Zwisler
# grep . mem_tgt2/* mem_tgt2/local_init/* 2>/dev/null mem_tgt2/firmware_id:1
This is here for folks that know their platform and know exactly the firmware ID (PXM in ACPI parlance) of a given piece of memory. Without this, we might be stuck with requiring the NUMA node ID that the kernel uses to be bound 1:1 with the firmware ID.
Quoted 1 line
Quoted 1 line
mem_tgt2/is_cached:0
This tells whether the memory is cached by some other memory. MCDRAM is an example of this. It can be used as a high-bandwidth cache in front of the lower-bandwidth DRAM.
This is referred to as "Memory Side Cache Information Structure" in the ACPI spec: www.uefi.org/sites/default/files/resources/ACPI_6_2.pdf
Quoted 2 lines
Quoted 2 lines
mem_tgt2/is_enabled:1
mem_tgt2/is_isolated:0
This one is described in detail in the ACPI spec. It's called "Reservation hint" in there.
Quoted 8 lines
Quoted 6 lines
mem_tgt2/phys_addr_base:0x0
mem_tgt2/phys_length_bytes:0x800000000
mem_tgt2/local_init/read_bw_MBps:30720
mem_tgt2/local_init/read_lat_nsec:100
mem_tgt2/local_init/write_bw_MBps:30720
mem_tgt2/local_init/write_lat_nsec:100How to these numbers compare to normal system memory?
They're made up in this instance. But, it's safe to expect 10x swings in bandwidth in latency, both up and down.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 22 lines · Balbir Singh
Quoted 21 lines · Ross Zwisler
==== Quick Summary ====
Platforms in the very near future will have multiple types of memory attached to a single CPU. These disparate memory ranges will have some characteristics in common, such as CPU cache coherence, but they can have wide ranges of performance both in terms of latency and bandwidth.
For example, consider a system that contains persistent memory, standard DDR memory and High Bandwidth Memory (HBM), all attached to the same CPU. There could potentially be an order of magnitude or more difference in performance between the slowest and fastest memory attached to that CPU.
With the current Linux code NUMA nodes are CPU-centric, so all the memory attached to a given CPU will be lumped into the same NUMA node. This makes it very difficult for userspace applications to understand the performance of different memory ranges on a given CPU.
We solve this issue by providing userspace with performance information on individual memory ranges. This performance information is exposed via sysfs:
Quoted 8 lines
Quoted 5 lines
# grep . mem_tgt2/* mem_tgt2/local_init/* 2>/dev/null mem_tgt2/firmware_id:1 mem_tgt2/is_cached:0 mem_tgt2/is_enabled:1 mem_tgt2/is_isolated:0Could you please explain these charactersitics, are they in the patches to follow?
Yea, sorry, these do need more explanation. These values are derived from the ACPI SRAT/HMAT tables:
Quoted 1 line
Quoted 1 line
mem_tgt2/firmware_id:1
This is the proximity domain, as defined in the SRAT and HMAT. Basically every ACPI proximity domain will end up being a unique NUMA node in Linux, but the numbers may get reordered and Linux can create extra NUMA nodes that don't map back to ACPI proximity domains. So, this value is needed if anyone ever wants to look at the ACPI HMAT and SRAT tables directly and make sense of how they map to NUMA nodes in Linux.
Quoted 1 line
Quoted 1 line
mem_tgt2/is_cached:0
The HMAT provides lots of detailed information when a memory region has caching layers. For each layer of memory caching it has the ability to provide latency and bandwidth information for both reads and writes, information about the caching associativity (direct mapped, something more complex), the writeback policy (WB, WT), the cache line size, etc.
For simplicity this sysfs interface doesn't expose that level of detail to the user, and this flag just lets the user know whether the memory region they are looking at has caching layers or not. Right now the additional details, if desired, can be gathered by looking at the raw tables.
Quoted 1 line
Quoted 1 line
mem_tgt2/is_enabled:1
Tells whether the memory region is enabled, as defined by the flags in the SRAT. Actually, though, in this version of the patch series we don't create entries for CPUs or memory regions that aren't enabled, so this isn't needed. I'll remove for v3.
Quoted 1 line
Quoted 1 line
mem_tgt2/is_isolated:0
This surfaces a flag in the HMAT's Memory Subsystem Address Range Structure:
Bit [2]: Reservation hint—if set to 1, it is recommended that the operating system avoid placing allocations in this region if it cannot relocate (e.g. OS core memory management structures, OS core executable). Any allocations placed here should be able to be relocated (e.g. disk cache) if the memory is needed for another purpose.
Adding kernel support for this hint (i.e. actually reserving the memory region during boot so it isn't used by the kernel or userspace, and is fully available for explicit allocation) is part of the future work that we'd do in follow-on patch series.
Quoted 8 lines
Quoted 6 lines
mem_tgt2/phys_addr_base:0x0
mem_tgt2/phys_length_bytes:0x800000000
mem_tgt2/local_init/read_bw_MBps:30720
mem_tgt2/local_init/read_lat_nsec:100
mem_tgt2/local_init/write_bw_MBps:30720
mem_tgt2/local_init/write_lat_nsec:100How to these numbers compare to normal system memory?
These are garbage numbers that I made up in my hacked-up QEMU target. :)
Quoted 48 lines
Quoted 41 lines
This allows applications to easily find the memory that they want to use. We expect that the existing NUMA APIs will be enhanced to use this new information so that applications can continue to use them to select their desired memory.
This series is built upon acpica-1705:
https://github.com/zetalog/linux/commits/acpica-1705
And you can find a working tree here:
https://git.kernel.org/pub/scm/linux/kernel/git/zwisler/linux.git/log/?h=hmem_sysfs
==== Lots of Details ====
This patch set is only concerned with CPU-addressable memory types, not on-device memory like what we have with Jerome Glisse's HMM series:
https://lwn.net/Articles/726691/
This patch set works by enabling the new Heterogeneous Memory Attribute Table (HMAT) table, newly defined in ACPI 6.2. One major conceptual change in ACPI 6.2 related to this work is that proximity domains no longer need to contain a processor. We can now have memory-only proximity domains, which means that we can now have memory-only Linux NUMA nodes.
Here is an example configuration where we have a single processor, one range of regular memory and one range of HBM:
+---------------+ +----------------+ | Processor | | Memory | | prox domain 0 +---+ prox domain 1 | | NUMA node 1 | | NUMA node 2 | +-------+-------+ +----------------+ | +-------+----------+ | HBM | | prox domain 2 | | NUMA node 0 | +------------------+Quoted 6 lines
This gives us one initiator (the processor) and two targets (the two memory ranges). Each of these three has its own ACPI proximity domain and associated Linux NUMA node. Note also that while there is a 1:1 mapping from each proximity domain to each NUMA node, the numbers don't necessarily match up. Additionally we can have extra NUMA nodes that don't map back to ACPI proximity domains.
Quoted 2 lines
Could you expand on proximity domains, are they the same as node distance or is this ACPI terminology for something more?
I think I answered this above in my explanation of the "firmware_id" field, but please let me know if you have any more questions. Basically, a proximity domain is an ACPI concept that is very similar to a Linux NUMA node, and every ACPI proximity domain generates and can be mapped to a unique Linux NUMA node.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 97 lines · Ross Zwisler
==== Quick Summary ====
Platforms in the very near future will have multiple types of memory attached to a single CPU. These disparate memory ranges will have some characteristics in common, such as CPU cache coherence, but they can have wide ranges of performance both in terms of latency and bandwidth.
For example, consider a system that contains persistent memory, standard DDR memory and High Bandwidth Memory (HBM), all attached to the same CPU. There could potentially be an order of magnitude or more difference in performance between the slowest and fastest memory attached to that CPU.
With the current Linux code NUMA nodes are CPU-centric, so all the memory attached to a given CPU will be lumped into the same NUMA node. This makes it very difficult for userspace applications to understand the performance of different memory ranges on a given CPU.
We solve this issue by providing userspace with performance information on individual memory ranges. This performance information is exposed via sysfs:
# grep . mem_tgt2/* mem_tgt2/local_init/* 2>/dev/null mem_tgt2/firmware_id:1 mem_tgt2/is_cached:0 mem_tgt2/is_enabled:1 mem_tgt2/is_isolated:0 mem_tgt2/phys_addr_base:0x0 mem_tgt2/phys_length_bytes:0x800000000 mem_tgt2/local_init/read_bw_MBps:30720 mem_tgt2/local_init/read_lat_nsec:100 mem_tgt2/local_init/write_bw_MBps:30720 mem_tgt2/local_init/write_lat_nsec:100This allows applications to easily find the memory that they want to use. We expect that the existing NUMA APIs will be enhanced to use this new information so that applications can continue to use them to select their desired memory.
This series is built upon acpica-1705:
https://github.com/zetalog/linux/commits/acpica-1705
And you can find a working tree here:
https://git.kernel.org/pub/scm/linux/kernel/git/zwisler/linux.git/log/?h=hmem_sysfs
==== Lots of Details ====
This patch set is only concerned with CPU-addressable memory types, not on-device memory like what we have with Jerome Glisse's HMM series:
https://lwn.net/Articles/726691/
This patch set works by enabling the new Heterogeneous Memory Attribute Table (HMAT) table, newly defined in ACPI 6.2. One major conceptual change in ACPI 6.2 related to this work is that proximity domains no longer need to contain a processor. We can now have memory-only proximity domains, which means that we can now have memory-only Linux NUMA nodes.
Here is an example configuration where we have a single processor, one range of regular memory and one range of HBM:
+---------------+ +----------------+ | Processor | | Memory | | prox domain 0 +---+ prox domain 1 | | NUMA node 1 | | NUMA node 2 | +-------+-------+ +----------------+ | +-------+----------+ | HBM | | prox domain 2 | | NUMA node 0 | +------------------+This gives us one initiator (the processor) and two targets (the two memory ranges). Each of these three has its own ACPI proximity domain and associated Linux NUMA node. Note also that while there is a 1:1 mapping from each proximity domain to each NUMA node, the numbers don't necessarily match up. Additionally we can have extra NUMA nodes that don't map back to ACPI proximity domains.
The above configuration could also have the processor and one of the two memory ranges sharing a proximity domain and NUMA node, but for the purposes of the HMAT the two memory ranges will always need to be separated.
The overall goal of this series and of the HMAT is to allow users to identify memory using its performance characteristics. This can broadly be done in one of two ways:
Option 1: Provide the user with a way to map between proximity domains and NUMA nodes and a way to access the HMAT directly (probably via
/sys/firmware/acpi/tables). Then, through possibly a library and a daemon, provide an API so that applications can either request information about memory ranges, or request memory allocations that meet a given set of performance characteristics.
Quoted 4 lines
Option 2: Provide the user with HMAT performance data directly in sysfs, allowing applications to directly access it without the need for the library and daemon.
Is it possible to do the memory allocation automatically by the kernel and transparent to users? It sounds like unreasonable that most users should aware this detail memory topology.
--
Thanks,
Bob Liu
Quoted 4 lines
The kernel work for option 1 is started by patches 1-3. These just surface the minimal amount of information in sysfs to allow userspace to map between proximity domains and NUMA nodes so that the raw data in the HMAT table can be understood.
Quoted 7 lines · Bob Liu
Quoted 4 lines
Option 2: Provide the user with HMAT performance data directly in sysfs, allowing applications to directly access it without the need for the library and daemon.
Is it possible to do the memory allocation automatically by the kernel and transparent to users? It sounds like unreasonable that most users should aware this detail memory topology.
It's possible, but I'm not sure this is something we automatically want to see added to the kernel.
I look at it like NUMA. We have lots of details available about how things are connected. But, "most users" are totally unaware of this. We give them decent default policies and the ones that need more can do so with the NUMA APIs.
These patches provide the framework to help users/apps who *do* care and want to make intelligent, topology-aware decisions.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm