2020-05-05 11:29:43 -07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
|
|
|
* Support for libpfm4 event encoding.
|
|
|
|
*
|
|
|
|
* Copyright 2020 Google LLC.
|
|
|
|
*/
|
|
|
|
#include "util/cpumap.h"
|
|
|
|
#include "util/debug.h"
|
|
|
|
#include "util/event.h"
|
|
|
|
#include "util/evlist.h"
|
|
|
|
#include "util/evsel.h"
|
|
|
|
#include "util/parse-events.h"
|
2023-05-27 00:22:03 -07:00
|
|
|
#include "util/pmus.h"
|
2020-05-05 11:29:43 -07:00
|
|
|
#include "util/pfm.h"
|
2022-11-17 19:46:07 -07:00
|
|
|
#include "util/strbuf.h"
|
2023-06-08 16:23:58 -07:00
|
|
|
#include "util/thread_map.h"
|
2020-05-05 11:29:43 -07:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <perfmon/pfmlib_perf_event.h>
|
|
|
|
|
|
|
|
static void libpfm_initialize(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = pfm_initialize();
|
|
|
|
if (ret != PFM_SUCCESS) {
|
|
|
|
ui__warning("libpfm failed to initialize: %s\n",
|
|
|
|
pfm_strerror(ret));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int parse_libpfm_events_option(const struct option *opt, const char *str,
|
|
|
|
int unset __maybe_unused)
|
|
|
|
{
|
|
|
|
struct evlist *evlist = *(struct evlist **)opt->value;
|
|
|
|
struct perf_event_attr attr;
|
|
|
|
struct perf_pmu *pmu;
|
|
|
|
struct evsel *evsel, *grp_leader = NULL;
|
|
|
|
char *p, *q, *p_orig;
|
|
|
|
const char *sep;
|
|
|
|
int grp_evt = -1;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
libpfm_initialize();
|
|
|
|
|
|
|
|
p_orig = p = strdup(str);
|
|
|
|
if (!p)
|
|
|
|
return -1;
|
|
|
|
/*
|
|
|
|
* force loading of the PMU list
|
|
|
|
*/
|
2023-05-27 00:22:03 -07:00
|
|
|
perf_pmus__scan(NULL);
|
2020-05-05 11:29:43 -07:00
|
|
|
|
|
|
|
for (q = p; strsep(&p, ",{}"); q = p) {
|
|
|
|
sep = p ? str + (p - p_orig - 1) : "";
|
|
|
|
if (*sep == '{') {
|
|
|
|
if (grp_evt > -1) {
|
|
|
|
ui__error(
|
|
|
|
"nested event groups not supported\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
grp_evt++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no event */
|
perf test: Fix libpfm4 support (63) test error for nested event groups
Compiling perf with make LIBPFM4=1 includes libpfm support and
enables test case 63 'Test libpfm4 support'. This test reports an error
on all platforms for subtest 63.2 'test groups of --pfm-events'.
The reported error message is 'nested event groups not supported'
# ./perf test -F 63
63: Test libpfm4 support :
63.1: test of individual --pfm-events :
Error:
failed to parse event stereolab : event not found
Error:
failed to parse event stereolab,instructions : event not found
Error:
failed to parse event instructions,stereolab : event not found
Ok
63.2: test groups of --pfm-events :
Error:
nested event groups not supported <------ Error message here
Error:
failed to parse event {stereolab} : event not found
Error:
failed to parse event {instructions,cycles},{instructions,stereolab} :\
event not found
Ok
#
This patch addresses the error message 'nested event groups not supported'.
The root cause is function parse_libpfm_events_option() which parses the
event string '{},{instructions}' and can not handle a leading empty
group notation '{},...'.
The code detects the first (empty) group indicator '{' but does not
terminate group processing on the following group closing character '}'.
So when the second group indicator '{' is detected, the code assumes
a nested group and returns an error.
With the error message fixed, also change the expected event number to
one for the test case to succeed.
While at it also fix a memory leak. In good case the function does not
free the duplicated string given as first parameter.
Output after:
# ./perf test -F 63
63: Test libpfm4 support :
63.1: test of individual --pfm-events :
Error:
failed to parse event stereolab : event not found
Error:
failed to parse event stereolab,instructions : event not found
Error:
failed to parse event instructions,stereolab : event not found
Ok
63.2: test groups of --pfm-events :
Error:
failed to parse event {stereolab} : event not found
Error:
failed to parse event {instructions,cycles},{instructions,stereolab} : \
event not found
Ok
#
Error message 'nested event groups not supported' is gone.
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Acked-By: Ian Rogers <irogers@google.com>
Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Link: http://lore.kernel.org/lkml/20210517140931.2559364-1-tmricht@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-05-17 07:09:31 -07:00
|
|
|
if (*q == '\0') {
|
|
|
|
if (*sep == '}') {
|
|
|
|
if (grp_evt < 0) {
|
|
|
|
ui__error("cannot close a non-existing event group\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
grp_evt--;
|
|
|
|
}
|
2020-05-05 11:29:43 -07:00
|
|
|
continue;
|
perf test: Fix libpfm4 support (63) test error for nested event groups
Compiling perf with make LIBPFM4=1 includes libpfm support and
enables test case 63 'Test libpfm4 support'. This test reports an error
on all platforms for subtest 63.2 'test groups of --pfm-events'.
The reported error message is 'nested event groups not supported'
# ./perf test -F 63
63: Test libpfm4 support :
63.1: test of individual --pfm-events :
Error:
failed to parse event stereolab : event not found
Error:
failed to parse event stereolab,instructions : event not found
Error:
failed to parse event instructions,stereolab : event not found
Ok
63.2: test groups of --pfm-events :
Error:
nested event groups not supported <------ Error message here
Error:
failed to parse event {stereolab} : event not found
Error:
failed to parse event {instructions,cycles},{instructions,stereolab} :\
event not found
Ok
#
This patch addresses the error message 'nested event groups not supported'.
The root cause is function parse_libpfm_events_option() which parses the
event string '{},{instructions}' and can not handle a leading empty
group notation '{},...'.
The code detects the first (empty) group indicator '{' but does not
terminate group processing on the following group closing character '}'.
So when the second group indicator '{' is detected, the code assumes
a nested group and returns an error.
With the error message fixed, also change the expected event number to
one for the test case to succeed.
While at it also fix a memory leak. In good case the function does not
free the duplicated string given as first parameter.
Output after:
# ./perf test -F 63
63: Test libpfm4 support :
63.1: test of individual --pfm-events :
Error:
failed to parse event stereolab : event not found
Error:
failed to parse event stereolab,instructions : event not found
Error:
failed to parse event instructions,stereolab : event not found
Ok
63.2: test groups of --pfm-events :
Error:
failed to parse event {stereolab} : event not found
Error:
failed to parse event {instructions,cycles},{instructions,stereolab} : \
event not found
Ok
#
Error message 'nested event groups not supported' is gone.
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Acked-By: Ian Rogers <irogers@google.com>
Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Link: http://lore.kernel.org/lkml/20210517140931.2559364-1-tmricht@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-05-17 07:09:31 -07:00
|
|
|
}
|
2020-05-05 11:29:43 -07:00
|
|
|
|
|
|
|
memset(&attr, 0, sizeof(attr));
|
|
|
|
event_attr_init(&attr);
|
|
|
|
|
|
|
|
ret = pfm_get_perf_event_encoding(q, PFM_PLM0|PFM_PLM3,
|
|
|
|
&attr, NULL, NULL);
|
|
|
|
|
|
|
|
if (ret != PFM_SUCCESS) {
|
|
|
|
ui__error("failed to parse event %s : %s\n", str,
|
|
|
|
pfm_strerror(ret));
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2023-05-27 00:22:03 -07:00
|
|
|
pmu = perf_pmus__find_by_type((unsigned int)attr.type);
|
2020-05-05 11:29:43 -07:00
|
|
|
evsel = parse_events__add_event(evlist->core.nr_entries,
|
2021-10-15 10:21:25 -07:00
|
|
|
&attr, q, /*metric_id=*/NULL,
|
|
|
|
pmu);
|
2020-05-05 11:29:43 -07:00
|
|
|
if (evsel == NULL)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
evsel->is_libpfm_event = true;
|
|
|
|
|
|
|
|
evlist__add(evlist, evsel);
|
|
|
|
|
|
|
|
if (grp_evt == 0)
|
|
|
|
grp_leader = evsel;
|
|
|
|
|
|
|
|
if (grp_evt > -1) {
|
2021-07-13 02:19:07 -07:00
|
|
|
evsel__set_leader(evsel, grp_leader);
|
2020-05-05 11:29:43 -07:00
|
|
|
grp_leader->core.nr_members++;
|
|
|
|
grp_evt++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*sep == '}') {
|
|
|
|
if (grp_evt < 0) {
|
|
|
|
ui__error(
|
|
|
|
"cannot close a non-existing event group\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
grp_leader = NULL;
|
|
|
|
grp_evt = -1;
|
|
|
|
}
|
|
|
|
}
|
perf test: Fix libpfm4 support (63) test error for nested event groups
Compiling perf with make LIBPFM4=1 includes libpfm support and
enables test case 63 'Test libpfm4 support'. This test reports an error
on all platforms for subtest 63.2 'test groups of --pfm-events'.
The reported error message is 'nested event groups not supported'
# ./perf test -F 63
63: Test libpfm4 support :
63.1: test of individual --pfm-events :
Error:
failed to parse event stereolab : event not found
Error:
failed to parse event stereolab,instructions : event not found
Error:
failed to parse event instructions,stereolab : event not found
Ok
63.2: test groups of --pfm-events :
Error:
nested event groups not supported <------ Error message here
Error:
failed to parse event {stereolab} : event not found
Error:
failed to parse event {instructions,cycles},{instructions,stereolab} :\
event not found
Ok
#
This patch addresses the error message 'nested event groups not supported'.
The root cause is function parse_libpfm_events_option() which parses the
event string '{},{instructions}' and can not handle a leading empty
group notation '{},...'.
The code detects the first (empty) group indicator '{' but does not
terminate group processing on the following group closing character '}'.
So when the second group indicator '{' is detected, the code assumes
a nested group and returns an error.
With the error message fixed, also change the expected event number to
one for the test case to succeed.
While at it also fix a memory leak. In good case the function does not
free the duplicated string given as first parameter.
Output after:
# ./perf test -F 63
63: Test libpfm4 support :
63.1: test of individual --pfm-events :
Error:
failed to parse event stereolab : event not found
Error:
failed to parse event stereolab,instructions : event not found
Error:
failed to parse event instructions,stereolab : event not found
Ok
63.2: test groups of --pfm-events :
Error:
failed to parse event {stereolab} : event not found
Error:
failed to parse event {instructions,cycles},{instructions,stereolab} : \
event not found
Ok
#
Error message 'nested event groups not supported' is gone.
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Acked-By: Ian Rogers <irogers@google.com>
Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Link: http://lore.kernel.org/lkml/20210517140931.2559364-1-tmricht@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-05-17 07:09:31 -07:00
|
|
|
free(p_orig);
|
2020-05-05 11:29:43 -07:00
|
|
|
return 0;
|
|
|
|
error:
|
|
|
|
free(p_orig);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2023-06-08 16:23:58 -07:00
|
|
|
static bool is_libpfm_event_supported(const char *name, struct perf_cpu_map *cpus,
|
|
|
|
struct perf_thread_map *threads)
|
|
|
|
{
|
|
|
|
struct perf_pmu *pmu;
|
|
|
|
struct evsel *evsel;
|
|
|
|
struct perf_event_attr attr = {};
|
|
|
|
bool result = true;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = pfm_get_perf_event_encoding(name, PFM_PLM0|PFM_PLM3,
|
|
|
|
&attr, NULL, NULL);
|
|
|
|
if (ret != PFM_SUCCESS)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
pmu = perf_pmus__find_by_type((unsigned int)attr.type);
|
|
|
|
evsel = parse_events__add_event(0, &attr, name, /*metric_id=*/NULL, pmu);
|
|
|
|
if (evsel == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
evsel->is_libpfm_event = true;
|
|
|
|
|
2023-09-06 16:44:16 -07:00
|
|
|
ret = evsel__open(evsel, cpus, threads);
|
|
|
|
if (ret == -EACCES) {
|
|
|
|
/*
|
|
|
|
* This happens if the paranoid value
|
|
|
|
* /proc/sys/kernel/perf_event_paranoid is set to 2
|
|
|
|
* Re-run with exclude_kernel set; we don't do that
|
|
|
|
* by default as some ARM machines do not support it.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
evsel->core.attr.exclude_kernel = 1;
|
|
|
|
ret = evsel__open(evsel, cpus, threads);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (ret < 0)
|
2023-06-08 16:23:58 -07:00
|
|
|
result = false;
|
|
|
|
|
|
|
|
evsel__close(evsel);
|
|
|
|
evsel__delete(evsel);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-05-05 11:29:43 -07:00
|
|
|
static const char *srcs[PFM_ATTR_CTRL_MAX] = {
|
|
|
|
[PFM_ATTR_CTRL_UNKNOWN] = "???",
|
|
|
|
[PFM_ATTR_CTRL_PMU] = "PMU",
|
|
|
|
[PFM_ATTR_CTRL_PERF_EVENT] = "perf_event",
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2022-11-17 19:46:07 -07:00
|
|
|
print_attr_flags(struct strbuf *buf, const pfm_event_attr_info_t *info)
|
2020-05-05 11:29:43 -07:00
|
|
|
{
|
2022-11-17 19:46:07 -07:00
|
|
|
if (info->is_dfl)
|
|
|
|
strbuf_addf(buf, "[default] ");
|
2020-05-05 11:29:43 -07:00
|
|
|
|
2022-11-17 19:46:07 -07:00
|
|
|
if (info->is_precise)
|
|
|
|
strbuf_addf(buf, "[precise] ");
|
2020-05-05 11:29:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-11-17 19:46:07 -07:00
|
|
|
print_libpfm_event(const struct print_callbacks *print_cb, void *print_state,
|
|
|
|
const pfm_pmu_info_t *pinfo, const pfm_event_info_t *info,
|
|
|
|
struct strbuf *buf)
|
2020-05-05 11:29:43 -07:00
|
|
|
{
|
|
|
|
int j, ret;
|
2022-11-17 19:46:07 -07:00
|
|
|
char topic[80], name[80];
|
2023-06-08 16:23:58 -07:00
|
|
|
struct perf_cpu_map *cpus = perf_cpu_map__empty_new(1);
|
|
|
|
struct perf_thread_map *threads = thread_map__new_by_tid(0);
|
2020-05-05 11:29:43 -07:00
|
|
|
|
2022-11-17 19:46:07 -07:00
|
|
|
strbuf_setlen(buf, 0);
|
|
|
|
snprintf(topic, sizeof(topic), "pfm %s", pinfo->name);
|
2020-05-05 11:29:43 -07:00
|
|
|
|
2022-11-17 19:46:07 -07:00
|
|
|
snprintf(name, sizeof(name), "%s::%s", pinfo->name, info->name);
|
|
|
|
strbuf_addf(buf, "Code: 0x%"PRIx64"\n", info->code);
|
2020-05-05 11:29:43 -07:00
|
|
|
|
|
|
|
pfm_for_each_event_attr(j, info) {
|
2022-11-17 19:46:07 -07:00
|
|
|
pfm_event_attr_info_t ainfo;
|
|
|
|
const char *src;
|
2020-05-05 11:29:43 -07:00
|
|
|
|
2022-11-17 19:46:07 -07:00
|
|
|
ainfo.size = sizeof(ainfo);
|
|
|
|
ret = pfm_get_event_attr_info(info->idx, j, PFM_OS_PERF_EVENT_EXT, &ainfo);
|
|
|
|
if (ret != PFM_SUCCESS)
|
2020-05-05 11:29:43 -07:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (ainfo.ctrl >= PFM_ATTR_CTRL_MAX)
|
|
|
|
ainfo.ctrl = PFM_ATTR_CTRL_UNKNOWN;
|
|
|
|
|
|
|
|
src = srcs[ainfo.ctrl];
|
|
|
|
switch (ainfo.type) {
|
2022-11-17 19:46:07 -07:00
|
|
|
case PFM_ATTR_UMASK: /* Ignore for now */
|
2020-05-05 11:29:43 -07:00
|
|
|
break;
|
|
|
|
case PFM_ATTR_MOD_BOOL:
|
2022-11-17 19:46:07 -07:00
|
|
|
strbuf_addf(buf, " Modif: %s: [%s] : %s (boolean)\n", src,
|
|
|
|
ainfo.name, ainfo.desc);
|
2020-05-05 11:29:43 -07:00
|
|
|
break;
|
|
|
|
case PFM_ATTR_MOD_INTEGER:
|
2022-11-17 19:46:07 -07:00
|
|
|
strbuf_addf(buf, " Modif: %s: [%s] : %s (integer)\n", src,
|
|
|
|
ainfo.name, ainfo.desc);
|
2020-05-05 11:29:43 -07:00
|
|
|
break;
|
|
|
|
case PFM_ATTR_NONE:
|
|
|
|
case PFM_ATTR_RAW_UMASK:
|
|
|
|
case PFM_ATTR_MAX:
|
|
|
|
default:
|
2022-11-17 19:46:07 -07:00
|
|
|
strbuf_addf(buf, " Attr: %s: [%s] : %s\n", src,
|
|
|
|
ainfo.name, ainfo.desc);
|
2020-05-05 11:29:43 -07:00
|
|
|
}
|
|
|
|
}
|
2023-06-08 16:23:58 -07:00
|
|
|
|
|
|
|
if (is_libpfm_event_supported(name, cpus, threads)) {
|
|
|
|
print_cb->print_event(print_state, pinfo->name, topic,
|
|
|
|
name, info->equiv,
|
|
|
|
/*scale_unit=*/NULL,
|
|
|
|
/*deprecated=*/NULL, "PFM event",
|
|
|
|
info->desc, /*long_desc=*/NULL,
|
|
|
|
/*encoding_desc=*/buf->buf);
|
|
|
|
}
|
2020-05-05 11:29:43 -07:00
|
|
|
|
2022-11-17 19:46:07 -07:00
|
|
|
pfm_for_each_event_attr(j, info) {
|
|
|
|
pfm_event_attr_info_t ainfo;
|
|
|
|
const char *src;
|
2020-05-05 11:29:43 -07:00
|
|
|
|
2022-11-17 19:46:07 -07:00
|
|
|
strbuf_setlen(buf, 0);
|
2020-05-05 11:29:43 -07:00
|
|
|
|
2022-11-17 19:46:07 -07:00
|
|
|
ainfo.size = sizeof(ainfo);
|
|
|
|
ret = pfm_get_event_attr_info(info->idx, j, PFM_OS_PERF_EVENT_EXT, &ainfo);
|
2020-05-05 11:29:43 -07:00
|
|
|
if (ret != PFM_SUCCESS)
|
|
|
|
continue;
|
|
|
|
|
2022-11-17 19:46:07 -07:00
|
|
|
if (ainfo.ctrl >= PFM_ATTR_CTRL_MAX)
|
|
|
|
ainfo.ctrl = PFM_ATTR_CTRL_UNKNOWN;
|
2020-05-05 11:29:43 -07:00
|
|
|
|
2022-11-17 19:46:07 -07:00
|
|
|
src = srcs[ainfo.ctrl];
|
|
|
|
if (ainfo.type == PFM_ATTR_UMASK) {
|
|
|
|
strbuf_addf(buf, "Umask: 0x%02"PRIx64" : %s: ",
|
|
|
|
ainfo.code, src);
|
|
|
|
print_attr_flags(buf, &ainfo);
|
|
|
|
snprintf(name, sizeof(name), "%s::%s:%s",
|
|
|
|
pinfo->name, info->name, ainfo.name);
|
2023-06-08 16:23:58 -07:00
|
|
|
|
|
|
|
if (!is_libpfm_event_supported(name, cpus, threads))
|
|
|
|
continue;
|
|
|
|
|
2022-11-17 19:46:07 -07:00
|
|
|
print_cb->print_event(print_state,
|
|
|
|
pinfo->name,
|
|
|
|
topic,
|
|
|
|
name, /*alias=*/NULL,
|
|
|
|
/*scale_unit=*/NULL,
|
|
|
|
/*deprecated=*/NULL, "PFM event",
|
|
|
|
ainfo.desc, /*long_desc=*/NULL,
|
2023-02-07 07:04:47 -07:00
|
|
|
/*encoding_desc=*/buf->buf);
|
2022-11-17 19:46:07 -07:00
|
|
|
}
|
2020-05-05 11:29:43 -07:00
|
|
|
}
|
2023-06-08 16:23:58 -07:00
|
|
|
|
|
|
|
perf_cpu_map__put(cpus);
|
|
|
|
perf_thread_map__put(threads);
|
2020-05-05 11:29:43 -07:00
|
|
|
}
|
|
|
|
|
2022-11-17 19:46:07 -07:00
|
|
|
void print_libpfm_events(const struct print_callbacks *print_cb, void *print_state)
|
2020-05-05 11:29:43 -07:00
|
|
|
{
|
|
|
|
pfm_event_info_t info;
|
|
|
|
pfm_pmu_info_t pinfo;
|
2022-11-17 19:46:07 -07:00
|
|
|
int p, ret;
|
|
|
|
struct strbuf storage;
|
2020-05-05 11:29:43 -07:00
|
|
|
|
|
|
|
libpfm_initialize();
|
|
|
|
|
|
|
|
/* initialize to zero to indicate ABI version */
|
|
|
|
info.size = sizeof(info);
|
|
|
|
pinfo.size = sizeof(pinfo);
|
|
|
|
|
2022-11-17 19:46:07 -07:00
|
|
|
strbuf_init(&storage, 2048);
|
2020-05-05 11:29:43 -07:00
|
|
|
|
|
|
|
pfm_for_all_pmus(p) {
|
|
|
|
ret = pfm_get_pmu_info(p, &pinfo);
|
|
|
|
if (ret != PFM_SUCCESS)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* only print events that are supported by host HW */
|
|
|
|
if (!pinfo.is_present)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* handled by perf directly */
|
|
|
|
if (pinfo.pmu == PFM_PMU_PERF_EVENT)
|
|
|
|
continue;
|
|
|
|
|
2022-11-17 19:46:07 -07:00
|
|
|
for (int i = pinfo.first_event; i != -1; i = pfm_get_event_next(i)) {
|
2020-05-05 11:29:43 -07:00
|
|
|
ret = pfm_get_event_info(i, PFM_OS_PERF_EVENT_EXT,
|
|
|
|
&info);
|
|
|
|
if (ret != PFM_SUCCESS)
|
|
|
|
continue;
|
|
|
|
|
2022-11-17 19:46:07 -07:00
|
|
|
print_libpfm_event(print_cb, print_state, &pinfo, &info, &storage);
|
2020-05-05 11:29:43 -07:00
|
|
|
}
|
|
|
|
}
|
2022-11-17 19:46:07 -07:00
|
|
|
strbuf_release(&storage);
|
2020-05-05 11:29:43 -07:00
|
|
|
}
|