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.
Unified · Split
| @@ -349,6 +349,10 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id) · 348 unmodified lines | |||
| 349 | hlist_for_each_entry(sid, pos, head, node) | 349 | hlist_for_each_entry(sid, pos, head, node) |
| 350 | if (sid->id == id) | 350 | if (sid->id == id) |
| 351 | return sid->evsel; | 351 | return sid->evsel; |
| 352 | |||
| 353 | if (!perf_evlist__sample_id_all(evlist)) | ||
| 354 | return list_entry(evlist->entries.next, struct perf_evsel, node); | ||
| 355 | |||
| 352 | return NULL; | 356 | return NULL; |
| 353 | } | 357 | } |
| 354 | 358 | ||