From patchwork Thu May 30 22:59:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10969341 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6EED214C0 for ; Thu, 30 May 2019 23:13:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EE1A28BE3 for ; Thu, 30 May 2019 23:13:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 538FA28BEE; Thu, 30 May 2019 23:13:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2E4828BED for ; Thu, 30 May 2019 23:13:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D57636B0269; Thu, 30 May 2019 19:13:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D07B46B0281; Thu, 30 May 2019 19:13:17 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF6DC6B0282; Thu, 30 May 2019 19:13:17 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 8476B6B0269 for ; Thu, 30 May 2019 19:13:17 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id g5so5710178pfb.20 for ; Thu, 30 May 2019 16:13:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=sQXI2+z5AuqKuGAGnDh+LIj6CV4drR2itzY1Fbq1HsE=; b=FZjZtR2Bei7yjvvtykP9uHvf8ujRgy71OSKbu03LvLboRU8jkdzemuCoW7qWvLOzCM dd6OucsCdB7om5Iz+41rvCaFytGNznaGHa5vmN6yeFdLLtpwaXil5mb2CPOwFSUfDM7D 1TBbCC9IBR4jxTnqXLLZRO3KtFMItrn+2aoTFlXOzQ2i75kmSzqZeh6qsj3sbhEaQduD x8vrMFRLBs9l3r9MJ8Cn6WtNSs2HNlemyS9fv5k0YRU2iOjzA/JGiqcbPKbvUBxm2fA1 k8tKkRUud5aKTBzmxT6jwYZTM235xHaZCghrTlRfzp3kZia7PmWkRnvqUTNDe9JDLIL/ nTBA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APjAAAVmbefD3jthVIo5pZfOwBBLYLrJLkCz9G1RLjsGilVPrf1spSV3 8Nv5Ink3iuax0FLQbLhvEQg6zltnSq93TgaNjpgspxTmAhJvPfA0m8xPtf69DLUeJdyd/lo3mnF R3deL+UjBxFUtSLT/SUYOkCFAXz748c7wR/g28HmvQ2qvgj2ulJq7cJPn93UmVDrIxg== X-Received: by 2002:a17:902:b490:: with SMTP id y16mr5852910plr.161.1559257997101; Thu, 30 May 2019 16:13:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqx816+0z+1qk+g7vvDuJUA5LgWeXocAbWGgIIHJhlShyw+lib8YZJffxTPhQ/JWzj4Qpr65 X-Received: by 2002:a17:902:b490:: with SMTP id y16mr5852864plr.161.1559257996410; Thu, 30 May 2019 16:13:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559257996; cv=none; d=google.com; s=arc-20160816; b=VViRQRBIl5LvimDLjKYU8MbfXiEA4dzAxtd1nubaYzG1Xq24Y3ZAr9yPOdO/A6C6Hg 1smEtKoOeNRk4WOdY+AM3Xj5JY4bC+iF4Icld3R8jZp81D6Ddzgu8d7gP2npNOMsc0e0 lOin73qQoW36CSQGZkrTKo4nx4FXGl5D2Z3A6vgJw2eEfIJ2znWN9Frccxt31Q6kSEps aTeX5/Roc7aBfIw8IS63Y0zytNP6hMYRjNgg5B3jzrzXCTVWiGP5/Vy0XsRawZglGA6G tppfGunq0k6llgVGO0ZGuMKBVibvDpv1zr/ezftL7EZ+MaVjwX1pRGejC5suNSZYBdRj DbDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject; bh=sQXI2+z5AuqKuGAGnDh+LIj6CV4drR2itzY1Fbq1HsE=; b=TLE+QlQ6WH5mcPPcr9j8GYJqeGXIVj4/cG9SQTQoHOx3d09SSvihAGZAwBD8hr3mBT O3+Neg3ntT1Au1XAkdftcIP1D5TvfRxoa4U2Mby0/ZYolkrjWv9oVeeo7k9S2fZ0s9ok e3R/DmPovnr656jH1UtxbVAguns87I8Nl/HuEFLBh5zQHBOi+ggDyls6m1Vc6pIgHfEq Vzu6H5U9p3G3xOTXOsy1V82l8XbiRTLjMXHoeISF124IGRndd3DF/hE1CItHjHIm/Fw4 fMoUjL5aHGW+yf5S7J/mTlyQwoT1wLJv1UEZHWW2d8ZQERsgeMeHH/QuEnS4Tkv+pCiC atEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga17.intel.com (mga17.intel.com. [192.55.52.151]) by mx.google.com with ESMTPS id k1si3552810pjw.56.2019.05.30.16.13.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 16:13:16 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.151 as permitted sender) client-ip=192.55.52.151; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 May 2019 16:13:15 -0700 X-ExtLoop1: 1 Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga004.jf.intel.com with ESMTP; 30 May 2019 16:13:15 -0700 Subject: [PATCH v2 1/8] acpi: Drop drivers/acpi/hmat/ directory From: Dan Williams To: linux-efi@vger.kernel.org Cc: Len Brown , Keith Busch , "Rafael J. Wysocki" , vishal.l.verma@intel.com, ard.biesheuvel@linaro.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-nvdimm@lists.01.org Date: Thu, 30 May 2019 15:59:27 -0700 Message-ID: <155925716783.3775979.13301455166290564145.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <155925716254.3775979.16716824941364738117.stgit@dwillia2-desk3.amr.corp.intel.com> References: <155925716254.3775979.16716824941364738117.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP As a single source file object there is no need for the hmat enabling to have its own directory. Cc: Len Brown Cc: Keith Busch Cc: "Rafael J. Wysocki" Signed-off-by: Dan Williams --- drivers/acpi/Kconfig | 12 +++++++++++- drivers/acpi/Makefile | 2 +- drivers/acpi/hmat.c | 0 drivers/acpi/hmat/Kconfig | 11 ----------- drivers/acpi/hmat/Makefile | 2 -- 5 files changed, 12 insertions(+), 15 deletions(-) rename drivers/acpi/{hmat/hmat.c => hmat.c} (100%) delete mode 100644 drivers/acpi/hmat/Kconfig delete mode 100644 drivers/acpi/hmat/Makefile diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 283ee94224c6..ec8691e4152f 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -475,7 +475,17 @@ 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/hmat/Kconfig" + +config ACPI_HMAT + bool "ACPI Heterogeneous Memory Attribute Table Support" + depends on ACPI_NUMA + select HMEM_REPORTING + help + If set, this option has the kernel parse and report the + platform's ACPI HMAT (Heterogeneous Memory Attributes Table), + register memory initiators with their targets, and export + performance attributes through the node's sysfs device if + provided. source "drivers/acpi/apei/Kconfig" source "drivers/acpi/dptf/Kconfig" diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 5d361e4e3405..fc89686498dd 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -80,7 +80,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_HMAT) += hmat/ +obj-$(CONFIG_ACPI_HMAT) += hmat.o obj-$(CONFIG_ACPI) += acpi_memhotplug.o obj-$(CONFIG_ACPI_HOTPLUG_IOAPIC) += ioapic.o obj-$(CONFIG_ACPI_BATTERY) += battery.o diff --git a/drivers/acpi/hmat/hmat.c b/drivers/acpi/hmat.c similarity index 100% rename from drivers/acpi/hmat/hmat.c rename to drivers/acpi/hmat.c diff --git a/drivers/acpi/hmat/Kconfig b/drivers/acpi/hmat/Kconfig deleted file mode 100644 index 95a29964dbea..000000000000 --- a/drivers/acpi/hmat/Kconfig +++ /dev/null @@ -1,11 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -config ACPI_HMAT - bool "ACPI Heterogeneous Memory Attribute Table Support" - depends on ACPI_NUMA - select HMEM_REPORTING - help - If set, this option has the kernel parse and report the - platform's ACPI HMAT (Heterogeneous Memory Attributes Table), - register memory initiators with their targets, and export - performance attributes through the node's sysfs device if - provided. diff --git a/drivers/acpi/hmat/Makefile b/drivers/acpi/hmat/Makefile deleted file mode 100644 index 1c20ef36a385..000000000000 --- a/drivers/acpi/hmat/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_ACPI_HMAT) := hmat.o From patchwork Thu May 30 22:59:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10969345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A281C112C for ; Thu, 30 May 2019 23:13:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 918F028BE3 for ; Thu, 30 May 2019 23:13:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8336728BFD; Thu, 30 May 2019 23:13:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2098628BE3 for ; Thu, 30 May 2019 23:13:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2341F6B0281; Thu, 30 May 2019 19:13:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1E4D66B0282; Thu, 30 May 2019 19:13:23 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D4146B0283; Thu, 30 May 2019 19:13:23 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id C65056B0281 for ; Thu, 30 May 2019 19:13:22 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id e69so3311806pgc.7 for ; Thu, 30 May 2019 16:13:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=7kUKQNIdOWgFr9qr6uEyM12Od3PL5kNQnr9fjqXe59M=; b=ecyqyB77nDi4pzcXzuyAaZv3Q/eMk309h02b9A9nspNNE1icdD0fRoXqGNYjwh45GM sMRvCE078mkSsRm4k9rD1/fs5bR0vXG531PC/YBPomJWPKXZZpQ6fnmVWbMA6Nd5h97R JLUS0igJPuTMkNyQdGDbAvv31U7hVCimJFz6YMpkf1uvAXtNelHrSNH9JxDLkvQjU/WU bQiKIUG9rF6srqOaTbHdqnVIegX0Zjvv1WZD1sgjUzZv4smmnfuO5Phs83RczxRXejn+ lXHvyEu2j0F2HSpFjIuMvJCXDZ71XEpK8IND+7d9TYSB+P4YeY5GHplTLeN2G+FFXF3y fjcQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APjAAAXNqnZvJO5qxwbdyYEGOtAdd3s2r3TRovah4S/ELxVYLUlngUiq +p+lOjaqS/CA40ds97EP/D8a5lI9YRuDTyV3IYLnUFsjtOWE2K+1rPTiuujdEzPcopxKV1s/yef dZAWoe/PuYGx9PXtjv5Bu2/Xd229i6lsP1GQcO1pcHOlYFj24DbpQGuoHPVZO0g3ESw== X-Received: by 2002:aa7:93a7:: with SMTP id x7mr6329044pff.196.1559258002381; Thu, 30 May 2019 16:13:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqznTKgS04EBm49u1+wM+NMebxjO/HrNUBzsgCV44lGamjPFEXXjl/zxoGZsF0NEt9VRNCF9 X-Received: by 2002:aa7:93a7:: with SMTP id x7mr6328987pff.196.1559258001603; Thu, 30 May 2019 16:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559258001; cv=none; d=google.com; s=arc-20160816; b=NYK3z/I53ZaxC1Bp641Waoq6AsMCw7dsUHFU160QxyM9d3si/IoXvX8WHzcGmYYjnS jcZ3qngGdxYS90KAkb4/GxGzdyJq1JgVN2MmIVAzDU4tMhwTRQj/wxsdqGFc2d/n5/zX d00+6lsXb3mEqOEGy98hmFecJitzwk2m3wexNExUpN/l5meUdmPMUBIXSEuXcD22jtIr ZqskP4m8yyiH/wYAj7C9chG+UMgRO8FCprfrhA/d1s8bn4qoQi7J8KmEb9PisJNDtqCp kKhhVRjnaltAJ8l08XteTByK8YEUqQl+j36HNrM1tcGY/0sd549FJOacuEYGBD0ZHaSd NsDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject; bh=7kUKQNIdOWgFr9qr6uEyM12Od3PL5kNQnr9fjqXe59M=; b=Pm3hQpfmdo7cG/PxB50gmAdbUG+jVColWS9g/pCGKYGsgRKDy8x+AGsZ/kS2GfA62U OPprwPMrjLH673SYWBXSFYiLrpztG5HlRcyzuiZU+svyuRM7iaUs0Um5DtsdQTA6xSnD 4gn0WwEfSmGYo7v1CvlGShbkmpFDo9caSfOLsDorB7fzOw5X2JFnnTgIfMz9Rhjfx7LT jRxN/VSIxSdK73/zo1fPg/xq8UK+nDLxGZxOC+o6oB6bbokmlOgqx8dRFbu9Px+EybYH u+ZlRLC2MPE18YAw5VjBEds9Fb2UsiUfuCWTGA83Ncc5YNMM0i4hoktBwceW+xbyPGYU Lw4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga14.intel.com (mga14.intel.com. [192.55.52.115]) by mx.google.com with ESMTPS id w2si4183851pga.495.2019.05.30.16.13.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 16:13:21 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.115 as permitted sender) client-ip=192.55.52.115; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 May 2019 16:13:21 -0700 X-ExtLoop1: 1 Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga006.jf.intel.com with ESMTP; 30 May 2019 16:13:20 -0700 Subject: [PATCH v2 2/8] acpi/hmat: Skip publishing target info for nodes with no online memory From: Dan Williams To: linux-efi@vger.kernel.org Cc: vishal.l.verma@intel.com, ard.biesheuvel@linaro.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-nvdimm@lists.01.org Date: Thu, 30 May 2019 15:59:32 -0700 Message-ID: <155925717294.3775979.5007799093584209240.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <155925716254.3775979.16716824941364738117.stgit@dwillia2-desk3.amr.corp.intel.com> References: <155925716254.3775979.16716824941364738117.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP There are multiple scenarios where the HMAT may contain information about proximity domains that are not currently online. Rather than fail to report any HMAT data just elide those offline domains. If and when those domains are later onlined they can be added to the HMEM reporting at that point. This was found while testing EFI_MEMORY_SP support which reserves "specific purpose" memory from the general allocation pool. If that reservation results in an empty numa-node then the node is not marked online leading a spurious: "acpi/hmat: Ignoring HMAT: Invalid table" ...result for HMAT parsing. Signed-off-by: Dan Williams --- drivers/acpi/hmat.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/hmat.c b/drivers/acpi/hmat.c index 96b7d39a97c6..2c220cb7b620 100644 --- a/drivers/acpi/hmat.c +++ b/drivers/acpi/hmat.c @@ -96,9 +96,6 @@ static __init void alloc_memory_target(unsigned int mem_pxm) { struct memory_target *target; - if (pxm_to_node(mem_pxm) == NUMA_NO_NODE) - return; - target = find_mem_target(mem_pxm); if (target) return; @@ -588,6 +585,17 @@ static __init void hmat_register_targets(void) struct memory_target *target; list_for_each_entry(target, &targets, node) { + int nid = pxm_to_node(target->memory_pxm); + + /* + * Skip offline nodes. This can happen when memory + * marked EFI_MEMORY_SP, "specific purpose", is applied + * to all the memory in a promixity domain leading to + * the node being marked offline / unplugged, or if + * memory-only "hotplug" node is offline. + */ + if (nid == NUMA_NO_NODE || !node_online(nid)) + continue; hmat_register_target_initiators(target); hmat_register_target_perf(target); } From patchwork Thu May 30 22:59:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10969349 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3944713AD for ; Thu, 30 May 2019 23:13:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28C1F28BE3 for ; Thu, 30 May 2019 23:13:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D39228BFD; Thu, 30 May 2019 23:13:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E7BB28BE3 for ; Thu, 30 May 2019 23:13:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D4E16B0282; Thu, 30 May 2019 19:13:28 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 987616B0283; Thu, 30 May 2019 19:13:28 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 875246B0285; Thu, 30 May 2019 19:13:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 4FFF16B0282 for ; Thu, 30 May 2019 19:13:28 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id h7so5702774pfq.22 for ; Thu, 30 May 2019 16:13:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=1to0Jqiq9dVqRgEdJfEpfS5IGUBxKlxG9mS5T8zXRtg=; b=WmAWQ4z7qq3nmUxs+1veR7yA6Y8naeZsR+s1Tj4MbTVB/WroOt9LlmR/NOdukFUuyM 8aLaea5P+D0JEMSuj2N1IK0yDkc2mOXxPQ93sh+k6vUtD7A45/SrNcPZ2GOVDVWVQpEf rMYN/IINC8XxHpVa84/DnLFTy8PT5/u1pelGDJKl8kE/HmzxO0UV7kIwO8aZ4Wv907Tt RSIGT5ZZQYEikabm+vVYQPxL0bnuNozNqsZgVm1ZzW2spMiYAr/sx+0LOiK+Bmu3qCTy h0PJj+qxKwBceoOJFNdSFq+tItcYCMDUEmCRhzqf4Y1GRB2EgjFmMsJ4BDSvfjtJArt4 zxPg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APjAAAVCERXxupLm3BssfLBZ5YA4hzeuv6T+SsTTyejWq/yJYI8Lz9t7 7KPPDFdtTShnWSWDk3Q+jQpVuOanFSJ+T29Ep0zTV/STrU16XwYjSEr26WIhuCTo5KDf71RRrhI /j/Z6INHsQGEGJppXfWvl323EyAv1+7jEcogamjqF2bcUN3hDxt6poIVTMxNFXcVfAg== X-Received: by 2002:a63:c006:: with SMTP id h6mr1722339pgg.368.1559258007940; Thu, 30 May 2019 16:13:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKX3gKQRJZNx+hbYSWfyUMued2eLxK0z4/SkYG5zUb9YKulHE9ue+jL/u1/wQI3ocMrIE1 X-Received: by 2002:a63:c006:: with SMTP id h6mr1722274pgg.368.1559258006646; Thu, 30 May 2019 16:13:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559258006; cv=none; d=google.com; s=arc-20160816; b=ASXHMsA+6xC0RAdx212myzMssUEoEieB8w/0Ty7fVWhrgVCXigSgKBechNPgWw917t q+W+8iqVI/eI8vY5vsSeo173AOfCiWey6oi6mevktcHw7CIhFAR6vmLC4q3Rwd7T9N0c +QTPROnhaQRUavlCHzn260pFDaD695Ojy47jbCxZfjyCuTvrMkm51XatTCbTyf4q0m+8 gkJjeC4B2aAYHub+H17aYe+EY7sYUccO3r9jGoQI6DNpecH0IhBL8iTW7DEe4E346QoJ HJsttao9rXu2yuoCsvpAtsa6cnNasw96fOU0yOdfbyMl0k77sG+3rC5k+NbV1kVqKcNJ 5wDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject; bh=1to0Jqiq9dVqRgEdJfEpfS5IGUBxKlxG9mS5T8zXRtg=; b=lJmWEiwOotb29MszN8Mqx8QscwK0/CvB9gLduINqmjfBwvTzdkGXG3v2GFvv1eh8DN 5C9gxfik5E5xSYVjAA2/44Kw483wllCtps6EwG/LnQqFUQVPu2RSzfYdeEfXqz5P7N2L gmNXBho9hwnwInzQu0HWIuoHhOjpWOTD1PceCpYY5FY6p79p4vpMSrFrnxABd+F+YXFe DNJCWSJf0f7S2mgXRMa7BVlc7S7IN26N7hqykqd0IPX6RHm2JhXCKwLfXn6t7Picq1DZ B88iJyEjfFy76FRAEJ6NiI8NK8dIvHUKlT5Lv7TFx0KYdd1ErTwatVPIX5iSYd4u/o+n kFVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga04.intel.com (mga04.intel.com. [192.55.52.120]) by mx.google.com with ESMTPS id d75si4519548pfm.259.2019.05.30.16.13.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 16:13:26 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) client-ip=192.55.52.120; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 May 2019 16:13:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,532,1549958400"; d="scan'208";a="180115547" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga002.fm.intel.com with ESMTP; 30 May 2019 16:13:25 -0700 Subject: [PATCH v2 3/8] efi: Enumerate EFI_MEMORY_SP From: Dan Williams To: linux-efi@vger.kernel.org Cc: Ard Biesheuvel , vishal.l.verma@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-nvdimm@lists.01.org Date: Thu, 30 May 2019 15:59:38 -0700 Message-ID: <155925717803.3775979.14412010256191901040.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <155925716254.3775979.16716824941364738117.stgit@dwillia2-desk3.amr.corp.intel.com> References: <155925716254.3775979.16716824941364738117.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP UEFI 2.8 defines an EFI_MEMORY_SP attribute bit to augment the interpretation of the EFI Memory Types as "reserved for a specific purpose". The intent of this bit is to allow the OS to identify precious or scarce memory resources and optionally manage it separately from EfiConventionalMemory. As defined older OSes that do not know about this attribute are permitted to ignore it and the memory will be handled according to the OS default policy for the given memory type. In other words, this "specific purpose" hint is deliberately weaker than EfiReservedMemoryType in that the system continues to operate if the OS takes no action on the attribute. The risk of taking no action is potentially unwanted / unmovable kernel allocations from the designated resource that prevent the full realization of the "specific purpose". For example, consider a system with a high-bandwidth memory pool. Older kernels are permitted to boot and consume that memory as conventional "System-RAM" newer kernels may arrange for that memory to be set aside by the system administrator for a dedicated high-bandwidth memory aware application to consume. Specifically, this mechanism allows for the elimination of scenarios where platform firmware tries to game OS policy by lying about ACPI SLIT values, i.e. claiming that a precious memory resource has a high distance to trigger the OS to avoid it by default. Implement simple detection of the bit for EFI memory table dumps and save the kernel policy for a follow-on change. Cc: Ard Biesheuvel Signed-off-by: Dan Williams Reviewed-by: Ard Biesheuvel --- drivers/firmware/efi/efi.c | 5 +++-- include/linux/efi.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 55b77c576c42..81db09485881 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -848,15 +848,16 @@ char * __init efi_md_typeattr_format(char *buf, size_t size, if (attr & ~(EFI_MEMORY_UC | EFI_MEMORY_WC | EFI_MEMORY_WT | EFI_MEMORY_WB | EFI_MEMORY_UCE | EFI_MEMORY_RO | EFI_MEMORY_WP | EFI_MEMORY_RP | EFI_MEMORY_XP | - EFI_MEMORY_NV | + EFI_MEMORY_NV | EFI_MEMORY_SP | EFI_MEMORY_RUNTIME | EFI_MEMORY_MORE_RELIABLE)) snprintf(pos, size, "|attr=0x%016llx]", (unsigned long long)attr); else snprintf(pos, size, - "|%3s|%2s|%2s|%2s|%2s|%2s|%2s|%3s|%2s|%2s|%2s|%2s]", + "|%3s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%3s|%2s|%2s|%2s|%2s]", attr & EFI_MEMORY_RUNTIME ? "RUN" : "", attr & EFI_MEMORY_MORE_RELIABLE ? "MR" : "", + attr & EFI_MEMORY_SP ? "SP" : "", attr & EFI_MEMORY_NV ? "NV" : "", attr & EFI_MEMORY_XP ? "XP" : "", attr & EFI_MEMORY_RP ? "RP" : "", diff --git a/include/linux/efi.h b/include/linux/efi.h index 6ebc2098cfe1..91368f5ce114 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -112,6 +112,7 @@ typedef struct { #define EFI_MEMORY_MORE_RELIABLE \ ((u64)0x0000000000010000ULL) /* higher reliability */ #define EFI_MEMORY_RO ((u64)0x0000000000020000ULL) /* read-only */ +#define EFI_MEMORY_SP ((u64)0x0000000000040000ULL) /* special purpose */ #define EFI_MEMORY_RUNTIME ((u64)0x8000000000000000ULL) /* range requires runtime mapping */ #define EFI_MEMORY_DESCRIPTOR_VERSION 1 From patchwork Thu May 30 22:59:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10969353 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B9FD13AD for ; Thu, 30 May 2019 23:13:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 097F228BE3 for ; Thu, 30 May 2019 23:13:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F10A428BED; Thu, 30 May 2019 23:13:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF8A528BFD for ; Thu, 30 May 2019 23:13:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE6EF6B0283; Thu, 30 May 2019 19:13:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A973C6B0285; Thu, 30 May 2019 19:13:33 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 986846B0286; Thu, 30 May 2019 19:13:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id 5B3306B0283 for ; Thu, 30 May 2019 19:13:33 -0400 (EDT) Received: by mail-pl1-f199.google.com with SMTP id o12so4886553pll.17 for ; Thu, 30 May 2019 16:13:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=UZfQfw/tv06I09tzxEA1NR+q+/SfO/X5yRnUA7mMO5E=; b=Onbxw3zIQzPz50oUlFeLebrhJlVm3bIA1A3GIc0gtcUVJGTKhXkdIwt2TOxVEN0dwJ V2NYG6rUWR2bgq87vnJ5ATjvKDykSQ9Ov+0lfEJ6ATBg3dUxu+hFdojGukqcuo98ADgZ 71g9NS1Yp41ZDkpCuGBFToEAjQpsfG7vdfHqHPcHFMRzZU0B96Kmq7apox1EcmNPO/Ez qlYL6V5B2r8ys0WmIRHhyqPKjDwPGx6HeUYRxbQVFwHL+6TpfOuC9K2/Z6+/v7Z+0aF5 arPJeRtzOl/XZjyW7fHOrEAiro9X9l54jcLR57jw5wVMkiQ/yfQglpJZ3MKimmMOOdyv lQ4w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APjAAAXVAZ0phbQ+h0VWpY4XEHxzu/1B9+JmcRKrZsr0Y/fv4EGkWrdT HI1uGmSU5v98gXnNfy2ai1WAnHd54e82cnEwdexoG3LY6m4Bcmu5zrBQiTxZDsaMST6CjaQKZsk /2KBM2F0h6q82XDF2QMgUzH0E1n3nNdQkMFTtBzp2u7p4l+iGhHMfr3ZVOh3+zjWG2g== X-Received: by 2002:a17:90a:9602:: with SMTP id v2mr5874757pjo.59.1559258012926; Thu, 30 May 2019 16:13:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOB1WGewuxMW2JZU6s/B2rXh0NNIEte9QkuEMxjBBuELcaGUerAy5ECv87NNfCmLozzt3m X-Received: by 2002:a17:90a:9602:: with SMTP id v2mr5874688pjo.59.1559258011759; Thu, 30 May 2019 16:13:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559258011; cv=none; d=google.com; s=arc-20160816; b=GCY+j6/i2QD4uQnTtSPIEv5wB/W9gqbrAps4wkpqwUTV7d87bC2K5PkR2RwRDpnfyL JwadDiTNcpn94uDSABgrVkU/VdxGWv4rGYIxHIyaYtcgDTEhUunqksBhWUfhg+eOWUfJ Jx4BQtIGx66AcBpbHI25mrZsBDbCqJyeG5rQWMMTFDI4WfCq7VB8ePgUuGZXKffrSjwN uaej9yOst9fbRqfpZi3cpzdHYWXLAsP/9UZFdEzJ526ZiheF9IFRsxPI1KQxWxfPIhHw uWKGrpzPeKN2WSXu/9fJOqKB0AFkIQiTl/FjNDdpCzbH4bAfj6Vcfa8jcsha+xDVAVxb F8yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject; bh=UZfQfw/tv06I09tzxEA1NR+q+/SfO/X5yRnUA7mMO5E=; b=QdxfKUV/XEkjVuph04LND5bllT1Xun82x4+0ZHK+OPPd7jTqJXVlHX+bxWHaXjU1Lc 28BZBkCXHxwVgJpjJPBFxrHxzYaI4RlOXY2lXgyjm90eQc3RC6l2eggEKNKjEfJuTklG 0OQ8XQTt7XO8K0pqQZ4LnsKGt0i13sl3ax5mtHupVlQcyUtOw5SnSdU0YLmt5vEDZKTG qgbG/3E6z+FADksuP0duwklRRFCAHYbaQQrQ83XxOup64+qTr41XLfe/2TccUPJQ16L2 yubGOFdt5DZPi9oVVivePMeuBpU/cFs4GrIb7O44q2+OnfW3l/QIJ77o2o8NqttKSUm6 MPyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id b9si852431pls.303.2019.05.30.16.13.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 16:13:31 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 May 2019 16:13:31 -0700 X-ExtLoop1: 1 Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga008.jf.intel.com with ESMTP; 30 May 2019 16:13:31 -0700 Subject: [PATCH v2 4/8] x86, efi: Reserve UEFI 2.8 Specific Purpose Memory for dax From: Dan Williams To: linux-efi@vger.kernel.org Cc: x86@kernel.org, Borislav Petkov , Ingo Molnar , "H. Peter Anvin" , Darren Hart , Andy Shevchenko , Thomas Gleixner , Ard Biesheuvel , kbuild test robot , vishal.l.verma@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-nvdimm@lists.01.org Date: Thu, 30 May 2019 15:59:43 -0700 Message-ID: <155925718351.3775979.13546720620952434175.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <155925716254.3775979.16716824941364738117.stgit@dwillia2-desk3.amr.corp.intel.com> References: <155925716254.3775979.16716824941364738117.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP UEFI 2.8 defines an EFI_MEMORY_SP attribute bit to augment the interpretation of the EFI Memory Types as "reserved for a special purpose". The proposed Linux behavior for specific purpose memory is that it is reserved for direct-access (device-dax) by default and not available for any kernel usage, not even as an OOM fallback. Later, through udev scripts or another init mechanism, these device-dax claimed ranges can be reconfigured and hot-added to the available System-RAM with a unique node identifier. This patch introduces 3 new concepts at once given the entanglement between early boot enumeration relative to memory that can optionally be reserved from the kernel page allocator by default. The new concepts are: - E820_TYPE_SPECIFIC: Upon detecting the EFI_MEMORY_SP attribute on EFI_CONVENTIONAL memory, update the E820 map with this new type. Only perform this classification if the CONFIG_EFI_SPECIFIC_DAX=y policy is enabled, otherwise treat it as typical ram. - IORES_DESC_APPLICATION_RESERVED: Add a new I/O resource descriptor for a device driver to search iomem resources for application specific memory. Teach the iomem code to identify such ranges as "Application Reserved". - MEMBLOCK_APP_SPECIFIC: Given the memory ranges can fallback to the traditional System RAM pool the expectation is that they will have typical SRAT entries. In order to support a policy of device-dax by default with the option to hotplug later, the numa initialization code is taught to avoid marking online MEMBLOCK_APP_SPECIFIC regions. A follow-on change integrates parsing of the ACPI HMAT to identify the node and sub-range boundaries of EFI_MEMORY_SP designated memory. For now, just identify and reserve memory of this type. Cc: Cc: Borislav Petkov Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: Darren Hart Cc: Andy Shevchenko Cc: Thomas Gleixner Cc: Ard Biesheuvel Reported-by: kbuild test robot Signed-off-by: Dan Williams --- arch/x86/Kconfig | 20 ++++++++++++++++++++ arch/x86/boot/compressed/eboot.c | 5 ++++- arch/x86/boot/compressed/kaslr.c | 2 +- arch/x86/include/asm/e820/types.h | 9 +++++++++ arch/x86/kernel/e820.c | 9 +++++++-- arch/x86/kernel/setup.c | 1 + arch/x86/platform/efi/efi.c | 37 +++++++++++++++++++++++++++++++++---- drivers/acpi/numa.c | 15 ++++++++++++++- include/linux/efi.h | 14 ++++++++++++++ include/linux/ioport.h | 1 + include/linux/memblock.h | 7 +++++++ mm/memblock.c | 4 ++++ 12 files changed, 115 insertions(+), 9 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 2bbbd4d1ba31..2d58f32ed6fa 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1955,6 +1955,26 @@ config EFI_MIXED If unsure, say N. +config EFI_SPECIFIC_DAX + bool "DAX Support for EFI Specific Purpose Memory" + depends on EFI + ---help--- + On systems that have mixed performance classes of memory EFI + may indicate specific purpose memory with an attribute (See + EFI_MEMORY_SP in UEFI 2.8). A memory range tagged with this + attribute may have unique performance characteristics compared + to the system's general purpose "System RAM" pool. On the + expectation that such memory has application specific usage, + and its base EFI memory type is "conventional" answer Y to + arrange for the kernel to reserve it for direct-access + (device-dax) by default. The memory range can later be + optionally assigned to the page allocator by system + administrator policy via the device-dax kmem facility. Say N + to have the kernel treat this memory as general purpose by + default. + + If unsure, say Y. + config SECCOMP def_bool y prompt "Enable seccomp to safely compute untrusted bytecode" diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index 544ac4fafd11..5afa6de508e4 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -560,7 +560,10 @@ setup_e820(struct boot_params *params, struct setup_data *e820ext, u32 e820ext_s case EFI_BOOT_SERVICES_CODE: case EFI_BOOT_SERVICES_DATA: case EFI_CONVENTIONAL_MEMORY: - e820_type = E820_TYPE_RAM; + if (is_efi_dax(d)) + e820_type = E820_TYPE_SPECIFIC; + else + e820_type = E820_TYPE_RAM; break; case EFI_ACPI_MEMORY_NVS: diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 2e53c056ba20..8af8b4d4ebc9 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -757,7 +757,7 @@ process_efi_entries(unsigned long minimum, unsigned long image_size) * * Only EFI_CONVENTIONAL_MEMORY is guaranteed to be free. */ - if (md->type != EFI_CONVENTIONAL_MEMORY) + if (md->type != EFI_CONVENTIONAL_MEMORY || is_efi_dax(md)) continue; if (efi_mirror_found && diff --git a/arch/x86/include/asm/e820/types.h b/arch/x86/include/asm/e820/types.h index c3aa4b5e49e2..7209e611a89d 100644 --- a/arch/x86/include/asm/e820/types.h +++ b/arch/x86/include/asm/e820/types.h @@ -28,6 +28,15 @@ enum e820_type { */ E820_TYPE_PRAM = 12, + /* + * Special-purpose / application-specific memory is indicated to + * the system via the EFI_MEMORY_SP attribute. Define an e820 + * translation of this memory type for the purpose of + * reserving this range and marking it with the + * IORES_DESC_APPLICATION_RESERVED designation. + */ + E820_TYPE_SPECIFIC = 0xefffffff, + /* * Reserved RAM used by the kernel itself if * CONFIG_INTEL_TXT=y is enabled, memory of this type diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 8f32e705a980..735f86594cab 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -189,6 +189,7 @@ static void __init e820_print_type(enum e820_type type) switch (type) { case E820_TYPE_RAM: /* Fall through: */ case E820_TYPE_RESERVED_KERN: pr_cont("usable"); break; + case E820_TYPE_SPECIFIC: pr_cont("application reserved"); break; case E820_TYPE_RESERVED: pr_cont("reserved"); break; case E820_TYPE_ACPI: pr_cont("ACPI data"); break; case E820_TYPE_NVS: pr_cont("ACPI NVS"); break; @@ -1036,6 +1037,7 @@ static const char *__init e820_type_to_string(struct e820_entry *entry) case E820_TYPE_UNUSABLE: return "Unusable memory"; case E820_TYPE_PRAM: return "Persistent Memory (legacy)"; case E820_TYPE_PMEM: return "Persistent Memory"; + case E820_TYPE_SPECIFIC: return "Application Reserved"; case E820_TYPE_RESERVED: return "Reserved"; default: return "Unknown E820 type"; } @@ -1051,6 +1053,7 @@ static unsigned long __init e820_type_to_iomem_type(struct e820_entry *entry) case E820_TYPE_UNUSABLE: /* Fall-through: */ case E820_TYPE_PRAM: /* Fall-through: */ case E820_TYPE_PMEM: /* Fall-through: */ + case E820_TYPE_SPECIFIC: /* Fall-through: */ case E820_TYPE_RESERVED: /* Fall-through: */ default: return IORESOURCE_MEM; } @@ -1063,6 +1066,7 @@ static unsigned long __init e820_type_to_iores_desc(struct e820_entry *entry) case E820_TYPE_NVS: return IORES_DESC_ACPI_NV_STORAGE; case E820_TYPE_PMEM: return IORES_DESC_PERSISTENT_MEMORY; case E820_TYPE_PRAM: return IORES_DESC_PERSISTENT_MEMORY_LEGACY; + case E820_TYPE_SPECIFIC: return IORES_DESC_APPLICATION_RESERVED; case E820_TYPE_RESERVED_KERN: /* Fall-through: */ case E820_TYPE_RAM: /* Fall-through: */ case E820_TYPE_UNUSABLE: /* Fall-through: */ @@ -1078,13 +1082,14 @@ static bool __init do_mark_busy(enum e820_type type, struct resource *res) return true; /* - * Treat persistent memory like device memory, i.e. reserve it - * for exclusive use of a driver + * Treat persistent memory and other special memory ranges like + * device memory, i.e. reserve it for exclusive use of a driver */ switch (type) { case E820_TYPE_RESERVED: case E820_TYPE_PRAM: case E820_TYPE_PMEM: + case E820_TYPE_SPECIFIC: return false; case E820_TYPE_RESERVED_KERN: case E820_TYPE_RAM: diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 08a5f4a131f5..ddde1c7b1f9a 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1109,6 +1109,7 @@ void __init setup_arch(char **cmdline_p) if (efi_enabled(EFI_MEMMAP)) { efi_fake_memmap(); + efi_find_app_specific(); efi_find_mirror(); efi_esrt_init(); diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index e1cb01a22fa8..899f1305c77a 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -123,10 +123,15 @@ void __init efi_find_mirror(void) * more than the max 128 entries that can fit in the e820 legacy * (zeropage) memory map. */ +enum add_efi_mode { + ADD_EFI_ALL, + ADD_EFI_APP_SPECIFIC, +}; -static void __init do_add_efi_memmap(void) +static void __init do_add_efi_memmap(enum add_efi_mode mode) { efi_memory_desc_t *md; + int add = 0; for_each_efi_memory_desc(md) { unsigned long long start = md->phys_addr; @@ -139,7 +144,9 @@ static void __init do_add_efi_memmap(void) case EFI_BOOT_SERVICES_CODE: case EFI_BOOT_SERVICES_DATA: case EFI_CONVENTIONAL_MEMORY: - if (md->attribute & EFI_MEMORY_WB) + if (is_efi_dax(md)) + e820_type = E820_TYPE_SPECIFIC; + else if (md->attribute & EFI_MEMORY_WB) e820_type = E820_TYPE_RAM; else e820_type = E820_TYPE_RESERVED; @@ -165,9 +172,24 @@ static void __init do_add_efi_memmap(void) e820_type = E820_TYPE_RESERVED; break; } + + if (e820_type == E820_TYPE_SPECIFIC) { + memblock_remove(start, size); + memblock_add_range(&memblock.reserved, start, size, + MAX_NUMNODES, MEMBLOCK_APP_SPECIFIC); + } else if (mode != ADD_EFI_APP_SPECIFIC) + continue; + + add++; e820__range_add(start, size, e820_type); } - e820__update_table(e820_table); + if (add) + e820__update_table(e820_table); +} + +void __init efi_find_app_specific(void) +{ + do_add_efi_memmap(ADD_EFI_APP_SPECIFIC); } int __init efi_memblock_x86_reserve_range(void) @@ -200,7 +222,7 @@ int __init efi_memblock_x86_reserve_range(void) return rv; if (add_efi_memmap) - do_add_efi_memmap(); + do_add_efi_memmap(ADD_EFI_ALL); WARN(efi.memmap.desc_version != 1, "Unexpected EFI_MEMORY_DESCRIPTOR version %ld", @@ -753,6 +775,13 @@ static bool should_map_region(efi_memory_desc_t *md) if (IS_ENABLED(CONFIG_X86_32)) return false; + /* + * Specific purpose memory assigned to device-dax is + * not mapped by default. + */ + if (is_efi_dax(md)) + return false; + /* * Map all of RAM so that we can access arguments in the 1:1 * mapping when making EFI runtime calls. diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index 30995834ad70..9083bb8f611b 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c @@ -260,7 +260,7 @@ void __init acpi_numa_slit_init(struct acpi_table_slit *slit) int __init acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) { - u64 start, end; + u64 start, end, i, a_start, a_end; u32 hotpluggable; int node, pxm; @@ -283,6 +283,19 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) if (acpi_srat_revision <= 1) pxm &= 0xff; + /* Clamp Application Specific Memory */ + for_each_mem_range(i, &memblock.reserved, NULL, NUMA_NO_NODE, + MEMBLOCK_APP_SPECIFIC, &a_start, &a_end, NULL) { + pr_debug("%s: SP: %#llx %#llx SRAT: %#llx %#llx\n", __func__, + a_start, a_end, start, end); + if (a_start <= start && a_end >= end) + goto out_err; + if (a_start >= start && a_start < end) + start = a_start; + if (a_end <= end && end > start) + end = a_end; + } + node = acpi_map_pxm_to_node(pxm); if (node == NUMA_NO_NODE || node >= MAX_NUMNODES) { pr_err("SRAT: Too many proximity domains.\n"); diff --git a/include/linux/efi.h b/include/linux/efi.h index 91368f5ce114..b57b123cbdf9 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -129,6 +129,19 @@ typedef struct { u64 attribute; } efi_memory_desc_t; +#ifdef CONFIG_EFI_SPECIFIC_DAX +static inline bool is_efi_dax(efi_memory_desc_t *md) +{ + return md->type == EFI_CONVENTIONAL_MEMORY + && (md->attribute & EFI_MEMORY_SP); +} +#else +static inline bool is_efi_dax(efi_memory_desc_t *md) +{ + return false; +} +#endif + typedef struct { efi_guid_t guid; u32 headersize; @@ -1043,6 +1056,7 @@ extern efi_status_t efi_query_variable_store(u32 attributes, unsigned long size, bool nonblocking); extern void efi_find_mirror(void); +extern void efi_find_app_specific(void); #else static inline efi_status_t efi_query_variable_store(u32 attributes, diff --git a/include/linux/ioport.h b/include/linux/ioport.h index da0ebaec25f0..2d79841ee9b9 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -133,6 +133,7 @@ enum { IORES_DESC_PERSISTENT_MEMORY_LEGACY = 5, IORES_DESC_DEVICE_PRIVATE_MEMORY = 6, IORES_DESC_DEVICE_PUBLIC_MEMORY = 7, + IORES_DESC_APPLICATION_RESERVED = 8, }; /* helpers to define resources */ diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 676d3900e1bd..58c29180f2cd 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -35,12 +35,14 @@ extern unsigned long long max_possible_pfn; * @MEMBLOCK_HOTPLUG: hotpluggable region * @MEMBLOCK_MIRROR: mirrored region * @MEMBLOCK_NOMAP: don't add to kernel direct mapping + * @MEMBLOCK_APP_SPECIFIC: reserved / application specific range */ enum memblock_flags { MEMBLOCK_NONE = 0x0, /* No special request */ MEMBLOCK_HOTPLUG = 0x1, /* hotpluggable region */ MEMBLOCK_MIRROR = 0x2, /* mirrored region */ MEMBLOCK_NOMAP = 0x4, /* don't add to kernel direct mapping */ + MEMBLOCK_APP_SPECIFIC = 0x8, /* reserved / application specific range */ }; /** @@ -215,6 +217,11 @@ static inline bool memblock_is_mirror(struct memblock_region *m) return m->flags & MEMBLOCK_MIRROR; } +static inline bool memblock_is_app_specific(struct memblock_region *m) +{ + return m->flags & MEMBLOCK_APP_SPECIFIC; +} + static inline bool memblock_is_nomap(struct memblock_region *m) { return m->flags & MEMBLOCK_NOMAP; diff --git a/mm/memblock.c b/mm/memblock.c index 6bbad46f4d2c..654fecb52ba5 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -982,6 +982,10 @@ static bool should_skip_region(struct memblock_region *m, int nid, int flags) if ((flags & MEMBLOCK_MIRROR) && !memblock_is_mirror(m)) return true; + /* if we want specific memory skip non-specific memory regions */ + if ((flags & MEMBLOCK_APP_SPECIFIC) && !memblock_is_app_specific(m)) + return true; + /* skip nomap memory unless we were asked for it explicitly */ if (!(flags & MEMBLOCK_NOMAP) && memblock_is_nomap(m)) return true; From patchwork Thu May 30 22:59:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10969357 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DB64112C for ; Thu, 30 May 2019 23:13:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D8E128BE3 for ; Thu, 30 May 2019 23:13:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11FC328BFD; Thu, 30 May 2019 23:13:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7ADAB28BE3 for ; Thu, 30 May 2019 23:13:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A0776B0285; Thu, 30 May 2019 19:13:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 651266B0286; Thu, 30 May 2019 19:13:39 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53FE56B0287; Thu, 30 May 2019 19:13:39 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id 1CA196B0285 for ; Thu, 30 May 2019 19:13:39 -0400 (EDT) Received: by mail-pl1-f199.google.com with SMTP id b69so4912990plb.9 for ; Thu, 30 May 2019 16:13:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=833GLhxPx8+W+AWCCBxBUiPBUhE9Sjsn7ePhU9KVSRs=; b=EqaN/RBbBSOwWD7LjoEDAXT6TdltKxpb/Hg3qxCdLeLNarXcBWjQ1jc01X9Tczkq38 6h3rZYIXUkl1hQsOCuWqLtRJ/PjvHKXSRV6Zlse/VzMwAkSce2ZL5JtOzJAlqLcZJEC0 aODaEvEWbwJVPKvEdsi2QzqAOx1n+XQcrpcdUhgZEugHCQ9I1yJbSE9kgi4LihEeUf3G d/ZfNufE1gIqPc8+DNO221Ca+JbuwpZmOcYauQB7ikIMPuxBD3/Hc4c4ZlHKBJ+9/DWG hY37rSxJ646/qzGMGkgswQ6kk/we89PYDjMGcFy+KKG26vL5FkBFs2ndEd55s59pjeOT eo2g== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APjAAAVgTOWIQQGEklkcC0dKDIAYmxncCRlUCU2NRmLjojh+Yv1EXPo8 YaM0TZF2UP3glbjY9QzsjrPI9PQwud1uf5Kbt//6zHo+wzkzr13OA13mM97KPMLyJUyfvPR7Mpg LqwLsNTgo11klv6CP6QqKqMlMRD3NRzjwdb1HjFM/8+UCa/xFCONjcY9Vy7zuK0Rn6Q== X-Received: by 2002:a17:902:a40b:: with SMTP id p11mr5989564plq.175.1559258018731; Thu, 30 May 2019 16:13:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRiWY2UxVHru1ZT1HLLLr3ahv8PDcMRK6nHWiLZ2ND3MCW1McH5JI5AyapOhlOvJeRekJF X-Received: by 2002:a17:902:a40b:: with SMTP id p11mr5989479plq.175.1559258017306; Thu, 30 May 2019 16:13:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559258017; cv=none; d=google.com; s=arc-20160816; b=UPfU3huljtdFau241pYcnCbX1dklqH+kHdSIdqYW3RSsxW1wFPHC/8EluzEbR8T8ak UYSR40x6cIWNKfq2uCamP3wDsN1bWb68Ky6Mn9LEnQGFcfV2BGaYmO/b3iY6AJiIwPOA RcnrQVv2lnB+NYXDLxaiU8uthL3nDtsH3NBJgNC4gEy/niGC11s1RBhNgV6kmGF+9XAB S/DyiCP8288GRXcAad0txhc36HhTG63AFFPpvdYN7duGwlBgE/Rh7GumBU5V3V66BAtc H9/15NN5L/bAdRQJl5V5w3CgdgL07csutaAxN/Z6255Zni4v/0o46+8qEHhw4kVomZnM HyPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject; bh=833GLhxPx8+W+AWCCBxBUiPBUhE9Sjsn7ePhU9KVSRs=; b=Z85GFPn2Al3Scq5yo6W/ZnytcmnM9XfsMVhf+HXzQvTZPUk2JYzkGlJpaM8Wn1pNju caESF0itaIIvgiOX6MYXSSONYysbxYqdA9ly3rIpbnW+7Bj2MIwYZFFswQXAE8927Ca5 LfxXpzu+lIQW8GwQ15REk/7qTFg8npR++NKH141BZzdEvZuHdo7p2JQe/bEfbC6I8yRW LqMmGWRaihF23Q6K3llcuwmTb9d/Vgp24Mj3FhpQuF51tO5DG/Zt9bvepCXw9RVJ8zut HO95f44SWMc151qlyCT15CXZz/Gf0VZZLd9tPM0DMyF6ay6TPA3HcFPca3GNlFAOagMy +TOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga04.intel.com (mga04.intel.com. [192.55.52.120]) by mx.google.com with ESMTPS id e6si752774pfn.273.2019.05.30.16.13.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 16:13:37 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) client-ip=192.55.52.120; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 May 2019 16:13:36 -0700 X-ExtLoop1: 1 Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga007.jf.intel.com with ESMTP; 30 May 2019 16:13:36 -0700 Subject: [PATCH v2 5/8] lib/memregion: Uplevel the pmem "region" ida to a global allocator From: Dan Williams To: linux-efi@vger.kernel.org Cc: Keith Busch , Matthew Wilcox , vishal.l.verma@intel.com, ard.biesheuvel@linaro.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-nvdimm@lists.01.org Date: Thu, 30 May 2019 15:59:48 -0700 Message-ID: <155925718863.3775979.5027759142906684801.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <155925716254.3775979.16716824941364738117.stgit@dwillia2-desk3.amr.corp.intel.com> References: <155925716254.3775979.16716824941364738117.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP In preparation for handling platform differentiated memory types beyond persistent memory, uplevel the "region" identifier to a global number space. This enables a device-dax instance to be registered to any memory type with guaranteed unique names. Cc: Keith Busch Cc: Matthew Wilcox Signed-off-by: Dan Williams --- drivers/nvdimm/Kconfig | 1 + drivers/nvdimm/core.c | 1 - drivers/nvdimm/nd-core.h | 1 - drivers/nvdimm/region_devs.c | 13 ++++--------- include/linux/memregion.h | 8 ++++++++ lib/Kconfig | 7 +++++++ lib/Makefile | 1 + lib/memregion.c | 15 +++++++++++++++ 8 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 include/linux/memregion.h create mode 100644 lib/memregion.c diff --git a/drivers/nvdimm/Kconfig b/drivers/nvdimm/Kconfig index 54500798f23a..4b3e66fe61c1 100644 --- a/drivers/nvdimm/Kconfig +++ b/drivers/nvdimm/Kconfig @@ -4,6 +4,7 @@ menuconfig LIBNVDIMM depends on PHYS_ADDR_T_64BIT depends on HAS_IOMEM depends on BLK_DEV + select MEMREGION help Generic support for non-volatile memory devices including ACPI-6-NFIT defined resources. On platforms that define an diff --git a/drivers/nvdimm/core.c b/drivers/nvdimm/core.c index acce050856a8..75fe651d327d 100644 --- a/drivers/nvdimm/core.c +++ b/drivers/nvdimm/core.c @@ -463,7 +463,6 @@ static __exit void libnvdimm_exit(void) nd_region_exit(); nvdimm_exit(); nvdimm_bus_exit(); - nd_region_devs_exit(); nvdimm_devs_exit(); } diff --git a/drivers/nvdimm/nd-core.h b/drivers/nvdimm/nd-core.h index e5ffd5733540..17561302dfec 100644 --- a/drivers/nvdimm/nd-core.h +++ b/drivers/nvdimm/nd-core.h @@ -133,7 +133,6 @@ struct nvdimm_bus *walk_to_nvdimm_bus(struct device *nd_dev); int __init nvdimm_bus_init(void); void nvdimm_bus_exit(void); void nvdimm_devs_exit(void); -void nd_region_devs_exit(void); void nd_region_probe_success(struct nvdimm_bus *nvdimm_bus, struct device *dev); struct nd_region; void nd_region_create_ns_seed(struct nd_region *nd_region); diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c index b4ef7d9ff22e..9e070363ff70 100644 --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c @@ -11,6 +11,7 @@ * General Public License for more details. */ #include +#include #include #include #include @@ -27,7 +28,6 @@ */ #include -static DEFINE_IDA(region_ida); static DEFINE_PER_CPU(int, flush_idx); static int nvdimm_map_flush(struct device *dev, struct nvdimm *nvdimm, int dimm, @@ -141,7 +141,7 @@ static void nd_region_release(struct device *dev) put_device(&nvdimm->dev); } free_percpu(nd_region->lane); - ida_simple_remove(®ion_ida, nd_region->id); + memregion_free(nd_region->id); if (is_nd_blk(dev)) kfree(to_nd_blk_region(dev)); else @@ -1036,7 +1036,7 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus, if (!region_buf) return NULL; - nd_region->id = ida_simple_get(®ion_ida, 0, 0, GFP_KERNEL); + nd_region->id = memregion_alloc(GFP_KERNEL); if (nd_region->id < 0) goto err_id; @@ -1090,7 +1090,7 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus, return nd_region; err_percpu: - ida_simple_remove(®ion_ida, nd_region->id); + memregion_free(nd_region->id); err_id: kfree(region_buf); return NULL; @@ -1237,8 +1237,3 @@ int nd_region_conflict(struct nd_region *nd_region, resource_size_t start, return device_for_each_child(&nvdimm_bus->dev, &ctx, region_conflict); } - -void __exit nd_region_devs_exit(void) -{ - ida_destroy(®ion_ida); -} diff --git a/include/linux/memregion.h b/include/linux/memregion.h new file mode 100644 index 000000000000..ba03c70f98d2 --- /dev/null +++ b/include/linux/memregion.h @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef _MEMREGION_H_ +#define _MEMREGION_H_ +#include + +int memregion_alloc(gfp_t gfp); +void memregion_free(int id); +#endif /* _MEMREGION_H_ */ diff --git a/lib/Kconfig b/lib/Kconfig index 90623a0e1942..68621a0505a6 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -335,6 +335,13 @@ config DECOMPRESS_LZ4 config GENERIC_ALLOCATOR bool +# +# Memory Region ID allocation for persistent memory and "specific +# purpose" / performance differentiated memory ranges. +# +config MEMREGION + bool + # # reed solomon support is select'ed if needed # diff --git a/lib/Makefile b/lib/Makefile index fb7697031a79..58cf99f68f36 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -136,6 +136,7 @@ obj-$(CONFIG_LIBCRC32C) += libcrc32c.o obj-$(CONFIG_CRC8) += crc8.o obj-$(CONFIG_XXHASH) += xxhash.o obj-$(CONFIG_GENERIC_ALLOCATOR) += genalloc.o +obj-$(CONFIG_MEMREGION) += memregion.o obj-$(CONFIG_842_COMPRESS) += 842/ obj-$(CONFIG_842_DECOMPRESS) += 842/ diff --git a/lib/memregion.c b/lib/memregion.c new file mode 100644 index 000000000000..f6c6a94c7921 --- /dev/null +++ b/lib/memregion.c @@ -0,0 +1,15 @@ +#include + +static DEFINE_IDA(region_ids); + +int memregion_alloc(gfp_t gfp) +{ + return ida_alloc(®ion_ids, gfp); +} +EXPORT_SYMBOL(memregion_alloc); + +void memregion_free(int id) +{ + ida_free(®ion_ids, id); +} +EXPORT_SYMBOL(memregion_free); From patchwork Thu May 30 22:59:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10969361 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A3A7013AD for ; Thu, 30 May 2019 23:13:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9137028BE3 for ; Thu, 30 May 2019 23:13:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 824C828BFD; Thu, 30 May 2019 23:13:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECECC28BE3 for ; Thu, 30 May 2019 23:13:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA5E66B0286; Thu, 30 May 2019 19:13:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D56346B0287; Thu, 30 May 2019 19:13:43 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C1D9F6B0288; Thu, 30 May 2019 19:13:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 8D07C6B0286 for ; Thu, 30 May 2019 19:13:43 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id 21so3318020pgl.5 for ; Thu, 30 May 2019 16:13:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=UCa3fSyiqlwrDpLod135rZpcU+wyxyzgxJdHWmkgxng=; b=lf6FcmxLmyWVdq6sdHyrKGaxtDgnLNT24eogjiUOKPJGorlSqQLAnm7UYb2FOQg1In fvRcnqH3Ie3GpP3mjSdpKyIHQb6oRXtQs5rguQtKmhXImvTGuXrQtU9IuhVS+a3GTP+N GvoMhFXuQ0evwRHwobIVNm99Pu8fLxj75FOLnC8s7j+5R+4g+zC/hAxDo0JAbcdvs6rW hVN5HvIEvXFGypNRsXxc4m1r/O/pD4dnmgMC4666N31B98j3EFtGtS+PGoIF7sMeBoST 6ocvz2qZcN9Hn2tEuQ74n/GFNxoP3BDsY6BhwPa/gTJpT8kGyiZwcpoHeilO85RinTgp a5Uw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APjAAAWTjpSTijweuI3A/1Z1R+oRKdQAfzoNEelEMyVT0mNpvQRlhR1p 2rXQ1JSXe3a+2QcS7oRt5H44bKBPR9IxZpmW0Eytci9iEpHdRk41Nzbmc9f64L2khOd0lzjChqt GUgApSvB/wL69h0iKpi7CFfbK1Nkt7GjNhoZ6BvabI3GHcrgX4FVn8ihI7KNm2lJa4g== X-Received: by 2002:a17:902:f215:: with SMTP id gn21mr6246305plb.194.1559258023164; Thu, 30 May 2019 16:13:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+xoFUlCiw0cER/jBFDvpJQWxiU79wl6+QaM74q5VWd7FLfPP3itiLG/0pZ6bwRsctWpiL X-Received: by 2002:a17:902:f215:: with SMTP id gn21mr6246255plb.194.1559258022281; Thu, 30 May 2019 16:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559258022; cv=none; d=google.com; s=arc-20160816; b=GgIB85WfKZsS0+Rwt4l0OivzKpbwZJEKPPFhWUvlSbr3ZmtYjY/VTpPOBjv6URwyjO YH1XYkJP+cKq9+U9U+Y0iLB0xHHWr7OnCaovvzsn6QnSCx6DRmWSF0kJqxQ2sB/Y9gC5 KRAteOfqi1I9af3ix0rUiMObDPSUk4nZrI+p7Ctms+/4QxR1ZBQBy8Qi75AxKCjK3x+h zALkphYjGb9qLamPRMn0wEKBucCIYCN8B+ECi37+DZKS9JnScxuzMd1IeKTte0j4ZfSy vrniG31WLRDVSjWpvZaVBa9MuORxqWboX8Kve7zCv8EMgFRxPe3ZEN8otMlbgSzs38cf KaAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject; bh=UCa3fSyiqlwrDpLod135rZpcU+wyxyzgxJdHWmkgxng=; b=j3uBzBpbtAVCDLej0htuRTe56L2NqcvSa6rQyDfJtFKP7D8UyksRPRkwZg0I5bMgcY +OISgsAjHBFVAuLlA1UG0Crg33SoeV+3uHTUh3UdCLt0QIMQiHffTEmtG8HmGzD8KqPR t2NfXAf7f6wdCVoUEoZGWFHUOE0ygvyIvJvrijjIFSj+axKgJB58H0XPQmUW8f8YxlBn yL6Pdq/74Fkw8ZZfVjI0+1YTsN9Ktg23py3D5amb18oF2cU1w0nPiTTfEbBecJ1rrJDq hUyR17rPSUPts8CNi9StkqIgMhSpuePWljOiM82kd8PN6StZSRWjQeWHP81oxDtCPidX avtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga14.intel.com (mga14.intel.com. [192.55.52.115]) by mx.google.com with ESMTPS id y12si4094562pgr.329.2019.05.30.16.13.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 16:13:42 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.115 as permitted sender) client-ip=192.55.52.115; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 May 2019 16:13:41 -0700 X-ExtLoop1: 1 Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga005.jf.intel.com with ESMTP; 30 May 2019 16:13:41 -0700 Subject: [PATCH v2 6/8] device-dax: Add a driver for "hmem" devices From: Dan Williams To: linux-efi@vger.kernel.org Cc: Vishal Verma , Keith Busch , Dave Jiang , kbuild test robot , ard.biesheuvel@linaro.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-nvdimm@lists.01.org Date: Thu, 30 May 2019 15:59:53 -0700 Message-ID: <155925719374.3775979.16707226817593415735.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <155925716254.3775979.16716824941364738117.stgit@dwillia2-desk3.amr.corp.intel.com> References: <155925716254.3775979.16716824941364738117.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Platform firmware like EFI/ACPI may publish "hmem" platform devices. Such a device is a performance differentiated memory range likely reserved for an application specific use case. The driver gives access to 100% of the capacity via a device-dax mmap instance by default. However, if over-subscription and other kernel memory management is desired the resulting dax device can be assigned to the core-mm via the kmem driver. This consumes "hmem" devices the producer of "hmem" devices is saved for a follow-on patch so that it can reference the new CONFIG_DEV_DAX_HMEM symbol to gate performing the enumeration work. Cc: Vishal Verma Cc: Keith Busch Cc: Dave Jiang Reported-by: kbuild test robot Signed-off-by: Dan Williams --- drivers/dax/Kconfig | 27 +++++++++++++++++---- drivers/dax/Makefile | 2 ++ drivers/dax/hmem.c | 58 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/memregion.h | 3 ++ 4 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 drivers/dax/hmem.c diff --git a/drivers/dax/Kconfig b/drivers/dax/Kconfig index f33c73e4af41..9d653dfcd425 100644 --- a/drivers/dax/Kconfig +++ b/drivers/dax/Kconfig @@ -32,19 +32,36 @@ config DEV_DAX_PMEM Say M if unsure +config DEV_DAX_HMEM + tristate "HMEM DAX: direct access to 'specific purpose' memory" + depends on EFI_SPECIFIC_DAX + default DEV_DAX + help + EFI 2.8 platforms, and others, may advertise 'specific purpose' + memory. For example, a high bandwidth memory pool. The + indication from platform firmware is meant to reserve the + memory from typical usage by default. This driver creates + device-dax instances for these memory ranges, and that also + enables the possibility to assign them to the DEV_DAX_KMEM + driver to override the reservation and add them to kernel + "System RAM" pool. + + Say M if unsure. + config DEV_DAX_KMEM tristate "KMEM DAX: volatile-use of persistent memory" default DEV_DAX depends on DEV_DAX depends on MEMORY_HOTPLUG # for add_memory() and friends help - Support access to persistent memory as if it were RAM. This - allows easier use of persistent memory by unmodified - applications. + Support access to persistent, or other performance + differentiated memory as if it were System RAM. This allows + easier use of persistent memory by unmodified applications, or + adds core kernel memory services to heterogeneous memory types + (HMEM) marked "reserved" by platform firmware. To use this feature, a DAX device must be unbound from the - device_dax driver (PMEM DAX) and bound to this kmem driver - on each boot. + device_dax driver and bound to this kmem driver on each boot. Say N if unsure. diff --git a/drivers/dax/Makefile b/drivers/dax/Makefile index 81f7d54dadfb..80065b38b3c4 100644 --- a/drivers/dax/Makefile +++ b/drivers/dax/Makefile @@ -2,9 +2,11 @@ obj-$(CONFIG_DAX) += dax.o obj-$(CONFIG_DEV_DAX) += device_dax.o obj-$(CONFIG_DEV_DAX_KMEM) += kmem.o +obj-$(CONFIG_DEV_DAX_HMEM) += dax_hmem.o dax-y := super.o dax-y += bus.o device_dax-y := device.o +dax_hmem-y := hmem.o obj-y += pmem/ diff --git a/drivers/dax/hmem.c b/drivers/dax/hmem.c new file mode 100644 index 000000000000..741f2c222271 --- /dev/null +++ b/drivers/dax/hmem.c @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include +#include "bus.h" + +static int dax_hmem_probe(struct platform_device *pdev) +{ + struct dev_pagemap pgmap = { NULL }; + struct device *dev = &pdev->dev; + struct dax_region *dax_region; + struct memregion_info *mri; + struct dev_dax *dev_dax; + struct resource *res; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -ENOMEM; + + mri = dev->platform_data; + pgmap.dev = dev; + memcpy(&pgmap.res, res, sizeof(*res)); + + dax_region = alloc_dax_region(dev, pdev->id, res, mri->target_node, + PMD_SIZE, PFN_DEV|PFN_MAP); + if (!dax_region) + return -ENOMEM; + + dev_dax = devm_create_dev_dax(dax_region, 0, &pgmap); + if (IS_ERR(dev_dax)) + return PTR_ERR(dev_dax); + + /* child dev_dax instances now own the lifetime of the dax_region */ + dax_region_put(dax_region); + return 0; +} + +static int dax_hmem_remove(struct platform_device *pdev) +{ + /* devm handles teardown */ + return 0; +} + +static struct platform_driver dax_hmem_driver = { + .probe = dax_hmem_probe, + .remove = dax_hmem_remove, + .driver = { + .name = "hmem", + }, +}; + +module_platform_driver(dax_hmem_driver); + +MODULE_ALIAS("platform:hmem*"); +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Intel Corporation"); diff --git a/include/linux/memregion.h b/include/linux/memregion.h index ba03c70f98d2..920fb300a98b 100644 --- a/include/linux/memregion.h +++ b/include/linux/memregion.h @@ -3,6 +3,9 @@ #define _MEMREGION_H_ #include +struct memregion_info { + int target_node; +}; int memregion_alloc(gfp_t gfp); void memregion_free(int id); #endif /* _MEMREGION_H_ */ From patchwork Thu May 30 22:59:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10969365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 71D3D112C for ; Thu, 30 May 2019 23:13:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6292D28BE3 for ; Thu, 30 May 2019 23:13:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56F0728BFD; Thu, 30 May 2019 23:13:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E883928BE3 for ; Thu, 30 May 2019 23:13:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E19FC6B0287; Thu, 30 May 2019 19:13:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DA36E6B0288; Thu, 30 May 2019 19:13:48 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C92E66B0289; Thu, 30 May 2019 19:13:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 942456B0287 for ; Thu, 30 May 2019 19:13:48 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id 91so4904510pla.7 for ; Thu, 30 May 2019 16:13:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=YMgYp1mW1UbkaCFwuYGS6OZUOqXORkNmF9ijUZyqrbk=; b=g6KhcwJUHjWot7I/EmF0TgQ+7tDzvffQWqeXdvpL7gXda5nT+CDVxj3Cmr0nRGtrZY idr27LYpf38C7cez7RuxvBU+ikZVE2FWkJr5foF076rAjdrreFKnonJAZMO5A1r/M0sX 9pHKB4AtSrZHhX4lWPXJSqfbXp0z4ZxFis6aWM4auFo7rXeQIJrOlYuoFrhRYxqxJms1 U4cfOYVgT9dXPTUg1QJpfpUGILklB2kyc+vPqW/pTouM90hZqHD8Yf/BgbRAnfYyhUkp nx4fWoIpiAo7gPN7dRUzqG8QkboK2khpWK6h3ntYrukzb7omq0MV4kLVk97QSDI0+5my vcbg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APjAAAVBAk/o0rCMUAtpn786RRMKP0HA/PAPyXO6mjii1VpS8hH2wLA5 noIva+TXTx8+ItY5mDXiuJMY7vOxkAqEeSSGNUksQzAFTNfrP93W8l4QUunu5P8RC/mgFAaKKg7 L/ugtE9f64QJa74HUWiY19Cu9I67wrXgjq8VhxA9wKnb1MKZz45ukw1Fc7iUe2WugVQ== X-Received: by 2002:a62:e803:: with SMTP id c3mr6064418pfi.58.1559258028228; Thu, 30 May 2019 16:13:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBO7kgcD3GjgWc48q1Of/7xSQ8BR4wONPS5FeTAGyK/Nof22G0LOrptVxBJV3ineLpBc4L X-Received: by 2002:a62:e803:: with SMTP id c3mr6064367pfi.58.1559258027592; Thu, 30 May 2019 16:13:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559258027; cv=none; d=google.com; s=arc-20160816; b=M7P9jiQWG07NJ305m1d3Q0NuYlpTjpYu/o++4lvCtCmLZVCgQvmaLFPdOsAfu83xl0 UxZ1xou79xXuiMPBZctFpaq/5RPNMe1ykMTYHUkMCIrsl1pZd0FhsXJqFA/2D9NskPk2 GXLPFxy442anZcNvMDopps231izGemMHgvWNwdReZDMAbuos1NH0U4YDRC26+HULWjdq cSSdtYxKoNc2mDXYd9EEnQPzU9kuviJ0CnxXDUZeNw4/ps9rZL1CrWXYVMy54mXlyyHi wIBr8zdRwk5zem/LLfhXYTOswEssCSmcMjVRjB5PSQ5OcEyRqGOArawxqWi1Gs5wAHYU 6ITg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject; bh=YMgYp1mW1UbkaCFwuYGS6OZUOqXORkNmF9ijUZyqrbk=; b=vgKM1dEIJ4PDNkWkhiSQqbnqrKgUgtzxYqRbLjkcDwA1Nc+VzEHUNcIXenHjhXUcT0 Yug06gCbA9fV2icoNk9UsJ/feJNO60rC8x+JcMB+ZrCMgL+t2U7miqoLTvIqtgykK7v2 mdC7tuWRw3wLs9dzyEQn6j7cDpJ/WP892+oxv8TddxqtzcMIGItKCdaI4MAULb+XOw4m eVwev+fCpa7JNw64ZJj+VFW35927e2AFvWRdfnXLU3+qgalzN3h92/QDtFhRiDV/Tvz9 q5UUGtTbg/9sdsAe1GU5nrPUWRYK+nW19PEWYfyxgi38AbZUK2Q7UqlbDMDbjxgofUOQ 2UDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga05.intel.com (mga05.intel.com. [192.55.52.43]) by mx.google.com with ESMTPS id u7si4646865pfb.223.2019.05.30.16.13.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 16:13:47 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.43 as permitted sender) client-ip=192.55.52.43; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 May 2019 16:13:46 -0700 X-ExtLoop1: 1 Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga003.jf.intel.com with ESMTP; 30 May 2019 16:13:46 -0700 Subject: [PATCH v2 7/8] acpi/hmat: Register HMAT at device_initcall level From: Dan Williams To: linux-efi@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown , Keith Busch , Jonathan Cameron , vishal.l.verma@intel.com, ard.biesheuvel@linaro.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-nvdimm@lists.01.org Date: Thu, 30 May 2019 15:59:58 -0700 Message-ID: <155925719885.3775979.7601024961163509938.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <155925716254.3775979.16716824941364738117.stgit@dwillia2-desk3.amr.corp.intel.com> References: <155925716254.3775979.16716824941364738117.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP In preparation for registering device-dax instances for accessing EFI specific-purpose memory, arrange for the HMAT registration to occur later in the init process. Critically HMAT initialization needs to occur after e820__reserve_resources_late() which is the point at which the iomem resource tree is populated with "Application Reserved" (IORES_DESC_APPLICATION_RESERVED). e820__reserve_resources_late() happens at subsys_initcall time. Cc: "Rafael J. Wysocki" Cc: Len Brown Cc: Keith Busch Cc: Jonathan Cameron Signed-off-by: Dan Williams --- drivers/acpi/hmat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/hmat.c b/drivers/acpi/hmat.c index 2c220cb7b620..1d329c4af3bf 100644 --- a/drivers/acpi/hmat.c +++ b/drivers/acpi/hmat.c @@ -671,4 +671,4 @@ static __init int hmat_init(void) acpi_put_table(tbl); return 0; } -subsys_initcall(hmat_init); +device_initcall(hmat_init); From patchwork Thu May 30 23:00:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10969369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E642813AD for ; Thu, 30 May 2019 23:13:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D684F28BE3 for ; Thu, 30 May 2019 23:13:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB00F28BFD; Thu, 30 May 2019 23:13:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFE6528BE3 for ; Thu, 30 May 2019 23:13:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E69E46B0288; Thu, 30 May 2019 19:13:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DF4D26B0289; Thu, 30 May 2019 19:13:54 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C92BF6B028A; Thu, 30 May 2019 19:13:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id 90A256B0288 for ; Thu, 30 May 2019 19:13:54 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id d19so4922452pls.1 for ; Thu, 30 May 2019 16:13:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=XtiKYu/9Wz1HoJjONkoVJc8Zdc5PX4OKfafpmfTQaBQ=; b=UiFSNnSJKbPGECmpXCEvsEFqiaSQq1lprGRHtmAteQ0aNZG6pCDuZzMHYNuTowwiB0 ExprK2U25MzqRMHh5/bvsjyyDLDT9xrGcmPYky8FT5YBQ1pNAAwWDp/zHTXbORsvBcI/ D4g88dKzJeOH8tNTK00aEgnOu1SS4Q0RAi6iRyr8XTNiRIq5M5hJwp4f7twy6mN6bPNY o7bWhyBkSt19Prik/vPptTwlnadXH2tLQtRKKMo5GmpYcnqbXK0YNkzSZYrPvnW6cfcX dtYH06iyXrvaXGUUjzPDm8STPdtl4yIjyEWpngNeTmR9d6Tkxrs+k3PlSnihE9LH1M8F oL2w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APjAAAVCJxv8Dh27ypP959zOZriaLJgT2yeNgOUXy1oCiyCEcljfCc2B dRr9sGzTSvDYnXcd5aydKaT2X5jz1dqFO91CHmjewXy64JBSZWEwqjqxRzwton3INe7gcEep7Iy qSvWlrAPRXId8/85+K1kCJoR6CYy9KNZvj0pP2w3dPK1/R9i+qr2zZMt8noDlePqY6Q== X-Received: by 2002:a17:902:a708:: with SMTP id w8mr5665918plq.162.1559258034069; Thu, 30 May 2019 16:13:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLxj2CEONZ2Ar4zXiqSohC+NAU6tFCWJOmqkDX2LF5eWjCDc8si44EfCpF4iIFC1s9yE0U X-Received: by 2002:a17:902:a708:: with SMTP id w8mr5665847plq.162.1559258032848; Thu, 30 May 2019 16:13:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559258032; cv=none; d=google.com; s=arc-20160816; b=XoByC1Xeg19BV/sT+kZrUCAU/CSJNitZ+e8bkGnRybgCZU4CiWAb3tidq1jElCmGnb VvWEAP+WTjHBtIuMLHosCvfCzPtFUW3Sp3UHQ2zlfNU8qMvPbWxExGqxGBT+2c8307CJ z3v7Gf6isHwMAD+/lMeuSTs1t1nA7wf+W3ZLQOBnQHD8+YrpjxAXXbZ4ci7EmFRs0CC2 l1jVvZD1Vs60lARTXJiZRP781zxmFn2fEcc2J8QNA4cKzMP5M6U97PrT3pDWGBeF7rXn Icwnq28hdy1joxUZXzHUqWMtB4lX6jIMmpvfBRMaiTCGS4vR73QaK+S3lFy1gtFh/o/H unog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject; bh=XtiKYu/9Wz1HoJjONkoVJc8Zdc5PX4OKfafpmfTQaBQ=; b=qMeo7gQAIEubn7w0+BD6s3aIRzMlJBscPEOYNkz55uEeooWTDVUMBGZQvQ3oG9a3Ew tKh/3EUw3uAM5x1CIC5vQobIpoEfwCqs5cRpVJVDeXGvhwoDSGThOvvAm4XdxN78JCWi wFMJVyc15HLES84n/oior2SIIkuXy/ffZzi4WxNsyrCHli/WuFj6ISie4kNb6nhUHKa2 zEH9nA64Ro3rZpGHgNFoDqpw9ZVCBp5vD4IVcRn6SijxBZZrflYtqTIVEnbVwyF3/yy9 d/1f6itGvqhxHEEuOIAT8t+tLLPjs2VLCUDJ68J52otUW7mJrso+6EaMAgrEgyRPAN2l uhfw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id y8si4057486plt.202.2019.05.30.16.13.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 16:13:52 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 May 2019 16:13:51 -0700 X-ExtLoop1: 1 Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga008.fm.intel.com with ESMTP; 30 May 2019 16:13:51 -0700 Subject: [PATCH v2 8/8] acpi/hmat: Register "specific purpose" memory as an "hmem" device From: Dan Williams To: linux-efi@vger.kernel.org Cc: Len Brown , Keith Busch , "Rafael J. Wysocki" , Vishal Verma , Jonathan Cameron , ard.biesheuvel@linaro.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-nvdimm@lists.01.org Date: Thu, 30 May 2019 16:00:04 -0700 Message-ID: <155925720396.3775979.9430953493521643811.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <155925716254.3775979.16716824941364738117.stgit@dwillia2-desk3.amr.corp.intel.com> References: <155925716254.3775979.16716824941364738117.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Memory that has been tagged EFI_MEMORY_SP, 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. The device-dax "hmem" driver claims these devices by default and provides an mmap interface for the target application. If the administrator prefers, the hmem resource range can be made available to the core-mm via the device-dax hotplug facility, kmem, to online the memory with its own numa node. This was tested with an emulated HMAT produced by qemu (with the pending HMAT enabling patches), and "efi_fake_mem=8G@9G:0x40000" on the kernel command line to mark the memory ranges associated with node2 and node3 as EFI_MEMORY_SP. qemu numa configuration options: -numa node,mem=4G,cpus=0-19,nodeid=0 -numa node,mem=4G,cpus=20-39,nodeid=1 -numa node,mem=4G,nodeid=2 -numa node,mem=4G,nodeid=3 -numa dist,src=0,dst=0,val=10 -numa dist,src=0,dst=1,val=21 -numa dist,src=0,dst=2,val=21 -numa dist,src=0,dst=3,val=21 -numa dist,src=1,dst=0,val=21 -numa dist,src=1,dst=1,val=10 -numa dist,src=1,dst=2,val=21 -numa dist,src=1,dst=3,val=21 -numa dist,src=2,dst=0,val=21 -numa dist,src=2,dst=1,val=21 -numa dist,src=2,dst=2,val=10 -numa dist,src=2,dst=3,val=21 -numa dist,src=3,dst=0,val=21 -numa dist,src=3,dst=1,val=21 -numa dist,src=3,dst=2,val=21 -numa dist,src=3,dst=3,val=10 -numa hmat-lb,initiator=0,target=0,hierarchy=memory,data-type=access-latency,base-lat=10,latency=5 -numa hmat-lb,initiator=0,target=0,hierarchy=memory,data-type=access-bandwidth,base-bw=20,bandwidth=5 -numa hmat-lb,initiator=0,target=1,hierarchy=memory,data-type=access-latency,base-lat=10,latency=10 -numa hmat-lb,initiator=0,target=1,hierarchy=memory,data-type=access-bandwidth,base-bw=20,bandwidth=10 -numa hmat-lb,initiator=0,target=2,hierarchy=memory,data-type=access-latency,base-lat=10,latency=15 -numa hmat-lb,initiator=0,target=2,hierarchy=memory,data-type=access-bandwidth,base-bw=20,bandwidth=15 -numa hmat-lb,initiator=0,target=3,hierarchy=memory,data-type=access-latency,base-lat=10,latency=20 -numa hmat-lb,initiator=0,target=3,hierarchy=memory,data-type=access-bandwidth,base-bw=20,bandwidth=20 -numa hmat-lb,initiator=1,target=0,hierarchy=memory,data-type=access-latency,base-lat=10,latency=10 -numa hmat-lb,initiator=1,target=0,hierarchy=memory,data-type=access-bandwidth,base-bw=20,bandwidth=10 -numa hmat-lb,initiator=1,target=1,hierarchy=memory,data-type=access-latency,base-lat=10,latency=5 -numa hmat-lb,initiator=1,target=1,hierarchy=memory,data-type=access-bandwidth,base-bw=20,bandwidth=5 -numa hmat-lb,initiator=1,target=2,hierarchy=memory,data-type=access-latency,base-lat=10,latency=15 -numa hmat-lb,initiator=1,target=2,hierarchy=memory,data-type=access-bandwidth,base-bw=20,bandwidth=15 -numa hmat-lb,initiator=1,target=3,hierarchy=memory,data-type=access-latency,base-lat=10,latency=20 -numa hmat-lb,initiator=1,target=3,hierarchy=memory,data-type=access-bandwidth,base-bw=20,bandwidth=20 Result: # daxctl list -RDu [ { "path":"\/platform\/hmem.1", "id":1, "size":"4.00 GiB (4.29 GB)", "align":2097152, "devices":[ { "chardev":"dax1.0", "size":"4.00 GiB (4.29 GB)" } ] }, { "path":"\/platform\/hmem.0", "id":0, "size":"4.00 GiB (4.29 GB)", "align":2097152, "devices":[ { "chardev":"dax0.0", "size":"4.00 GiB (4.29 GB)" } ] } ] # cat /proc/iomem [..] 240000000-43fffffff : Application Reserved 240000000-33fffffff : hmem.0 240000000-33fffffff : dax0.0 340000000-43fffffff : hmem.1 340000000-43fffffff : dax1.0 Cc: Len Brown Cc: Keith Busch Cc: "Rafael J. Wysocki" Cc: Vishal Verma Cc: Jonathan Cameron Signed-off-by: Dan Williams --- drivers/acpi/Kconfig | 1 drivers/acpi/hmat.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 123 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index ec8691e4152f..a4e67b7dcc9d 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -480,6 +480,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.c b/drivers/acpi/hmat.c index 1d329c4af3bf..5c714e6e5293 100644 --- a/drivers/acpi/hmat.c +++ b/drivers/acpi/hmat.c @@ -8,11 +8,17 @@ * the applicable attributes with the node's interfaces. */ +#define pr_fmt(fmt) "acpi/hmat: " fmt +#define dev_fmt(fmt) "acpi/hmat: " fmt + #include #include #include #include #include +#include +#include +#include #include #include #include @@ -40,6 +46,7 @@ struct memory_target { struct list_head node; unsigned int memory_pxm; unsigned int processor_pxm; + struct resource memregions; struct node_hmem_attrs hmem_attrs; }; @@ -92,21 +99,35 @@ static __init void alloc_memory_initiator(unsigned int cpu_pxm) list_add_tail(&initiator->node, &initiators); } -static __init void alloc_memory_target(unsigned int mem_pxm) +static __init void alloc_memory_target(unsigned int mem_pxm, + resource_size_t start, resource_size_t len) { struct memory_target *target; target = find_mem_target(mem_pxm); - if (target) - return; - - target = kzalloc(sizeof(*target), GFP_KERNEL); - if (!target) - return; + if (!target) { + target = kzalloc(sizeof(*target), GFP_KERNEL); + if (!target) + return; + target->memory_pxm = mem_pxm; + target->processor_pxm = PXM_INVAL; + target->memregions = (struct resource) { + .name = "ACPI mem", + .start = 0, + .end = -1, + .flags = IORESOURCE_MEM, + }; + list_add_tail(&target->node, &targets); + } - target->memory_pxm = mem_pxm; - target->processor_pxm = PXM_INVAL; - list_add_tail(&target->node, &targets); + /* + * There are potentially multiple ranges per PXM, so record each + * in the per-target memregions resource tree. + */ + if (!__request_region(&target->memregions, start, len, "memory target", + IORESOURCE_MEM)) + pr_warn("failed to reserve %#llx - %#llx in pxm: %d\n", + start, start + len, mem_pxm); } static __init const char *hmat_data_type(u8 type) @@ -428,7 +449,7 @@ static __init int srat_parse_mem_affinity(union acpi_subtable_headers *header, return -EINVAL; if (!(ma->flags & ACPI_SRAT_MEM_ENABLED)) return 0; - alloc_memory_target(ma->proximity_domain); + alloc_memory_target(ma->proximity_domain, ma->base_address, ma->length); return 0; } @@ -580,6 +601,81 @@ 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 resource *r) +{ + /* define a clean / non-busy resource for the platform device */ + struct resource res = { + .start = r->start, + .end = r->end, + .flags = IORESOURCE_MEM, + }; + struct platform_device *pdev; + struct memregion_info info; + int rc, id; + + rc = region_intersects(res.start, resource_size(&res), IORESOURCE_MEM, + IORES_DESC_APPLICATION_RESERVED); + if (rc != REGION_INTERSECTS) + return; + + id = memregion_alloc(GFP_KERNEL); + if (id < 0) { + pr_err("memregion allocation failure for %pr\n", &res); + return; + } + + pdev = platform_device_alloc("hmem", id); + if (!pdev) { + pr_err("hmem device allocation failure for %pr\n", &res); + goto out_pdev; + } + + pdev->dev.numa_node = acpi_map_pxm_to_online_node(target->memory_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("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("hmem resource allocation failure for %pr\n", &res); + goto out_resource; + } + + rc = platform_device_add(pdev); + if (rc < 0) { + dev_err(&pdev->dev, "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_target_devices(struct memory_target *target) +{ + struct resource *res; + + /* + * Do not bother creating devices if no driver is available to + * consume them. + */ + if (!IS_ENABLED(CONFIG_DEV_DAX_HMEM)) + return; + + for (res = target->memregions.child; res; res = res->sibling) + hmat_register_target_device(target, res); +} + static __init void hmat_register_targets(void) { struct memory_target *target; @@ -587,6 +683,12 @@ static __init void hmat_register_targets(void) list_for_each_entry(target, &targets, node) { int nid = pxm_to_node(target->memory_pxm); + /* + * Devices may belong to either an offline or online + * node, so unconditionally add them. + */ + hmat_register_target_devices(target); + /* * Skip offline nodes. This can happen when memory * marked EFI_MEMORY_SP, "specific purpose", is applied @@ -608,7 +710,16 @@ static __init void hmat_free_structures(void) struct memory_initiator *initiator, *inext; list_for_each_entry_safe(target, tnext, &targets, node) { + struct resource *res, *res_next; + list_del(&target->node); + res = target->memregions.child; + while (res) { + res_next = res->sibling; + __release_region(&target->memregions, res->start, + resource_size(res)); + res = res_next; + } kfree(target); }