From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by kanga.kvack.org (Postfix) with ESMTP id AC6D06B6BB2 for ; Mon, 3 Dec 2018 18:36:11 -0500 (EST) Received: by mail-qt1-f200.google.com with SMTP id z6so15158280qtj.21 for ; Mon, 03 Dec 2018 15:36:11 -0800 (PST) Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id n69si2780294qkn.55.2018.12.03.15.36.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Dec 2018 15:36:10 -0800 (PST) From: jglisse@redhat.com Subject: [RFC PATCH 08/14] mm/hms: register main CPUs with heterogenenous memory system Date: Mon, 3 Dec 2018 18:35:03 -0500 Message-Id: <20181203233509.20671-9-jglisse@redhat.com> In-Reply-To: <20181203233509.20671-1-jglisse@redhat.com> References: <20181203233509.20671-1-jglisse@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: owner-linux-mm@kvack.org List-ID: To: linux-mm@kvack.org Cc: Andrew Morton , linux-kernel@vger.kernel.org, =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , "Rafael J . Wysocki" , Ross Zwisler , Dan Williams , Dave Hansen , Haggai Eran , Balbir Singh , "Aneesh Kumar K . V" , Benjamin Herrenschmidt , Felix Kuehling , Philip Yang , =?UTF-8?q?Christian=20K=C3=B6nig?= , Paul Blinzer , Logan Gunthorpe , John Hubbard , Ralph Campbell , Michal Hocko , Jonathan Cameron , Mark Hairgrove , Vivek Kini , Mel Gorman , Dave Airlie , Ben Skeggs , Andrea Arcangeli From: Jérôme Glisse 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 Cc: Rafael J. Wysocki Cc: Ross Zwisler Cc: Dan Williams Cc: Dave Hansen Cc: Haggai Eran Cc: Balbir Singh Cc: Aneesh Kumar K.V Cc: Benjamin Herrenschmidt Cc: Felix Kuehling Cc: Philip Yang Cc: Christian König Cc: Paul Blinzer Cc: Logan Gunthorpe Cc: John Hubbard Cc: Ralph Campbell Cc: Michal Hocko Cc: Jonathan Cameron Cc: Mark Hairgrove Cc: Vivek Kini Cc: Mel Gorman Cc: Dave Airlie Cc: Ben Skeggs Cc: Andrea Arcangeli --- 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 #include #include #include @@ -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