History

perf/x86: Add flags to event constraints

This patch adds a flags field to each event constraint. It can be used to store event specific features which can then later be used by scheduling code or low-level x86 code. The flags are propagated into event->hw.flags during the get_event_constraint() call. They are cleared during the put_event_constraint() call. This mechanism is going to be used by the PEBS-LL patches. It avoids defining yet another table to hold event specific information.

Stephane Eranian committed 13 years ago

Commit 9fac2cf1 parent 3a54aaa6 files · +16 −7Browse files

Unified · Split

6 files
  1. arch/x86/kernel/cpu/perf_event.c +1 −1
  2. arch/x86/kernel/cpu/perf_event.h +5 −3
  3. arch/x86/kernel/cpu/perf_event_intel.c +5 −1
  4. arch/x86/kernel/cpu/perf_event_intel_ds.c +3 −1
  5. arch/x86/kernel/cpu/perf_event_intel_uncore.c +1 −1
  6. include/linux/perf_event.h +1 −0
arch/x86/kernel/cpu/perf_event.c+1−1
@@ -1489,7 +1489,7 @@ static int __init init_hw_perf_events(void) · 1488 unmodified lines
14891489
14901490 unconstrained = (struct event_constraint)
14911491 __EVENT_CONSTRAINT(0, (1ULL << x86_pmu.num_counters) - 1,
1492− 0, x86_pmu.num_counters, 0);
1492+ 0, x86_pmu.num_counters, 0, 0);
14931493
14941494 x86_pmu.attr_rdpmc = 1; /* enable userspace RDPMC usage by default */
14951495 x86_pmu_format_group.attrs = x86_pmu.format_attrs;
arch/x86/kernel/cpu/perf_event.h+5−3
@@ -59,6 +59,7 @@ struct event_constraint { · 58 unmodified lines
5959 u64 cmask;
6060 int weight;
6161 int overlap;
62+ int flags;
6263 };
6364
6465 struct amd_nb {
@@ -170,16 +171,17 @@ struct cpu_hw_events { · 105 unmodified lines
170171 void *kfree_on_online;
171172 };
172173
173−#define __EVENT_CONSTRAINT(c, n, m, w, o) {\
174+#define __EVENT_CONSTRAINT(c, n, m, w, o, f) {\
174175 { .idxmsk64 = (n) }, \
175176 .code = (c), \
176177 .cmask = (m), \
177178 .weight = (w), \
178179 .overlap = (o), \
180+ .flags = f, \
179181 }
180182
181183 #define EVENT_CONSTRAINT(c, n, m) \
182− __EVENT_CONSTRAINT(c, n, m, HWEIGHT(n), 0)
184+ __EVENT_CONSTRAINT(c, n, m, HWEIGHT(n), 0, 0)
183185
184186 /*
185187 * The overlap flag marks event constraints with overlapping counter
@@ -203,7 +205,7 @@ struct cpu_hw_events { · 17 unmodified lines
203205 * and its counter masks must be kept at a minimum.
204206 */
205207 #define EVENT_CONSTRAINT_OVERLAP(c, n, m) \
206− __EVENT_CONSTRAINT(c, n, m, HWEIGHT(n), 1)
208+ __EVENT_CONSTRAINT(c, n, m, HWEIGHT(n), 1, 0)
207209
208210 /*
209211 * Constraint on the Event code.
arch/x86/kernel/cpu/perf_event_intel.c+5−1
@@ -1392,8 +1392,11 @@ x86_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event) · 1391 unmodified lines
13921392
13931393 if (x86_pmu.event_constraints) {
13941394 for_each_event_constraint(c, x86_pmu.event_constraints) {
1395− if ((event->hw.config & c->cmask) == c->code)
1395+ if ((event->hw.config & c->cmask) == c->code) {
1396+ /* hw.flags zeroed at initialization */
1397+ event->hw.flags |= c->flags;
13961398 return c;
1399+ }
13971400 }
13981401 }
13991402
@@ -1438,6 +1441,7 @@ intel_put_shared_regs_event_constraints(struct cpu_hw_events *cpuc, · 38 unmodified lines
14381441 static void intel_put_event_constraints(struct cpu_hw_events *cpuc,
14391442 struct perf_event *event)
14401443 {
1444+ event->hw.flags = 0;
14411445 intel_put_shared_regs_event_constraints(cpuc, event);
14421446 }
14431447
arch/x86/kernel/cpu/perf_event_intel_ds.c+3−1
@@ -430,8 +430,10 @@ struct event_constraint *intel_pebs_constraints(struct perf_event *event) · 429 unmodified lines
430430
431431 if (x86_pmu.pebs_constraints) {
432432 for_each_event_constraint(c, x86_pmu.pebs_constraints) {
433− if ((event->hw.config & c->cmask) == c->code)
433+ if ((event->hw.config & c->cmask) == c->code) {
434+ event->hw.flags |= c->flags;
434435 return c;
436+ }
435437 }
436438 }
437439
arch/x86/kernel/cpu/perf_event_intel_uncore.c+1−1
@@ -2438,7 +2438,7 @@ static int __init uncore_type_init(struct intel_uncore_type *type) · 2437 unmodified lines
24382438
24392439 type->unconstrainted = (struct event_constraint)
24402440 __EVENT_CONSTRAINT(0, (1ULL << type->num_counters) - 1,
2441− 0, type->num_counters, 0);
2441+ 0, type->num_counters, 0, 0);
24422442
24432443 for (i = 0; i < type->num_boxes; i++) {
24442444 pmus[i].func_id = -1;
include/linux/perf_event.h+1−0
@@ -127,6 +127,7 @@ struct hw_perf_event { · 126 unmodified lines
127127 int event_base_rdpmc;
128128 int idx;
129129 int last_cpu;
130+ int flags;
130131
131132 struct hw_perf_event_extra extra_reg;
132133 struct hw_perf_event_extra branch_reg;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t