History

perf evlist: Return first evsel for non-sample event on old kernel

On old kernels that don't support sample_id_all feature, perf_evlist__id2evsel() returns NULL for non-sampling events. This breaks perf top when multiple events are given on command line. Fix it by using first evsel in the evlist. This will also prevent getting the same (potential) problem in such new tool/ old kernel combo.

Namhyung Kim committed 14 years ago

Commit 30e68bc1 parent 30ce2f71 file · +4 −0Browse files

Showing the changes to tools (1 of 1 file). Show all

Unified · Split

tools/perf/util/evlist.c+4−0
@@ -349,6 +349,10 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id) · 348 unmodified lines
349349 hlist_for_each_entry(sid, pos, head, node)
350350 if (sid->id == id)
351351 return sid->evsel;
352+
353+ if (!perf_evlist__sample_id_all(evlist))
354+ return list_entry(evlist->entries.next, struct perf_evsel, node);
355+
352356 return NULL;
353357 }
354358

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t