Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp499235ybb; Wed, 25 Mar 2020 04:11:19 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsX5Nwzq5iuqY64+laBLBOr4xq87EQ4TEYCBT402KFyzH87rqBGMs03jSDhszJ0dZvKn4h5 X-Received: by 2002:aca:37c3:: with SMTP id e186mr2085759oia.155.1585134679409; Wed, 25 Mar 2020 04:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585134679; cv=none; d=google.com; s=arc-20160816; b=czka6B9VpLlAEcy3iabgDEYaGlV+wFFvU01pSfKuUKbLOUtTDVZAn7n3oCWZXz6uO7 Hjzr7Qv/OvUtjXcVWGlLHx4Og3fKKqwiwL5I3uDGriCJ0jw7DlXutYGeNc9mq0y9lxjY 3MnEwubbLnfAoFdSJXzTyP4OPdFpmCgg/GuHdkle00AKmadLzzoRxMsFbKKj6c0N3T9v N4Hts/H/3OKipwdpGjEiBEC1T5n8H/oUFIHHGGgZm4PJM1Int73zTUii9BXLLpITMmFe JSGlRorwRV24VmchtWJMJlaQ4RgcddwY50Jfbxr2tO4IhO2CAfjw1cyn+3Tlb5LNpqci 81Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wDkZ1rZEhoGNt7FkxFmt5VG/KHsbc/xAaI8XrHHImCc=; b=zPNSffuO8q7FVf80mJw9HkPI7eeB3SaNiVXmJ534T0F7lyyBRU+NDfvewNGDbIOCer GBEI8F/D1zcoyWPKx8/u1VsaoY6c7zs2Oec3rJjwh+SQWvT+HqNCSOGusz4yK9Og6iBp Vj43iwgRLjfa0bK2Iq2TnE/mLsifJie7Gf+NA+9cY0jl48dOgB8gW+GgwYATPHwCfOL4 jcYapyGoaxfuLJcI7+YjrBGTndGVw5YLML7FfI2kzr3g8N9lg59P4002xHNxVT1/T1z0 jIBzQnZWVftn/l7wboK4idKFbQyFutl/XyRlI5+TVqd7SeqtqgDFRDxykCBkBUkyPLdW VZ9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LyTvEz1H; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6si4227114oto.92.2020.03.25.04.11.06; Wed, 25 Mar 2020 04:11:19 -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=@kernel.org header.s=default header.b=LyTvEz1H; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727046AbgCYLKq (ORCPT + 99 others); Wed, 25 Mar 2020 07:10:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:55142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726262AbgCYLKq (ORCPT ); Wed, 25 Mar 2020 07:10:46 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6B8A320714; Wed, 25 Mar 2020 11:10:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585134645; bh=+oORi421RJ9kNbff15hBXNngbNzPdLiPd7dkY8ZfVx8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LyTvEz1HkRScEIks3fLO6NxSaEHP3bTnF7g8lw6/Sw86AIEcst4Vj/SPWtZuK/NmF k0ZGmVK6WItq5DMMpc4X2IZd9Mq49bJLWf0Xffqqi6SYMw1UYEfFYhdKwRRgO6bl8X /zcT5VGeyoe/A3wFwuVze9CnAzNQ3nI/5MVCmnjU= Date: Wed, 25 Mar 2020 11:10:40 +0000 From: Will Deacon To: Dan Williams Cc: linux-acpi@vger.kernel.org, Jonathan Cameron , Brice Goglin , Ard Biesheuvel , "Rafael J. Wysocki" , Jeff Moyer , Catalin Marinas , peterz@infradead.org, dave.hansen@linux.intel.com, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, x86@kernel.org, joao.m.martins@oracle.com Subject: Re: [PATCH v2 6/6] ACPI: HMAT: Attach a device for each soft-reserved range Message-ID: <20200325111039.GA32109@willie-the-truck> References: <158489354353.1457606.8327903161927980740.stgit@dwillia2-desk3.amr.corp.intel.com> <158489357825.1457606.17352509511987748598.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <158489357825.1457606.17352509511987748598.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 22, 2020 at 09:12:58AM -0700, 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/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c > index 4decf1659700..00fba21eaec0 100644 > --- a/arch/arm64/mm/numa.c > +++ b/arch/arm64/mm/numa.c > @@ -468,3 +468,16 @@ int memory_add_physaddr_to_nid(u64 addr) > pr_warn("Unknown node for memory at 0x%llx, assuming node 0\n", addr); > return 0; > } > + > +/* > + * device-dax instance registrations want a valid target-node in case > + * they are ever onlined as memory (see hmem_register_device()). > + * > + * TODO: consult cached numa info > + */ > +int phys_to_target_node(phys_addr_t addr) > +{ > + pr_warn_once("Unknown target node for memory at 0x%llx, assuming node 0\n", > + addr); > + return 0; > +} Could you implement a generic version of this by iterating over the nodes with for_each_{,online_}node() and checking for intersection with node_{start,end}_pfn()? Will