Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1446341
| From | Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v3] arm/perf: Convert to hotplug state machine |
| Date | 2016-07-19 13:20 +0200 |
| Message-ID | <rWBea-3l1-19@gated-at.bofh.it> (permalink) |
| References | (1 earlier) <rWxtU-129-17@gated-at.bofh.it> <rWxNg-18Q-17@gated-at.bofh.it> <rWxWW-1ci-25@gated-at.bofh.it> <rWzcl-27O-19@gated-at.bofh.it> <rWzYK-2o0-27@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Thomas Gleixner <tglx@linutronix.de>
Straight forward conversion w/o bells and whistles.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: rt@linutronix.de
[bigeasy@l.de: use arm_pmu_list to handle multiple PMUs in the system]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
v2…v3: >80 chars line for per_err, added Mark's Acked-by
v1…v2: use arm_pmu_list
drivers/perf/arm_pmu.c | 59 +++++++++++++++++++++++++++-----------------
include/linux/cpuhotplug.h | 1 +
include/linux/perf/arm_pmu.h | 2 +-
3 files changed, 39 insertions(+), 23 deletions(-)
diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c
index 140436a046c0..f6ab4f7f75bf 100644
--- a/drivers/perf/arm_pmu.c
+++ b/drivers/perf/arm_pmu.c
@@ -685,30 +685,29 @@ static int cpu_pmu_request_irq(struct arm_pmu *cpu_pmu, irq_handler_t handler)
return 0;
}
+static DEFINE_MUTEX(arm_pmu_mutex);
+static LIST_HEAD(arm_pmu_list);
+
/*
* PMU hardware loses all context when a CPU goes offline.
* When a CPU is hotplugged back in, since some hardware registers are
* UNKNOWN at reset, the PMU must be explicitly reset to avoid reading
* junk values out of them.
*/
-static int cpu_pmu_notify(struct notifier_block *b, unsigned long action,
- void *hcpu)
+static int arm_perf_starting_cpu(unsigned int cpu)
{
- int cpu = (unsigned long)hcpu;
- struct arm_pmu *pmu = container_of(b, struct arm_pmu, hotplug_nb);
+ struct arm_pmu *pmu;
- if ((action & ~CPU_TASKS_FROZEN) != CPU_STARTING)
- return NOTIFY_DONE;
+ mutex_lock(&arm_pmu_mutex);
+ list_for_each_entry(pmu, &arm_pmu_list, entry) {
- if (!cpumask_test_cpu(cpu, &pmu->supported_cpus))
- return NOTIFY_DONE;
-
- if (pmu->reset)
- pmu->reset(pmu);
- else
- return NOTIFY_DONE;
-
- return NOTIFY_OK;
+ if (!cpumask_test_cpu(cpu, &pmu->supported_cpus))
+ continue;
+ if (pmu->reset)
+ pmu->reset(pmu);
+ }
+ mutex_unlock(&arm_pmu_mutex);
+ return 0;
}
#ifdef CONFIG_CPU_PM
@@ -819,10 +818,9 @@ static int cpu_pmu_init(struct arm_pmu *cpu_pmu)
if (!cpu_hw_events)
return -ENOMEM;
- cpu_pmu->hotplug_nb.notifier_call = cpu_pmu_notify;
- err = register_cpu_notifier(&cpu_pmu->hotplug_nb);
- if (err)
- goto out_hw_events;
+ mutex_lock(&arm_pmu_mutex);
+ list_add_tail(&cpu_pmu->entry, &arm_pmu_list);
+ mutex_unlock(&arm_pmu_mutex);
err = cpu_pm_pmu_register(cpu_pmu);
if (err)
@@ -858,8 +856,9 @@ static int cpu_pmu_init(struct arm_pmu *cpu_pmu)
return 0;
out_unregister:
- unregister_cpu_notifier(&cpu_pmu->hotplug_nb);
-out_hw_events:
+ mutex_lock(&arm_pmu_mutex);
+ list_del(&cpu_pmu->entry);
+ mutex_unlock(&arm_pmu_mutex);
free_percpu(cpu_hw_events);
return err;
}
@@ -867,7 +866,9 @@ static int cpu_pmu_init(struct arm_pmu *cpu_pmu)
static void cpu_pmu_destroy(struct arm_pmu *cpu_pmu)
{
cpu_pm_pmu_unregister(cpu_pmu);
- unregister_cpu_notifier(&cpu_pmu->hotplug_nb);
+ mutex_lock(&arm_pmu_mutex);
+ list_del(&cpu_pmu->entry);
+ mutex_unlock(&arm_pmu_mutex);
free_percpu(cpu_pmu->hw_events);
}
@@ -1044,3 +1045,17 @@ int arm_pmu_device_probe(struct platform_device *pdev,
kfree(pmu);
return ret;
}
+
+static int arm_pmu_hp_init(void)
+{
+ int ret;
+
+ ret = cpuhp_setup_state_nocalls(CPUHP_AP_PERF_ARM_STARTING,
+ "AP_PERF_ARM_STARTING",
+ arm_perf_starting_cpu, NULL);
+ if (ret)
+ pr_err("CPU hotplug notifier for ARM PMU could not be registered: %d\n",
+ ret);
+ return ret;
+}
+subsys_initcall(arm_pmu_hp_init);
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 4c63cb30aee6..a5b6a6526af8 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -35,6 +35,7 @@ enum cpuhp_state {
CPUHP_AP_PERF_X86_CSTATE_STARTING,
CPUHP_AP_PERF_XTENSA_STARTING,
CPUHP_AP_ARM_VFP_STARTING,
+ CPUHP_AP_PERF_ARM_STARTING,
CPUHP_AP_NOTIFY_STARTING,
CPUHP_AP_ONLINE,
CPUHP_TEARDOWN_CPU,
diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h
index d28ac05c7f92..e18843809eec 100644
--- a/include/linux/perf/arm_pmu.h
+++ b/include/linux/perf/arm_pmu.h
@@ -109,7 +109,7 @@ struct arm_pmu {
DECLARE_BITMAP(pmceid_bitmap, ARMV8_PMUV3_MAX_COMMON_EVENTS);
struct platform_device *plat_device;
struct pmu_hw_events __percpu *hw_events;
- struct notifier_block hotplug_nb;
+ struct list_head entry;
struct notifier_block cpu_pm_nb;
};
--
2.8.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[patch V2 35/67] arm/perf: Convert to hotplug state machine Anna-Maria Gleixner <anna-maria@linutronix.de> - 2016-07-13 19:30 +0200
Re: [patch V2 35/67] arm/perf: Convert to hotplug state machine Mark Rutland <mark.rutland@arm.com> - 2016-07-15 15:10 +0200
Re: [patch V2 35/67] arm/perf: Convert to hotplug state machine Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2016-07-15 17:30 +0200
Re: [patch V2 35/67] arm/perf: Convert to hotplug state machine Mark Rutland <mark.rutland@arm.com> - 2016-07-15 18:20 +0200
[tip:smp/hotplug] arm/perf: Convert to hotplug state machine tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-07-19 09:20 +0200
Re: [tip:smp/hotplug] arm/perf: Convert to hotplug state machine Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2016-07-19 09:40 +0200
Re: [tip:smp/hotplug] arm/perf: Convert to hotplug state machine Ingo Molnar <mingo@kernel.org> - 2016-07-19 09:50 +0200
[PATCH v2] arm/perf: Convert to hotplug state machine Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2016-07-19 11:10 +0200
Re: [PATCH v2] arm/perf: Convert to hotplug state machine Mark Rutland <mark.rutland@arm.com> - 2016-07-19 12:00 +0200
[PATCH v3] arm/perf: Convert to hotplug state machine Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2016-07-19 13:20 +0200
Re: [PATCH v3] arm/perf: Convert to hotplug state machine Ingo Molnar <mingo@kernel.org> - 2016-07-20 10:10 +0200
[tip:smp/hotplug] arm/perf: Fix hotplug state machine conversion tip-bot for Sebastian Andrzej Siewior <tipbot@zytor.com> - 2016-07-20 12:50 +0200
csiph-web