memset(&attr, 0, sizeof(struct perf_event_attr));
attr.type = type;
attr.size = sizeof(struct perf_event_attr);
attr.config = config; /* * When creating an event group, typically the group leader is * initialized with disabled set to 1 and any child events are * initialized with disabled set to 0. Despite disabled being 0, * the child events will not start until the group leader is * enabled.
*/
attr.disabled = group_fd == -1 ? 1 : 0;
staticint setup_uncore_event(void)
{ struct perf_pmu *pmu = NULL; int i, fd;
while ((pmu = perf_pmus__scan(pmu)) != NULL) { for (i = 0; i < NR_UNCORE_PMUS; i++) { if (!strcmp(uncore_pmus[i].name, pmu->name)) {
pr_debug("Using %s for uncore pmu event\n", pmu->name);
types[2] = pmu->type;
configs[2] = uncore_pmus[i].config; /* * Check if the chosen uncore pmu event can be * used in the test. For example, incase of accessing * hv_24x7 pmu counters, partition should have * additional permissions. If not, event open will * fail. So check if the event open succeeds * before proceeding.
*/
fd = event_open(types[2], configs[2], -1); if (fd < 0) return -1;
close(fd); return 0;
}
}
} return -1;
}
staticint run_test(int i, int j, int k)
{ int erroneous = ((((1 << i) | (1 << j) | (1 << k)) & 5) == 5); int group_fd, sibling_fd1, sibling_fd2;
/* * if all three events (leader and two sibling events) * are hardware events, use instructions as one of the * sibling event. There is event constraint in powerpc that * events using same counter cannot be programmed in a group. * Since PERF_COUNT_HW_INSTRUCTIONS is a generic hardware * event and present in all platforms, lets use that.
*/ if (!i && !j && !k)
sibling_fd2 = event_open(types[k], configs_hw[k], group_fd); else
sibling_fd2 = event_open(types[k], configs[k], group_fd); if (sibling_fd2 == -1) {
close(sibling_fd1);
close(group_fd); return erroneous ? 0 : -1;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.