Skip to content

Commit 9bcb929

Browse files
rmurphy-armwildea01
authored andcommitted
perf/arm-ccn: Clean up CPU hotplug handling
Like arm-cci, arm-ccn has the same issue of disabling preemption around operations which can take mutexes. Again, remove the definite bug by simply not trying to fight the theoretical races. And since we are touching the hotplug handling code, take the opportunity to streamline it, as there's really no need to store a full-sized cpumask to keep track of a single CPU ID. Reviewed-by: Suzuki K Poulose <[email protected]> Signed-off-by: Robin Murphy <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 0d2e2a8 commit 9bcb929

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

drivers/perf/arm-ccn.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ struct arm_ccn_dt {
167167

168168
struct hrtimer hrtimer;
169169

170-
cpumask_t cpu;
170+
unsigned int cpu;
171171
struct hlist_node node;
172172

173173
struct pmu pmu;
@@ -559,7 +559,7 @@ static ssize_t arm_ccn_pmu_cpumask_show(struct device *dev,
559559
{
560560
struct arm_ccn *ccn = pmu_to_arm_ccn(dev_get_drvdata(dev));
561561

562-
return cpumap_print_to_pagebuf(true, buf, &ccn->dt.cpu);
562+
return cpumap_print_to_pagebuf(true, buf, cpumask_of(ccn->dt.cpu));
563563
}
564564

565565
static struct device_attribute arm_ccn_pmu_cpumask_attr =
@@ -759,7 +759,7 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
759759
* mitigate this, we enforce CPU assignment to one, selected
760760
* processor (the one described in the "cpumask" attribute).
761761
*/
762-
event->cpu = cpumask_first(&ccn->dt.cpu);
762+
event->cpu = ccn->dt.cpu;
763763

764764
node_xp = CCN_CONFIG_NODE(event->attr.config);
765765
type = CCN_CONFIG_TYPE(event->attr.config);
@@ -1215,15 +1215,15 @@ static int arm_ccn_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
12151215
struct arm_ccn *ccn = container_of(dt, struct arm_ccn, dt);
12161216
unsigned int target;
12171217

1218-
if (!cpumask_test_and_clear_cpu(cpu, &dt->cpu))
1218+
if (cpu != dt->cpu)
12191219
return 0;
12201220
target = cpumask_any_but(cpu_online_mask, cpu);
12211221
if (target >= nr_cpu_ids)
12221222
return 0;
12231223
perf_pmu_migrate_context(&dt->pmu, cpu, target);
1224-
cpumask_set_cpu(target, &dt->cpu);
1224+
dt->cpu = target;
12251225
if (ccn->irq)
1226-
WARN_ON(irq_set_affinity_hint(ccn->irq, &dt->cpu) != 0);
1226+
WARN_ON(irq_set_affinity_hint(ccn->irq, cpumask_of(dt->cpu)));
12271227
return 0;
12281228
}
12291229

@@ -1299,29 +1299,30 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn)
12991299
}
13001300

13011301
/* Pick one CPU which we will use to collect data from CCN... */
1302-
cpumask_set_cpu(get_cpu(), &ccn->dt.cpu);
1302+
ccn->dt.cpu = raw_smp_processor_id();
13031303

13041304
/* Also make sure that the overflow interrupt is handled by this CPU */
13051305
if (ccn->irq) {
1306-
err = irq_set_affinity_hint(ccn->irq, &ccn->dt.cpu);
1306+
err = irq_set_affinity_hint(ccn->irq, cpumask_of(ccn->dt.cpu));
13071307
if (err) {
13081308
dev_err(ccn->dev, "Failed to set interrupt affinity!\n");
13091309
goto error_set_affinity;
13101310
}
13111311
}
13121312

1313+
cpuhp_state_add_instance_nocalls(CPUHP_AP_PERF_ARM_CCN_ONLINE,
1314+
&ccn->dt.node);
1315+
13131316
err = perf_pmu_register(&ccn->dt.pmu, name, -1);
13141317
if (err)
13151318
goto error_pmu_register;
13161319

1317-
cpuhp_state_add_instance_nocalls(CPUHP_AP_PERF_ARM_CCN_ONLINE,
1318-
&ccn->dt.node);
1319-
put_cpu();
13201320
return 0;
13211321

13221322
error_pmu_register:
1323+
cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_CCN_ONLINE,
1324+
&ccn->dt.node);
13231325
error_set_affinity:
1324-
put_cpu();
13251326
error_choose_name:
13261327
ida_simple_remove(&arm_ccn_pmu_ida, ccn->dt.id);
13271328
for (i = 0; i < ccn->num_xps; i++)

0 commit comments

Comments
 (0)