Commit 6e103c0c authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Thomas Gleixner

arm/perf: Use multi instance instead of custom list

Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160817171420.sdwk2qivxunzryz4@linutronix.deSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent cf392d10
...@@ -688,28 +688,20 @@ static int cpu_pmu_request_irq(struct arm_pmu *cpu_pmu, irq_handler_t handler) ...@@ -688,28 +688,20 @@ static int cpu_pmu_request_irq(struct arm_pmu *cpu_pmu, irq_handler_t handler)
return 0; return 0;
} }
static DEFINE_SPINLOCK(arm_pmu_lock);
static LIST_HEAD(arm_pmu_list);
/* /*
* PMU hardware loses all context when a CPU goes offline. * PMU hardware loses all context when a CPU goes offline.
* When a CPU is hotplugged back in, since some hardware registers are * When a CPU is hotplugged back in, since some hardware registers are
* UNKNOWN at reset, the PMU must be explicitly reset to avoid reading * UNKNOWN at reset, the PMU must be explicitly reset to avoid reading
* junk values out of them. * junk values out of them.
*/ */
static int arm_perf_starting_cpu(unsigned int cpu) static int arm_perf_starting_cpu(unsigned int cpu, struct hlist_node *node)
{ {
struct arm_pmu *pmu; struct arm_pmu *pmu = hlist_entry_safe(node, struct arm_pmu, node);
spin_lock(&arm_pmu_lock);
list_for_each_entry(pmu, &arm_pmu_list, entry) {
if (!cpumask_test_cpu(cpu, &pmu->supported_cpus)) if (!cpumask_test_cpu(cpu, &pmu->supported_cpus))
continue; return 0;
if (pmu->reset) if (pmu->reset)
pmu->reset(pmu); pmu->reset(pmu);
}
spin_unlock(&arm_pmu_lock);
return 0; return 0;
} }
...@@ -821,9 +813,10 @@ static int cpu_pmu_init(struct arm_pmu *cpu_pmu) ...@@ -821,9 +813,10 @@ static int cpu_pmu_init(struct arm_pmu *cpu_pmu)
if (!cpu_hw_events) if (!cpu_hw_events)
return -ENOMEM; return -ENOMEM;
spin_lock(&arm_pmu_lock); err = cpuhp_state_add_instance_nocalls(CPUHP_AP_PERF_ARM_STARTING,
list_add_tail(&cpu_pmu->entry, &arm_pmu_list); &cpu_pmu->node);
spin_unlock(&arm_pmu_lock); if (err)
goto out_free;
err = cpu_pm_pmu_register(cpu_pmu); err = cpu_pm_pmu_register(cpu_pmu);
if (err) if (err)
...@@ -859,9 +852,9 @@ static int cpu_pmu_init(struct arm_pmu *cpu_pmu) ...@@ -859,9 +852,9 @@ static int cpu_pmu_init(struct arm_pmu *cpu_pmu)
return 0; return 0;
out_unregister: out_unregister:
spin_lock(&arm_pmu_lock); cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_STARTING,
list_del(&cpu_pmu->entry); &cpu_pmu->node);
spin_unlock(&arm_pmu_lock); out_free:
free_percpu(cpu_hw_events); free_percpu(cpu_hw_events);
return err; return err;
} }
...@@ -869,9 +862,8 @@ static int cpu_pmu_init(struct arm_pmu *cpu_pmu) ...@@ -869,9 +862,8 @@ static int cpu_pmu_init(struct arm_pmu *cpu_pmu)
static void cpu_pmu_destroy(struct arm_pmu *cpu_pmu) static void cpu_pmu_destroy(struct arm_pmu *cpu_pmu)
{ {
cpu_pm_pmu_unregister(cpu_pmu); cpu_pm_pmu_unregister(cpu_pmu);
spin_lock(&arm_pmu_lock); cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_STARTING,
list_del(&cpu_pmu->entry); &cpu_pmu->node);
spin_unlock(&arm_pmu_lock);
free_percpu(cpu_pmu->hw_events); free_percpu(cpu_pmu->hw_events);
} }
...@@ -1068,7 +1060,7 @@ static int arm_pmu_hp_init(void) ...@@ -1068,7 +1060,7 @@ static int arm_pmu_hp_init(void)
{ {
int ret; int ret;
ret = cpuhp_setup_state_nocalls(CPUHP_AP_PERF_ARM_STARTING, ret = cpuhp_setup_state_multi(CPUHP_AP_PERF_ARM_STARTING,
"AP_PERF_ARM_STARTING", "AP_PERF_ARM_STARTING",
arm_perf_starting_cpu, NULL); arm_perf_starting_cpu, NULL);
if (ret) if (ret)
......
...@@ -109,7 +109,7 @@ struct arm_pmu { ...@@ -109,7 +109,7 @@ struct arm_pmu {
DECLARE_BITMAP(pmceid_bitmap, ARMV8_PMUV3_MAX_COMMON_EVENTS); DECLARE_BITMAP(pmceid_bitmap, ARMV8_PMUV3_MAX_COMMON_EVENTS);
struct platform_device *plat_device; struct platform_device *plat_device;
struct pmu_hw_events __percpu *hw_events; struct pmu_hw_events __percpu *hw_events;
struct list_head entry; struct hlist_node node;
struct notifier_block cpu_pm_nb; struct notifier_block cpu_pm_nb;
}; };
......
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