|
@@ -302,6 +302,17 @@ static int perf_evlist__id_add_fd(struct perf_evlist *evlist,
|
|
|
{
|
|
|
u64 read_data[4] = { 0, };
|
|
|
int id_idx = 1; /* The first entry is the counter value */
|
|
|
+ u64 id;
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ ret = ioctl(fd, PERF_EVENT_IOC_ID, &id);
|
|
|
+ if (!ret)
|
|
|
+ goto add;
|
|
|
+
|
|
|
+ if (errno != ENOTTY)
|
|
|
+ return -1;
|
|
|
+
|
|
|
+ /* Legacy way to get event id.. All hail to old kernels! */
|
|
|
|
|
|
if (!(evsel->attr.read_format & PERF_FORMAT_ID) ||
|
|
|
read(fd, &read_data, sizeof(read_data)) == -1)
|
|
@@ -312,7 +323,10 @@ static int perf_evlist__id_add_fd(struct perf_evlist *evlist,
|
|
|
if (evsel->attr.read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
|
|
|
++id_idx;
|
|
|
|
|
|
- perf_evlist__id_add(evlist, evsel, cpu, thread, read_data[id_idx]);
|
|
|
+ id = read_data[id_idx];
|
|
|
+
|
|
|
+ add:
|
|
|
+ perf_evlist__id_add(evlist, evsel, cpu, thread, id);
|
|
|
return 0;
|
|
|
}
|
|
|
|