|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* Copyright (c) 2005-2006 Hewlett-Packard Development Company, L.P.
|
|
Packit |
577717 |
* Copyright (c) 2006 IBM Corp.
|
|
Packit |
577717 |
* Contributed by Kevin Corry <kevcorry@us.ibm.com>
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
Packit |
577717 |
* copy of this software and associated documentation files (the "Software"),
|
|
Packit |
577717 |
* to deal in the Software without restriction, including without limitation
|
|
Packit |
577717 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
Packit |
577717 |
* and/or sell copies of the Software, and to permit persons to whom the
|
|
Packit |
577717 |
* Software is furnished to do so, subject to the following conditions:
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* The above copyright notice and this permission notice shall be included in
|
|
Packit |
577717 |
* all copies or substantial portions of the Software.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
Packit |
577717 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
Packit |
577717 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
Packit |
577717 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
Packit |
577717 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
Packit |
577717 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
Packit |
577717 |
* IN THE SOFTWARE.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* pfmlib_intel_netburst.c
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Support for the Pentium4/Xeon/EM64T processor family (family=15).
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
/* private headers */
|
|
Packit |
577717 |
#include "pfmlib_priv.h"
|
|
Packit |
577717 |
#include "pfmlib_intel_netburst_priv.h"
|
|
Packit |
577717 |
#include "pfmlib_intel_x86_priv.h"
|
|
Packit |
577717 |
#include "events/intel_netburst_events.h"
|
|
Packit |
577717 |
|
|
Packit |
577717 |
const pfmlib_attr_desc_t netburst_mods[]={
|
|
Packit |
577717 |
PFM_ATTR_B("u", "monitor at priv level 1, 2, 3"), /* monitor priv level 1, 2, 3 */
|
|
Packit |
577717 |
PFM_ATTR_B("k", "monitor at priv level 0"), /* monitor priv level 0 */
|
|
Packit |
577717 |
PFM_ATTR_B("cmpl", "complement"), /* set: <=, clear: > */
|
|
Packit |
577717 |
PFM_ATTR_B("e", "edge"), /* edge */
|
|
Packit |
577717 |
PFM_ATTR_I("thr", "event threshold in range [0-15]"), /* threshold */
|
|
Packit |
577717 |
};
|
|
Packit |
577717 |
#define NETBURST_MODS_COUNT (sizeof(netburst_mods)/sizeof(pfmlib_attr_desc_t))
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
extern pfmlib_pmu_t netburst_support;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static inline int
|
|
Packit |
577717 |
netburst_get_numasks(int pidx)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int i = 0;
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* name = NULL is end-marker
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
while (netburst_events[pidx].event_masks[i].name)
|
|
Packit |
577717 |
i++;
|
|
Packit |
577717 |
return i;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static void
|
|
Packit |
577717 |
netburst_display_reg(pfmlib_event_desc_t *e)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
netburst_escr_value_t escr;
|
|
Packit |
577717 |
netburst_cccr_value_t cccr;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
escr.val = e->codes[0];
|
|
Packit |
577717 |
cccr.val = e->codes[1];
|
|
Packit |
577717 |
|
|
Packit |
577717 |
__pfm_vbprintf("[0x%"PRIx64" 0x%"PRIx64" 0x%"PRIx64" usr=%d os=%d tag_ena=%d tag_val=%d "
|
|
Packit |
577717 |
"evmask=0x%x evsel=0x%x escr_sel=0x%x comp=%d cmpl=%d thr=%d e=%d",
|
|
Packit |
577717 |
escr,
|
|
Packit |
577717 |
cccr,
|
|
Packit |
577717 |
e->codes[2], /* perf_event code */
|
|
Packit |
577717 |
escr.bits.t0_usr, /* t1 is identical */
|
|
Packit |
577717 |
escr.bits.t0_os, /* t1 is identical */
|
|
Packit |
577717 |
escr.bits.tag_enable,
|
|
Packit |
577717 |
escr.bits.tag_value,
|
|
Packit |
577717 |
escr.bits.event_mask,
|
|
Packit |
577717 |
escr.bits.event_select,
|
|
Packit |
577717 |
cccr.bits.escr_select,
|
|
Packit |
577717 |
cccr.bits.compare,
|
|
Packit |
577717 |
cccr.bits.complement,
|
|
Packit |
577717 |
cccr.bits.threshold,
|
|
Packit |
577717 |
cccr.bits.edge);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
__pfm_vbprintf("] %s\n", e->fstr);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static int
|
|
Packit |
577717 |
netburst_add_defaults(pfmlib_event_desc_t *e, unsigned int *evmask)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int i, n;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
n = netburst_get_numasks(e->event);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
for (i = 0; i < n; i++) {
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (netburst_events[e->event].event_masks[i].flags & NETBURST_FL_DFL)
|
|
Packit |
577717 |
goto found;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
return PFM_ERR_ATTR;
|
|
Packit |
577717 |
found:
|
|
Packit |
577717 |
*evmask = 1 << netburst_events[e->event].event_masks[i].bit;
|
|
Packit |
577717 |
n = e->nattrs;
|
|
Packit |
577717 |
e->attrs[n].id = i;
|
|
Packit |
577717 |
e->attrs[n].ival = i;
|
|
Packit |
577717 |
e->nattrs = n+1;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return PFM_SUCCESS;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int
|
|
Packit |
577717 |
pfm_netburst_get_encoding(void *this, pfmlib_event_desc_t *e)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
pfmlib_event_attr_info_t *a;
|
|
Packit |
577717 |
netburst_escr_value_t escr;
|
|
Packit |
577717 |
netburst_cccr_value_t cccr;
|
|
Packit |
577717 |
unsigned int evmask = 0;
|
|
Packit |
577717 |
unsigned int plmmsk = 0;
|
|
Packit |
577717 |
int umask_done = 0;
|
|
Packit |
577717 |
const char *n;
|
|
Packit |
577717 |
int k, id, bit, ret;
|
|
Packit |
577717 |
int tag_enable = 0, tag_value = 0;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
e->fstr[0] = '\0';
|
|
Packit |
577717 |
|
|
Packit |
577717 |
escr.val = 0;
|
|
Packit |
577717 |
cccr.val = 0;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
for(k=0; k < e->nattrs; k++) {
|
|
Packit |
577717 |
a = attr(e, k);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (a->ctrl != PFM_ATTR_CTRL_PMU)
|
|
Packit |
577717 |
continue;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (a->type == PFM_ATTR_UMASK) {
|
|
Packit |
577717 |
|
|
Packit |
577717 |
bit = netburst_events[e->event].event_masks[a->idx].bit;
|
|
Packit |
577717 |
n = netburst_events[e->event].event_masks[a->idx].name;
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* umask combination seems possible, although it does
|
|
Packit |
577717 |
* not always make sense, e.g., BOGUS vs. NBOGUS
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
if (bit < EVENT_MASK_BITS && n) {
|
|
Packit |
577717 |
evmask |= (1 << bit);
|
|
Packit |
577717 |
} else if (bit >= EVENT_MASK_BITS && n) {
|
|
Packit |
577717 |
tag_value |= (1 << (bit - EVENT_MASK_BITS));
|
|
Packit |
577717 |
tag_enable = 1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
umask_done = 1;
|
|
Packit |
577717 |
} else if (a->type == PFM_ATTR_RAW_UMASK) {
|
|
Packit |
577717 |
/* should not happen */
|
|
Packit |
577717 |
return PFM_ERR_ATTR;
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
uint64_t ival = e->attrs[k].ival;
|
|
Packit |
577717 |
switch (a->idx) {
|
|
Packit |
577717 |
case NETBURST_ATTR_U:
|
|
Packit |
577717 |
escr.bits.t1_usr = !!ival;
|
|
Packit |
577717 |
escr.bits.t0_usr = !!ival;
|
|
Packit |
577717 |
plmmsk |= _NETBURST_ATTR_U;
|
|
Packit |
577717 |
break;
|
|
Packit |
577717 |
case NETBURST_ATTR_K:
|
|
Packit |
577717 |
escr.bits.t1_os = !!ival;
|
|
Packit |
577717 |
escr.bits.t0_os = !!ival;
|
|
Packit |
577717 |
plmmsk |= _NETBURST_ATTR_K;
|
|
Packit |
577717 |
break;
|
|
Packit |
577717 |
case NETBURST_ATTR_E:
|
|
Packit |
577717 |
if (ival) {
|
|
Packit |
577717 |
cccr.bits.compare = 1;
|
|
Packit |
577717 |
cccr.bits.edge = 1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
break;
|
|
Packit |
577717 |
case NETBURST_ATTR_C:
|
|
Packit |
577717 |
if (ival) {
|
|
Packit |
577717 |
cccr.bits.compare = 1;
|
|
Packit |
577717 |
cccr.bits.complement = 1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
break;
|
|
Packit |
577717 |
case NETBURST_ATTR_T:
|
|
Packit |
577717 |
if (ival > 15)
|
|
Packit |
577717 |
return PFM_ERR_ATTR_VAL;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (ival) {
|
|
Packit |
577717 |
cccr.bits.compare = 1;
|
|
Packit |
577717 |
cccr.bits.threshold = ival;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
break;
|
|
Packit |
577717 |
default:
|
|
Packit |
577717 |
return PFM_ERR_ATTR;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* handle case where no priv level mask was passed.
|
|
Packit |
577717 |
* then we use the dfl_plm
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
if (!(plmmsk & (_NETBURST_ATTR_K|_NETBURST_ATTR_U))) {
|
|
Packit |
577717 |
if (e->dfl_plm & PFM_PLM0) {
|
|
Packit |
577717 |
escr.bits.t1_os = 1;
|
|
Packit |
577717 |
escr.bits.t0_os = 1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
if (e->dfl_plm & PFM_PLM3) {
|
|
Packit |
577717 |
escr.bits.t1_usr = 1;
|
|
Packit |
577717 |
escr.bits.t0_usr = 1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (!umask_done) {
|
|
Packit |
577717 |
ret = netburst_add_defaults(e, &evmask);
|
|
Packit |
577717 |
if (ret != PFM_SUCCESS)
|
|
Packit |
577717 |
return ret;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
escr.bits.tag_enable = tag_enable;
|
|
Packit |
577717 |
escr.bits.tag_value = tag_value;
|
|
Packit |
577717 |
escr.bits.event_mask = evmask;
|
|
Packit |
577717 |
escr.bits.event_select = netburst_events[e->event].event_select;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
cccr.bits.enable = 1;
|
|
Packit |
577717 |
cccr.bits.escr_select = netburst_events[e->event].escr_select;
|
|
Packit |
577717 |
cccr.bits.active_thread = 3;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (e->event == PME_REPLAY_EVENT)
|
|
Packit |
577717 |
escr.bits.event_mask &= P4_REPLAY_REAL_MASK; /* remove virtual mask bits */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* reorder all the attributes such that the fstr appears always
|
|
Packit |
577717 |
* the same regardless of how the attributes were submitted.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
evt_strcat(e->fstr, "%s", netburst_events[e->event].name);
|
|
Packit |
577717 |
pfmlib_sort_attr(e);
|
|
Packit |
577717 |
for(k=0; k < e->nattrs; k++) {
|
|
Packit |
577717 |
a = attr(e, k);
|
|
Packit |
577717 |
if (a->ctrl != PFM_ATTR_CTRL_PMU)
|
|
Packit |
577717 |
continue;
|
|
Packit |
577717 |
if (a->type == PFM_ATTR_UMASK) {
|
|
Packit |
577717 |
id = e->attrs[k].id;
|
|
Packit |
577717 |
evt_strcat(e->fstr, ":%s", netburst_events[e->event].event_masks[id].name);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
evt_strcat(e->fstr, ":%s=%lu", netburst_mods[NETBURST_ATTR_K].name, escr.bits.t0_os);
|
|
Packit |
577717 |
evt_strcat(e->fstr, ":%s=%lu", netburst_mods[NETBURST_ATTR_U].name, escr.bits.t0_usr);
|
|
Packit |
577717 |
evt_strcat(e->fstr, ":%s=%lu", netburst_mods[NETBURST_ATTR_E].name, cccr.bits.edge);
|
|
Packit |
577717 |
evt_strcat(e->fstr, ":%s=%lu", netburst_mods[NETBURST_ATTR_C].name, cccr.bits.complement);
|
|
Packit |
577717 |
evt_strcat(e->fstr, ":%s=%lu", netburst_mods[NETBURST_ATTR_T].name, cccr.bits.threshold);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
e->count = 2;
|
|
Packit |
577717 |
e->codes[0] = escr.val;
|
|
Packit |
577717 |
e->codes[1] = cccr.val;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
netburst_display_reg(e);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return PFM_SUCCESS;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static int
|
|
Packit |
577717 |
pfm_netburst_detect(void *this)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int ret;
|
|
Packit |
577717 |
int model;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
ret = pfm_intel_x86_detect();
|
|
Packit |
577717 |
if (ret != PFM_SUCCESS)
|
|
Packit |
577717 |
return ret;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (pfm_intel_x86_cfg.family != 15)
|
|
Packit |
577717 |
return PFM_ERR_NOTSUPP;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
model = pfm_intel_x86_cfg.model;
|
|
Packit |
577717 |
if (model == 3 || model == 4 || model == 6)
|
|
Packit |
577717 |
return PFM_ERR_NOTSUPP;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return PFM_SUCCESS;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static int
|
|
Packit |
577717 |
pfm_netburst_detect_prescott(void *this)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int ret;
|
|
Packit |
577717 |
int model;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
ret = pfm_intel_x86_detect();
|
|
Packit |
577717 |
if (ret != PFM_SUCCESS)
|
|
Packit |
577717 |
return ret;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (pfm_intel_x86_cfg.family != 15)
|
|
Packit |
577717 |
return PFM_ERR_NOTSUPP;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* prescott has one more event (instr_completed)
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
model = pfm_intel_x86_cfg.model;
|
|
Packit |
577717 |
if (model != 3 && model != 4 && model != 6)
|
|
Packit |
577717 |
return PFM_ERR_NOTSUPP;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return PFM_SUCCESS;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static int
|
|
Packit |
577717 |
pfm_netburst_get_event_first(void *this)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
pfmlib_pmu_t *p = this;
|
|
Packit |
577717 |
return p->pme_count ? 0 : -1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static int
|
|
Packit |
577717 |
pfm_netburst_get_event_next(void *this, int idx)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
pfmlib_pmu_t *p = this;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (idx >= (p->pme_count-1))
|
|
Packit |
577717 |
return -1;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return idx+1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static int
|
|
Packit |
577717 |
pfm_netburst_event_is_valid(void *this, int pidx)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
pfmlib_pmu_t *p = this;
|
|
Packit |
577717 |
return pidx >= 0 && pidx < p->pme_count;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static int
|
|
Packit |
577717 |
pfm_netburst_get_event_attr_info(void *this, int pidx, int attr_idx, pfmlib_event_attr_info_t *info)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
const netburst_entry_t *pe = this_pe(this);
|
|
Packit |
577717 |
int numasks, idx;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
numasks = netburst_get_numasks(pidx);
|
|
Packit |
577717 |
if (attr_idx < numasks) {
|
|
Packit |
577717 |
//idx = pfm_intel_x86_attr2umask(this, pidx, attr_idx);
|
|
Packit |
577717 |
idx = attr_idx;
|
|
Packit |
577717 |
info->name = pe[pidx].event_masks[idx].name;
|
|
Packit |
577717 |
info->desc = pe[pidx].event_masks[idx].desc;
|
|
Packit |
577717 |
info->equiv= NULL;
|
|
Packit |
577717 |
info->code = pe[pidx].event_masks[idx].bit;
|
|
Packit |
577717 |
info->type = PFM_ATTR_UMASK;
|
|
Packit |
577717 |
info->is_dfl = !!(pe[pidx].event_masks[idx].flags & NETBURST_FL_DFL);
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
idx = attr_idx - numasks;
|
|
Packit |
577717 |
info->name = netburst_mods[idx].name;
|
|
Packit |
577717 |
info->desc = netburst_mods[idx].desc;
|
|
Packit |
577717 |
info->equiv= NULL;
|
|
Packit |
577717 |
info->code = idx;
|
|
Packit |
577717 |
info->type = netburst_mods[idx].type;
|
|
Packit |
577717 |
info->is_dfl = 0;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
info->ctrl = PFM_ATTR_CTRL_PMU;
|
|
Packit |
577717 |
info->idx = idx; /* namespace specific index */
|
|
Packit |
577717 |
info->dfl_val64 = 0;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return PFM_SUCCESS;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static int
|
|
Packit |
577717 |
pfm_netburst_get_event_info(void *this, int idx, pfm_event_info_t *info)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
const netburst_entry_t *pe = this_pe(this);
|
|
Packit |
577717 |
pfmlib_pmu_t *pmu = this;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* pmu and idx filled out by caller
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
info->name = pe[idx].name;
|
|
Packit |
577717 |
info->desc = pe[idx].desc;
|
|
Packit |
577717 |
info->code = pe[idx].event_select | (pe[idx].escr_select << 8);
|
|
Packit |
577717 |
info->equiv = NULL;
|
|
Packit |
577717 |
info->idx = idx; /* private index */
|
|
Packit |
577717 |
info->pmu = pmu->pmu;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
info->nattrs = netburst_get_numasks(idx);
|
|
Packit |
577717 |
info->nattrs += NETBURST_MODS_COUNT;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return PFM_SUCCESS;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static int
|
|
Packit |
577717 |
pfm_netburst_validate_table(void *this, FILE *fp)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
pfmlib_pmu_t *pmu = this;
|
|
Packit |
577717 |
const netburst_entry_t *pe = netburst_events;
|
|
Packit |
577717 |
const char *name = pmu->name;
|
|
Packit |
577717 |
int i, j, noname, ndfl;
|
|
Packit |
577717 |
int error = 0;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
for(i=0; i < pmu->pme_count; i++) {
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (!pe[i].name) {
|
|
Packit |
577717 |
fprintf(fp, "pmu: %s event%d: :: no name (prev event was %s)\n", pmu->name, i,
|
|
Packit |
577717 |
i > 1 ? pe[i-1].name : "??");
|
|
Packit |
577717 |
error++;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (!pe[i].desc) {
|
|
Packit |
577717 |
fprintf(fp, "pmu: %s event%d: %s :: no description\n", name, i, pe[i].name);
|
|
Packit |
577717 |
error++;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
noname = ndfl = 0;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* name = NULL is end-marker, veryfy there is at least one */
|
|
Packit |
577717 |
for(j= 0; j < EVENT_MASK_BITS; j++) {
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (!pe[i].event_masks[j].name)
|
|
Packit |
577717 |
noname++;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (pe[i].event_masks[j].name) {
|
|
Packit |
577717 |
if (!pe[i].event_masks[j].desc) {
|
|
Packit |
577717 |
fprintf(fp, "pmu: %s event%d:%s umask%d: %s :: no description\n", name, i, pe[i].name, j, pe[i].event_masks[j].name);
|
|
Packit |
577717 |
error++;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
if (pe[i].event_masks[j].bit >= (EVENT_MASK_BITS+4)) {
|
|
Packit |
577717 |
fprintf(fp, "pmu: %s event%d:%s umask%d: %s :: invalid bit field\n", name, i, pe[i].name, j, pe[i].event_masks[j].name);
|
|
Packit |
577717 |
error++;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (pe[i].event_masks[j].flags & NETBURST_FL_DFL)
|
|
Packit |
577717 |
ndfl++;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
if (ndfl > 1) {
|
|
Packit |
577717 |
fprintf(fp, "pmu: %s event%d:%s :: more than one default umask\n", name, i, pe[i].name);
|
|
Packit |
577717 |
error++;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
if (!noname) {
|
|
Packit |
577717 |
fprintf(fp, "pmu: %s event%d:%s :: no event mask end-marker\n", name, i, pe[i].name);
|
|
Packit |
577717 |
error++;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
return error ? PFM_ERR_INVAL : PFM_SUCCESS;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static unsigned int
|
|
Packit |
577717 |
pfm_netburst_get_event_nattrs(void *this, int pidx)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
unsigned int nattrs;
|
|
Packit |
577717 |
nattrs = netburst_get_numasks(pidx);
|
|
Packit |
577717 |
nattrs += NETBURST_MODS_COUNT;
|
|
Packit |
577717 |
return nattrs;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
pfmlib_pmu_t netburst_support = {
|
|
Packit |
577717 |
.desc = "Pentium4",
|
|
Packit |
577717 |
.name = "netburst",
|
|
Packit |
577717 |
.pmu = PFM_PMU_INTEL_NETBURST,
|
|
Packit |
577717 |
.pme_count = LIBPFM_ARRAY_SIZE(netburst_events) - 1,
|
|
Packit |
577717 |
.type = PFM_PMU_TYPE_CORE,
|
|
Packit |
577717 |
.supported_plm = INTEL_X86_PLM,
|
|
Packit |
577717 |
.atdesc = netburst_mods,
|
|
Packit |
577717 |
.pe = netburst_events,
|
|
Packit |
577717 |
.max_encoding = 3,
|
|
Packit |
577717 |
.num_cntrs = 18,
|
|
Packit |
577717 |
|
|
Packit |
577717 |
.pmu_detect = pfm_netburst_detect,
|
|
Packit |
577717 |
.get_event_encoding[PFM_OS_NONE] = pfm_netburst_get_encoding,
|
|
Packit |
577717 |
PFMLIB_ENCODE_PERF(pfm_netburst_get_perf_encoding),
|
|
Packit |
577717 |
.get_event_first = pfm_netburst_get_event_first,
|
|
Packit |
577717 |
.get_event_next = pfm_netburst_get_event_next,
|
|
Packit |
577717 |
.event_is_valid = pfm_netburst_event_is_valid,
|
|
Packit |
577717 |
.validate_table = pfm_netburst_validate_table,
|
|
Packit |
577717 |
.get_event_info = pfm_netburst_get_event_info,
|
|
Packit |
577717 |
.get_event_attr_info = pfm_netburst_get_event_attr_info,
|
|
Packit |
577717 |
.get_event_nattrs = pfm_netburst_get_event_nattrs,
|
|
Packit |
577717 |
PFMLIB_VALID_PERF_PATTRS(pfm_netburst_perf_validate_pattrs),
|
|
Packit |
577717 |
};
|
|
Packit |
577717 |
|
|
Packit |
577717 |
pfmlib_pmu_t netburst_p_support = {
|
|
Packit |
577717 |
.desc = "Pentium4 (Prescott)",
|
|
Packit |
577717 |
.name = "netburst_p",
|
|
Packit |
577717 |
.pmu = PFM_PMU_INTEL_NETBURST_P,
|
|
Packit |
577717 |
.pme_count = LIBPFM_ARRAY_SIZE(netburst_events),
|
|
Packit |
577717 |
.type = PFM_PMU_TYPE_CORE,
|
|
Packit |
577717 |
.supported_plm = INTEL_X86_PLM,
|
|
Packit |
577717 |
.atdesc = netburst_mods,
|
|
Packit |
577717 |
.pe = netburst_events,
|
|
Packit |
577717 |
.max_encoding = 3,
|
|
Packit |
577717 |
.num_cntrs = 18,
|
|
Packit |
577717 |
|
|
Packit |
577717 |
.pmu_detect = pfm_netburst_detect_prescott,
|
|
Packit |
577717 |
.get_event_encoding[PFM_OS_NONE] = pfm_netburst_get_encoding,
|
|
Packit |
577717 |
PFMLIB_ENCODE_PERF(pfm_netburst_get_perf_encoding),
|
|
Packit |
577717 |
.get_event_first = pfm_netburst_get_event_first,
|
|
Packit |
577717 |
.get_event_next = pfm_netburst_get_event_next,
|
|
Packit |
577717 |
.event_is_valid = pfm_netburst_event_is_valid,
|
|
Packit |
577717 |
.validate_table = pfm_netburst_validate_table,
|
|
Packit |
577717 |
.get_event_info = pfm_netburst_get_event_info,
|
|
Packit |
577717 |
.get_event_attr_info = pfm_netburst_get_event_attr_info,
|
|
Packit |
577717 |
.get_event_nattrs = pfm_netburst_get_event_nattrs,
|
|
Packit |
577717 |
PFMLIB_VALID_PERF_PATTRS(pfm_netburst_perf_validate_pattrs),
|
|
Packit |
577717 |
};
|