From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8810DC43334 for ; Mon, 25 Jul 2022 06:37:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 78E678E0002; Mon, 25 Jul 2022 02:37:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 73DE18E0001; Mon, 25 Jul 2022 02:37:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 605F08E0002; Mon, 25 Jul 2022 02:37:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 523C88E0001 for ; Mon, 25 Jul 2022 02:37:50 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 163011A03CB for ; Mon, 25 Jul 2022 06:37:50 +0000 (UTC) X-FDA: 79724666700.21.74BF875 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf12.hostedemail.com (Postfix) with ESMTP id 3B46F400B9 for ; Mon, 25 Jul 2022 06:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658731069; x=1690267069; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=8SLs0JY1kGfaVztg6KPS61atwTU4p6amQQzBfjOtz3o=; b=MZBpCpAYhUyDR9O23LnnNbrIR+uJUQUFiCg9g5eMfP4qzCQ4h0jZPOe4 q8jUfn4ySQSghTOY7SwPin6OuujQFgpEYt+MvRXcQCyLb5iYHSXS+hunb L7pP4fbQ1iawPdNYSM1n3PwDpM7BJtW84aAE0IExhhNW0PgGOR8NWO5ce S5LpVqBO3wDb4L8EeiaTSeFPEYtz6J+OJKTkCXJt5wVZJb1PuC7v59/oS c1uGqiTP7s/7k1Vnnjk3xmhNXXCGrfd0hYQCX1KBpUacrPJ8Ws9Dqu3b/ MsLc0NxNJUFfeHsEnNX5EEahD5I5/LOjrzq2cLLrSBkG/R6WIf2hFr45V A==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="351619714" X-IronPort-AV: E=Sophos;i="5.93,192,1654585200"; d="scan'208";a="351619714" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 23:37:42 -0700 X-IronPort-AV: E=Sophos;i="5.93,192,1654585200"; d="scan'208";a="926777672" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.239.13.94]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 23:37:38 -0700 From: "Huang, Ying" To: "Aneesh Kumar K.V" Cc: linux-mm@kvack.org, akpm@linux-foundation.org, Wei Xu , Yang Shi , Davidlohr Bueso , Tim C Chen , Michal Hocko , Linux Kernel Mailing List , Hesham Almatary , Dave Hansen , Jonathan Cameron , Alistair Popple , Dan Williams , Johannes Weiner , jvgediya.oss@gmail.com Subject: Re: [PATCH v10 4/8] mm/demotion/dax/kmem: Set node's performance level to MEMTIER_PERF_LEVEL_PMEM References: <20220720025920.1373558-1-aneesh.kumar@linux.ibm.com> <20220720025920.1373558-5-aneesh.kumar@linux.ibm.com> Date: Mon, 25 Jul 2022 14:37:34 +0800 In-Reply-To: <20220720025920.1373558-5-aneesh.kumar@linux.ibm.com> (Aneesh Kumar K. V.'s message of "Wed, 20 Jul 2022 08:29:16 +0530") Message-ID: <874jz5zoi9.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658731069; a=rsa-sha256; cv=none; b=cgHQy6fO5xurc/yWiD+FVKuGWLFu2td0Jqboh+WWKEJQlgoMoQlPucf5hkYZHpHnyQIkpG dxBIt1GdIO8IYC3qNST25lkZWRfCB0stFcNDNHKKknqrWLcLSQWHDOLB85NFaU8OeC7oC1 J/DWuUiOJZPPH81J0BwR54rV3KKROWY= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=MZBpCpAY; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf12.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.100) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658731069; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+xVtVVppyBeZExZJwUgCSJEQC9I+Ibct+U/3YbiphxA=; b=5UgjdDBnPGq0nRyLBWFu9t+9o6qwi2THjDGvXZ6OtYylliRYVJZN9Xsmsecc64fhfTBD4E 22v22BLlBZaHzTl3BlEAvBLBrKTTE02qw3PxNZADL6ycdSlSaAbBzgopxLPcnMdxGZaAaS ka98Qfx0xLa7bvziKVWYbBV5k3O80DQ= X-Rspamd-Queue-Id: 3B46F400B9 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=MZBpCpAY; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf12.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.100) smtp.mailfrom=ying.huang@intel.com X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: q7ge38gb6wss5nno388bknyqyi8durxn X-HE-Tag: 1658731068-32214 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: "Aneesh Kumar K.V" writes: > By default, all nodes are assigned to the default memory tier which > is the memory tier designated for nodes with DRAM > > Set dax kmem device node's tier to slower memory tier by assigning > performance level to MEMTIER_PERF_LEVEL_PMEM. PMEM tier > appears below the default memory tier in demotion order. > > Signed-off-by: Aneesh Kumar K.V > --- > arch/powerpc/platforms/pseries/papr_scm.c | 41 ++++++++++++++++++++--- > drivers/acpi/nfit/core.c | 41 ++++++++++++++++++++++- > 2 files changed, 76 insertions(+), 6 deletions(-) > > diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c > index 82cae08976bc..3b6164418d6f 100644 > --- a/arch/powerpc/platforms/pseries/papr_scm.c > +++ b/arch/powerpc/platforms/pseries/papr_scm.c > @@ -14,6 +14,8 @@ > #include > #include > #include > +#include > +#include > > #include > #include > @@ -98,6 +100,7 @@ struct papr_scm_priv { > bool hcall_flush_required; > > uint64_t bound_addr; > + int target_node; > > struct nvdimm_bus_descriptor bus_desc; > struct nvdimm_bus *bus; > @@ -1278,6 +1281,7 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p) > p->bus_desc.module = THIS_MODULE; > p->bus_desc.of_node = p->pdev->dev.of_node; > p->bus_desc.provider_name = kstrdup(p->pdev->name, GFP_KERNEL); > + p->target_node = dev_to_node(&p->pdev->dev); > > /* Set the dimm command family mask to accept PDSMs */ > set_bit(NVDIMM_FAMILY_PAPR, &p->bus_desc.dimm_family_mask); > @@ -1322,7 +1326,7 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p) > mapping.size = p->blocks * p->block_size; // XXX: potential overflow? > > memset(&ndr_desc, 0, sizeof(ndr_desc)); > - target_nid = dev_to_node(&p->pdev->dev); > + target_nid = p->target_node; > online_nid = numa_map_to_online_node(target_nid); > ndr_desc.numa_node = online_nid; > ndr_desc.target_node = target_nid; > @@ -1582,15 +1586,42 @@ static struct platform_driver papr_scm_driver = { > }, > }; > > +static int papr_scm_callback(struct notifier_block *self, > + unsigned long action, void *arg) > +{ > + struct memory_notify *mnb = arg; > + int nid = mnb->status_change_nid; > + struct papr_scm_priv *p; > + > + if (nid == NUMA_NO_NODE || action != MEM_ONLINE) > + return NOTIFY_OK; > + > + mutex_lock(&papr_ndr_lock); > + list_for_each_entry(p, &papr_nd_regions, region_list) { > + if (p->target_node == nid) { > + node_devices[nid]->perf_level = MEMTIER_PERF_LEVEL_PMEM; > + break; > + } > + } > + > + mutex_unlock(&papr_ndr_lock); > + return NOTIFY_OK; > +} > + > static int __init papr_scm_init(void) > { > int ret; > > ret = platform_driver_register(&papr_scm_driver); > - if (!ret) > - mce_register_notifier(&mce_ue_nb); > - > - return ret; > + if (ret) > + return ret; > + mce_register_notifier(&mce_ue_nb); > + /* > + * register a memory hotplug notifier at prio 2 so that we > + * can update the perf level for the node. > + */ > + hotplug_memory_notifier(papr_scm_callback, MEMTIER_HOTPLUG_PRIO + 1); > + return 0; > } > module_init(papr_scm_init); > > diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c > index ae5f4acf2675..7ea1017ef790 100644 > --- a/drivers/acpi/nfit/core.c > +++ b/drivers/acpi/nfit/core.c > @@ -15,6 +15,8 @@ > #include > #include > #include > +#include > +#include > #include > #include > #include "intel.h" > @@ -3470,6 +3472,39 @@ static struct acpi_driver acpi_nfit_driver = { > }, > }; > > +static int nfit_callback(struct notifier_block *self, > + unsigned long action, void *arg) > +{ > + bool found = false; > + struct memory_notify *mnb = arg; > + int nid = mnb->status_change_nid; > + struct nfit_spa *nfit_spa; > + struct acpi_nfit_desc *acpi_desc; > + > + if (nid == NUMA_NO_NODE || action != MEM_ONLINE) > + return NOTIFY_OK; > + > + mutex_lock(&acpi_desc_lock); > + list_for_each_entry(acpi_desc, &acpi_descs, list) { > + mutex_lock(&acpi_desc->init_mutex); > + list_for_each_entry(nfit_spa, &acpi_desc->spas, list) { > + struct acpi_nfit_system_address *spa = nfit_spa->spa; > + int target_node = pxm_to_node(spa->proximity_domain); > + > + if (target_node == nid) { > + node_devices[nid]->perf_level = MEMTIER_PERF_LEVEL_PMEM; > + found = true; > + break; > + } > + } > + mutex_unlock(&acpi_desc->init_mutex); > + if (found) > + break; > + } > + mutex_unlock(&acpi_desc_lock); > + return NOTIFY_OK; > +} > + > static __init int nfit_init(void) > { > int ret; > @@ -3509,7 +3544,11 @@ static __init int nfit_init(void) > nfit_mce_unregister(); > destroy_workqueue(nfit_wq); > } > - > + /* > + * register a memory hotplug notifier at prio 2 so that we > + * can update the perf level for the node. > + */ > + hotplug_memory_notifier(nfit_callback, MEMTIER_HOTPLUG_PRIO + 1); > return ret; > > } I don't think that it's a good idea to set perf_level of a memory device (node) via NFIT only. For example, we may prefer HMAT over NFIT when it's available. So the perf_level should be set in dax/kmem.c based on information provided by ACPI or other information sources. ACPI can provide some functions/data structures to let drivers (like dax/kmem.c) to query the properties of the memory device (node). As the simplest first version, this can be just hard coded. Best Regards, Huang, Ying