Skip to content

Commit

Permalink
Fix for NEST counters on IBM POWER9 due to renaming in perf_event
Browse files Browse the repository at this point in the history
  • Loading branch information
TomTheBear committed Jun 18, 2021
1 parent 49ea772 commit 3fd0ce4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 15 deletions.
57 changes: 42 additions & 15 deletions src/includes/perfmon_perfevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ static char* perfEventOptionNames[] = {
#ifdef _ARCH_PPC
[EVENT_OPTION_PMC] = "pmc",
[EVENT_OPTION_PMCXSEL] = "pmcxsel",
[EVENT_OPTION_UNCORE_CONFIG] = "event",
#endif
};

Expand Down Expand Up @@ -490,6 +491,7 @@ int perf_uncore_setup(struct perf_event_attr *attr, RegisterType type, PerfmonEv
int perf_type = 0;
PERF_EVENT_PMC_OPT_REGS reg = PERF_EVENT_INVAL_REG;
int start = 0, end = -1;
uint64_t eventConfig = 0x0;
if (perf_event_paranoid > 0 && getuid() != 0)
{
return EPERM;
Expand Down Expand Up @@ -525,32 +527,57 @@ int perf_uncore_setup(struct perf_event_attr *attr, RegisterType type, PerfmonEv
attr->type = perf_type;
attr->disabled = 1;
attr->inherit = 1;
//attr->config = (event->umask<<8) + event->eventId;
#ifdef _ARCH_PPC
eventConfig = (event->umask<<8)|event->eventId;
#else
eventConfig = event->eventId;
#endif
getEventOptionConfig(translate_types[type], EVENT_OPTION_GENERIC_CONFIG, &reg, &start, &end);
switch(reg)
{
case PERF_EVENT_CONFIG_REG:
attr->config |= create_mask(event->eventId, start, end);
attr->config |= create_mask(eventConfig, start, end);
break;
case PERF_EVENT_CONFIG1_REG:
attr->config1 |= create_mask(event->eventId, start, end);
attr->config1 |= create_mask(eventConfig, start, end);
break;
case PERF_EVENT_CONFIG2_REG:
attr->config2 |= create_mask(event->eventId, start, end);
attr->config2 |= create_mask(eventConfig, start, end);
break;
}
getEventOptionConfig(translate_types[type], EVENT_OPTION_GENERIC_UMASK, &reg, &start, &end);
switch(reg)
#ifdef _ARCH_PPC
if (reg == PERF_EVENT_INVAL_REG)
{
case PERF_EVENT_CONFIG_REG:
attr->config |= create_mask(event->umask, start, end);
break;
case PERF_EVENT_CONFIG1_REG:
attr->config1 |= create_mask(event->umask, start, end);
break;
case PERF_EVENT_CONFIG2_REG:
attr->config2 |= create_mask(event->umask, start, end);
break;
getEventOptionConfig(translate_types[type], EVENT_OPTION_UNCORE_CONFIG, &reg, &start, &end);
switch(reg)
{
case PERF_EVENT_CONFIG_REG:
attr->config |= create_mask(eventConfig, start, end);
break;
case PERF_EVENT_CONFIG1_REG:
attr->config1 |= create_mask(eventConfig, start, end);
break;
case PERF_EVENT_CONFIG2_REG:
attr->config2 |= create_mask(eventConfig, start, end);
break;
}
}
#endif
if (event->umask != 0x0)
{
getEventOptionConfig(translate_types[type], EVENT_OPTION_GENERIC_UMASK, &reg, &start, &end);
switch(reg)
{
case PERF_EVENT_CONFIG_REG:
attr->config |= create_mask(event->umask, start, end);
break;
case PERF_EVENT_CONFIG1_REG:
attr->config1 |= create_mask(event->umask, start, end);
break;
case PERF_EVENT_CONFIG2_REG:
attr->config2 |= create_mask(event->umask, start, end);
break;
}
}


Expand Down
1 change: 1 addition & 0 deletions src/includes/perfmon_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ typedef enum {
#ifdef _ARCH_PPC
EVENT_OPTION_PMC,
EVENT_OPTION_PMCXSEL,
EVENT_OPTION_UNCORE_CONFIG, /*!< \brief Configuration bitmask for NEST (uncore) counters */
#endif
NUM_EVENT_OPTIONS /*!< \brief Amount of defined options */
} EventOptionType;
Expand Down

0 comments on commit 3fd0ce4

Please sign in to comment.