Skip to content

Commit

Permalink
perf: Clarify perf_cpu_context::active_pmu usage by renaming it to ::…
Browse files Browse the repository at this point in the history
…unique_pmu

commit 3f1f332 upstream.

Stephane thought the perf_cpu_context::active_pmu name confusing and
suggested using 'unique_pmu' instead.

This pointer is a pointer to a 'random' pmu sharing the cpuctx
instance, therefore limiting a for_each_pmu loop to those where
cpuctx->unique_pmu matches the pmu we get a loop over unique cpuctx
instances.

Suggested-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-kxyjqpfj2fn9gt7kwu5ag9ks@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Peter Zijlstra authored and Greg Kroah-Hartman committed Oct 1, 2013
1 parent 2927937 commit 2cd21fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/linux/perf_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ struct perf_cpu_context {
int exclusive;
struct list_head rotation_list;
int jiffies_interval;
struct pmu *active_pmu;
struct pmu *unique_pmu;
struct perf_cgroup *cgrp;
};

Expand Down
12 changes: 6 additions & 6 deletions kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -4332,7 +4332,7 @@ static void perf_event_task_event(struct perf_task_event *task_event)
rcu_read_lock();
list_for_each_entry_rcu(pmu, &pmus, entry) {
cpuctx = get_cpu_ptr(pmu->pmu_cpu_context);
if (cpuctx->active_pmu != pmu)
if (cpuctx->unique_pmu != pmu)
goto next;
perf_event_task_ctx(&cpuctx->ctx, task_event);

Expand Down Expand Up @@ -4478,7 +4478,7 @@ static void perf_event_comm_event(struct perf_comm_event *comm_event)
rcu_read_lock();
list_for_each_entry_rcu(pmu, &pmus, entry) {
cpuctx = get_cpu_ptr(pmu->pmu_cpu_context);
if (cpuctx->active_pmu != pmu)
if (cpuctx->unique_pmu != pmu)
goto next;
perf_event_comm_ctx(&cpuctx->ctx, comm_event);

Expand Down Expand Up @@ -4674,7 +4674,7 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
rcu_read_lock();
list_for_each_entry_rcu(pmu, &pmus, entry) {
cpuctx = get_cpu_ptr(pmu->pmu_cpu_context);
if (cpuctx->active_pmu != pmu)
if (cpuctx->unique_pmu != pmu)
goto next;
perf_event_mmap_ctx(&cpuctx->ctx, mmap_event,
vma->vm_flags & VM_EXEC);
Expand Down Expand Up @@ -5750,8 +5750,8 @@ static void update_pmu_context(struct pmu *pmu, struct pmu *old_pmu)

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

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

Expand Down Expand Up @@ -5886,7 +5886,7 @@ int perf_pmu_register(struct pmu *pmu, char *name, int type)
cpuctx->ctx.pmu = pmu;
cpuctx->jiffies_interval = 1;
INIT_LIST_HEAD(&cpuctx->rotation_list);
cpuctx->active_pmu = pmu;
cpuctx->unique_pmu = pmu;
}

got_cpu_context:
Expand Down

0 comments on commit 2cd21fa

Please sign in to comment.