perf-tools: Don't assume there's no attr info if no sample ids is provided
PATCH 1/1 perf-tools: Don't assume there's no attr info if no sample ids is provided
From: Franck Bui-Huu <[email protected]>
This primarily fixes perf-report, which didn't report the correct type of event if perf-record was called to record one event different from 'cycles':
$ perf record -e instructions true
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.007 MB perf.data (~295 samples) ] $ perf report | head -n1
# Events: 7 cyclesSigned-off-by Franck Bui-Huu <[email protected]>
--- tools/perf/util/header.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-)
tools/perf/util/header.c +8 -3
@@ -946,11 +946,16 @@ perf_header__find_attr(u64 id, struct perf_header *header)/* * We set id to -1 if the data file doesn't contain sample -* ids. Check for this and avoid walking through the entire -* list of ids which may be large. +* ids. This can happen when the data file contains one type +* of event and in that case, the header can still store the +* event attribute information. Check for this and avoid +* walking through the entire list of ids which may be large. */ -if (id ==-1ULL ) +if (id ==-1ULL ) { +if (header->attrs >0 ) +return &header->attr[0 ]->attr;return NULL ; + }for (i =0 ; i < header->attrs; i++) {struct perf_header_attr *attr = header->attr[i];
Signature · 1 line
1.7.3.2
Em Tue, Nov 30, 2010 at 12:50:14PM +0100, Franck Bui-Huu escreveu:
Quoted 10 lines
From: Franck Bui-Huu <[email protected]>
This primarily fixes perf-report, which didn't report the correct type of event if perf-record was called to record one event different from 'cycles':
$ perf record -e instructions true [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.007 MB perf.data (~295 samples) ]
Quoted 7 lines
$ perf report | head -n1 # Events: 7 cyclesSigned-off-by Franck Bui-Huu <[email protected]>--- tools/perf/util/header.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-)
Please CC lkml when submitting patches.
Thanks a lot, applied to my perf/urgent branch.
- Arnaldo
Quoted 30 lines
tools/perf/util/header.c +8
-3@@ -946,11 +946,16 @@ perf_header__find_attr(u64 id, struct perf_header *header)/* * We set id to -1 if the data file doesn't contain sample -* ids. Check for this and avoid walking through the entire -* list of ids which may be large. +* ids. This can happen when the data file contains one type +* of event and in that case, the header can still store the +* event attribute information. Check for this and avoid +* walking through the entire list of ids which may be large. */ -if (id ==-1ULL ) +if (id ==-1ULL ) { +if (header->attrs >0 ) +return &header->attr[0 ]->attr;return NULL ; + }for (i =0 ; i < header->attrs; i++) {struct perf_header_attr *attr = header->attr[i];Signature · 5 lines
1.7.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html