Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp5269409ybb; Tue, 24 Mar 2020 14:07:39 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvDY0VTINPEJrXF3dyO97gpJDdnozWDhIyd25yrPWX5L8fTSHHuSbXzpZteh8VXq6s9+E+z X-Received: by 2002:a9d:a51:: with SMTP id 75mr44925otg.112.1585084059454; Tue, 24 Mar 2020 14:07:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585084059; cv=none; d=google.com; s=arc-20160816; b=EINHxZOp+JuCQ5D8vjivayLqLaigqnAxmh56FHrpGZC9SsdgnZlbqlaaBF/TEpMKK8 4zth5zQ82qzmMFKrtNWkBvt3z5gGmwksuK7qmBSeRNzTb8/wPNh3IWsoiabZR5LPVfSE Z1hXQDUn4neJ6eahIhDln8cxbO2xAAQWKDoTfItgZpsiB9y3Nvz6dNVzOafR6cct/bTW OwEtydTg9UwIkQoE4kSqb5oSXkp/bJP9VU1xCrqWD89Tg5lDuQuKm/De+qN74v8uZKhG Mr1UUd8Op/GQ1sD8G+8iVV4oJU8vOZnVc0S8Fakua5bXDni376QN14W7AR/L7S/d6+Pm NgBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=upl2vPR8qJWq0P3veNASLF2x9fKiteylDIqdLD2DSM4=; b=E6dhoibH+7QXv0igeRDkTV0BGIqz+AtVQpjLBVXtJx+DIlJrGsKJHTRHspIwDNfSXg 9uXvs0Ip9Fbx7/ZaMrTLEF+kug+QyD0t9FAuBqTlunaPxROwlBIpIZntnyL18InjTWIH iEVMWhAFp19WBazkKi0puoTWroUTMtvAtVvqu3OF488CRqEs7ThDoXlR6Xev2EPOuAG5 9u77aCv/DKYXxL23gP1ApftaclTMpZ3gwGwBWiYsq6PIf6n/3FsZJxldZdCoA7PDLs1r M5qPgk1539JTzItWEUYT7Mk0gPfNI7MCotoggC1bU53QYGjQuW2LhGBN2J3IepA+Zjhg cGkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=ptpy7rs5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b187si7317151oif.221.2020.03.24.14.07.25; Tue, 24 Mar 2020 14:07:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=ptpy7rs5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728049AbgCXVHF (ORCPT + 99 others); Tue, 24 Mar 2020 17:07:05 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:38926 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726673AbgCXVHE (ORCPT ); Tue, 24 Mar 2020 17:07:04 -0400 Received: by mail-oi1-f195.google.com with SMTP id d63so39212oig.6 for ; Tue, 24 Mar 2020 14:07:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=upl2vPR8qJWq0P3veNASLF2x9fKiteylDIqdLD2DSM4=; b=ptpy7rs5mB6uI4afsGX5d/xHC6v7jmwoP62AcU7hxqL8oy2KD1VBx8vnzGN1Z/YTu9 eQ2RSUwJ8nwlwFEdQaeBQML+Iairvcj1+qqNWJRo8jkY6k8tyFkYrc6Y/cP8aez8cl6K hwoPHaoibOwKdsohj+wZ+OwahZk2LbNJbzWMs9Ydj33jMr+HkVS/L5JZWugDUnywZrBP KTt9kpWf6BW8M03A4JP8SwzRz5ntebA8IUbxg+tqsU6koNGEeAi3UMY/3t7BT2/9+2EC MxHJuiEganu/DEyTeou3e77JmKbYjRNYEMiesXx+7UTQk6Li+EpZgi/Qw+zSXEQRCbVl hoHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=upl2vPR8qJWq0P3veNASLF2x9fKiteylDIqdLD2DSM4=; b=ekmwTadWQxzQsAo/BwZKU8NL2sdYGtUxc3ZsUU5B3gvruBHog7j+tg/UWegSbBhEL2 zjfFNDctwX/+y8rybu3Z0h9Fqse61woJnpjsv/RKOH8ztYOsHKNyVX+FQtYB7bvakNr4 I05tmOKO/HNvkjOnFifOzBuRr676SY7Gz9OxBupujkzjG0c5SUdo+uNXYF0O/JLqAL68 OCzTuFU2hH10uv7Kfepkz1mzXrW0ty1L8PcFUUiW7PVZrhNPCgOyk9ln4Qvswp8r9roF wIJbLjXmJGeqls1J8oIoyZAJUkfhEP+UJ+TyidT4MuvD+PrAyI8I4VZ5aPzMENM44V21 rPYA== X-Gm-Message-State: ANhLgQ0R5LRmxKyWMWmlDZiK/v8x7jt9FxMDT5HEjA5X50dG2DBhMj8Y hXbW/GcJnO2Nj5AncdaTCg4Yj/UbnSn0F5qjzOqOcQ== X-Received: by 2002:a05:6808:b0f:: with SMTP id s15mr151586oij.105.1585084023289; Tue, 24 Mar 2020 14:07:03 -0700 (PDT) MIME-Version: 1.0 References: <158489354353.1457606.8327903161927980740.stgit@dwillia2-desk3.amr.corp.intel.com> <158489357825.1457606.17352509511987748598.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: From: Dan Williams Date: Tue, 24 Mar 2020 14:06:52 -0700 Message-ID: Subject: Re: [PATCH v2 6/6] ACPI: HMAT: Attach a device for each soft-reserved range To: Joao Martins Cc: Linux ACPI , Jonathan Cameron , Brice Goglin , Ard Biesheuvel , "Rafael J. Wysocki" , Catalin Marinas , Will Deacon , Peter Zijlstra , Dave Hansen , linux-nvdimm , Linux Kernel Mailing List , X86 ML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 24, 2020 at 12:41 PM Joao Martins wrote: > > On 3/22/20 4:12 PM, Dan Williams wrote: > > The hmem enabling in commit 'cf8741ac57ed ("ACPI: NUMA: HMAT: Register > > "soft reserved" memory as an "hmem" device")' only registered ranges to > > the hmem driver for each soft-reservation that also appeared in the > > HMAT. While this is meant to encourage platform firmware to "do the > > right thing" and publish an HMAT, the corollary is that platforms that > > fail to publish an accurate HMAT will strand memory from Linux usage. > > Additionally, the "efi_fake_mem" kernel command line option enabling > > will strand memory by default without an HMAT. > > > > Arrange for "soft reserved" memory that goes unclaimed by HMAT entries > > to be published as raw resource ranges for the hmem driver to consume. > > > > Include a module parameter to disable either this fallback behavior, or > > the hmat enabling from creating hmem devices. The module parameter > > requires the hmem device enabling to have unique name in the module > > namespace: "device_hmem". > > > > Rather than mark this x86-only, include an interim phys_to_target_node() > > implementation for arm64. > > > > Cc: Jonathan Cameron > > Cc: Brice Goglin > > Cc: Ard Biesheuvel > > Cc: "Rafael J. Wysocki" > > Cc: Jeff Moyer > > Cc: Catalin Marinas > > Cc: Will Deacon > > Signed-off-by: Dan Williams > > --- > > arch/arm64/mm/numa.c | 13 +++++++++++++ > > drivers/dax/Kconfig | 1 + > > drivers/dax/hmem/Makefile | 3 ++- > > drivers/dax/hmem/device.c | 33 +++++++++++++++++++++++++++++++++ > > 4 files changed, 49 insertions(+), 1 deletion(-) > > > > [...] > > > diff --git a/drivers/dax/hmem/device.c b/drivers/dax/hmem/device.c > > index 99bc15a8b031..f9c5fa8b1880 100644 > > --- a/drivers/dax/hmem/device.c > > +++ b/drivers/dax/hmem/device.c > > @@ -4,6 +4,9 @@ > > #include > > #include > > > > +static bool nohmem; > > +module_param_named(disable, nohmem, bool, 0444); > > + > > void hmem_register_device(int target_nid, struct resource *r) > > { > > /* define a clean / non-busy resource for the platform device */ > > @@ -16,6 +19,9 @@ void hmem_register_device(int target_nid, struct resource *r) > > struct memregion_info info; > > int rc, id; > > > > + if (nohmem) > > + return; > > + > > rc = region_intersects(res.start, resource_size(&res), IORESOURCE_MEM, > > IORES_DESC_SOFT_RESERVED); > > if (rc != REGION_INTERSECTS) > > @@ -62,3 +68,30 @@ void hmem_register_device(int target_nid, struct resource *r) > > out_pdev: > > memregion_free(id); > > } > > + > > +static __init int hmem_register_one(struct resource *res, void *data) > > +{ > > + /* > > + * If the resource is not a top-level resource it was already > > + * assigned to a device by the HMAT parsing. > > + */ > > + if (res->parent != &iomem_resource) > > + return 0; > > + > > + hmem_register_device(phys_to_target_node(res->start), res); > > + > > + return 0; > > Should we add an error returning value to hmem_register_device() perhaps this > ought to be reflected in hmem_register_one(). > > > +} > > + > > +static __init int hmem_init(void) > > +{ > > + walk_iomem_res_desc(IORES_DESC_SOFT_RESERVED, > > + IORESOURCE_MEM, 0, -1, NULL, hmem_register_one); > > + return 0; > > +} > > + > > (...) and then perhaps here returning in the initcall if any of the resources > failed hmem registration? Except that hmem_register_one() is a stop-gap to collect soft-reserved ranges that were not already registered, and it's not an error to find already registered devices. However, I do think it's a good idea to log registrations that failed for other reasons.