Skip to content

Commit

Permalink
perf/x86: Add 3 new scheduling callbacks
Browse files Browse the repository at this point in the history
This patch adds 3 new PMU model specific callbacks
during the event scheduling done by x86_schedule_events().

  ->start_scheduling():  invoked when entering the schedule routine.
  ->stop_scheduling():   invoked at the end of the schedule routine
  ->commit_scheduling(): invoked for each committed event

To be used optionally by model-specific code.

Signed-off-by: Maria Dimakopoulou <maria.n.dimakopoulou@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Stephane Eranian <eranian@google.com>
Cc: bp@alien8.de
Cc: jolsa@redhat.com
Cc: kan.liang@intel.com
Link: http://lkml.kernel.org/r/1416251225-17721-4-git-send-email-eranian@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Maria Dimakopoulou authored and Ingo Molnar committed Apr 2, 2015
1 parent 9041346 commit c5362c0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions arch/x86/kernel/cpu/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,9 @@ int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)

bitmap_zero(used_mask, X86_PMC_IDX_MAX);

if (x86_pmu.start_scheduling)
x86_pmu.start_scheduling(cpuc);

for (i = 0, wmin = X86_PMC_IDX_MAX, wmax = 0; i < n; i++) {
hwc = &cpuc->event_list[i]->hw;
c = x86_pmu.get_event_constraints(cpuc, cpuc->event_list[i]);
Expand Down Expand Up @@ -830,6 +833,8 @@ int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)
for (i = 0; i < n; i++) {
e = cpuc->event_list[i];
e->hw.flags |= PERF_X86_EVENT_COMMITTED;
if (x86_pmu.commit_scheduling)
x86_pmu.commit_scheduling(cpuc, e, assign[i]);
}
}
/*
Expand All @@ -850,6 +855,10 @@ int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)
x86_pmu.put_event_constraints(cpuc, e);
}
}

if (x86_pmu.stop_scheduling)
x86_pmu.stop_scheduling(cpuc);

return num ? -EINVAL : 0;
}

Expand Down
9 changes: 9 additions & 0 deletions arch/x86/kernel/cpu/perf_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,15 @@ struct x86_pmu {

void (*put_event_constraints)(struct cpu_hw_events *cpuc,
struct perf_event *event);

void (*commit_scheduling)(struct cpu_hw_events *cpuc,
struct perf_event *event,
int cntr);

void (*start_scheduling)(struct cpu_hw_events *cpuc);

void (*stop_scheduling)(struct cpu_hw_events *cpuc);

struct event_constraint *event_constraints;
struct x86_pmu_quirk *quirks;
int perfctr_second_write;
Expand Down

0 comments on commit c5362c0

Please sign in to comment.