From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: <linux-kernel@vger.kernel.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Len Brown <lenb@kernel.org>, Keith Busch <keith.busch@intel.com>,
<vishal.l.verma@intel.com>, <x86@kernel.org>,
<linux-mm@kvack.org>, <linux-nvdimm@lists.01.org>
Subject: Re: [RFC PATCH 4/5] acpi/hmat: Register special purpose memory as a device
Date: Fri, 5 Apr 2019 12:18:57 +0100 [thread overview]
Message-ID: <20190405121857.0000718a@huawei.com> (raw)
In-Reply-To: <155440492988.3190322.4475460421334178449.stgit@dwillia2-desk3.amr.corp.intel.com>
On Thu, 4 Apr 2019 12:08:49 -0700
Dan Williams <dan.j.williams@intel.com> wrote:
> Memory that has been tagged EFI_SPECIAL_PURPOSE, and has performance
> properties described by the ACPI HMAT is expected to have an application
> specific consumer.
>
> Those consumers may want 100% of the memory capacity to be reserved from
> any usage by the kernel. By default, with this enabling, a platform
> device is created to represent this differentiated resource.
>
> A follow on change arranges for device-dax to claim these devices by
> default and provide an mmap interface for the target application.
> However, if the administrator prefers that some or all of the special
> purpose memory is made available to the core-mm the device-dax hotplug
> facility can be used to online the memory with its own numa node.
>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Keith Busch <keith.busch@intel.com>
> Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Hi Dan,
Great to see you getting this discussion going so fast and in
general the approach makes sense to me.
I'm a little confused why HMAT has anything to do with this.
SPM is defined either via the attribute in SRAT SPA entries,
EF_MEMORY_SP or via the EFI memory map.
Whether it is in HMAT or not isn't all that relevant.
Back in the days of the reservation hint (so before yesterday :)
it was relevant obviously but that's no longer true.
So what am I missing?
Thanks,
Jonathan
> ---
> drivers/acpi/hmat/Kconfig | 1 +
> drivers/acpi/hmat/hmat.c | 63 +++++++++++++++++++++++++++++++++++++++++++++
> include/linux/memregion.h | 3 ++
> 3 files changed, 67 insertions(+)
>
> diff --git a/drivers/acpi/hmat/Kconfig b/drivers/acpi/hmat/Kconfig
> index 95a29964dbea..4fcf76e8aa1d 100644
> --- a/drivers/acpi/hmat/Kconfig
> +++ b/drivers/acpi/hmat/Kconfig
> @@ -3,6 +3,7 @@ config ACPI_HMAT
> bool "ACPI Heterogeneous Memory Attribute Table Support"
> depends on ACPI_NUMA
> select HMEM_REPORTING
> + select MEMREGION
> help
> If set, this option has the kernel parse and report the
> platform's ACPI HMAT (Heterogeneous Memory Attributes Table),
> diff --git a/drivers/acpi/hmat/hmat.c b/drivers/acpi/hmat/hmat.c
> index e7ae44c8d359..482360004ea0 100644
> --- a/drivers/acpi/hmat/hmat.c
> +++ b/drivers/acpi/hmat/hmat.c
> @@ -13,6 +13,9 @@
> #include <linux/device.h>
> #include <linux/init.h>
> #include <linux/list.h>
> +#include <linux/mm.h>
> +#include <linux/memregion.h>
> +#include <linux/platform_device.h>
> #include <linux/list_sort.h>
> #include <linux/node.h>
> #include <linux/sysfs.h>
> @@ -612,6 +615,65 @@ static __init void hmat_register_target_perf(struct memory_target *target)
> node_set_perf_attrs(mem_nid, &target->hmem_attrs, 0);
> }
>
> +static __init void hmat_register_target_device(struct memory_target *target)
> +{
> + struct memregion_info info;
> + struct resource res = {
> + .start = target->start,
> + .end = target->start + target->size - 1,
> + .flags = IORESOURCE_MEM,
> + .desc = IORES_DESC_APPLICATION_RESERVED,
> + };
> + struct platform_device *pdev;
> + int rc, id;
> +
> + if (region_intersects(target->start, target->size, IORESOURCE_MEM,
> + IORES_DESC_APPLICATION_RESERVED)
> + != REGION_INTERSECTS)
> + return;
> +
> + id = memregion_alloc();
> + if (id < 0) {
> + pr_err("acpi/hmat: memregion allocation failure for %pr\n", &res);
> + return;
> + }
> +
> + pdev = platform_device_alloc("hmem", id);
> + if (!pdev) {
> + pr_err("acpi/hmat: hmem device allocation failure for %pr\n", &res);
> + goto out_pdev;
> + }
> +
> + pdev->dev.numa_node = acpi_map_pxm_to_online_node(target->processor_pxm);
> + info = (struct memregion_info) {
> + .target_node = acpi_map_pxm_to_node(target->memory_pxm),
> + };
> + rc = platform_device_add_data(pdev, &info, sizeof(info));
> + if (rc < 0) {
> + pr_err("acpi/hmat: hmem memregion_info allocation failure for %pr\n", &res);
> + goto out_pdev;
> + }
> +
> + rc = platform_device_add_resources(pdev, &res, 1);
> + if (rc < 0) {
> + pr_err("acpi/hmat: hmem resource allocation failure for %pr\n", &res);
> + goto out_resource;
> + }
> +
> + rc = platform_device_add(pdev);
> + if (rc < 0) {
> + dev_err(&pdev->dev, "acpi/hmat: device add failed for %pr\n", &res);
> + goto out_resource;
> + }
> +
> + return;
> +
> +out_resource:
> + put_device(&pdev->dev);
> +out_pdev:
> + memregion_free(id);
> +}
> +
> static __init void hmat_register_targets(void)
> {
> struct memory_target *target;
> @@ -619,6 +681,7 @@ static __init void hmat_register_targets(void)
> list_for_each_entry(target, &targets, node) {
> hmat_register_target_initiators(target);
> hmat_register_target_perf(target);
> + hmat_register_target_device(target);
> }
> }
>
> diff --git a/include/linux/memregion.h b/include/linux/memregion.h
> index 99fa47793b49..5de2ac7fcf5e 100644
> --- a/include/linux/memregion.h
> +++ b/include/linux/memregion.h
> @@ -1,6 +1,9 @@
> // SPDX-License-Identifier: GPL-2.0
> #ifndef _MEMREGION_H_
> #define _MEMREGION_H_
> +struct memregion_info {
> + int target_node;
> +};
> int memregion_alloc(void);
> void memregion_free(int id);
> #endif /* _MEMREGION_H_ */
>
next prev parent reply other threads:[~2019-04-05 11:19 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-04 19:08 [RFC PATCH 0/5] EFI Special Purpose Memory Support Dan Williams
2019-04-04 19:08 ` [RFC PATCH 1/5] efi: Detect UEFI 2.8 Special Purpose Memory Dan Williams
2019-04-06 4:21 ` Ard Biesheuvel
2019-04-09 16:43 ` Dan Williams
2019-04-09 17:21 ` Ard Biesheuvel
2019-04-10 2:10 ` Dan Williams
2019-04-12 20:43 ` Ard Biesheuvel
2019-04-12 21:18 ` Dan Williams
2019-04-15 11:43 ` Enrico Weigelt, metux IT consult
2019-04-04 19:08 ` [RFC PATCH 2/5] lib/memregion: Uplevel the pmem "region" ida to a global allocator Dan Williams
2019-04-04 19:32 ` Matthew Wilcox
2019-04-04 21:02 ` Dan Williams
2019-04-04 19:08 ` [RFC PATCH 3/5] acpi/hmat: Track target address ranges Dan Williams
2019-04-04 20:58 ` Keith Busch
2019-04-04 20:58 ` Dan Williams
2019-04-04 19:08 ` [RFC PATCH 4/5] acpi/hmat: Register special purpose memory as a device Dan Williams
2019-04-05 11:18 ` Jonathan Cameron [this message]
2019-04-05 15:43 ` Dan Williams
2019-04-05 16:23 ` Jonathan Cameron
2019-04-05 16:56 ` Dan Williams
2019-04-05 17:39 ` Jonathan Cameron
2019-04-09 12:13 ` Christoph Hellwig
2019-04-09 14:49 ` Dan Williams
2019-04-04 19:08 ` [RFC PATCH 5/5] device-dax: Add a driver for "hmem" devices Dan Williams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190405121857.0000718a@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=dan.j.williams@intel.com \
--cc=keith.busch@intel.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nvdimm@lists.01.org \
--cc=rjw@rjwysocki.net \
--cc=vishal.l.verma@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).