perf report: Fix segfault with '-F phys_daddr'
PATCH 1/1 perf report: Fix segfault with '-F phys_daddr'
If perf.data file is not recorded with mem-info, adding 'phys_daddr' to output field in perf report results in segfault. Fix that.
Before:
$ ./perf record ls $ ./perf report -F +phys_daddr Segmentation fault (core dumped)
After:
$ ./perf report -F +phys_daddr
Samples: 11 of event 'cycles:u', Event count (approx.): 1485821
Overhead Data Physical Address Command Shared Object Symbol
22.57% [.] 0000000000000000 ls libc-2.29.so [.] __strcoll_l
21.87% [.] 0000000000000000 ls ld-2.29.so [.] _dl_relocate_object
...--- tools/perf/util/sort.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/sort.c +1 -1
@@ -1413,7 +1413,7 @@ static int hist_entry__phys_daddr_snprintf(struct hist_entry *he, char *bf,size_t ret =0 ;size_t len =BITS_PER_LONG /4 ; - addr = he->mem_info->daddr.phys_addr; + addr = he->mem_info ? he->mem_info->daddr.phys_addr :0 ; ret +=repsep_snprintf (bf + ret, size - ret,"[%c] " , he->level);
Signature · 1 line
2.21.0
Em Tue, Nov 12, 2019 at 11:19:46AM +0530, Ravi Bangoria escreveu:
Quoted 8 lines
If perf.data file is not recorded with mem-info, adding '
phys_daddr' to output field in perf report results in segfault. Fix that.Before:
$ ./perf record ls $ ./perf report -F +phys_daddr Segmentation fault (core dumped)
Quoted 7 lines
After:
$ ./perf report -F +phys_daddr Samples: 11 of event 'cycles:u', Event count (approx.): 1485821 Overhead Data Physical Address Command Shared Object Symbol 22.57% [.] 0000000000000000 ls libc-2.29.so [.] __strcoll_l 21.87% [.] 0000000000000000 ls ld-2.29.so [.] _dl_relocate_object ...
Shouldn't we instead just bail out and state that this isn't possible and leave the user wondering why what was asked isn't presented?
- Arnaldo
Quoted 21 lines
Fixes 8780fb25ab06 ("perf sort: Add sort option for physical address")Signed-off-by Ravi Bangoria <[email protected]>--- tools/perf/util/sort.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/util/sort.c +1
-1@@ -1413,7 +1413,7 @@ static int hist_entry__phys_daddr_snprintf(struct hist_entry *he, char *bf,size_t ret =0 ;size_t len =BITS_PER_LONG /4 ; - addr = he->mem_info->daddr.phys_addr; + addr = he->mem_info ? he->mem_info->daddr.phys_addr :0 ; ret +=repsep_snprintf (bf + ret, size - ret,"[%c] " , he->level);Signature · 1 line
2.21.0
Signature · 1 line
- Arnaldo
Quoted 17 lines · Arnaldo Carvalho de Melo
Em Tue, Nov 12, 2019 at 11:19:46AM +0530, Ravi Bangoria escreveu:
Quoted 8 lines
If perf.data file is not recorded with mem-info, adding '
phys_daddr' to output field in perf report results in segfault. Fix that.Before:
$ ./perf record ls $ ./perf report -F +phys_daddr Segmentation fault (core dumped)Quoted 7 lines
After:
$ ./perf report -F +phys_daddr Samples: 11 of event 'cycles:u', Event count (approx.): 1485821 Overhead Data Physical Address Command Shared Object Symbol 22.57% [.] 0000000000000000 ls libc-2.29.so [.] __strcoll_l 21.87% [.] 0000000000000000 ls ld-2.29.so [.] _dl_relocate_object ...
Quoted 2 lines
Shouldn't we instead just bail out and state that this isn't possible and leave the user wondering why what was asked isn't presented?
You mean popup with something like "phys_daddr is not available in perf.data" and also don't show that column in perf report?
Em Tue, Nov 12, 2019 at 07:28:06PM +0530, Ravi Bangoria escreveu:
Quoted 20 lines · Arnaldo Carvalho de Melo
Quoted 17 lines
Em Tue, Nov 12, 2019 at 11:19:46AM +0530, Ravi Bangoria escreveu:
Quoted 15 lines
If perf.data file is not recorded with mem-info, adding '
phys_daddr' to output field in perf report results in segfault. Fix that.Before:
$ ./perf record ls $ ./perf report -F +phys_daddr Segmentation fault (core dumped)After:
$ ./perf report -F +phys_daddr Samples: 11 of event 'cycles:u', Event count (approx.): 1485821 Overhead Data Physical Address Command Shared Object Symbol 22.57% [.] 0000000000000000 ls libc-2.29.so [.] __strcoll_l 21.87% [.] 0000000000000000 ls ld-2.29.so [.] _dl_relocate_object ...
Quoted 5 lines
Quoted 2 lines
Shouldn't we instead just bail out and state that this isn't possible and leave the user wondering why what was asked isn't presented?
You mean popup with something like "
phys_daddris not available in perf.data" and also don't show that column in perf report?
Just bail out completely, something like:
$ ./perf report -F +phys_daddr "phys_daddr" is not available in perf.data, use 'record -e some,thing' to have it.
- Arnaldo
Quoted 24 lines · Arnaldo Carvalho de Melo
Em Tue, Nov 12, 2019 at 07:28:06PM +0530, Ravi Bangoria escreveu:
Quoted 23 lines · Arnaldo Carvalho de Melo
Quoted 19 lines
Em Tue, Nov 12, 2019 at 11:19:46AM +0530, Ravi Bangoria escreveu:
Quoted 8 lines
If perf.data file is not recorded with mem-info, adding '
phys_daddr' to output field in perf report results in segfault. Fix that.Before:
$ ./perf record ls $ ./perf report -F +phys_daddr Segmentation fault (core dumped)Quoted 7 lines
After:
$ ./perf report -F +phys_daddr Samples: 11 of event 'cycles:u', Event count (approx.): 1485821 Overhead Data Physical Address Command Shared Object Symbol 22.57% [.] 0000000000000000 ls libc-2.29.so [.] __strcoll_l 21.87% [.] 0000000000000000 ls ld-2.29.so [.] _dl_relocate_object ...Shouldn't we instead just bail out and state that this isn't possible and leave the user wondering why what was asked isn't presented?
Quoted 8 lines
Quoted 2 lines
You mean popup with something like "
phys_daddris not available in perf.data" and also don't show that column in perf report?Just bail out completely, something like:
$ ./perf report -F +phys_daddr "phys_daddr" is not available in perf.data, use 'record -e some,thing' to have it.
Sure. Thanks for the suggestion. Will re-spin.
Ravi