Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147388
b: refs/heads/master
c: 72eae04
h: refs/heads/master
v: v3
  • Loading branch information
Robert Richter authored and Ingo Molnar committed Apr 29, 2009
1 parent 3c30862 commit 7e7b968
Show file tree
Hide file tree
Showing 2 changed files with 17 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: 55de0f2e57994b525324bf0d04d242d9358a2417
refs/heads/master: 72eae04d3a3075c26d39e1e685acfc8e8c29db64
27 changes: 16 additions & 11 deletions trunk/arch/x86/kernel/cpu/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,65 +913,70 @@ static struct x86_pmu amd_pmu = {
.max_events = ARRAY_SIZE(amd_perfmon_event_map),
};

static struct x86_pmu *intel_pmu_init(void)
static int intel_pmu_init(void)
{
union cpuid10_edx edx;
union cpuid10_eax eax;
unsigned int unused;
unsigned int ebx;

if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON))
return NULL;
return -ENODEV;

/*
* Check whether the Architectural PerfMon supports
* Branch Misses Retired Event or not.
*/
cpuid(10, &eax.full, &ebx, &unused, &edx.full);
if (eax.split.mask_length <= ARCH_PERFMON_BRANCH_MISSES_RETIRED)
return NULL;
return -ENODEV;

intel_perfmon_version = eax.split.version_id;
if (intel_perfmon_version < 2)
return NULL;
return -ENODEV;

pr_info("Intel Performance Monitoring support detected.\n");
pr_info("... version: %d\n", intel_perfmon_version);
pr_info("... bit width: %d\n", eax.split.bit_width);
pr_info("... mask length: %d\n", eax.split.mask_length);

x86_pmu = &intel_pmu;

nr_counters_generic = eax.split.num_counters;
nr_counters_fixed = edx.split.num_counters_fixed;
counter_value_mask = (1ULL << eax.split.bit_width) - 1;

return &intel_pmu;
return 0;
}

static struct x86_pmu *amd_pmu_init(void)
static int amd_pmu_init(void)
{
x86_pmu = &amd_pmu;

nr_counters_generic = 4;
nr_counters_fixed = 0;
counter_value_mask = 0x0000FFFFFFFFFFFFULL;
counter_value_bits = 48;

pr_info("AMD Performance Monitoring support detected.\n");

return &amd_pmu;
return 0;
}

void __init init_hw_perf_counters(void)
{
int err;

switch (boot_cpu_data.x86_vendor) {
case X86_VENDOR_INTEL:
x86_pmu = intel_pmu_init();
err = intel_pmu_init();
break;
case X86_VENDOR_AMD:
x86_pmu = amd_pmu_init();
err = amd_pmu_init();
break;
default:
return;
}
if (!x86_pmu)
if (err != 0)
return;

pr_info("... num counters: %d\n", nr_counters_generic);
Expand Down

0 comments on commit 7e7b968

Please sign in to comment.