Re: [PATCH 11/48] perf data: Support converting data from bpf_perf_event_output()
From: Jiri Olsa
Date: Tue Feb 23 2016 - 14:22:16 EST
On Mon, Feb 22, 2016 at 09:10:38AM +0000, Wang Nan wrote:
SNIP
> usleep 14942 92503.298562: evt: ffffffff810585e9 kretprobe_trampoline_holder (/lib....
>
> # ./perf data convert --to-ctf ./out.ctf
> [ perf data convert: Converted 'perf.data' into CTF data './out.ctf' ]
> [ perf data convert: Converted and wrote 0.000 MB (2 samples) ]
>
> # babeltrace ./out.ctf
> [01:41:43.198504134] (+?.?????????) evt: { cpu_id = 0 }, { perf_ip = 0xFFFFFFFF810E0BA1, perf_tid = 14942, perf_pid = 14942, perf_id = 1044, raw_len = 3, raw_data = [ [0] = 0x32C0C07B, [1] = 0x5421, [2] = 0x1 ] }
> [01:41:43.298562257] (+0.100058123) evt: { cpu_id = 0 }, { perf_ip = 0xFFFFFFFF810585E9, perf_tid = 14942, perf_pid = 14942, perf_id = 1044, raw_len = 3, raw_data = [ [0] = 0x38B77FAA, [1] = 0x5421, [2] = 0x2 ] }
>
> # cat ./test_bpf_output_2.py
> from babeltrace import TraceCollection
> tc = TraceCollection()
> tc.add_trace('./out.ctf', 'ctf')
> d = {1:[], 2:[]}
> for event in tc.events:
> if not event.name.startswith('evt'):
> continue
> raw_data = event['raw_data']
> (time, type) = ((raw_data[0] + (raw_data[1] << 32)), raw_data[2])
> d[type].append(time)
> print(list(map(lambda i: d[2][i] - d[1][i], range(len(d[1])))));
>
> # python3 ./test_bpf_output_2.py
> [100056879]
>
Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx>
looks good to me.. also note I just compiled, haven't tried
the example above.. too far in bpf land for me ATM ;-)
thanks,
jirka