From: "Gautham R. Shenoy" <ego@linux.vnet.ibm.com>
To: Dave Hansen <dave.hansen@intel.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Michael Neuling <mikey@neuling.org>,
Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>,
Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>,
Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>,
"Oliver O'Halloran" <oohall@gmail.com>,
Nicholas Piggin <npiggin@gmail.com>,
Murilo Opsfelder Araujo <muriloo@linux.ibm.com>,
Anton Blanchard <anton@samba.org>
Cc: "Gautham R. Shenoy" <ego@linux.vnet.ibm.com>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: [PATCH v9 3/3] powerpc/sysfs: Add topology/smallcore_thread_siblings[_list]
Date: Mon, 1 Oct 2018 18:46:42 +0530 [thread overview]
Message-ID: <1538399802-23582-4-git-send-email-ego@linux.vnet.ibm.com> (raw)
In-Reply-To: <1538399802-23582-1-git-send-email-ego@linux.vnet.ibm.com>
From: "Gautham R. Shenoy" <ego@linux.vnet.ibm.com>
This patch adds two sysfs attributes named smallcore_thread_siblings
and smallcore_thread_siblings_list to the "topology" attribute group
for each CPU device.
The read-only attributes
/sys/device/system/cpu/cpuN/topology/smallcore_thread_siblings and
/sys/device/system/cpu/cpuN/topology/smallcore_thread_siblings_list
will the online siblings of CPU N that share the L1 cache with it on
big-core configurations in cpumask format and cpu-list format
respectively.
Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
---
Documentation/ABI/testing/sysfs-devices-system-cpu | 14 ++++
arch/powerpc/kernel/sysfs.c | 91 ++++++++++++++++++++++
2 files changed, 105 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu
index 7331822..2a80dc2 100644
--- a/Documentation/ABI/testing/sysfs-devices-system-cpu
+++ b/Documentation/ABI/testing/sysfs-devices-system-cpu
@@ -511,3 +511,17 @@ Description: Control Symetric Multi Threading (SMT)
If control status is "forceoff" or "notsupported" writes
are rejected.
+
+What: /sys/devices/system/cpu/cpu#/topology/smallcore_thread_siblings
+ /sys/devices/system/cpu/cpu#/topology/smallcore_thread_siblings_list
+Date: Sept 2018
+Contact: Linux for PowerPC mailing list <linuxppc-dev@ozlabs.org>
+Description: CPU topology files that describe the thread siblings of a
+ logical CPU that share the L1-cache with it on POWER9
+ big-core configurations.
+
+ smallcore_thread_siblings: internal kernel map of
+ cpu#'s hardware threads that share L1-cache with cpu#.
+
+ smallcore_thread_siblings_list: human-readable list of
+ cpu#'s hardware threads that share L1-cache with cpu#.
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 755dc98..3049511 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -18,6 +18,7 @@
#include <asm/smp.h>
#include <asm/pmc.h>
#include <asm/firmware.h>
+#include <asm/cputhreads.h>
#include "cacheinfo.h"
#include "setup.h"
@@ -1060,3 +1061,93 @@ static int __init topology_init(void)
return 0;
}
subsys_initcall(topology_init);
+
+#ifdef CONFIG_SMP
+static ssize_t smallcore_thread_siblings_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ int cpu = dev->id;
+
+ return cpumap_print_to_pagebuf(false, buf, cpu_smallcore_mask(cpu));
+}
+static DEVICE_ATTR_RO(smallcore_thread_siblings);
+
+static ssize_t
+ smallcore_thread_siblings_list_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ int cpu = dev->id;
+
+ return cpumap_print_to_pagebuf(true, buf, cpu_smallcore_mask(cpu));
+}
+static DEVICE_ATTR_RO(smallcore_thread_siblings_list);
+
+static struct attribute *smallcore_attrs[] = {
+ &dev_attr_smallcore_thread_siblings.attr,
+ &dev_attr_smallcore_thread_siblings_list.attr,
+ NULL
+};
+
+static const struct attribute_group smallcore_attr_group = {
+ .name = "topology",
+ .attrs = smallcore_attrs
+};
+
+static int smallcore_register_cpu_online(unsigned int cpu)
+{
+ int err;
+ struct device *cpu_dev = get_cpu_device(cpu);
+
+ if (!has_big_cores)
+ return 0;
+
+ err = sysfs_merge_group(&cpu_dev->kobj, &smallcore_attr_group);
+
+ return err;
+}
+
+static int smallcore_unregister_cpu_online(unsigned int cpu)
+{
+ struct device *cpu_dev = get_cpu_device(cpu);
+
+ if (!has_big_cores)
+ return 0;
+
+ sysfs_unmerge_group(&cpu_dev->kobj, &smallcore_attr_group);
+
+ return 0;
+}
+
+/*
+ * NOTE: The smallcore_register_cpu_online
+ * (resp. smallcore_unregister_cpu_online) callback will merge
+ * (resp. unmerge) a couple of additional attributes to the
+ * "topology" attribute group of a CPU device when the CPU comes
+ * online (resp. goes offline).
+ *
+ * Hence, the registration of these callbacks must happen after
+ * topology_sysfs_init() is called so that the topology
+ * attribute group is created before these additional attributes
+ * can be merged/unmerged. We cannot register these callbacks in
+ * topology_init() since this function is called before
+ * topology_sysfs_init(). Hence we define the following
+ * late_initcall for this purpose.
+ */
+static int __init smallcore_topology_init(void)
+{
+ int r;
+
+ if (!has_big_cores)
+ return 0;
+
+ r = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
+ "powerpc/topology/smallcore:online",
+ smallcore_register_cpu_online,
+ smallcore_unregister_cpu_online);
+ WARN_ON(r < 0);
+ return 0;
+}
+late_initcall(smallcore_topology_init);
+#endif /* CONFIG_SMP */
--
1.9.4
next prev parent reply other threads:[~2018-10-01 13:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-01 13:16 [PATCH v9 0/3] powerpc: Detection and scheduler optimization for POWER9 bigcore Gautham R. Shenoy
2018-10-01 13:16 ` [PATCH v9 1/3] powerpc: Detect the presence of big-cores via "ibm, thread-groups" Gautham R. Shenoy
2018-10-01 13:16 ` [PATCH v9 2/3] powerpc: Use cpu_smallcore_sibling_mask at SMT level on bigcores Gautham R. Shenoy
2018-10-01 13:16 ` Gautham R. Shenoy [this message]
2018-10-01 14:05 ` [PATCH v9 0/3] powerpc: Detection and scheduler optimization for POWER9 bigcore Dave Hansen
2018-10-03 11:19 ` Gautham R Shenoy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1538399802-23582-4-git-send-email-ego@linux.vnet.ibm.com \
--to=ego@linux.vnet.ibm.com \
--cc=akshay.adiga@linux.vnet.ibm.com \
--cc=aneesh.kumar@linux.ibm.com \
--cc=anton@samba.org \
--cc=benh@kernel.crashing.org \
--cc=dave.hansen@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mikey@neuling.org \
--cc=mpe@ellerman.id.au \
--cc=muriloo@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=oohall@gmail.com \
--cc=shilpa.bhat@linux.vnet.ibm.com \
--cc=srikar@linux.vnet.ibm.com \
--cc=svaidy@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).