Skip to content

Commit

Permalink
perf/core: Remove perf_cpu_context::unique_pmu
Browse files Browse the repository at this point in the history
cpuctx->unique_pmu was originally introduced as a way to identify cpuctxs
with shared pmus in order to avoid visiting the same cpuctx more than once
in a for_each_pmu loop.

cpuctx->unique_pmu == cpuctx->pmu in non-software task contexts since they
have only one pmu per cpuctx. Since perf_pmu_sched_task() is only called in
hw contexts, this patch replaces cpuctx->unique_pmu by cpuctx->pmu in it.

The change above, together with the previous patch in this series, removed
the remaining uses of cpuctx->unique_pmu, so we remove it altogether.

Signed-off-by: David Carrillo-Cisneros <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Acked-by: Mark Rutland <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Paul Turner <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Srinivas Pandruvada <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Vikas Shivappa <[email protected]>
Cc: Vince Weaver <[email protected]>
Cc: Vince Weaver <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
David Carrillo-Cisneros authored and Ingo Molnar committed Jan 30, 2017
1 parent 058fe1c commit 1fd7e41
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 31 deletions.
1 change: 0 additions & 1 deletion include/linux/perf_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,6 @@ struct perf_cpu_context {
ktime_t hrtimer_interval;
unsigned int hrtimer_active;

struct pmu *unique_pmu;
#ifdef CONFIG_CGROUP_PERF
struct perf_cgroup *cgrp;
struct list_head cgrp_cpuctx_entry;
Expand Down
31 changes: 1 addition & 30 deletions kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2932,7 +2932,7 @@ static void perf_pmu_sched_task(struct task_struct *prev,
return;

list_for_each_entry(cpuctx, this_cpu_ptr(&sched_cb_list), sched_cb_entry) {
pmu = cpuctx->unique_pmu; /* software PMUs will not have sched_task */
pmu = cpuctx->ctx.pmu; /* software PMUs will not have sched_task */

if (WARN_ON_ONCE(!pmu->sched_task))
continue;
Expand Down Expand Up @@ -8636,37 +8636,10 @@ static struct perf_cpu_context __percpu *find_pmu_context(int ctxn)
return NULL;
}

static void update_pmu_context(struct pmu *pmu, struct pmu *old_pmu)
{
int cpu;

for_each_possible_cpu(cpu) {
struct perf_cpu_context *cpuctx;

cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu);

if (cpuctx->unique_pmu == old_pmu)
cpuctx->unique_pmu = pmu;
}
}

static void free_pmu_context(struct pmu *pmu)
{
struct pmu *i;

mutex_lock(&pmus_lock);
/*
* Like a real lame refcount.
*/
list_for_each_entry(i, &pmus, entry) {
if (i->pmu_cpu_context == pmu->pmu_cpu_context) {
update_pmu_context(i, pmu);
goto out;
}
}

free_percpu(pmu->pmu_cpu_context);
out:
mutex_unlock(&pmus_lock);
}

Expand Down Expand Up @@ -8870,8 +8843,6 @@ int perf_pmu_register(struct pmu *pmu, const char *name, int type)
cpuctx->ctx.pmu = pmu;

__perf_mux_hrtimer_init(cpuctx, cpu);

cpuctx->unique_pmu = pmu;
}

got_cpu_context:
Expand Down

0 comments on commit 1fd7e41

Please sign in to comment.