Commit dcb5cdf6 authored by Kajol Jain's avatar Kajol Jain Committed by Michael Ellerman

powerpc/perf/hv-gpci: Add cpu hotplug support

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

The online callback function updates the cpumask only if its
empty. As the primary intention of adding hotplug support
is to designate a CPU to make HCALL to collect the
counter data.

The offline function test and clear corresponding cpu in a cpumask
and update cpumask to any other active cpu.
Signed-off-by: default avatarKajol Jain <kjain@linux.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20201003074943.338618-4-kjain@linux.ibm.com
parent 435387dd
...@@ -48,6 +48,8 @@ EVENT_DEFINE_RANGE_FORMAT(length, config1, 24, 31); ...@@ -48,6 +48,8 @@ EVENT_DEFINE_RANGE_FORMAT(length, config1, 24, 31);
/* u32, byte offset */ /* u32, byte offset */
EVENT_DEFINE_RANGE_FORMAT(offset, config1, 32, 63); EVENT_DEFINE_RANGE_FORMAT(offset, config1, 32, 63);
static cpumask_t hv_gpci_cpumask;
static struct attribute *format_attrs[] = { static struct attribute *format_attrs[] = {
&format_attr_request.attr, &format_attr_request.attr,
&format_attr_starting_index.attr, &format_attr_starting_index.attr,
...@@ -266,6 +268,45 @@ static struct pmu h_gpci_pmu = { ...@@ -266,6 +268,45 @@ static struct pmu h_gpci_pmu = {
.capabilities = PERF_PMU_CAP_NO_EXCLUDE, .capabilities = PERF_PMU_CAP_NO_EXCLUDE,
}; };
static int ppc_hv_gpci_cpu_online(unsigned int cpu)
{
if (cpumask_empty(&hv_gpci_cpumask))
cpumask_set_cpu(cpu, &hv_gpci_cpumask);
return 0;
}
static int ppc_hv_gpci_cpu_offline(unsigned int cpu)
{
int target;
/* Check if exiting cpu is used for collecting gpci events */
if (!cpumask_test_and_clear_cpu(cpu, &hv_gpci_cpumask))
return 0;
/* Find a new cpu to collect gpci events */
target = cpumask_last(cpu_active_mask);
if (target < 0 || target >= nr_cpu_ids) {
pr_err("hv_gpci: CPU hotplug init failed\n");
return -1;
}
/* Migrate gpci events to the new target */
cpumask_set_cpu(target, &hv_gpci_cpumask);
perf_pmu_migrate_context(&h_gpci_pmu, cpu, target);
return 0;
}
static int hv_gpci_cpu_hotplug_init(void)
{
return cpuhp_setup_state(CPUHP_AP_PERF_POWERPC_HV_GPCI_ONLINE,
"perf/powerpc/hv_gcpi:online",
ppc_hv_gpci_cpu_online,
ppc_hv_gpci_cpu_offline);
}
static int hv_gpci_init(void) static int hv_gpci_init(void)
{ {
int r; int r;
...@@ -286,6 +327,11 @@ static int hv_gpci_init(void) ...@@ -286,6 +327,11 @@ static int hv_gpci_init(void)
return -ENODEV; return -ENODEV;
} }
/* init cpuhotplug */
r = hv_gpci_cpu_hotplug_init();
if (r)
return r;
/* sampling not supported */ /* sampling not supported */
h_gpci_pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; h_gpci_pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT;
......
...@@ -183,6 +183,7 @@ enum cpuhp_state { ...@@ -183,6 +183,7 @@ enum cpuhp_state {
CPUHP_AP_PERF_POWERPC_THREAD_IMC_ONLINE, CPUHP_AP_PERF_POWERPC_THREAD_IMC_ONLINE,
CPUHP_AP_PERF_POWERPC_TRACE_IMC_ONLINE, CPUHP_AP_PERF_POWERPC_TRACE_IMC_ONLINE,
CPUHP_AP_PERF_POWERPC_HV_24x7_ONLINE, CPUHP_AP_PERF_POWERPC_HV_24x7_ONLINE,
CPUHP_AP_PERF_POWERPC_HV_GPCI_ONLINE,
CPUHP_AP_WATCHDOG_ONLINE, CPUHP_AP_WATCHDOG_ONLINE,
CPUHP_AP_WORKQUEUE_ONLINE, CPUHP_AP_WORKQUEUE_ONLINE,
CPUHP_AP_RCUTREE_ONLINE, CPUHP_AP_RCUTREE_ONLINE,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment