summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2018-12-19 23:29:14 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2018-12-19 23:29:13 -0800
commitd67787b7c6a3edf348ea61b10a5031e42d3abfed (patch)
tree7ab61947ac7ec4c040b6b46e3920e212e579a39a /kernel
parent16f7475b49e50cde34d10497b4583701d16b1e9e (diff)
parenta486143d54295787909673dbaee6a6b6042a3377 (diff)
Merge "perf: Cancel the mux hrtimer during CPU hotplug to avoid migration"
Diffstat (limited to 'kernel')
-rw-r--r--kernel/events/core.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 77bbbc18ce1f..66c1084752f9 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -9656,13 +9656,26 @@ static void __perf_event_stop_swclock(void *__info)
static void perf_event_exit_cpu_context(int cpu)
{
+ struct perf_cpu_context *cpuctx;
struct perf_event_context *ctx;
+ unsigned long flags;
struct pmu *pmu;
int idx;
idx = srcu_read_lock(&pmus_srcu);
list_for_each_entry_rcu(pmu, &pmus, entry) {
- ctx = &per_cpu_ptr(pmu->pmu_cpu_context, cpu)->ctx;
+ cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu);
+ ctx = &cpuctx->ctx;
+
+ /* Cancel the mux hrtimer to avoid CPU migration */
+ if (pmu->task_ctx_nr != perf_sw_context) {
+ raw_spin_lock_irqsave(&cpuctx->hrtimer_lock, flags);
+ hrtimer_cancel(&cpuctx->hrtimer);
+ cpuctx->hrtimer_active = 0;
+ raw_spin_unlock_irqrestore(&cpuctx->hrtimer_lock,
+ flags);
+ }
+
mutex_lock(&ctx->mutex);
/*
* If keeping events across hotplugging is supported, do not