47#define sel_event_select perfevtsel.sel_event_select
48#define sel_unit_mask perfevtsel.sel_unit_mask
49#define sel_usr perfevtsel.sel_usr
50#define sel_os perfevtsel.sel_os
51#define sel_edge perfevtsel.sel_edge
52#define sel_pc perfevtsel.sel_pc
53#define sel_int perfevtsel.sel_int
54#define sel_en perfevtsel.sel_en
55#define sel_inv perfevtsel.sel_inv
56#define sel_cnt_mask perfevtsel.sel_cnt_mask
58#define is_pebs(i) (core_pe[i].pme_flags & PFMLIB_CORE_PEBS)
77#define CORE_SEL_BASE 0x186
78#define CORE_CTR_BASE 0xc1
79#define FIXED_CTR_BASE 0x309
81#define PFMLIB_CORE_ALL_FLAGS \
82 (PFM_CORE_SEL_INV|PFM_CORE_SEL_EDGE)
98 if (strcmp(buffer,
"GenuineIntel"))
114 model = atoi(buffer);
155 unsigned int fl, flc,
i;
156 unsigned int mask = 0;
190 return flc > 0 && flc == e->
num_masks ? 1 : 0;
200#define HAS_OPTIONS(x) (cntrs && (cntrs[x].flags || cntrs[x].cnt_mask))
201#define is_fixed_pmc(a) (a == 16 || a == 17 || a == 18)
210 unsigned long long fixed_ctr;
211 unsigned int npc, npmc0, npmc1, nf2;
212 unsigned int i, j, n, k, ucode, use_pebs = 0, done_pebs;
214 unsigned int next_gen, last_gen;
216 npc = npmc0 = npmc1 = nf2 = 0;
238 for(
i=0;
i < n;
i++) {
252 && e[
i].num_masks > 1) {
253 DPRINT(
"events does not support unit mask combination\n");
263 DPRINT(
"two events compete for a PMC0\n");
272 DPRINT(
"two events compete for a PMC1\n");
281 DPRINT(
"two events compete for FIXED_CTR2\n");
285 DPRINT(
"fixed counters do not support inversion/counter-mask\n");
299 DPRINT(
"two events compete for FIXED_CTR2\n");
303 DPRINT(
"fixed counters do not support inversion/counter-mask\n");
321 for(
i=0;
i < n;
i++) {
352 for(
i=0;
i < n;
i++) {
374 for(
i=0;
i < n;
i++) {
375 if (assign_pc[
i] == -1) {
376 for(; next_gen <= last_gen; next_gen++) {
381 if (next_gen <= last_gen)
382 assign_pc[
i] = next_gen++;
384 DPRINT(
"cannot assign generic counters\n");
394 for (
i=0;
i < n ;
i++ ) {
406 reg.
val |= val << ((assign_pc[
i]-16)<<2);
415 __pfm_vbprintf(
"[FIXED_CTRL(pmc%u)=0x%"PRIx64
" pmi0=1 en0=0x%"PRIx64
" pmi1=1 en1=0x%"PRIx64
" pmi2=1 en2=0x%"PRIx64
"] ",
419 (reg.
val>>4) & 0x3ULL,
420 (reg.
val>>8) & 0x3ULL);
422 if ((fixed_ctr & 0x1) == 0)
424 if ((fixed_ctr & 0x2) == 0)
426 if ((fixed_ctr & 0x4) == 0)
432 if ((fixed_ctr & 0x1) == 0)
434 if ((fixed_ctr & 0x2) == 0)
436 if ((fixed_ctr & 0x4) == 0)
440 for (
i=0;
i < n ;
i++ ) {
454 ucode = (val >> 8) & 0xff;
466 && ((ucode & (0x3 << 6)) == 0)) {
475 && ((ucode & 0xf) == 0)) {
497 if (cntrs[
i].cnt_mask > 255)
513 __pfm_vbprintf(
"[PERFEVTSEL%u(pmc%u)=0x%"PRIx64
" event_sel=0x%x umask=0x%x os=%d usr=%d en=%d int=%d inv=%d edge=%d cnt_mask=%d] %s\n",
537 for (
i=0;
i < n ;
i++) {
555 if (use_pebs && done_pebs) {
569 pc[npc].reg_value & 0x1ull);
585 unsigned int umask, npc, npd, k, plm;
656 __pfm_vbprintf(
"[PERFEVTSEL%u(pmc%u)=0x%"PRIx64
" event_sel=0x%x umask=0x%x os=%d usr=%d en=%d int=%d inv=%d edge=%d cnt_mask=%d] %s\n",
688 pc[npc].reg_value & 0x1ull);
729 unsigned int has_f0, has_f1, has_f2;
731 memset(counters, 0,
sizeof(*counters));
734 has_f0 = has_f1 = has_f2 = 0;
736 for (
i=0;
i < n;
i++) {
799#define PMU_CORE_COUNTER_WIDTH 32
#define PME_CORE_INSTRUCTIONS_RETIRED
#define PME_CORE_EVENT_COUNT
#define PME_CORE_UNHALTED_CORE_CYCLES
static pme_core_entry_t core_pe[]
#define PFMLIB_ERR_FEATCOMB
static int pfm_regmask_set(pfmlib_regmask_t *h, unsigned int b)
static int pfm_regmask_clr(pfmlib_regmask_t *h, unsigned int b)
#define PFMLIB_ERR_TOOMANY
static int pfm_regmask_isset(pfmlib_regmask_t *h, unsigned int b)
#define PFMLIB_ERR_NOASSIGN
#define PFMLIB_ERR_NOTSUPP
static int pfm_core_dispatch_events(pfmlib_input_param_t *inp, void *model_in, pfmlib_output_param_t *outp, void *model_out)
static int pfm_core_get_event_code(unsigned int i, unsigned int cnt, int *code)
static int pfm_core_is_fixed(pfmlib_event_t *e, unsigned int f)
static char * pfm_core_get_event_mask_name(unsigned int ev, unsigned int midx)
static int pfm_core_get_event_mask_code(unsigned int ev, unsigned int midx, unsigned int *code)
static void pfm_core_get_event_counters(unsigned int j, pfmlib_regmask_t *counters)
static int pfm_core_get_inst_retired(pfmlib_event_t *e)
pfm_pmu_support_t core_support
static int pfm_core_detect(void)
static int highest_counter
static pfmlib_regmask_t core_impl_pmds
static int pfm_core_get_event_mask_desc(unsigned int ev, unsigned int midx, char **str)
static char * pfm_core_get_event_name(unsigned int i)
static void pfm_core_get_impl_pmcs(pfmlib_regmask_t *impl_pmcs)
static int pfm_core_get_cycle_event(pfmlib_event_t *e)
int pfm_core_is_pebs(pfmlib_event_t *e)
static void pfm_core_get_impl_pmds(pfmlib_regmask_t *impl_pmds)
static int pfm_core_init(void)
static int pfm_core_dispatch_counters(pfmlib_input_param_t *inp, pfmlib_core_input_param_t *param, pfmlib_output_param_t *outp)
static pfmlib_regmask_t core_impl_pmcs
static void pfm_core_get_hw_counter_width(unsigned int *width)
static int pfm_core_get_event_description(unsigned int ev, char **str)
#define PMU_CORE_COUNTER_WIDTH
static void pfm_core_get_impl_counters(pfmlib_regmask_t *impl_counters)
#define PFMLIB_CORE_ALL_FLAGS
static unsigned int pfm_core_get_num_event_masks(unsigned int ev)
#define PMU_CORE_NUM_COUNTERS
#define PFM_CORE_SEL_EDGE
#define PFMLIB_CORE_UMASK_NCOMBO
#define PFMLIB_CORE_FIXED1
#define PFMLIB_CORE_FIXED0
#define PFMLIB_CORE_FIXED2_ONLY
#define PFMLIB_CORE_CSPEC
int __pfm_getcpuinfo_attr(const char *attr, char *ret_buf, size_t maxlen)
void __pfm_vbprintf(const char *fmt,...)
#define DPRINT(fmt, a...)
unsigned int unit_masks[PFMLIB_MAX_MASKS_PER_EVENT]
pfmlib_reg_t pfp_pmds[PFMLIB_MAX_PMDS]
pfmlib_reg_t pfp_pmcs[PFMLIB_MAX_PMCS]
unsigned int pfp_pmc_count
unsigned int pfp_pmd_count
unsigned long long reg_value
unsigned long reg_alt_addr
unsigned long long reg_addr
pme_core_umask_t pme_umasks[PFMLIB_CORE_MAX_UMASK]
unsigned long sel_cnt_mask
unsigned long sel_event_select
unsigned long sel_unit_mask