Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 155708
b: refs/heads/master
c: 9c74fb5
h: refs/heads/master
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Jul 10, 2009
1 parent 55f08e1 commit 8c1e72f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 11d1578f9454159c43499d1d8fe8a7d728c176a3
refs/heads/master: 9c74fb50867e8fb5f3be3be06716492c0f79309e
28 changes: 23 additions & 5 deletions trunk/arch/x86/kernel/cpu/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ static u64 p6_pmu_event_map(int event)
return p6_perfmon_event_map[event];
}

/*
* Counter setting that is specified not to count anything.
* We use this to effectively disable a counter.
*
* L2_RQSTS with 0 MESI unit mask.
*/
#define P6_NOP_COUNTER 0x0000002EULL

static u64 p6_pmu_raw_event(u64 event)
{
#define P6_EVNTSEL_EVENT_MASK 0x000000FFULL
Expand Down Expand Up @@ -704,6 +712,7 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
{
struct perf_counter_attr *attr = &counter->attr;
struct hw_perf_counter *hwc = &counter->hw;
u64 config;
int err;

if (!x86_pmu_initialized())
Expand Down Expand Up @@ -756,18 +765,27 @@ static int __hw_perf_counter_init(struct perf_counter *counter)

if (attr->config >= x86_pmu.max_events)
return -EINVAL;

/*
* The generic map:
*/
hwc->config |= x86_pmu.event_map(attr->config);
config = x86_pmu.event_map(attr->config);

if (config == 0)
return -ENOENT;

if (config == -1LL)
return -EINVAL;

hwc->config |= config;

return 0;
}

static void p6_pmu_disable_all(void)
{
struct cpu_hw_counters *cpuc = &__get_cpu_var(cpu_hw_counters);
unsigned long val;
u64 val;

if (!cpuc->enabled)
return;
Expand Down Expand Up @@ -917,10 +935,10 @@ static inline void
p6_pmu_disable_counter(struct hw_perf_counter *hwc, int idx)
{
struct cpu_hw_counters *cpuc = &__get_cpu_var(cpu_hw_counters);
unsigned long val = ARCH_PERFMON_EVENTSEL0_ENABLE;
u64 val = P6_NOP_COUNTER;

if (!cpuc->enabled)
val = 0;
if (cpuc->enabled)
val |= ARCH_PERFMON_EVENTSEL0_ENABLE;

(void)checking_wrmsrl(hwc->config_base + idx, val);
}
Expand Down

0 comments on commit 8c1e72f

Please sign in to comment.