Changeset View
Changeset View
Standalone View
Standalone View
lib/libpmc/libpmc.c
Show First 20 Lines • Show All 1,361 Lines • ▼ Show 20 Lines | |||||
int | int | ||||
pmc_init(void) | pmc_init(void) | ||||
{ | { | ||||
int error, pmc_mod_id; | int error, pmc_mod_id; | ||||
unsigned int n; | unsigned int n; | ||||
uint32_t abi_version; | uint32_t abi_version; | ||||
struct module_stat pmc_modstat; | struct module_stat pmc_modstat; | ||||
struct pmc_op_getcpuinfo op_cpu_info; | struct pmc_op_getcpuinfo op_cpu_info; | ||||
#if defined(__amd64__) || defined(__i386__) | |||||
int cpu_has_iaf_counters; | |||||
unsigned int t; | |||||
#endif | |||||
if (pmc_syscall != -1) /* already inited */ | if (pmc_syscall != -1) /* already inited */ | ||||
return (0); | return (0); | ||||
/* retrieve the system call number from the KLD */ | /* retrieve the system call number from the KLD */ | ||||
if ((pmc_mod_id = modfind(PMC_MODULE_NAME)) < 0) | if ((pmc_mod_id = modfind(PMC_MODULE_NAME)) < 0) | ||||
return (-1); | return (-1); | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | pmc_init(void) | ||||
*/ | */ | ||||
n = 0; | n = 0; | ||||
/* Fill soft events information. */ | /* Fill soft events information. */ | ||||
pmc_class_table[n++] = &soft_class_table_descr; | pmc_class_table[n++] = &soft_class_table_descr; | ||||
#if defined(__amd64__) || defined(__i386__) | #if defined(__amd64__) || defined(__i386__) | ||||
if (cpu_info.pm_cputype != PMC_CPU_GENERIC) | if (cpu_info.pm_cputype != PMC_CPU_GENERIC) | ||||
pmc_class_table[n++] = &tsc_class_table_descr; | pmc_class_table[n++] = &tsc_class_table_descr; | ||||
/* | |||||
* Check if this CPU has fixed function counters. | |||||
*/ | |||||
cpu_has_iaf_counters = 0; | |||||
for (t = 0; t < cpu_info.pm_nclass; t++) | |||||
if (cpu_info.pm_classes[t].pm_class == PMC_CLASS_IAF && | |||||
cpu_info.pm_classes[t].pm_num > 0) | |||||
cpu_has_iaf_counters = 1; | |||||
#endif | #endif | ||||
#define PMC_MDEP_INIT(C) do { \ | #define PMC_MDEP_INIT(C) do { \ | ||||
pmc_mdep_event_aliases = C##_aliases; \ | pmc_mdep_event_aliases = C##_aliases; \ | ||||
pmc_mdep_class_list = C##_pmc_classes; \ | pmc_mdep_class_list = C##_pmc_classes; \ | ||||
pmc_mdep_class_list_size = \ | pmc_mdep_class_list_size = \ | ||||
PMC_TABLE_SIZE(C##_pmc_classes); \ | PMC_TABLE_SIZE(C##_pmc_classes); \ | ||||
} while (0) | |||||
#define PMC_MDEP_INIT_INTEL_V2(C) do { \ | |||||
PMC_MDEP_INIT(C); \ | |||||
pmc_class_table[n++] = &iaf_class_table_descr; \ | |||||
if (!cpu_has_iaf_counters) \ | |||||
pmc_mdep_event_aliases = \ | |||||
C##_aliases_without_iaf; \ | |||||
pmc_class_table[n] = &C##_class_table_descr; \ | |||||
} while (0) | } while (0) | ||||
/* Configure the event name parser. */ | /* Configure the event name parser. */ | ||||
switch (cpu_info.pm_cputype) { | switch (cpu_info.pm_cputype) { | ||||
#if defined(__amd64__) || defined(__i386__) | #if defined(__amd64__) || defined(__i386__) | ||||
case PMC_CPU_AMD_K8: | case PMC_CPU_AMD_K8: | ||||
PMC_MDEP_INIT(k8); | PMC_MDEP_INIT(k8); | ||||
pmc_class_table[n] = &k8_class_table_descr; | pmc_class_table[n] = &k8_class_table_descr; | ||||
▲ Show 20 Lines • Show All 411 Lines • Show Last 20 Lines |