42#ifdef CONFIG_PFMLIB_ARCH_IA64
49#ifdef CONFIG_PFMLIB_ARCH_X86_64
59#ifdef CONFIG_PFMLIB_ARCH_I386
74#ifdef CONFIG_PFMLIB_ARCH_MIPS64
78#ifdef CONFIG_PFMLIB_ARCH_SICORTEX
82#ifdef CONFIG_PFMLIB_ARCH_POWERPC
86#ifdef CONFIG_PFMLIB_ARCH_SPARC
90#ifdef CONFIG_PFMLIB_ARCH_CRAYX2
94#ifdef CONFIG_PFMLIB_CELL
122 str = getenv(
"LIBPFM_VERBOSE");
123 if (str && *str >=
'0' && *str <=
'9') {
128 str = getenv(
"LIBPFM_DEBUG");
129 if (str && *str >=
'0' && *str <=
'9') {
134 str = getenv(
"LIBPFM_DEBUG_STDOUT");
138 str = getenv(
"LIBPFM_FORCE_PMU");
156 DPRINT(
"trying %s\n", (*p)->pmu_name);
172 DPRINT(
"found %s\n", (*p)->pmu_name);
182 if ((*p)->pmu_init) {
183 ret = (*p)->pmu_init();
219 if ((*p)->pmu_type ==
type)
goto found;
224 strncpy(
name, (*p)->pmu_name, maxlen-1);
227 name[maxlen-1] =
'\0';
239 (*pf)(
"supported PMU models: ");
242 (*pf)(
"[%s] ", (*p)->pmu_name);;
259 name[maxlen-1] =
'\0';
299 if ((*p)->pmu_type ==
type)
goto found;
319 if (n == NULL || idx == NULL)
340 if (!strncasecmp(e, n, len)
354 unsigned int i, j, num_cnt;
366 for(j=0; num_cnt; j++) {
378 if (code2 == code)
goto found;
390 unsigned long number;
397 if (v == NULL || ev == NULL)
400 if (isdigit((
int)*v)) {
401 number = strtoul(v,&endptr, 0);
406 if (number <= INT_MAX) {
407 int the_int_number = (
int)number;
428 if (code2 == code)
goto found;
439 unsigned int i,
c, num_masks = 0;
440 unsigned long mask_val = -1;
449 for (
i = 0;
i < num_masks;
i++) {
453 if (strcasecmp(mask_name, str))
459 mask_val = strtoul(str, &endptr, 0);
460 if (mask_val != ULONG_MAX && endptr && *endptr ==
'\0') {
461 for (
i = 0;
i < num_masks;
i++) {
478 if (str == NULL || mask_idx == NULL || ev >=
pfm_current->pme_count)
502 unsigned int i, j,
c;
503 unsigned int num_masks = 0;
504 unsigned long mask_val = -1, m = 0;
523 mask_val = strtoul(str, &endptr, 0);
524 if (endptr && *endptr !=
'\0')
530 for (
i = 0;
i < num_masks;
i++) {
532 if ((mask_val &
c) == (
unsigned long)
c) {
590 name[j] = (
char)toupper(str[j]);
664 if (islower(
name[j]))
733 if (!inp && !model_in)
735 if (!outp && !model_out)
761 memset(outp, 0,
sizeof(*outp));
763 return pfm_current->dispatch_events(inp, model_in, outp, model_out);
811 memset(impl_pmcs , 0,
sizeof(*impl_pmcs));
824 memset(impl_pmds, 0,
sizeof(*impl_pmds));
837 memset(impl_counters, 0,
sizeof(*impl_counters));
861 "invalid parameters",
862 "pfmlib not initialized",
864 "cannot assign events to counters",
865 "buffer is full or too small",
866 "event used more than once",
867 "invalid model specific magic number",
868 "invalid combination of model specific features",
869 "incompatible event sets",
870 "incompatible events combination",
871 "too many events or unit masks",
872 "code range too big",
874 "invalid code range",
875 "too many code ranges",
876 "invalid data range",
877 "too many data ranges",
878 "not supported by host cpu",
879 "code range is not bundle-aligned",
880 "code range requires some flags in rr_flags",
881 "invalid or missing unit mask",
905 unsigned int i, j, num_masks;
919 if (l > max) max = l;
927 for (j = 0; j < num_masks; j++) {
931 l += 1 + strlen(str);
933 if (l > max) max = l;
953 memset(e, 0,
sizeof(*e));
972 memset(e, 0,
sizeof(*e));
985 *str = strdup(
"no description available");
999 *desc = strdup(
"no description available");
1002 if (mask_idx >=
pfm_current->get_num_event_masks(event_idx))
1005 return pfm_current->get_event_mask_desc(event_idx, mask_idx, desc);
1019 if (mask_idx >=
pfm_current->get_num_event_masks(event_idx))
1022 return pfm_current->get_event_mask_code(event_idx, mask_idx, code);
1035 if (e == NULL ||
name == NULL || maxlen < 1)
1074 for(j=0; j < l; j++)
1075 if (islower(
name[j]))
1084 unsigned int j, mask;
1090 if (v == NULL || e == NULL)
1093 memset(e, 0,
sizeof(*e));
1117 p = strchr(str,
':');
1121 if ((j == 0) && (p == NULL)) {
1156 for( q = p; q ; p = q) {
static double c[MATRIX_SIZE][MATRIX_SIZE]
#define PFMLIB_ERR_BADHOST
#define PFMLIB_MAX_MASKS_PER_EVENT
#define PFMLIB_ERR_NOTFOUND
#define PFMLIB_ERR_TOOMANY
#define PFMLIB_ERR_NOINIT
static int pfm_regmask_isset(pfmlib_regmask_t *h, unsigned int b)
#define PFMLIB_ERR_NOASSIGN
#define PFMLIB_ERR_NOTSUPP
pfm_pmu_support_t amd64_support
pfm_pmu_support_t cell_support
int pfm_get_version(unsigned int *version)
int pfm_get_event_mask_description(unsigned int event_idx, unsigned int mask_idx, char **desc)
int pfm_list_supported_pmus(int(*pf)(const char *fmt,...))
char * pfm_strerror(int code)
int pfm_get_event_code_counter(unsigned int i, unsigned int cnt, int *code)
int pfm_get_num_pmcs(unsigned int *num)
int pfm_find_event_bycode(int code, unsigned int *idx)
int pfm_get_event_counters(unsigned int i, pfmlib_regmask_t *counters)
int pfm_find_full_event(const char *v, pfmlib_event_t *e)
int pfm_get_pmu_name_bytype(int type, char *name, size_t maxlen)
int pfm_get_inst_retired_event(pfmlib_event_t *e)
static char * pfmlib_err_list[]
int pfm_dispatch_events(pfmlib_input_param_t *inp, void *model_in, pfmlib_output_param_t *outp, void *model_out)
int pfm_find_event_mask(unsigned int ev, const char *str, unsigned int *mask_idx)
int pfm_get_event_description(unsigned int i, char **str)
int pfm_get_num_event_masks(unsigned int ev, unsigned int *count)
int pfm_get_max_event_name_len(size_t *len)
int pfm_find_event(const char *v, unsigned int *ev)
static int pfm_add_numeric_masks(pfmlib_event_t *e, const char *str)
static void pfm_check_debug_env(void)
int pfm_get_num_counters(unsigned int *num)
int pfm_get_event_mask_name(unsigned int ev, unsigned int mask, char *name, size_t maxlen)
int pfm_find_event_byname(const char *n, unsigned int *idx)
static int pfm_check_duplicates(pfmlib_event_t *e, unsigned int u)
int pfm_find_event_bycode_next(int code, unsigned int i, unsigned int *next)
int pfm_is_pmu_supported(int type)
int pfm_get_impl_counters(pfmlib_regmask_t *impl_counters)
int pfm_get_num_events(unsigned int *count)
int pfm_get_impl_pmds(pfmlib_regmask_t *impl_pmds)
int pfm_get_event_code(unsigned int i, int *code)
int pfm_get_impl_pmcs(pfmlib_regmask_t *impl_pmcs)
int pfm_get_hw_counter_width(unsigned int *width)
int pfm_get_cycle_event(pfmlib_event_t *e)
static pfm_pmu_support_t * supported_pmus[]
int pfm_set_options(pfmlib_options_t *opt)
int pfm_get_num_pmds(unsigned int *num)
int pfm_get_event_name(unsigned int i, char *name, size_t maxlen)
int pfm_get_pmu_name(char *name, int maxlen)
static int pfm_do_find_event_mask(unsigned int ev, const char *str, unsigned int *mask_idx)
int pfm_force_pmu(int type)
static size_t pfmlib_err_count
int pfm_get_pmu_type(int *type)
int pfm_get_full_event_name(pfmlib_event_t *e, char *name, size_t maxlen)
int pfm_get_event_mask_code(unsigned int event_idx, unsigned int mask_idx, unsigned int *code)
pfm_pmu_support_t core_support
pfm_pmu_support_t coreduo_support
pfm_pmu_support_t crayx2_support
pfm_pmu_support_t gen_ia32_support
pfm_pmu_support_t generic_ia64_support
pfm_pmu_support_t generic_mips64_support
pfm_pmu_support_t gen_powerpc_support
pfm_pmu_support_t i386_pii_support
pfm_pmu_support_t i386_pm_support
pfm_pmu_support_t i386_ppro_support
pfm_pmu_support_t i386_p6_support
pfm_pmu_support_t intel_atom_support
pfm_pmu_support_t intel_nhm_support
pfm_pmu_support_t intel_wsm_support
pfm_pmu_support_t itanium2_support
pfm_pmu_support_t itanium_support
pfm_pmu_support_t montecito_support
void pfm_init_syscalls(void)
pfm_pmu_support_t pentium4_support
void __pfm_vbprintf(const char *fmt,...)
int __pfm_check_event(pfmlib_event_t *e)
#define PFMLIB_INITIALIZED()
pfm_pmu_support_t sparc_support
static unsigned int pfm_num_masks(int e)
#define DPRINT(fmt, a...)
pfm_pmu_support_t sicortex_support
#define PFMLIB_MULT_CODE_EVENT
pfm_pmu_support_t * current
unsigned int unit_masks[PFMLIB_MAX_MASKS_PER_EVENT]
pfmlib_regmask_bits_t bits[PFMLIB_REG_BV]