aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/cpu/perf_event.c
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2010-01-22 10:32:17 -0500
committerIngo Molnar <mingo@elte.hu>2010-01-29 03:01:41 -0500
commit272d30be622c9c6cbd514b1211ff359292001baa (patch)
tree7c792dfbac3a18187c58ba292ecb3af819ef330a /arch/x86/kernel/cpu/perf_event.c
parent63b146490befc027a7e0923e333269e68b20d380 (diff)
perf_event: x86: Optimize constraint weight computation
Add a weight member to the constraint structure and avoid recomputing the weight at runtime. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> LKML-Reference: <20100122155535.963944926@chello.nl> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/cpu/perf_event.c')
-rw-r--r--arch/x86/kernel/cpu/perf_event.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 092ad566734c..2c22ce4fa784 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -23,6 +23,7 @@
23#include <linux/uaccess.h> 23#include <linux/uaccess.h>
24#include <linux/highmem.h> 24#include <linux/highmem.h>
25#include <linux/cpu.h> 25#include <linux/cpu.h>
26#include <linux/bitops.h>
26 27
27#include <asm/apic.h> 28#include <asm/apic.h>
28#include <asm/stacktrace.h> 29#include <asm/stacktrace.h>
@@ -76,6 +77,7 @@ struct event_constraint {
76 }; 77 };
77 int code; 78 int code;
78 int cmask; 79 int cmask;
80 int weight;
79}; 81};
80 82
81struct cpu_hw_events { 83struct cpu_hw_events {
@@ -95,6 +97,7 @@ struct cpu_hw_events {
95 { .idxmsk64[0] = (n) }, \ 97 { .idxmsk64[0] = (n) }, \
96 .code = (c), \ 98 .code = (c), \
97 .cmask = (m), \ 99 .cmask = (m), \
100 .weight = HWEIGHT64((u64)(n)), \
98} 101}
99 102
100#define INTEL_EVENT_CONSTRAINT(c, n) \ 103#define INTEL_EVENT_CONSTRAINT(c, n) \
@@ -1242,8 +1245,7 @@ static inline int is_x86_event(struct perf_event *event)
1242 1245
1243static int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign) 1246static int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)
1244{ 1247{
1245 int i, j , w, num; 1248 int i, j, w, num, wmax;
1246 int weight, wmax;
1247 struct event_constraint *c, *constraints[X86_PMC_IDX_MAX]; 1249 struct event_constraint *c, *constraints[X86_PMC_IDX_MAX];
1248 unsigned long used_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)]; 1250 unsigned long used_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)];
1249 struct hw_perf_event *hwc; 1251 struct hw_perf_event *hwc;
@@ -1320,8 +1322,7 @@ static int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)
1320 c = constraints[i]; 1322 c = constraints[i];
1321 hwc = &cpuc->event_list[i]->hw; 1323 hwc = &cpuc->event_list[i]->hw;
1322 1324
1323 weight = bitmap_weight(c->idxmsk, X86_PMC_IDX_MAX); 1325 if (c->weight != w)
1324 if (weight != w)
1325 continue; 1326 continue;
1326 1327
1327 for_each_bit(j, c->idxmsk, X86_PMC_IDX_MAX) { 1328 for_each_bit(j, c->idxmsk, X86_PMC_IDX_MAX) {