Re: [RFC v2 3/5] hmem: add heterogeneous memory sysfs support
On Thu, Jul 06, 2017 at 10:53:39PM -0700, John Hubbard wrote: > On 07/06/2017 02:52 PM, Ross Zwisler wrote: > [...] > > diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile > > index b1aacfc..31e3f20 100644 > > --- a/drivers/acpi/Makefile > > +++ b/drivers/acpi/Makefile > > @@ -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. Sure, these all seem sane to me, thanks. I'll fix this up in v3.
Re: [RFC v2 3/5] hmem: add heterogeneous memory sysfs support
On 07/06/2017 02:52 PM, Ross Zwisler wrote: [...] > diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile > index b1aacfc..31e3f20 100644 > --- a/drivers/acpi/Makefile > +++ b/drivers/acpi/Makefile > @@ -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. > diff --git a/drivers/acpi/hmem/Kconfig b/drivers/acpi/hmem/Kconfig > new file mode 100644 > index 000..09282be > --- /dev/null > +++ b/drivers/acpi/hmem/Kconfig > @@ -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. > + depends on ACPI_NUMA > + depends on SYSFS > + help > + Exports a sysfs representation of the ACPI Heterogeneous Memory > + Attributes Table (HMAT). > diff --git a/drivers/acpi/hmem/Makefile b/drivers/acpi/hmem/Makefile > new file mode 100644 > index 000..d2aa546 > --- /dev/null > +++ b/drivers/acpi/hmem/Makefile > @@ -0,0 +1,2 @@ > +obj-$(CONFIG_ACPI_HMEM) := hmem.o > +hmem-y := core.o initiator.o target.o > diff --git a/drivers/acpi/hmem/core.c b/drivers/acpi/hmem/core.c > new file mode 100644 > index 000..f7638db > --- /dev/null > +++ b/drivers/acpi/hmem/core.c > @@ -0,0 +1,569 @@ > +/* > + * Heterogeneous memory representation in sysfs Heterogeneous memory, as discovered via ACPI's Heterogeneous Memory Attribute Table: representation in sysfs > + * > + * 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 [...] > diff --git a/drivers/acpi/hmem/hmem.h b/drivers/acpi/hmem/hmem.h > new file mode 100644 > index 000..38ff540 > --- /dev/null > +++ b/drivers/acpi/hmem/hmem.h > @@ -0,0 +1,47 @@ > +/* > + * Heterogeneous memory representation in sysfs Heterogeneous memory, as discovered via ACPI's Heterogeneous Memory Attribute Table: representation in sysfs > + * > + * 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_ */ > diff --git a/drivers/acpi/hmem/initiator.c b/drivers/acpi/hmem/i
[RFC v2 3/5] hmem: add heterogeneous memory sysfs support
Add 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 Signed-off-by: Ross Zwisler --- 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 diff --git a/MAINTAINERS b/MAINTAINERS index 053c3bd..554b833 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -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 +S: Supported +F: drivers/acpi/hmem/ + HOST AP DRIVER M: Jouni Malinen L: linux-wirel...@vger.kernel.org diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 1ce52f8..44dd97f 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -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" diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index b1aacfc..31e3f20 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -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 diff --git a/drivers/acpi/hmem/Kconfig b/drivers/acpi/hmem/Kconfig new file mode 100644 index 000..09282be --- /dev/null +++ b/drivers/acpi/hmem/Kconfig @@ -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). diff --git a/drivers/acpi/hmem/Makefile b/drivers/acpi/hmem/Makefile new file mode 100644 index 000..d2aa546 --- /dev/null +++ b/drivers/acpi/hmem/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_ACPI_HMEM) := hmem.o +hmem-y := core.o initiator.o target.o diff --git a/drivers/acpi/hmem/core.c b/drivers/acpi/hmem/core.c new file mode 100644 index 000..f7638db --- /dev/null +++ b/drivers/acpi/hmem/core.c @@ -0,0 +1,569 @@ +/* + * Heterogeneous memory representation in sysfs + * + * 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 +#include +#include +#include