[PATCH v2 3/5] powerpc/perf: Add an interface sub-folder to imc pmu

Anju T Sudhakar anju at linux.vnet.ibm.com
Tue Jan 21 21:17:26 AEDT 2020


From: Madhavan Srinivasan <maddy at linux.ibm.com>

Patch adds an interface attribute folder to imc pmu.
This is intended to include pmu intreface capabilities
which will be useful to userspace likes selftest
testcases. Patch adds a "glob_lck" file to notify to
userspace of global lock mechanism added to imc devices
like core, thread and trace.

"glob_lck" will be used by selftest file to execute
interface test for the global lock mechanism.

Signed-off-by: Madhavan Srinivasan <maddy at linux.ibm.com>
---
 arch/powerpc/include/asm/imc-pmu.h | 11 ++++++-----
 arch/powerpc/perf/imc-pmu.c        | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/include/asm/imc-pmu.h b/arch/powerpc/include/asm/imc-pmu.h
index 4da4fcba0684..1b2c33c30e7c 100644
--- a/arch/powerpc/include/asm/imc-pmu.h
+++ b/arch/powerpc/include/asm/imc-pmu.h
@@ -87,8 +87,9 @@ struct trace_imc_data {
 /* Event attribute array index */
 #define IMC_FORMAT_ATTR		0
 #define IMC_EVENT_ATTR		1
-#define IMC_CPUMASK_ATTR	2
-#define IMC_NULL_ATTR		3
+#define IMC_INTERFACE_ATTR	2
+#define IMC_CPUMASK_ATTR	3
+#define IMC_NULL_ATTR		4
 
 /* PMU Format attribute macros */
 #define IMC_EVENT_OFFSET_MASK	0xffffffffULL
@@ -114,10 +115,10 @@ struct imc_pmu {
 	/*
 	 * Attribute groups for the PMU. Slot 0 used for
 	 * format attribute, slot 1 used for cpusmask attribute,
-	 * slot 2 used for event attribute. Slot 3 keep as
-	 * NULL.
+	 * slot 2 used for event attribute. Slot 3 used for interface
+	 * attribute and Slot 4 is NULL.
 	 */
-	const struct attribute_group *attr_groups[4];
+	const struct attribute_group *attr_groups[5];
 	u32 counter_mem_size;
 	int domain;
 	/*
diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c
index 2e220f199530..3f49664f29f1 100644
--- a/arch/powerpc/perf/imc-pmu.c
+++ b/arch/powerpc/perf/imc-pmu.c
@@ -54,6 +54,24 @@ static struct imc_pmu_ref imc_global_refc = {
 	.refc = 0,
 };
 
+static ssize_t glob_lck_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%d\n", 1);
+}
+
+static DEVICE_ATTR_RO(glob_lck);
+
+static struct attribute *imc_interface_attrs[] = {
+	&dev_attr_glob_lck.attr,
+	NULL,
+};
+
+static struct attribute_group imc_interface_group = {
+	.name = "interface",
+	.attrs = imc_interface_attrs,
+};
+
 static struct imc_pmu *imc_event_to_pmu(struct perf_event *event)
 {
 	return container_of(event->pmu, struct imc_pmu, pmu);
@@ -1462,6 +1480,7 @@ static int update_pmu_ops(struct imc_pmu *pmu)
 	pmu->pmu.attr_groups = pmu->attr_groups;
 	pmu->pmu.capabilities = PERF_PMU_CAP_NO_EXCLUDE;
 	pmu->attr_groups[IMC_FORMAT_ATTR] = &imc_format_group;
+	pmu->attr_groups[IMC_INTERFACE_ATTR] = &imc_interface_group;
 
 	switch (pmu->domain) {
 	case IMC_DOMAIN_NEST:
-- 
2.20.1



More information about the Linuxppc-dev mailing list