Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147398
b: refs/heads/master
c: 85cf9db
h: refs/heads/master
v: v3
  • Loading branch information
Robert Richter authored and Ingo Molnar committed Apr 29, 2009
1 parent ea804b1 commit 3a44c85
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 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: d43698918bd46c71d494555fb92195fbea1fcb6c
refs/heads/master: 85cf9dba92152bb4edec118b2f4f0be1ae7fdcab
34 changes: 13 additions & 21 deletions trunk/arch/x86/kernel/cpu/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <asm/stacktrace.h>
#include <asm/nmi.h>

static bool perf_counters_initialized __read_mostly;
static u64 perf_counter_mask __read_mostly;

struct cpu_hw_counters {
Expand Down Expand Up @@ -227,6 +226,11 @@ static void hw_perf_counter_destroy(struct perf_counter *counter)
}
}

static inline int x86_pmu_initialized(void)
{
return x86_pmu.handle_irq != NULL;
}

/*
* Setup the hardware configuration for a given hw_event_type
*/
Expand All @@ -240,8 +244,8 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
return -ENOSYS;

if (unlikely(!perf_counters_initialized))
return -EINVAL;
if (!x86_pmu_initialized())
return -ENODEV;

err = 0;
if (atomic_inc_not_zero(&num_counters)) {
Expand Down Expand Up @@ -348,9 +352,8 @@ static u64 amd_pmu_save_disable_all(void)

u64 hw_perf_save_disable(void)
{
if (unlikely(!perf_counters_initialized))
if (!x86_pmu_initialized())
return 0;

return x86_pmu.save_disable_all();
}
/*
Expand Down Expand Up @@ -388,9 +391,8 @@ static void amd_pmu_restore_all(u64 ctrl)

void hw_perf_restore(u64 ctrl)
{
if (unlikely(!perf_counters_initialized))
if (!x86_pmu_initialized())
return;

x86_pmu.restore_all(ctrl);
}
/*
Expand All @@ -402,8 +404,6 @@ static inline u64 intel_pmu_get_status(u64 mask)
{
u64 status;

if (unlikely(!perf_counters_initialized))
return 0;
rdmsrl(MSR_CORE_PERF_GLOBAL_STATUS, status);

return status;
Expand All @@ -417,21 +417,13 @@ static inline void intel_pmu_ack_status(u64 ack)
static inline void x86_pmu_enable_counter(struct hw_perf_counter *hwc, int idx)
{
int err;

if (unlikely(!perf_counters_initialized))
return;

err = checking_wrmsrl(hwc->config_base + idx,
hwc->config | ARCH_PERFMON_EVENTSEL0_ENABLE);
}

static inline void x86_pmu_disable_counter(struct hw_perf_counter *hwc, int idx)
{
int err;

if (unlikely(!perf_counters_initialized))
return;

err = checking_wrmsrl(hwc->config_base + idx,
hwc->config);
}
Expand Down Expand Up @@ -787,10 +779,10 @@ void perf_counter_unthrottle(void)
{
struct cpu_hw_counters *cpuc;

if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON))
if (!x86_pmu_initialized())
return;

if (unlikely(!perf_counters_initialized))
if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON))
return;

cpuc = &__get_cpu_var(cpu_hw_counters);
Expand Down Expand Up @@ -829,8 +821,9 @@ void perf_counters_lapic_init(int nmi)
{
u32 apic_val;

if (!perf_counters_initialized)
if (!x86_pmu_initialized())
return;

/*
* Enable the performance counter vector in the APIC LVT:
*/
Expand Down Expand Up @@ -988,7 +981,6 @@ void __init init_hw_perf_counters(void)
((1LL << x86_pmu.num_counters_fixed)-1) << X86_PMC_IDX_FIXED;

pr_info("... counter mask: %016Lx\n", perf_counter_mask);
perf_counters_initialized = true;

perf_counters_lapic_init(0);
register_die_notifier(&perf_counter_nmi_notifier);
Expand Down

0 comments on commit 3a44c85

Please sign in to comment.