Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147394
b: refs/heads/master
c: 0953423
h: refs/heads/master
v: v3
  • Loading branch information
Robert Richter authored and Ingo Molnar committed Apr 29, 2009
1 parent 72a6513 commit 1c93186
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 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: 93904966934193204ad08e951f806d5631c29eb3
refs/heads/master: 095342389e2ed8deed07b3076f990260ce3c7c9f
20 changes: 9 additions & 11 deletions trunk/arch/x86/kernel/cpu/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ static void amd_pmu_enable_counter(int idx, u64 config)
{
struct cpu_hw_counters *cpuc = &__get_cpu_var(cpu_hw_counters);

set_bit(idx, cpuc->active);
if (cpuc->enabled)
config |= ARCH_PERFMON_EVENTSEL0_ENABLE;

Expand All @@ -446,9 +445,6 @@ static void intel_pmu_disable_counter(int idx, u64 config)

static void amd_pmu_disable_counter(int idx, u64 config)
{
struct cpu_hw_counters *cpuc = &__get_cpu_var(cpu_hw_counters);

clear_bit(idx, cpuc->active);
wrmsrl(MSR_K7_EVNTSEL0 + idx, config);

}
Expand Down Expand Up @@ -633,10 +629,7 @@ static int x86_pmu_enable(struct perf_counter *counter)
__x86_pmu_disable(counter, hwc, idx);

cpuc->counters[idx] = counter;
/*
* Make it visible before enabling the hw:
*/
barrier();
set_bit(idx, cpuc->active);

x86_perf_counter_set_period(counter, hwc, idx);
__x86_pmu_enable(counter, hwc, idx);
Expand Down Expand Up @@ -700,10 +693,13 @@ static void x86_pmu_disable(struct perf_counter *counter)
struct hw_perf_counter *hwc = &counter->hw;
unsigned int idx = hwc->idx;

/*
* Must be done before we disable, otherwise the nmi handler
* could reenable again:
*/
clear_bit(idx, cpuc->active);
__x86_pmu_disable(counter, hwc, idx);

clear_bit(idx, cpuc->used);
cpuc->counters[idx] = NULL;
/*
* Make sure the cleared pointer becomes visible before we
* (potentially) free the counter:
Expand All @@ -715,6 +711,8 @@ static void x86_pmu_disable(struct perf_counter *counter)
* that we are disabling:
*/
x86_perf_counter_update(counter, hwc, idx);
cpuc->counters[idx] = NULL;
clear_bit(idx, cpuc->used);
}

/*
Expand Down Expand Up @@ -763,7 +761,7 @@ static int intel_pmu_handle_irq(struct pt_regs *regs, int nmi)
struct perf_counter *counter = cpuc->counters[bit];

clear_bit(bit, (unsigned long *) &status);
if (!counter)
if (!test_bit(bit, cpuc->active))
continue;

intel_pmu_save_and_restart(counter);
Expand Down

0 comments on commit 1c93186

Please sign in to comment.