aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorStephane Eranian <eranian@google.com>2014-11-17 14:06:56 -0500
committerIngo Molnar <mingo@kernel.org>2015-04-02 11:33:10 -0400
commit79cba822443a168c8f7f5b853d9c7225a6d5415e (patch)
tree26f3d2fd2b5b1d6c8118861288e83ff90ccf7125 /arch/x86
parentc5362c0c376486afcf3c91d3c2691d348ac1e2fd (diff)
perf/x86: Add 'index' param to get_event_constraint() callback
This patch adds an index parameter to the get_event_constraint() x86_pmu callback. It is expected to represent the index of the event in the cpuc->event_list[] array. When the callback is used for fake_cpuc (evnet validation), then the index must be -1. The motivation for passing the index is to use it to index into another cpuc array. Signed-off-by: Stephane Eranian <eranian@google.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: bp@alien8.de Cc: jolsa@redhat.com Cc: kan.liang@intel.com Cc: maria.n.dimakopoulou@gmail.com Link: http://lkml.kernel.org/r/1416251225-17721-5-git-send-email-eranian@google.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kernel/cpu/perf_event.c4
-rw-r--r--arch/x86/kernel/cpu/perf_event.h4
-rw-r--r--arch/x86/kernel/cpu/perf_event_amd.c6
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c15
4 files changed, 19 insertions, 10 deletions
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index cd6115867fb8..71755401476c 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -789,7 +789,7 @@ int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)
789 789
790 for (i = 0, wmin = X86_PMC_IDX_MAX, wmax = 0; i < n; i++) { 790 for (i = 0, wmin = X86_PMC_IDX_MAX, wmax = 0; i < n; i++) {
791 hwc = &cpuc->event_list[i]->hw; 791 hwc = &cpuc->event_list[i]->hw;
792 c = x86_pmu.get_event_constraints(cpuc, cpuc->event_list[i]); 792 c = x86_pmu.get_event_constraints(cpuc, i, cpuc->event_list[i]);
793 hwc->constraint = c; 793 hwc->constraint = c;
794 794
795 wmin = min(wmin, c->weight); 795 wmin = min(wmin, c->weight);
@@ -1777,7 +1777,7 @@ static int validate_event(struct perf_event *event)
1777 if (IS_ERR(fake_cpuc)) 1777 if (IS_ERR(fake_cpuc))
1778 return PTR_ERR(fake_cpuc); 1778 return PTR_ERR(fake_cpuc);
1779 1779
1780 c = x86_pmu.get_event_constraints(fake_cpuc, event); 1780 c = x86_pmu.get_event_constraints(fake_cpuc, -1, event);
1781 1781
1782 if (!c || !c->weight) 1782 if (!c || !c->weight)
1783 ret = -EINVAL; 1783 ret = -EINVAL;
diff --git a/arch/x86/kernel/cpu/perf_event.h b/arch/x86/kernel/cpu/perf_event.h
index ea27e63fc945..24a65057c1c0 100644
--- a/arch/x86/kernel/cpu/perf_event.h
+++ b/arch/x86/kernel/cpu/perf_event.h
@@ -456,6 +456,7 @@ struct x86_pmu {
456 u64 max_period; 456 u64 max_period;
457 struct event_constraint * 457 struct event_constraint *
458 (*get_event_constraints)(struct cpu_hw_events *cpuc, 458 (*get_event_constraints)(struct cpu_hw_events *cpuc,
459 int idx,
459 struct perf_event *event); 460 struct perf_event *event);
460 461
461 void (*put_event_constraints)(struct cpu_hw_events *cpuc, 462 void (*put_event_constraints)(struct cpu_hw_events *cpuc,
@@ -751,7 +752,8 @@ static inline bool intel_pmu_has_bts(struct perf_event *event)
751int intel_pmu_save_and_restart(struct perf_event *event); 752int intel_pmu_save_and_restart(struct perf_event *event);
752 753
753struct event_constraint * 754struct event_constraint *
754x86_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event); 755x86_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
756 struct perf_event *event);
755 757
756struct intel_shared_regs *allocate_shared_regs(int cpu); 758struct intel_shared_regs *allocate_shared_regs(int cpu);
757 759
diff --git a/arch/x86/kernel/cpu/perf_event_amd.c b/arch/x86/kernel/cpu/perf_event_amd.c
index e4302b8fed2a..1cee5d2d7ece 100644
--- a/arch/x86/kernel/cpu/perf_event_amd.c
+++ b/arch/x86/kernel/cpu/perf_event_amd.c
@@ -430,7 +430,8 @@ static void amd_pmu_cpu_dead(int cpu)
430} 430}
431 431
432static struct event_constraint * 432static struct event_constraint *
433amd_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event) 433amd_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
434 struct perf_event *event)
434{ 435{
435 /* 436 /*
436 * if not NB event or no NB, then no constraints 437 * if not NB event or no NB, then no constraints
@@ -538,7 +539,8 @@ static struct event_constraint amd_f15_PMC50 = EVENT_CONSTRAINT(0, 0x3F, 0);
538static struct event_constraint amd_f15_PMC53 = EVENT_CONSTRAINT(0, 0x38, 0); 539static struct event_constraint amd_f15_PMC53 = EVENT_CONSTRAINT(0, 0x38, 0);
539 540
540static struct event_constraint * 541static struct event_constraint *
541amd_get_event_constraints_f15h(struct cpu_hw_events *cpuc, struct perf_event *event) 542amd_get_event_constraints_f15h(struct cpu_hw_events *cpuc, int idx,
543 struct perf_event *event)
542{ 544{
543 struct hw_perf_event *hwc = &event->hw; 545 struct hw_perf_event *hwc = &event->hw;
544 unsigned int event_code = amd_get_event_code(hwc); 546 unsigned int event_code = amd_get_event_code(hwc);
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index c0ed5a4b9537..2dd34b57d3ff 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -1827,7 +1827,8 @@ intel_shared_regs_constraints(struct cpu_hw_events *cpuc,
1827} 1827}
1828 1828
1829struct event_constraint * 1829struct event_constraint *
1830x86_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event) 1830x86_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
1831 struct perf_event *event)
1831{ 1832{
1832 struct event_constraint *c; 1833 struct event_constraint *c;
1833 1834
@@ -1844,7 +1845,8 @@ x86_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event)
1844} 1845}
1845 1846
1846static struct event_constraint * 1847static struct event_constraint *
1847intel_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event) 1848intel_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
1849 struct perf_event *event)
1848{ 1850{
1849 struct event_constraint *c; 1851 struct event_constraint *c;
1850 1852
@@ -1860,7 +1862,7 @@ intel_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event
1860 if (c) 1862 if (c)
1861 return c; 1863 return c;
1862 1864
1863 return x86_get_event_constraints(cpuc, event); 1865 return x86_get_event_constraints(cpuc, idx, event);
1864} 1866}
1865 1867
1866static void 1868static void
@@ -2105,9 +2107,12 @@ static struct event_constraint counter2_constraint =
2105 EVENT_CONSTRAINT(0, 0x4, 0); 2107 EVENT_CONSTRAINT(0, 0x4, 0);
2106 2108
2107static struct event_constraint * 2109static struct event_constraint *
2108hsw_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event) 2110hsw_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
2111 struct perf_event *event)
2109{ 2112{
2110 struct event_constraint *c = intel_get_event_constraints(cpuc, event); 2113 struct event_constraint *c;
2114
2115 c = intel_get_event_constraints(cpuc, idx, event);
2111 2116
2112 /* Handle special quirk on in_tx_checkpointed only in counter 2 */ 2117 /* Handle special quirk on in_tx_checkpointed only in counter 2 */
2113 if (event->hw.config & HSW_IN_TX_CHECKPOINTED) { 2118 if (event->hw.config & HSW_IN_TX_CHECKPOINTED) {