[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20181203233509.20671-9-jglisse@redhat.com>
Date: Mon, 3 Dec 2018 18:35:03 -0500
From: jglisse@...hat.com
To: linux-mm@...ck.org
Cc: Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org,
Jérôme Glisse <jglisse@...hat.com>,
"Rafael J . Wysocki" <rafael@...nel.org>,
Ross Zwisler <ross.zwisler@...ux.intel.com>,
Dan Williams <dan.j.williams@...el.com>,
Dave Hansen <dave.hansen@...el.com>,
Haggai Eran <haggaie@...lanox.com>,
Balbir Singh <balbirs@....ibm.com>,
"Aneesh Kumar K . V" <aneesh.kumar@...ux.ibm.com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Felix Kuehling <felix.kuehling@....com>,
Philip Yang <Philip.Yang@....com>,
Christian König <christian.koenig@....com>,
Paul Blinzer <Paul.Blinzer@....com>,
Logan Gunthorpe <logang@...tatee.com>,
John Hubbard <jhubbard@...dia.com>,
Ralph Campbell <rcampbell@...dia.com>,
Michal Hocko <mhocko@...nel.org>,
Jonathan Cameron <jonathan.cameron@...wei.com>,
Mark Hairgrove <mhairgrove@...dia.com>,
Vivek Kini <vkini@...dia.com>,
Mel Gorman <mgorman@...hsingularity.net>,
Dave Airlie <airlied@...hat.com>,
Ben Skeggs <bskeggs@...hat.com>,
Andrea Arcangeli <aarcange@...hat.com>
Subject: [RFC PATCH 08/14] mm/hms: register main CPUs with heterogenenous memory system
From: Jérôme Glisse <jglisse@...hat.com>
Register CPUs as initiator under HMS scheme. CPUs are registered per
node (one initiator device per node per CPU). We also add the CPU to
the node default link so it is connected to main memory for the node.
For details see Documentation/vm/hms.rst.
Signed-off-by: Jérôme Glisse <jglisse@...hat.com>
Cc: Rafael J. Wysocki <rafael@...nel.org>
Cc: Ross Zwisler <ross.zwisler@...ux.intel.com>
Cc: Dan Williams <dan.j.williams@...el.com>
Cc: Dave Hansen <dave.hansen@...el.com>
Cc: Haggai Eran <haggaie@...lanox.com>
Cc: Balbir Singh <balbirs@....ibm.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@...ux.ibm.com>
Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>
Cc: Felix Kuehling <felix.kuehling@....com>
Cc: Philip Yang <Philip.Yang@....com>
Cc: Christian König <christian.koenig@....com>
Cc: Paul Blinzer <Paul.Blinzer@....com>
Cc: Logan Gunthorpe <logang@...tatee.com>
Cc: John Hubbard <jhubbard@...dia.com>
Cc: Ralph Campbell <rcampbell@...dia.com>
Cc: Michal Hocko <mhocko@...nel.org>
Cc: Jonathan Cameron <jonathan.cameron@...wei.com>
Cc: Mark Hairgrove <mhairgrove@...dia.com>
Cc: Vivek Kini <vkini@...dia.com>
Cc: Mel Gorman <mgorman@...hsingularity.net>
Cc: Dave Airlie <airlied@...hat.com>
Cc: Ben Skeggs <bskeggs@...hat.com>
Cc: Andrea Arcangeli <aarcange@...hat.com>
---
drivers/base/cpu.c | 5 +++++
drivers/base/node.c | 18 +++++++++++++++++-
include/linux/cpu.h | 4 ++++
3 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index eb9443d5bae1..160454bc5c38 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -76,6 +76,8 @@ void unregister_cpu(struct cpu *cpu)
{
int logical_cpu = cpu->dev.id;
+ hms_initiator_unregister(&cpu->initiator);
+
unregister_cpu_under_node(logical_cpu, cpu_to_node(logical_cpu));
device_unregister(&cpu->dev);
@@ -392,6 +394,9 @@ int register_cpu(struct cpu *cpu, int num)
dev_pm_qos_expose_latency_limit(&cpu->dev,
PM_QOS_RESUME_LATENCY_NO_CONSTRAINT);
+ hms_initiator_register(&cpu->initiator, &cpu->dev,
+ cpu_to_node(num), 0);
+
return 0;
}
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 05621ba3cf13..43f1820cdadb 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -375,9 +375,19 @@ int register_cpu_under_node(unsigned int cpu, unsigned int nid)
if (ret)
return ret;
- return sysfs_create_link(&obj->kobj,
+ ret = sysfs_create_link(&obj->kobj,
&node_devices[nid]->dev.kobj,
kobject_name(&node_devices[nid]->dev.kobj));
+ if (ret)
+ return ret;
+
+ if (IS_ENABLED(CONFIG_HMS)) {
+ struct cpu *cpu = container_of(obj, struct cpu, dev);
+
+ hms_link_initiator(node_devices[nid]->link, cpu->initiator);
+ }
+
+ return 0;
}
int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
@@ -396,6 +406,12 @@ int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
sysfs_remove_link(&obj->kobj,
kobject_name(&node_devices[nid]->dev.kobj));
+ if (IS_ENABLED(CONFIG_HMS)) {
+ struct cpu *cpu = container_of(obj, struct cpu, dev);
+
+ hms_unlink_initiator(node_devices[nid]->link, cpu->initiator);
+ }
+
return 0;
}
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 218df7f4d3e1..1e3a777bfa3d 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -14,6 +14,7 @@
#ifndef _LINUX_CPU_H_
#define _LINUX_CPU_H_
+#include <linux/hms.h>
#include <linux/node.h>
#include <linux/compiler.h>
#include <linux/cpumask.h>
@@ -27,6 +28,9 @@ struct cpu {
int node_id; /* The node which contains the CPU */
int hotpluggable; /* creates sysfs control file if hotpluggable */
struct device dev;
+#if defined(CONFIG_HMS)
+ struct hms_initiator *initiator;
+#endif
};
extern void boot_cpu_init(void);
--
2.17.2
Powered by blists - more mailing lists