Skip to contentSkip to conversation

Add cpu hotplug support for powerpc/perf/hv-24x7

PATCH Superseded Kajol Jain 2 participants 7 messages Jun 18, 2020 – Jun 22, 2020

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Kajol Jain

author
#0 lore raw

cover Add cpu hotplug support for powerpc/perf/hv-24x7

This patchset add cpu hotplug support for hv_24x7 driver by adding online/offline cpu hotplug function. It also add sysfs file "cpumask" to expose current online cpu that can be used for hv_24x7 event count.

Kajol Jain (2):
powerpc/perf/hv-24x7: Add cpu hotplug support powerpc/hv-24x7: Add sysfs files inside hv-24x7 device to show cpumask

 .../sysfs-bus-event_source-devices-hv_24x7    |  6 ++
 arch/powerpc/perf/hv-24x7.c                   | 74 +++++++++++++++++++
 include/linux/cpuhotplug.h                    |  1 +
 3 files changed, 81 insertions(+)
Signature · 1 line
2.18.2
author
#1 lore raw

PATCH 1/2 powerpc/perf/hv-24x7: Add cpu hotplug support

Patch here adds cpu hotplug functions to hv_24x7 pmu. A new cpuhp_state "CPUHP_AP_PERF_POWERPC_HV_24x7_ONLINE" enum is added.

The online function update the cpumask only if its NULL. As the primary intention for adding hotplug support is to desiginate a CPU to make HCALL to collect the count data.

The offline function test and clear corresponding cpu in a cpumask and update cpumask to any other active cpu.

With this patchset, perf tool side does not need "-C <cpu>" to be added.

---
 arch/powerpc/perf/hv-24x7.c | 45 +++++++++++++++++++++++++++++++++++++
 include/linux/cpuhotplug.h  |  1 +
 2 files changed, 46 insertions(+)
arch/powerpc/perf/hv-24x7.c +45 -0
index db213eb7cb02..fdc4ae155d60 100644
@@ -31,6 +31,8 @@ static int interface_version;
 /* Whether we have to aggregate result data for some domains. */
 static bool aggregate_result_elements;
 
+static cpumask_t hv_24x7_cpumask;
+
 static bool domain_is_valid(unsigned domain)
 {
 	switch (domain) {
@@ -1641,6 +1643,44 @@ static struct pmu h_24x7_pmu = {
 	.capabilities = PERF_PMU_CAP_NO_EXCLUDE,
 };
 
+static int ppc_hv_24x7_cpu_online(unsigned int cpu)
+{
+	/* Make this CPU the designated target for counter collection */
+	if (cpumask_empty(&hv_24x7_cpumask))
+		cpumask_set_cpu(cpu, &hv_24x7_cpumask);
+
+	return 0;
+}
+
+static int ppc_hv_24x7_cpu_offline(unsigned int cpu)
+{
+	int target = -1;
+
+	/* Check if exiting cpu is used for collecting 24x7 events */
+	if (!cpumask_test_and_clear_cpu(cpu, &hv_24x7_cpumask))
+		return 0;
+
+	/* Find a new cpu to collect 24x7 events */
+	target = cpumask_any_but(cpu_active_mask, cpu);
+
+	if (target < 0 || target >= nr_cpu_ids)
+		return -1;
+
+	/* Migrate 24x7 events to the new target */
+	cpumask_set_cpu(target, &hv_24x7_cpumask);
+	perf_pmu_migrate_context(&h_24x7_pmu, cpu, target);
+
+	return 0;
+}
+
+static int hv_24x7_cpu_hotplug_init(void)
+{
+	return cpuhp_setup_state(CPUHP_AP_PERF_POWERPC_HV_24x7_ONLINE,
+			  "perf/powerpc/hv_24x7:online",
+			  ppc_hv_24x7_cpu_online,
+			  ppc_hv_24x7_cpu_offline);
+}
+
 static int hv_24x7_init(void)
 {
 	int r;
@@ -1685,6 +1725,11 @@ static int hv_24x7_init(void)
 	if (r)
 		return r;
 
+	/* init cpuhotplug */
+	r = hv_24x7_cpu_hotplug_init();
+	if (r)
+		pr_err("hv_24x7: CPU hotplug init failed\n");
+
 	r = perf_pmu_register(&h_24x7_pmu, h_24x7_pmu.name, -1);
 	if (r)
 		return r;
include/linux/cpuhotplug.h +1 -0
index 8377afef8806..16ed8f6f8774 100644
@@ -180,6 +180,7 @@ enum cpuhp_state {
 	CPUHP_AP_PERF_POWERPC_CORE_IMC_ONLINE,
 	CPUHP_AP_PERF_POWERPC_THREAD_IMC_ONLINE,
 	CPUHP_AP_PERF_POWERPC_TRACE_IMC_ONLINE,
+	CPUHP_AP_PERF_POWERPC_HV_24x7_ONLINE,
 	CPUHP_AP_WATCHDOG_ONLINE,
 	CPUHP_AP_WORKQUEUE_ONLINE,
 	CPUHP_AP_RCUTREE_ONLINE,
Signature · 1 line
2.18.2
#2 lore raw

Re: [PATCH 1/2] powerpc/perf/hv-24x7: Add cpu hotplug support

Hello Kajol,

Quoted 47 lines · Kajol Jain

Patch here adds cpu hotplug functions to hv_24x7 pmu. A new cpuhp_state "CPUHP_AP_PERF_POWERPC_HV_24x7_ONLINE" enum is added.

The online function update the cpumask only if its NULL. As the primary intention for adding hotplug support is to desiginate a CPU to make HCALL to collect the count data.

The offline function test and clear corresponding cpu in a cpumask and update cpumask to any other active cpu.

With this patchset, perf tool side does not need "-C <cpu>" to be added.

---
 arch/powerpc/perf/hv-24x7.c | 45 +++++++++++++++++++++++++++++++++++++
 include/linux/cpuhotplug.h  |  1 +
 2 files changed, 46 insertions(+)
arch/powerpc/perf/hv-24x7.c +11 -0
index db213eb7cb02..fdc4ae155d60 100644
@@ -31,6 +31,8 @@ static int interface_version;
 /* Whether we have to aggregate result data for some domains. */
 static bool aggregate_result_elements;
 
+static cpumask_t hv_24x7_cpumask;
+
 static bool domain_is_valid(unsigned domain)
 {
 	switch (domain) {
@@ -1641,6 +1643,44 @@ static struct pmu h_24x7_pmu = {
 	.capabilities = PERF_PMU_CAP_NO_EXCLUDE,
 };
 
+static int ppc_hv_24x7_cpu_online(unsigned int cpu)
+{
+	/* Make this CPU the designated target for counter collection */
+	if (cpumask_empty(&hv_24x7_cpumask))
+		cpumask_set_cpu(cpu, &hv_24x7_cpumask);
+
+	return 0;
+}
+

arch/powerpc/perf/hv-24x7.c static struct pmu h_24x7_pmu = { · line 1664

Quoted 10 lines
arch/powerpc/perf/hv-24x7.c +10 -0
+static int ppc_hv_24x7_cpu_offline(unsigned int cpu)
+{
+	int target = -1;
+
+	/* Check if exiting cpu is used for collecting 24x7 events */
+	if (!cpumask_test_and_clear_cpu(cpu, &hv_24x7_cpumask))
+		return 0;
+
+	/* Find a new cpu to collect 24x7 events */
+	target = cpumask_any_but(cpu_active_mask, cpu);

cpumask_any_but() typically picks the first CPU in cpu_active_mask that is not @cpu.

arch/powerpc/perf/hv-24x7.c static struct pmu h_24x7_pmu = { · line 1671

Quoted 7 lines
arch/powerpc/perf/hv-24x7.c +7 -0
+
+	if (target < 0 || target >= nr_cpu_ids)
+		return -1;
+
+	/* Migrate 24x7 events to the new target */
+	cpumask_set_cpu(target, &hv_24x7_cpumask);
+	perf_pmu_migrate_context(&h_24x7_pmu, cpu, target);

On a system with N CPUs numbered [O..N-1], can you please verify if the time required to sequentially offline CPUs [0..N-2] ,in that order, increase with this patch ?

I am asking this because we have encountered this problem once before at a customer site and the commit 9c9f8fb71fee ("powerpc/perf: Use cpumask_last() to determine the designated cpu for nest/core units.") was introduced to fix that problem.

Quoted 42 lines
arch/powerpc/perf/hv-24x7.c +17 -0
+
+	return 0;
+}
+
+static int hv_24x7_cpu_hotplug_init(void)
+{
+	return cpuhp_setup_state(CPUHP_AP_PERF_POWERPC_HV_24x7_ONLINE,
+			  "perf/powerpc/hv_24x7:online",
+			  ppc_hv_24x7_cpu_online,
+			  ppc_hv_24x7_cpu_offline);
+}
+
 static int hv_24x7_init(void)
 {
 	int r;
@@ -1685,6 +1725,11 @@ static int hv_24x7_init(void)
 	if (r)
 		return r;
 
+	/* init cpuhotplug */
+	r = hv_24x7_cpu_hotplug_init();
+	if (r)
+		pr_err("hv_24x7: CPU hotplug init failed\n");
+
 	r = perf_pmu_register(&h_24x7_pmu, h_24x7_pmu.name, -1);
 	if (r)
 		return r;
include/linux/cpuhotplug.h +1 -0
index 8377afef8806..16ed8f6f8774 100644
@@ -180,6 +180,7 @@ enum cpuhp_state {
 	CPUHP_AP_PERF_POWERPC_CORE_IMC_ONLINE,
 	CPUHP_AP_PERF_POWERPC_THREAD_IMC_ONLINE,
 	CPUHP_AP_PERF_POWERPC_TRACE_IMC_ONLINE,
+	CPUHP_AP_PERF_POWERPC_HV_24x7_ONLINE,
 	CPUHP_AP_WATCHDOG_ONLINE,
 	CPUHP_AP_WORKQUEUE_ONLINE,
 	CPUHP_AP_RCUTREE_ONLINE,
Signature · 1 line
2.18.2
author
#3 lore raw

Re: [PATCH 1/2] powerpc/perf/hv-24x7: Add cpu hotplug support

Quoted 78 lines · Gautham R Shenoy

Hello Kajol,

Quoted 47 lines · Kajol Jain

Patch here adds cpu hotplug functions to hv_24x7 pmu. A new cpuhp_state "CPUHP_AP_PERF_POWERPC_HV_24x7_ONLINE" enum is added.

The online function update the cpumask only if its NULL. As the primary intention for adding hotplug support is to desiginate a CPU to make HCALL to collect the count data.

The offline function test and clear corresponding cpu in a cpumask and update cpumask to any other active cpu.

With this patchset, perf tool side does not need "-C <cpu>" to be added.

---
 arch/powerpc/perf/hv-24x7.c | 45 +++++++++++++++++++++++++++++++++++++
 include/linux/cpuhotplug.h  |  1 +
 2 files changed, 46 insertions(+)
arch/powerpc/perf/hv-24x7.c +11 -0
index db213eb7cb02..fdc4ae155d60 100644
@@ -31,6 +31,8 @@ static int interface_version;
 /* Whether we have to aggregate result data for some domains. */
 static bool aggregate_result_elements;
 
+static cpumask_t hv_24x7_cpumask;
+
 static bool domain_is_valid(unsigned domain)
 {
 	switch (domain) {
@@ -1641,6 +1643,44 @@ static struct pmu h_24x7_pmu = {
 	.capabilities = PERF_PMU_CAP_NO_EXCLUDE,
 };
 
+static int ppc_hv_24x7_cpu_online(unsigned int cpu)
+{
+	/* Make this CPU the designated target for counter collection */
+	if (cpumask_empty(&hv_24x7_cpumask))
+		cpumask_set_cpu(cpu, &hv_24x7_cpumask);
+
+	return 0;
+}
+

arch/powerpc/perf/hv-24x7.c static struct pmu h_24x7_pmu = { · line 1664

Quoted 10 lines
arch/powerpc/perf/hv-24x7.c +10 -0
+static int ppc_hv_24x7_cpu_offline(unsigned int cpu)
+{
+	int target = -1;
+
+	/* Check if exiting cpu is used for collecting 24x7 events */
+	if (!cpumask_test_and_clear_cpu(cpu, &hv_24x7_cpumask))
+		return 0;
+
+	/* Find a new cpu to collect 24x7 events */
+	target = cpumask_any_but(cpu_active_mask, cpu);

cpumask_any_but() typically picks the first CPU in cpu_active_mask that is not @cpu.

arch/powerpc/perf/hv-24x7.c static struct pmu h_24x7_pmu = { · line 1671

Quoted 7 lines
arch/powerpc/perf/hv-24x7.c +7 -0
+
+	if (target < 0 || target >= nr_cpu_ids)
+		return -1;
+
+	/* Migrate 24x7 events to the new target */
+	cpumask_set_cpu(target, &hv_24x7_cpumask);
+	perf_pmu_migrate_context(&h_24x7_pmu, cpu, target);

On a system with N CPUs numbered [O..N-1], can you please verify if the time required to sequentially offline CPUs [0..N-2] ,in that order, increase with this patch ?

Quoted 5 lines

I am asking this because we have encountered this problem once before at a customer site and the commit 9c9f8fb71fee ("powerpc/perf: Use cpumask_last() to determine the designated cpu for nest/core units.") was introduced to fix that problem.

Hi Gautham,
Thanks for reviewing the patch. So, cpu_active_mask has bit 'cpu' set
only if that cpu is available. Even if we offline cpu non-sequentially it will update "cpu_acive_mask" accordingly.

This is some of test I tried:

command:# cat /sys/devices/hv_24x7/cpumask
0
command:# echo 0 > /sys/devices/system/cpu/cpu0/online command:# echo 0 > /sys/devices/system/cpu/cpu2/online command:# cat /sys/devices/hv_24x7/cpumask
1
command:# echo 0 > /sys/devices/system/cpu/cpu1/online command:# cat /sys/devices/hv_24x7/cpumask
3

Please let me know if my understanding is fine.

Thanks,
Kajol Jain

Quoted 42 lines
Quoted 42 lines
arch/powerpc/perf/hv-24x7.c +17 -0
+
+	return 0;
+}
+
+static int hv_24x7_cpu_hotplug_init(void)
+{
+	return cpuhp_setup_state(CPUHP_AP_PERF_POWERPC_HV_24x7_ONLINE,
+			  "perf/powerpc/hv_24x7:online",
+			  ppc_hv_24x7_cpu_online,
+			  ppc_hv_24x7_cpu_offline);
+}
+
 static int hv_24x7_init(void)
 {
 	int r;
@@ -1685,6 +1725,11 @@ static int hv_24x7_init(void)
 	if (r)
 		return r;
 
+	/* init cpuhotplug */
+	r = hv_24x7_cpu_hotplug_init();
+	if (r)
+		pr_err("hv_24x7: CPU hotplug init failed\n");
+
 	r = perf_pmu_register(&h_24x7_pmu, h_24x7_pmu.name, -1);
 	if (r)
 		return r;
include/linux/cpuhotplug.h +1 -0
index 8377afef8806..16ed8f6f8774 100644
@@ -180,6 +180,7 @@ enum cpuhp_state {
 	CPUHP_AP_PERF_POWERPC_CORE_IMC_ONLINE,
 	CPUHP_AP_PERF_POWERPC_THREAD_IMC_ONLINE,
 	CPUHP_AP_PERF_POWERPC_TRACE_IMC_ONLINE,
+	CPUHP_AP_PERF_POWERPC_HV_24x7_ONLINE,
 	CPUHP_AP_WATCHDOG_ONLINE,
 	CPUHP_AP_WORKQUEUE_ONLINE,
 	CPUHP_AP_RCUTREE_ONLINE,
Signature · 1 line
2.18.2
author
#4 lore raw

PATCH 2/2 powerpc/hv-24x7: Add sysfs files inside hv-24x7 device to show cpumask

In reply to Kajol Jain

Patch here adds a cpumask attr to hv_24x7 pmu along with ABI documentation.

command:# cat /sys/devices/hv_24x7/cpumask
0

---
 .../sysfs-bus-event_source-devices-hv_24x7    |  6 ++++
 arch/powerpc/perf/hv-24x7.c                   | 31 ++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 +6 -0
index e8698afcd952..281e7b367733 100644
@@ -43,6 +43,12 @@ Description:	read only
 		This sysfs interface exposes the number of cores per chip
 		present in the system.
 
+What:		/sys/devices/hv_24x7/cpumask
+Date:		June 2020
+Contact:	Linux on PowerPC Developer List <[email protected]>
+Description:	read only
+		This sysfs file exposes cpumask.
+
 What:		/sys/bus/event_source/devices/hv_24x7/event_descs/<event-name>
 Date:		February 2014
 Contact:	Linux on PowerPC Developer List <[email protected]>
arch/powerpc/perf/hv-24x7.c +30 -1
index fdc4ae155d60..03d870a9fc36 100644
@@ -448,6 +448,12 @@ static ssize_t device_show_string(struct device *dev,
 	return sprintf(buf, "%s\n", (char *)d->var);
 }
 
+static ssize_t cpumask_get_attr(struct device *dev,
+				struct device_attribute *attr, char *buf)
+{
+	return cpumap_print_to_pagebuf(true, buf, &hv_24x7_cpumask);
+}
+
 static ssize_t sockets_show(struct device *dev,
 			    struct device_attribute *attr, char *buf)
 {
@@ -1116,6 +1122,17 @@ static DEVICE_ATTR_RO(sockets);
 static DEVICE_ATTR_RO(chipspersocket);
 static DEVICE_ATTR_RO(coresperchip);
 
+static DEVICE_ATTR(cpumask, S_IRUGO, cpumask_get_attr, NULL);
+
+static struct attribute *cpumask_attrs[] = {
+	&dev_attr_cpumask.attr,
+	NULL,
+};
+
+static struct attribute_group cpumask_attr_group = {
+	.attrs = cpumask_attrs,
+};
+
 static struct bin_attribute *if_bin_attrs[] = {
 	&bin_attr_catalog,
 	NULL,
@@ -1143,6 +1160,11 @@ static const struct attribute_group *attr_groups[] = {
 	&event_desc_group,
 	&event_long_desc_group,
 	&if_group,
+	/*
+	 * This NULL is a placeholder for the cpumask attr which will update
+	 * onlyif cpuhotplug registration is successful
+	 */
+	NULL,
 	NULL,
 };
 
@@ -1727,8 +1749,15 @@ static int hv_24x7_init(void)
 
 	/* init cpuhotplug */
 	r = hv_24x7_cpu_hotplug_init();
-	if (r)
+	if (r) {
 		pr_err("hv_24x7: CPU hotplug init failed\n");
+	} else {
+		/*
+		 * Cpu hotplug init is successful, add the
+		 * cpumask file as part of pmu attr group
+		 */
+		attr_groups[5] = &cpumask_attr_group;
+	}
 
 	r = perf_pmu_register(&h_24x7_pmu, h_24x7_pmu.name, -1);
 	if (r)
Signature · 1 line
2.18.2
#5 lore raw

Re: [PATCH 2/2] powerpc/hv-24x7: Add sysfs files inside hv-24x7 device to show cpumask

Quoted 16 lines · Kajol Jain

Patch here adds a cpumask attr to hv_24x7 pmu along with ABI documentation.

command:# cat /sys/devices/hv_24x7/cpumask
0

---
 .../sysfs-bus-event_source-devices-hv_24x7    |  6 ++++
 arch/powerpc/perf/hv-24x7.c                   | 31 ++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 +0 -0
index e8698afcd952..281e7b367733 100644

Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 Description: read only · line 50

Quoted 8 lines
Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 +5 -0
@@ -43,6 +43,12 @@ Description:	read only
 		This sysfs interface exposes the number of cores per chip
 		present in the system.
 
+What:		/sys/devices/hv_24x7/cpumask
+Date:		June 2020
+Contact:	Linux on PowerPC Developer List <[email protected]>
+Description:	read only
+		This sysfs file exposes cpumask.

Could you please describe this in little more detail as to what the cpumask is ?

Quoted 54 lines
Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 +1 -0
+
 What:		/sys/bus/event_source/devices/hv_24x7/event_descs/<event-name>
 Date:		February 2014
 Contact:	Linux on PowerPC Developer List <[email protected]>
arch/powerpc/perf/hv-24x7.c +22 -0
index fdc4ae155d60..03d870a9fc36 100644
@@ -448,6 +448,12 @@ static ssize_t device_show_string(struct device *dev,
 	return sprintf(buf, "%s\n", (char *)d->var);
 }
 
+static ssize_t cpumask_get_attr(struct device *dev,
+				struct device_attribute *attr, char *buf)
+{
+	return cpumap_print_to_pagebuf(true, buf, &hv_24x7_cpumask);
+}
+
 static ssize_t sockets_show(struct device *dev,
 			    struct device_attribute *attr, char *buf)
 {
@@ -1116,6 +1122,17 @@ static DEVICE_ATTR_RO(sockets);
 static DEVICE_ATTR_RO(chipspersocket);
 static DEVICE_ATTR_RO(coresperchip);
 
+static DEVICE_ATTR(cpumask, S_IRUGO, cpumask_get_attr, NULL);
+
+static struct attribute *cpumask_attrs[] = {
+	&dev_attr_cpumask.attr,
+	NULL,
+};
+
+static struct attribute_group cpumask_attr_group = {
+	.attrs = cpumask_attrs,
+};
+
 static struct bin_attribute *if_bin_attrs[] = {
 	&bin_attr_catalog,
 	NULL,
@@ -1143,6 +1160,11 @@ static const struct attribute_group *attr_groups[] = {
 	&event_desc_group,
 	&event_long_desc_group,
 	&if_group,
+	/*
+	 * This NULL is a placeholder for the cpumask attr which will update
+	 * onlyif cpuhotplug registration is successful
+	 */
+	NULL,
 	NULL,
 };
 
@@ -1727,8 +1749,15 @@ static int hv_24x7_init(void)
 
 	/* init cpuhotplug */

arch/powerpc/perf/hv-24x7.c static int hv_24x7_init(void) · line 1759

Quoted 10 lines
arch/powerpc/perf/hv-24x7.c +7 -1
 	r = hv_24x7_cpu_hotplug_init();
-	if (r)
+	if (r) {
 		pr_err("hv_24x7: CPU hotplug init failed\n");
+	} else {
+		/*
+		 * Cpu hotplug init is successful, add the
+		 * cpumask file as part of pmu attr group
+		 */
+		attr_groups[5] = &cpumask_attr_group;

Since this is only a one-time initialization, wouldn't it be safer to iterate through attr_groups[] and assin cpumask_attr_group to the first NULL location ?

Quoted 7 lines
arch/powerpc/perf/hv-24x7.c +1 -0
+	}
 
 	r = perf_pmu_register(&h_24x7_pmu, h_24x7_pmu.name, -1);
 	if (r)
Signature · 1 line
2.18.2
author
#6 lore raw

Re: [PATCH 2/2] powerpc/hv-24x7: Add sysfs files inside hv-24x7 device to show cpumask

Quoted 20 lines · Gautham R Shenoy
Quoted 19 lines · Kajol Jain

Patch here adds a cpumask attr to hv_24x7 pmu along with ABI documentation.

command:# cat /sys/devices/hv_24x7/cpumask
0

---
 .../sysfs-bus-event_source-devices-hv_24x7    |  6 ++++
 arch/powerpc/perf/hv-24x7.c                   | 31 ++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 +0 -0
index e8698afcd952..281e7b367733 100644
@@ -43,6 +43,12 @@ Description:	read only
 		This sysfs interface exposes the number of cores per chip
 		present in the system.
 
Quoted 9 lines

Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 Description: read only · line 50

Quoted 5 lines
Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 +5 -0
+What:		/sys/devices/hv_24x7/cpumask
+Date:		June 2020
+Contact:	Linux on PowerPC Developer List <[email protected]>
+Description:	read only
+		This sysfs file exposes cpumask.

Could you please describe this in little more detail as to what the cpumask is ?

Hi Gautham,
Sure I will update the detail.

Quoted 53 lines
Quoted 53 lines
Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 +1 -0
+
 What:		/sys/bus/event_source/devices/hv_24x7/event_descs/<event-name>
 Date:		February 2014
 Contact:	Linux on PowerPC Developer List <[email protected]>
arch/powerpc/perf/hv-24x7.c +22 -0
index fdc4ae155d60..03d870a9fc36 100644
@@ -448,6 +448,12 @@ static ssize_t device_show_string(struct device *dev,
 	return sprintf(buf, "%s\n", (char *)d->var);
 }
 
+static ssize_t cpumask_get_attr(struct device *dev,
+				struct device_attribute *attr, char *buf)
+{
+	return cpumap_print_to_pagebuf(true, buf, &hv_24x7_cpumask);
+}
+
 static ssize_t sockets_show(struct device *dev,
 			    struct device_attribute *attr, char *buf)
 {
@@ -1116,6 +1122,17 @@ static DEVICE_ATTR_RO(sockets);
 static DEVICE_ATTR_RO(chipspersocket);
 static DEVICE_ATTR_RO(coresperchip);
 
+static DEVICE_ATTR(cpumask, S_IRUGO, cpumask_get_attr, NULL);
+
+static struct attribute *cpumask_attrs[] = {
+	&dev_attr_cpumask.attr,
+	NULL,
+};
+
+static struct attribute_group cpumask_attr_group = {
+	.attrs = cpumask_attrs,
+};
+
 static struct bin_attribute *if_bin_attrs[] = {
 	&bin_attr_catalog,
 	NULL,
@@ -1143,6 +1160,11 @@ static const struct attribute_group *attr_groups[] = {
 	&event_desc_group,
 	&event_long_desc_group,
 	&if_group,
+	/*
+	 * This NULL is a placeholder for the cpumask attr which will update
+	 * onlyif cpuhotplug registration is successful
+	 */
+	NULL,
 	NULL,
 };
 
@@ -1727,8 +1749,15 @@ static int hv_24x7_init(void)
 
Quoted 15 lines

arch/powerpc/perf/hv-24x7.c static int hv_24x7_init(void) · line 1759

Quoted 11 lines
arch/powerpc/perf/hv-24x7.c +7 -1
 	/* init cpuhotplug */
 	r = hv_24x7_cpu_hotplug_init();
-	if (r)
+	if (r) {
 		pr_err("hv_24x7: CPU hotplug init failed\n");
+	} else {
+		/*
+		 * Cpu hotplug init is successful, add the
+		 * cpumask file as part of pmu attr group
+		 */
+		attr_groups[5] = &cpumask_attr_group;

Since this is only a one-time initialization, wouldn't it be safer to iterate through attr_groups[] and assin cpumask_attr_group to the first NULL location ?

Yes thats right. Will update that part.

Thanks,
Kajol Jain

Quoted 8 lines
Quoted 8 lines
arch/powerpc/perf/hv-24x7.c +1 -0
+	}
 
 	r = perf_pmu_register(&h_24x7_pmu, h_24x7_pmu.name, -1);
 	if (r)
Signature · 1 line
2.18.2