Re: [PATCH 06/11] perf data: Switch to multiple cpu stream files

From: Wang Nan
Date: Thu Mar 12 2015 - 09:42:20 EST


On 2015/3/12 20:34, Jiri Olsa wrote:
> On Thu, Mar 12, 2015 at 07:37:02PM +0800, Wang Nan wrote:
>> Hi Jiri,
>>
>> Have you noticed that this patch causes a endianess problem?
>>
>> Without this patch:
>>
>> $ 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 (11 samples) ]
>>
>> With this patch:
>>
>> $ perf data convert --to-ctf ./out.ctf
>> perf: event-types.c:1855: bt_ctf_field_type_set_native_byte_order: Assertion `byte_order == 1234 || byte_order == 4321' failed.
>> Aborted
>>
>> I'll look into this problem if you haven't solved it yet. Please let me know if you have already
>> have some solutions.
>
> hum, never seen this.. any other details?



My perf is -tip tree (commit 4b52a8d), with patch 'perf data: Add tracepoint events fields CTF conversion support'
applied. Babeltrace is fresh new git clone (commit 48d711a).

you moved perf.data
> through different endian server or something like that?
>

Never.

> jirka
>
---
I think I find the problem, but I fill strange whether you and others never hit it.

The problem is that, in babeltrace, stream_class->byte_order is never setup until someone calls bt_ctf_trace_create_stream(),
which do it by bt_ctf_stream_class_set_byte_order(), set stream_class->byte_order according to trace->byte_order.

(However, according to the name of bt_ctf_trace_create_stream, people (like me) believe stream_class
should be a fully initialized structure, bt_ctf_trace_create_stream() is used to create a bt_ctf_stream,
it should not be a part of initialization of bt_ctf_stream_class().)

After applying patch 6/11, such call (bt_ctf_writer_create_stream()) is moved from ctf_writer__init()
to ctf_stream(), that is, later than bt_ctf_event_create(). However, bt_ctf_event_create() -> bt_ctf_stream_class_freeze()
requires stream_class->byte_order been set.

At the bottom of this mail is a workable workaround (an ugly workaround since I'm not sure which part is responsible
for the problem) and my SOB.

Thank you.

Signed-off-by: Wang Nan <wangnan0@xxxxxxxxxx>

---
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -557,6 +557,8 @@ static int process_sample_event(struct perf_tool *tool,

pr_time2(sample->time, "sample %" PRIu64 "\n", c->events_count);

+ cs = ctf_stream(cw, get_sample_cpu(cw, sample, evsel));
+
event = bt_ctf_event_create(event_class);
if (!event) {
pr_err("Failed to create an CTF event\n");
@@ -576,7 +578,6 @@ static int process_sample_event(struct perf_tool *tool,
return -1;
}

- cs = ctf_stream(cw, get_sample_cpu(cw, sample, evsel));
if (cs)
bt_ctf_stream_append_event(cs->stream, event);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/