Commit 272d30be authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

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: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
LKML-Reference: <20100122155535.963944926@chello.nl>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 63b14649
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/highmem.h> #include <linux/highmem.h>
#include <linux/cpu.h> #include <linux/cpu.h>
#include <linux/bitops.h>
#include <asm/apic.h> #include <asm/apic.h>
#include <asm/stacktrace.h> #include <asm/stacktrace.h>
...@@ -76,6 +77,7 @@ struct event_constraint { ...@@ -76,6 +77,7 @@ struct event_constraint {
}; };
int code; int code;
int cmask; int cmask;
int weight;
}; };
struct cpu_hw_events { struct cpu_hw_events {
...@@ -95,6 +97,7 @@ struct cpu_hw_events { ...@@ -95,6 +97,7 @@ struct cpu_hw_events {
{ .idxmsk64[0] = (n) }, \ { .idxmsk64[0] = (n) }, \
.code = (c), \ .code = (c), \
.cmask = (m), \ .cmask = (m), \
.weight = HWEIGHT64((u64)(n)), \
} }
#define INTEL_EVENT_CONSTRAINT(c, n) \ #define INTEL_EVENT_CONSTRAINT(c, n) \
...@@ -1242,8 +1245,7 @@ static inline int is_x86_event(struct perf_event *event) ...@@ -1242,8 +1245,7 @@ static inline int is_x86_event(struct perf_event *event)
static int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign) static int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)
{ {
int i, j , w, num; int i, j, w, num, wmax;
int weight, wmax;
struct event_constraint *c, *constraints[X86_PMC_IDX_MAX]; struct event_constraint *c, *constraints[X86_PMC_IDX_MAX];
unsigned long used_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)]; unsigned long used_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)];
struct hw_perf_event *hwc; struct hw_perf_event *hwc;
...@@ -1320,8 +1322,7 @@ static int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign) ...@@ -1320,8 +1322,7 @@ static int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)
c = constraints[i]; c = constraints[i];
hwc = &cpuc->event_list[i]->hw; hwc = &cpuc->event_list[i]->hw;
weight = bitmap_weight(c->idxmsk, X86_PMC_IDX_MAX); if (c->weight != w)
if (weight != w)
continue; continue;
for_each_bit(j, c->idxmsk, X86_PMC_IDX_MAX) { for_each_bit(j, c->idxmsk, X86_PMC_IDX_MAX) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment