Unmerged patches adding audit when protected_regular/fifos sysctl causes EACCES

2019-09-25 Thread Jérémie Galarneau
Hi Kees,

I have noticed that the two top-most patches of your protected-creat
branch were never merged upstream [1]. Those patches add audit logs
whenever the protected_regular or protected_fifo sysctl prevent the
creation of a file/fifo.

They were mentioned in the v4 thread [2] of the "main" patch and
seemed acceptable, but they were no longer mentioned in v5 [3], which
was merged.

Now that systemd enables those sysctls by default (v241+), I got
bitten pretty hard by this check and it took me a while to figure out
what was happening [4]. I ended up catching it by adding a bunch of
printk(), including where you proposed to add an audit log statement.

I just found your two patches while implementing what you proposed almost 1:1.

Was there a reason why those were abandoned? Otherwise, would you mind
resubmitting them?

Thanks!
Jérémie

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/log/?h=kspp/userspace/protected-creat
[2] https://lkml.org/lkml/2018/4/10/840
[3] https://lore.kernel.org/lkml/20180416175918.GA13494@beast/
[4] 
https://github.com/lttng/lttng-tools/commit/cf86ff2c4ababd01fea7ab2c9c289cb7c0a1bcd5

-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com


[tip:perf/core] perf tools: Initialize perf_data_file fd field

2018-09-25 Thread tip-bot for Jérémie Galarneau
Commit-ID:  c04c859f439fb4de9039246370d60a07b9b5bcb5
Gitweb: https://git.kernel.org/tip/c04c859f439fb4de9039246370d60a07b9b5bcb5
Author: Jérémie Galarneau 
AuthorDate: Wed, 29 Aug 2018 16:16:48 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 19 Sep 2018 10:25:13 -0300

perf tools: Initialize perf_data_file fd field

Building the perf CTF converter fails with gcc 4.8.4 on Ubuntu 14.04
with the following error:

  error: missing initializer for field ‘fd’ of ‘struct perf_data_file’
  [-Werror=missing-field-initializers]

Per 4b838b0db4e9 ("perf tools: Add compression id into 'struct
kmod_path'") and the ensuing discussion on the mailing list, it appears
that this affects other distributions and gcc versions.

Signed-off-by: Jeremie Galarneau 
Cc: Alexander Shishkin 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/20180829201648.19588-1-jeremie.galarn...@efficios.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/data-convert-bt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/data-convert-bt.c 
b/tools/perf/util/data-convert-bt.c
index abd38abf1d91..f75d4aa612c5 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -1578,7 +1578,7 @@ int bt_convert__perf2ctf(const char *input, const char 
*path,
 {
struct perf_session *session;
struct perf_data data = {
-   .file.path = input,
+   .file  = { .path = input, .fd = -1 },
.mode  = PERF_DATA_MODE_READ,
.force = opts->force,
};


[tip:perf/core] perf tools: Initialize perf_data_file fd field

2018-09-25 Thread tip-bot for Jérémie Galarneau
Commit-ID:  c04c859f439fb4de9039246370d60a07b9b5bcb5
Gitweb: https://git.kernel.org/tip/c04c859f439fb4de9039246370d60a07b9b5bcb5
Author: Jérémie Galarneau 
AuthorDate: Wed, 29 Aug 2018 16:16:48 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 19 Sep 2018 10:25:13 -0300

perf tools: Initialize perf_data_file fd field

Building the perf CTF converter fails with gcc 4.8.4 on Ubuntu 14.04
with the following error:

  error: missing initializer for field ‘fd’ of ‘struct perf_data_file’
  [-Werror=missing-field-initializers]

Per 4b838b0db4e9 ("perf tools: Add compression id into 'struct
kmod_path'") and the ensuing discussion on the mailing list, it appears
that this affects other distributions and gcc versions.

Signed-off-by: Jeremie Galarneau 
Cc: Alexander Shishkin 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/20180829201648.19588-1-jeremie.galarn...@efficios.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/data-convert-bt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/data-convert-bt.c 
b/tools/perf/util/data-convert-bt.c
index abd38abf1d91..f75d4aa612c5 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -1578,7 +1578,7 @@ int bt_convert__perf2ctf(const char *input, const char 
*path,
 {
struct perf_session *session;
struct perf_data data = {
-   .file.path = input,
+   .file  = { .path = input, .fd = -1 },
.mode  = PERF_DATA_MODE_READ,
.force = opts->force,
};


Re: [PATCH] perf tools: Initialize perf_data_file fd field

2018-09-18 Thread Jérémie Galarneau
Hi Arnaldo,

Anything I can do to help you with this patch?

Thanks,
Jérémie

On 5 September 2018 at 12:09, Jiri Olsa  wrote:
> On Wed, Aug 29, 2018 at 04:16:48PM -0400, Jérémie Galarneau wrote:
>> Building the perf CTF converter fails with gcc 4.8.4
>> on Ubuntu 14.04 with the following error:
>>
>> error: missing initializer for field ‘fd’ of ‘struct perf_data_file’
>> [-Werror=missing-field-initializers]
>>
>> Per 4b838b0d and the ensuing discussion on the mailing
>> list, it appears that this affects other distributions
>> and gcc versions.
>>
>> Signed-off-by: Jérémie Galarneau 
>
> Acked-by: Jiri Olsa 
>
> thanks,
> jirka
>
>> Cc: Jiri Olsa 
>> Cc: Arnaldo Carvalho de Melo 
>> Cc: Peter Zijlstra 
>> Cc: Ingo Molnar 
>> Cc: Alexander Shishkin 
>> ---
>>  tools/perf/util/data-convert-bt.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/util/data-convert-bt.c 
>> b/tools/perf/util/data-convert-bt.c
>> index abd38abf1d91..f75d4aa612c5 100644
>> --- a/tools/perf/util/data-convert-bt.c
>> +++ b/tools/perf/util/data-convert-bt.c
>> @@ -1578,7 +1578,7 @@ int bt_convert__perf2ctf(const char *input, const char 
>> *path,
>>  {
>>   struct perf_session *session;
>>   struct perf_data data = {
>> - .file.path = input,
>> + .file  = { .path = input, .fd = -1 },
>>   .mode  = PERF_DATA_MODE_READ,
>>   .force = opts->force,
>>   };
>> --
>> 2.18.0
>>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com


Re: [PATCH] perf tools: Initialize perf_data_file fd field

2018-09-18 Thread Jérémie Galarneau
Hi Arnaldo,

Anything I can do to help you with this patch?

Thanks,
Jérémie

On 5 September 2018 at 12:09, Jiri Olsa  wrote:
> On Wed, Aug 29, 2018 at 04:16:48PM -0400, Jérémie Galarneau wrote:
>> Building the perf CTF converter fails with gcc 4.8.4
>> on Ubuntu 14.04 with the following error:
>>
>> error: missing initializer for field ‘fd’ of ‘struct perf_data_file’
>> [-Werror=missing-field-initializers]
>>
>> Per 4b838b0d and the ensuing discussion on the mailing
>> list, it appears that this affects other distributions
>> and gcc versions.
>>
>> Signed-off-by: Jérémie Galarneau 
>
> Acked-by: Jiri Olsa 
>
> thanks,
> jirka
>
>> Cc: Jiri Olsa 
>> Cc: Arnaldo Carvalho de Melo 
>> Cc: Peter Zijlstra 
>> Cc: Ingo Molnar 
>> Cc: Alexander Shishkin 
>> ---
>>  tools/perf/util/data-convert-bt.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/util/data-convert-bt.c 
>> b/tools/perf/util/data-convert-bt.c
>> index abd38abf1d91..f75d4aa612c5 100644
>> --- a/tools/perf/util/data-convert-bt.c
>> +++ b/tools/perf/util/data-convert-bt.c
>> @@ -1578,7 +1578,7 @@ int bt_convert__perf2ctf(const char *input, const char 
>> *path,
>>  {
>>   struct perf_session *session;
>>   struct perf_data data = {
>> - .file.path = input,
>> + .file  = { .path = input, .fd = -1 },
>>   .mode  = PERF_DATA_MODE_READ,
>>   .force = opts->force,
>>   };
>> --
>> 2.18.0
>>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com


[PATCH] perf tools: Initialize perf_data_file fd field

2018-08-29 Thread Jérémie Galarneau
Building the perf CTF converter fails with gcc 4.8.4
on Ubuntu 14.04 with the following error:

error: missing initializer for field ‘fd’ of ‘struct perf_data_file’
[-Werror=missing-field-initializers]

Per 4b838b0d and the ensuing discussion on the mailing
list, it appears that this affects other distributions
and gcc versions.

Signed-off-by: Jérémie Galarneau 
Cc: Jiri Olsa 
Cc: Arnaldo Carvalho de Melo 
Cc: Peter Zijlstra 
Cc: Ingo Molnar 
Cc: Alexander Shishkin 
---
 tools/perf/util/data-convert-bt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/data-convert-bt.c 
b/tools/perf/util/data-convert-bt.c
index abd38abf1d91..f75d4aa612c5 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -1578,7 +1578,7 @@ int bt_convert__perf2ctf(const char *input, const char 
*path,
 {
struct perf_session *session;
struct perf_data data = {
-   .file.path = input,
+   .file  = { .path = input, .fd = -1 },
.mode  = PERF_DATA_MODE_READ,
.force = opts->force,
};
-- 
2.18.0



[PATCH] perf tools: Initialize perf_data_file fd field

2018-08-29 Thread Jérémie Galarneau
Building the perf CTF converter fails with gcc 4.8.4
on Ubuntu 14.04 with the following error:

error: missing initializer for field ‘fd’ of ‘struct perf_data_file’
[-Werror=missing-field-initializers]

Per 4b838b0d and the ensuing discussion on the mailing
list, it appears that this affects other distributions
and gcc versions.

Signed-off-by: Jérémie Galarneau 
Cc: Jiri Olsa 
Cc: Arnaldo Carvalho de Melo 
Cc: Peter Zijlstra 
Cc: Ingo Molnar 
Cc: Alexander Shishkin 
---
 tools/perf/util/data-convert-bt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/data-convert-bt.c 
b/tools/perf/util/data-convert-bt.c
index abd38abf1d91..f75d4aa612c5 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -1578,7 +1578,7 @@ int bt_convert__perf2ctf(const char *input, const char 
*path,
 {
struct perf_session *session;
struct perf_data data = {
-   .file.path = input,
+   .file  = { .path = input, .fd = -1 },
.mode  = PERF_DATA_MODE_READ,
.force = opts->force,
};
-- 
2.18.0



[PATCH] Fix: perf data convert: leak of bt_ctf_field_type

2016-10-22 Thread Jérémie Galarneau
The ctf_writer structure contains an union of a structure containing
7 pointer members and an array of 6 struct bt_ctf_field_type*, which
are used to release the references to these objects in
ctf_writer__cleanup_data().

26812d46 introduced the u32_hex member and should have increased the
array's size. The disparity results in the last member of the "data"
structure being leaked as its reference is never released/put.

Philippe Proulx proposed a patch back in February which hasn't received
any feedback and would eliminate the need to manually update this
array.
http://lkml.iu.edu/hypermail/linux/kernel/1602.1/03800.html

CC-ing the people who were CC-ed on the original patch.

Signed-off-by: Jérémie Galarneau <jeremie.galarn...@efficios.com>
Cc: Wang Nan <wangn...@huawei.com>
Cc: Philippe Proulx <philippe.pro...@efficios.com>
Cc: David S. Miller <da...@davemloft.net>
Cc: Alexei Starovoitov <a...@kernel.org>
Cc: Brendan Gregg <brendan.d.gr...@gmail.com>
Cc: David S. Miller <da...@davemloft.net>
Cc: Jiri Olsa <jo...@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu...@hitachi.com>
Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Zefan Li <lize...@huawei.com>
Cc: pi3or...@163.com
---
 tools/perf/util/data-convert-bt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/data-convert-bt.c 
b/tools/perf/util/data-convert-bt.c
index 7123f4d..16364f0 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -67,7 +67,7 @@ struct ctf_writer {
struct bt_ctf_field_type*u32_hex;
struct bt_ctf_field_type*u64_hex;
};
-   struct bt_ctf_field_type *array[6];
+   struct bt_ctf_field_type *array[7];
} data;
struct bt_ctf_event_class   *comm_class;
struct bt_ctf_event_class   *exit_class;
-- 
2.10.1



[PATCH] Fix: perf data convert: leak of bt_ctf_field_type

2016-10-22 Thread Jérémie Galarneau
The ctf_writer structure contains an union of a structure containing
7 pointer members and an array of 6 struct bt_ctf_field_type*, which
are used to release the references to these objects in
ctf_writer__cleanup_data().

26812d46 introduced the u32_hex member and should have increased the
array's size. The disparity results in the last member of the "data"
structure being leaked as its reference is never released/put.

Philippe Proulx proposed a patch back in February which hasn't received
any feedback and would eliminate the need to manually update this
array.
http://lkml.iu.edu/hypermail/linux/kernel/1602.1/03800.html

CC-ing the people who were CC-ed on the original patch.

Signed-off-by: Jérémie Galarneau 
Cc: Wang Nan 
Cc: Philippe Proulx 
Cc: David S. Miller 
Cc: Alexei Starovoitov 
Cc: Brendan Gregg 
Cc: David S. Miller 
Cc: Jiri Olsa 
Cc: Masami Hiramatsu 
Cc: Namhyung Kim 
Cc: Zefan Li 
Cc: pi3or...@163.com
---
 tools/perf/util/data-convert-bt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/data-convert-bt.c 
b/tools/perf/util/data-convert-bt.c
index 7123f4d..16364f0 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -67,7 +67,7 @@ struct ctf_writer {
struct bt_ctf_field_type*u32_hex;
struct bt_ctf_field_type*u64_hex;
};
-   struct bt_ctf_field_type *array[6];
+   struct bt_ctf_field_type *array[7];
} data;
struct bt_ctf_event_class   *comm_class;
struct bt_ctf_event_class   *exit_class;
-- 
2.10.1



Re: [PATCH 6/7] perf data: Fix duplicate field names and avoid reserved keywords

2015-04-18 Thread Jérémie Galarneau
  struct bt_ctf_event_class *event_class)
> @@ -595,14 +673,14 @@ static int add_tracepoint_fields_types(struct 
> ctf_writer *cw,
> if (flags & FIELD_IS_ARRAY)
> type = bt_ctf_field_type_array_create(type, 
> field->arraylen);
>
> -   ret = bt_ctf_event_class_add_field(event_class, type,
> -   field->name);
> +   ret = event_class_add_field(event_class, type, field);
>
> if (flags & FIELD_IS_ARRAY)
> bt_ctf_field_type_put(type);
>
> if (ret) {
> -   pr_err("Failed to add field '%s\n", field->name);
> +   pr_err("Failed to add field '%s': %d\n",
> +   field->name, ret);
> return -1;
> }
> }
> @@ -646,7 +724,7 @@ static int add_generic_types(struct ctf_writer *cw, 
> struct perf_evsel *evsel,
> do {\
> pr2("  field '%s'\n", n);   \
> if (bt_ctf_event_class_add_field(cl, t, n)) {   \
> -   pr_err("Failed to add field '%s;\n", n);\
> +   pr_err("Failed to add field '%s';\n", n);   \
> return -1;  \
> }   \
> } while (0)
> --
> 1.9.3
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 6/7] perf data: Fix duplicate field names and avoid reserved keywords

2015-04-18 Thread Jérémie Galarneau
);

 if (flags  FIELD_IS_ARRAY)
 bt_ctf_field_type_put(type);

 if (ret) {
 -   pr_err(Failed to add field '%s\n, field-name);
 +   pr_err(Failed to add field '%s': %d\n,
 +   field-name, ret);
 return -1;
 }
 }
 @@ -646,7 +724,7 @@ static int add_generic_types(struct ctf_writer *cw, 
 struct perf_evsel *evsel,
 do {\
 pr2(  field '%s'\n, n);   \
 if (bt_ctf_event_class_add_field(cl, t, n)) {   \
 -   pr_err(Failed to add field '%s;\n, n);\
 +   pr_err(Failed to add field '%s';\n, n);   \
 return -1;  \
 }   \
 } while (0)
 --
 1.9.3




-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] perf data: Show error message when ctf setup failed

2015-04-14 Thread Jérémie Galarneau
Should be fixed as of this commit.

commit 29664b2a3a15c7233d916887d2f58fc42e18521e
Author: Philippe Proulx 
Date:   Mon Apr 13 18:14:59 2015 -0400

Fix: ir: make sure "stream_id" attr is always right

Make sure the "stream_id" attribute of all the event
classes of a given stream class is updated at the following
places:

  * user sets the stream class ID manually: calling
bt_ctf_stream_class_set_id()
  * stream class ID is automatically set: in
bt_ctf_trace_add_stream_class()
  * an event class is added to an existing stream
class: in bt_ctf_stream_class_add_event_class()

Signed-off-by: Philippe Proulx 
Signed-off-by: Jérémie Galarneau 

Jérémie

On Mon, Apr 13, 2015 at 4:30 PM, Jérémie Galarneau
 wrote:
> On Fri, Apr 10, 2015 at 8:37 AM, Jiri Olsa  wrote:
>> On Fri, Apr 10, 2015 at 02:05:45PM +0200, Jiri Olsa wrote:
>>
>> SNIP
>>
>>> > >>I tested by using babeltrace binary and it works.
>>> > >>
>>> > >>After receiving your reply, I test on the latest tracecompass. A
>>> > >>folder named 'ctf' is showed instead of the expected file
>>> > >>'ctf-data', this folder only contains the raw metadata and
>>> > >>perf-stream files but not analysed.
>>> > >CC-ing Alexandre from tracecompass devel ^^^
>>> >
>>> > Hi,
>>> >
>>> > I just came back from vacation, sorry for not replying earlier!
>>> >
>>> > I managed to compile perf with CTF support, but by using Babeltrace's 
>>> > commit
>>> > 5584a48. It fails to compile against current master, because of private
>>> > headers getting exposed. I reported that to the BT maintainers.
>>>
>>> there's fix in babeltrace tree already
>>>
>>> >
>>> > Then it seems there's another bug with Trace Compass's current master, 
>>> > trace
>>> > validation cannot fail, and any file will get imported with no errors. We
>>> > will look into this.
>>> > But the root of the problem was that the converted CTF trace was not being
>>> > recognized as valid. This is because some events define "stream_id = 0;",
>>> > and others don't specify a stream_id at all. It seems quite random, see 
>>> > the
>>> > full metadata here: http://pastebin.com/pACgV5JU
>>> >
>>> > Is there a reason why some events specify a stream_id and some don't?
>>>
>>> hum, that seems like a bug.. I'll check
>>>
>>
>> ok, found the problem.. the "stream_id" event_class's attribute is created
>> only when the instance of the event (not event_class) is created
>>
>> so you'll see the stream_id attribute only for events, that
>> we actually got data for.. the rest is without, because
>> their instance was never created
>>
>> seems to me like libbabeltrace bug, unless the application should
>> take care about stream_id attribute.. but it's not the case for
>> the rest of the 'internal' attributes.. Jeremie?
>
> According to the spec, the stream_id attribute can be left unspecified
> if only one stream is defined. However, is seems Babeltrace's CTF-Writer
> will leave the stream_id out of the event's declaration even when
> multiple streams are defined.
>
> I'll submit a fix.
>
> Thanks.
> Jérémie
>
>>
>> anyway, I made a attached workaround and it all works nicely again,
>> tracecompass is happy and shows the data properly
>>
>> I put all the pending ctf changes (plus the workaround) into:
>>   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
>>   perf/ctf branch
>>
>> jirka
>>
>>
>> ---
>> diff --git a/tools/perf/util/data-convert-bt.c 
>> b/tools/perf/util/data-convert-bt.c
>> index 977cc3f98d8f..d7f03dcb1700 100644
>> --- a/tools/perf/util/data-convert-bt.c
>> +++ b/tools/perf/util/data-convert-bt.c
>> @@ -803,6 +803,7 @@ static int add_generic_types(struct ctf_writer *cw, 
>> struct perf_evsel *evsel,
>>  static int add_event(struct ctf_writer *cw, struct perf_evsel *evsel)
>>  {
>> struct bt_ctf_event_class *event_class;
>> +   struct bt_ctf_event *event;
>> struct evsel_priv *priv;
>> const char *name = perf_evsel__name(evsel);
>> int ret;
>> @@ -833,6 +834,14 @@ static int add_event(struct ctf_writer *cw, struct 
>> perf_evsel *evsel)
>> if (!priv)
>> goto err;
>>
>> +   event = bt_ctf_event_create(event_class);
>> +   if (!event) {
>> +   pr_err("Failed to create an CTF event\n");
>> +   goto err;
>> +   }
>> +
>> +   bt_ctf_event_put(event);
>> +
>> priv->event_class = event_class;
>> evsel->priv   = priv;
>> return 0;
>
>
>
> --
> Jérémie Galarneau
> EfficiOS Inc.
> http://www.efficios.com



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] perf data: Show error message when ctf setup failed

2015-04-14 Thread Jérémie Galarneau
Should be fixed as of this commit.

commit 29664b2a3a15c7233d916887d2f58fc42e18521e
Author: Philippe Proulx eeppelitel...@gmail.com
Date:   Mon Apr 13 18:14:59 2015 -0400

Fix: ir: make sure stream_id attr is always right

Make sure the stream_id attribute of all the event
classes of a given stream class is updated at the following
places:

  * user sets the stream class ID manually: calling
bt_ctf_stream_class_set_id()
  * stream class ID is automatically set: in
bt_ctf_trace_add_stream_class()
  * an event class is added to an existing stream
class: in bt_ctf_stream_class_add_event_class()

Signed-off-by: Philippe Proulx eeppelitel...@gmail.com
Signed-off-by: Jérémie Galarneau jeremie.galarn...@efficios.com

Jérémie

On Mon, Apr 13, 2015 at 4:30 PM, Jérémie Galarneau
jeremie.galarn...@efficios.com wrote:
 On Fri, Apr 10, 2015 at 8:37 AM, Jiri Olsa jo...@redhat.com wrote:
 On Fri, Apr 10, 2015 at 02:05:45PM +0200, Jiri Olsa wrote:

 SNIP

  I tested by using babeltrace binary and it works.
  
  After receiving your reply, I test on the latest tracecompass. A
  folder named 'ctf' is showed instead of the expected file
  'ctf-data', this folder only contains the raw metadata and
  perf-stream files but not analysed.
  CC-ing Alexandre from tracecompass devel ^^^
 
  Hi,
 
  I just came back from vacation, sorry for not replying earlier!
 
  I managed to compile perf with CTF support, but by using Babeltrace's 
  commit
  5584a48. It fails to compile against current master, because of private
  headers getting exposed. I reported that to the BT maintainers.

 there's fix in babeltrace tree already

 
  Then it seems there's another bug with Trace Compass's current master, 
  trace
  validation cannot fail, and any file will get imported with no errors. We
  will look into this.
  But the root of the problem was that the converted CTF trace was not being
  recognized as valid. This is because some events define stream_id = 0;,
  and others don't specify a stream_id at all. It seems quite random, see 
  the
  full metadata here: http://pastebin.com/pACgV5JU
 
  Is there a reason why some events specify a stream_id and some don't?

 hum, that seems like a bug.. I'll check


 ok, found the problem.. the stream_id event_class's attribute is created
 only when the instance of the event (not event_class) is created

 so you'll see the stream_id attribute only for events, that
 we actually got data for.. the rest is without, because
 their instance was never created

 seems to me like libbabeltrace bug, unless the application should
 take care about stream_id attribute.. but it's not the case for
 the rest of the 'internal' attributes.. Jeremie?

 According to the spec, the stream_id attribute can be left unspecified
 if only one stream is defined. However, is seems Babeltrace's CTF-Writer
 will leave the stream_id out of the event's declaration even when
 multiple streams are defined.

 I'll submit a fix.

 Thanks.
 Jérémie


 anyway, I made a attached workaround and it all works nicely again,
 tracecompass is happy and shows the data properly

 I put all the pending ctf changes (plus the workaround) into:
   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
   perf/ctf branch

 jirka


 ---
 diff --git a/tools/perf/util/data-convert-bt.c 
 b/tools/perf/util/data-convert-bt.c
 index 977cc3f98d8f..d7f03dcb1700 100644
 --- a/tools/perf/util/data-convert-bt.c
 +++ b/tools/perf/util/data-convert-bt.c
 @@ -803,6 +803,7 @@ static int add_generic_types(struct ctf_writer *cw, 
 struct perf_evsel *evsel,
  static int add_event(struct ctf_writer *cw, struct perf_evsel *evsel)
  {
 struct bt_ctf_event_class *event_class;
 +   struct bt_ctf_event *event;
 struct evsel_priv *priv;
 const char *name = perf_evsel__name(evsel);
 int ret;
 @@ -833,6 +834,14 @@ static int add_event(struct ctf_writer *cw, struct 
 perf_evsel *evsel)
 if (!priv)
 goto err;

 +   event = bt_ctf_event_create(event_class);
 +   if (!event) {
 +   pr_err(Failed to create an CTF event\n);
 +   goto err;
 +   }
 +
 +   bt_ctf_event_put(event);
 +
 priv-event_class = event_class;
 evsel-priv   = priv;
 return 0;



 --
 Jérémie Galarneau
 EfficiOS Inc.
 http://www.efficios.com



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] perf data: Show error message when ctf setup failed

2015-04-13 Thread Jérémie Galarneau
On Fri, Apr 10, 2015 at 8:37 AM, Jiri Olsa  wrote:
> On Fri, Apr 10, 2015 at 02:05:45PM +0200, Jiri Olsa wrote:
>
> SNIP
>
>> > >>I tested by using babeltrace binary and it works.
>> > >>
>> > >>After receiving your reply, I test on the latest tracecompass. A
>> > >>folder named 'ctf' is showed instead of the expected file
>> > >>'ctf-data', this folder only contains the raw metadata and
>> > >>perf-stream files but not analysed.
>> > >CC-ing Alexandre from tracecompass devel ^^^
>> >
>> > Hi,
>> >
>> > I just came back from vacation, sorry for not replying earlier!
>> >
>> > I managed to compile perf with CTF support, but by using Babeltrace's 
>> > commit
>> > 5584a48. It fails to compile against current master, because of private
>> > headers getting exposed. I reported that to the BT maintainers.
>>
>> there's fix in babeltrace tree already
>>
>> >
>> > Then it seems there's another bug with Trace Compass's current master, 
>> > trace
>> > validation cannot fail, and any file will get imported with no errors. We
>> > will look into this.
>> > But the root of the problem was that the converted CTF trace was not being
>> > recognized as valid. This is because some events define "stream_id = 0;",
>> > and others don't specify a stream_id at all. It seems quite random, see the
>> > full metadata here: http://pastebin.com/pACgV5JU
>> >
>> > Is there a reason why some events specify a stream_id and some don't?
>>
>> hum, that seems like a bug.. I'll check
>>
>
> ok, found the problem.. the "stream_id" event_class's attribute is created
> only when the instance of the event (not event_class) is created
>
> so you'll see the stream_id attribute only for events, that
> we actually got data for.. the rest is without, because
> their instance was never created
>
> seems to me like libbabeltrace bug, unless the application should
> take care about stream_id attribute.. but it's not the case for
> the rest of the 'internal' attributes.. Jeremie?

According to the spec, the stream_id attribute can be left unspecified
if only one stream is defined. However, is seems Babeltrace's CTF-Writer
will leave the stream_id out of the event's declaration even when
multiple streams are defined.

I'll submit a fix.

Thanks.
Jérémie

>
> anyway, I made a attached workaround and it all works nicely again,
> tracecompass is happy and shows the data properly
>
> I put all the pending ctf changes (plus the workaround) into:
>   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
>   perf/ctf branch
>
> jirka
>
>
> ---
> diff --git a/tools/perf/util/data-convert-bt.c 
> b/tools/perf/util/data-convert-bt.c
> index 977cc3f98d8f..d7f03dcb1700 100644
> --- a/tools/perf/util/data-convert-bt.c
> +++ b/tools/perf/util/data-convert-bt.c
> @@ -803,6 +803,7 @@ static int add_generic_types(struct ctf_writer *cw, 
> struct perf_evsel *evsel,
>  static int add_event(struct ctf_writer *cw, struct perf_evsel *evsel)
>  {
> struct bt_ctf_event_class *event_class;
> +   struct bt_ctf_event *event;
> struct evsel_priv *priv;
> const char *name = perf_evsel__name(evsel);
> int ret;
> @@ -833,6 +834,14 @@ static int add_event(struct ctf_writer *cw, struct 
> perf_evsel *evsel)
> if (!priv)
> goto err;
>
> +   event = bt_ctf_event_create(event_class);
> +   if (!event) {
> +   pr_err("Failed to create an CTF event\n");
> +   goto err;
> +   }
> +
> +   bt_ctf_event_put(event);
> +
> priv->event_class = event_class;
> evsel->priv   = priv;
> return 0;



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] perf data: Show error message when ctf setup failed

2015-04-13 Thread Jérémie Galarneau
On Fri, Apr 10, 2015 at 8:37 AM, Jiri Olsa jo...@redhat.com wrote:
 On Fri, Apr 10, 2015 at 02:05:45PM +0200, Jiri Olsa wrote:

 SNIP

  I tested by using babeltrace binary and it works.
  
  After receiving your reply, I test on the latest tracecompass. A
  folder named 'ctf' is showed instead of the expected file
  'ctf-data', this folder only contains the raw metadata and
  perf-stream files but not analysed.
  CC-ing Alexandre from tracecompass devel ^^^
 
  Hi,
 
  I just came back from vacation, sorry for not replying earlier!
 
  I managed to compile perf with CTF support, but by using Babeltrace's 
  commit
  5584a48. It fails to compile against current master, because of private
  headers getting exposed. I reported that to the BT maintainers.

 there's fix in babeltrace tree already

 
  Then it seems there's another bug with Trace Compass's current master, 
  trace
  validation cannot fail, and any file will get imported with no errors. We
  will look into this.
  But the root of the problem was that the converted CTF trace was not being
  recognized as valid. This is because some events define stream_id = 0;,
  and others don't specify a stream_id at all. It seems quite random, see the
  full metadata here: http://pastebin.com/pACgV5JU
 
  Is there a reason why some events specify a stream_id and some don't?

 hum, that seems like a bug.. I'll check


 ok, found the problem.. the stream_id event_class's attribute is created
 only when the instance of the event (not event_class) is created

 so you'll see the stream_id attribute only for events, that
 we actually got data for.. the rest is without, because
 their instance was never created

 seems to me like libbabeltrace bug, unless the application should
 take care about stream_id attribute.. but it's not the case for
 the rest of the 'internal' attributes.. Jeremie?

According to the spec, the stream_id attribute can be left unspecified
if only one stream is defined. However, is seems Babeltrace's CTF-Writer
will leave the stream_id out of the event's declaration even when
multiple streams are defined.

I'll submit a fix.

Thanks.
Jérémie


 anyway, I made a attached workaround and it all works nicely again,
 tracecompass is happy and shows the data properly

 I put all the pending ctf changes (plus the workaround) into:
   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
   perf/ctf branch

 jirka


 ---
 diff --git a/tools/perf/util/data-convert-bt.c 
 b/tools/perf/util/data-convert-bt.c
 index 977cc3f98d8f..d7f03dcb1700 100644
 --- a/tools/perf/util/data-convert-bt.c
 +++ b/tools/perf/util/data-convert-bt.c
 @@ -803,6 +803,7 @@ static int add_generic_types(struct ctf_writer *cw, 
 struct perf_evsel *evsel,
  static int add_event(struct ctf_writer *cw, struct perf_evsel *evsel)
  {
 struct bt_ctf_event_class *event_class;
 +   struct bt_ctf_event *event;
 struct evsel_priv *priv;
 const char *name = perf_evsel__name(evsel);
 int ret;
 @@ -833,6 +834,14 @@ static int add_event(struct ctf_writer *cw, struct 
 perf_evsel *evsel)
 if (!priv)
 goto err;

 +   event = bt_ctf_event_create(event_class);
 +   if (!event) {
 +   pr_err(Failed to create an CTF event\n);
 +   goto err;
 +   }
 +
 +   bt_ctf_event_put(event);
 +
 priv-event_class = event_class;
 evsel-priv   = priv;
 return 0;



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] perf data: Fix ctf_writer setupenv failure

2015-04-09 Thread Jérémie Galarneau
Hi He,

This commit should fix the problem:

commit a0d129162d2fdd1a99553a6cfbdf4e77ad3f7334
Author: Jérémie Galarneau 
Date:   Thu Apr 9 14:57:44 2015 -0400

Fix: Allow the addition of environment fields to a frozen trace

Commit 7f800dc7 introduced a behavior change which made it
impossible to add environment fields to a frozen trace (after the
creation of a stream).

This fix makes it possible to add new fields to a trace's
environment while making it impossible to modify existing fields
hereby restoring CTF Writer's v1.2 behavior.

Signed-off-by: Jérémie Galarneau 

Can you reproduce the problem with the latest Babeltrace master?
Otherwise, is there a branch I can checkout to try it out?

Jérémie

On Thu, Apr 9, 2015 at 3:38 AM, He Kuang  wrote:
> On 2015/4/9 1:59, Jiri Olsa wrote:
>>
>> On Wed, Apr 08, 2015 at 12:49:20PM +0800, He Kuang wrote:
>>>
>>> Due to babeltrace commit:
>>>7f800dc7c2a1 ("ir: make trace environment use bt_object")
>>>
>>> The trace->frozen flag is set in bt_ctf_trace_create_stream(), this flag
>>> is checked before adding environment field to trace, and causes
>>> ctf_writer__setup_env() failed. Fix this by setting all environment
>>> fields before bt_ctf_trace_create_stream().
>>>
>>> Before this patch:
>>>$ perf data convert --to-ctf=ctf
>>>Error during CTF convert setup.
>>
>> have you tested with the latest babeltrace sources?
>> this reminds me the bug they fixed recently, CCing Jeremie
>>
>> thanks,
>> jirka
>
>
> Yes,  the latest babeltrace commit id:
> dfdad2587b12d454e7235e01508a266d83e3e264
>
>>> After this patch:
>>>$ perf data convert --to-ctf=ctf
>>>[ perf data convert: Converted 'perf.data' into CTF data 'ctf' ]
>>>[ perf data convert: Converted and wrote 0.023 MB (596 samples) ]
>>>
>>> Signed-off-by: He Kuang 
>>> ---
>>>   tools/perf/util/data-convert-bt.c | 30 --
>>>   1 file changed, 20 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/tools/perf/util/data-convert-bt.c
>>> b/tools/perf/util/data-convert-bt.c
>>> index a5b89b9..718dc8a 100644
>>> --- a/tools/perf/util/data-convert-bt.c
>>> +++ b/tools/perf/util/data-convert-bt.c
>>> @@ -604,6 +604,22 @@ static int setup_events(struct ctf_writer *cw,
>>> struct perf_session *session)
>>> return 0;
>>>   }
>>>   +static int ctf_writer__setup_stream(struct ctf_writer *cw)
>>> +{
>>> +   struct bt_ctf_stream*stream;
>>> +
>>> +   /* CTF stream instance */
>>> +   stream = bt_ctf_writer_create_stream(cw->writer,
>>> cw->stream_class);
>>> +   if (!stream) {
>>> +   pr("Failed to create CTF stream.\n");
>>> +   return -1;
>>> +   }
>>> +
>>> +   cw->stream = stream;
>>> +
>>> +   return 0;
>>> +}
>>> +
>>>   static int ctf_writer__setup_env(struct ctf_writer *cw,
>>>  struct perf_session *session)
>>>   {
>>> @@ -725,7 +741,6 @@ static int ctf_writer__init(struct ctf_writer *cw,
>>> const char *path)
>>>   {
>>> struct bt_ctf_writer*writer;
>>> struct bt_ctf_stream_class  *stream_class;
>>> -   struct bt_ctf_stream*stream;
>>> struct bt_ctf_clock *clock;
>>> /* CTF writer */
>>> @@ -767,15 +782,6 @@ static int ctf_writer__init(struct ctf_writer *cw,
>>> const char *path)
>>> if (ctf_writer__init_data(cw))
>>> goto err_cleanup;
>>>   - /* CTF stream instance */
>>> -   stream = bt_ctf_writer_create_stream(writer, stream_class);
>>> -   if (!stream) {
>>> -   pr("Failed to create CTF stream.\n");
>>> -   goto err_cleanup;
>>> -   }
>>> -
>>> -   cw->stream = stream;
>>> -
>>> /* CTF clock writer setup */
>>> if (bt_ctf_writer_add_clock(writer, clock)) {
>>> pr("Failed to assign CTF clock to writer.\n");
>>> @@ -830,6 +836,10 @@ int bt_convert__perf2ctf(const char *input, const
>>> char *path, bool force)
>>> if (ctf_writer__setup_env(cw, session))
>>> goto free_session;
>>>   + /* CTF writer trace stream setup */
>>> +   if (ctf_writer__setup_stream(cw))
>>> +   goto free_session;
>>> +
>>> /* CTF events setup */
>>> if (setup_events(cw, session))
>>> goto free_session;
>>> --
>>> 2.3.3.220.g9ab698f
>>>
>>
>
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] perf data: Fix ctf_writer setupenv failure

2015-04-09 Thread Jérémie Galarneau
Hi He,

This commit should fix the problem:

commit a0d129162d2fdd1a99553a6cfbdf4e77ad3f7334
Author: Jérémie Galarneau jeremie.galarn...@efficios.com
Date:   Thu Apr 9 14:57:44 2015 -0400

Fix: Allow the addition of environment fields to a frozen trace

Commit 7f800dc7 introduced a behavior change which made it
impossible to add environment fields to a frozen trace (after the
creation of a stream).

This fix makes it possible to add new fields to a trace's
environment while making it impossible to modify existing fields
hereby restoring CTF Writer's v1.2 behavior.

Signed-off-by: Jérémie Galarneau jeremie.galarn...@efficios.com

Can you reproduce the problem with the latest Babeltrace master?
Otherwise, is there a branch I can checkout to try it out?

Jérémie

On Thu, Apr 9, 2015 at 3:38 AM, He Kuang heku...@huawei.com wrote:
 On 2015/4/9 1:59, Jiri Olsa wrote:

 On Wed, Apr 08, 2015 at 12:49:20PM +0800, He Kuang wrote:

 Due to babeltrace commit:
7f800dc7c2a1 (ir: make trace environment use bt_object)

 The trace-frozen flag is set in bt_ctf_trace_create_stream(), this flag
 is checked before adding environment field to trace, and causes
 ctf_writer__setup_env() failed. Fix this by setting all environment
 fields before bt_ctf_trace_create_stream().

 Before this patch:
$ perf data convert --to-ctf=ctf
Error during CTF convert setup.

 have you tested with the latest babeltrace sources?
 this reminds me the bug they fixed recently, CCing Jeremie

 thanks,
 jirka


 Yes,  the latest babeltrace commit id:
 dfdad2587b12d454e7235e01508a266d83e3e264

 After this patch:
$ perf data convert --to-ctf=ctf
[ perf data convert: Converted 'perf.data' into CTF data 'ctf' ]
[ perf data convert: Converted and wrote 0.023 MB (596 samples) ]

 Signed-off-by: He Kuang heku...@huawei.com
 ---
   tools/perf/util/data-convert-bt.c | 30 --
   1 file changed, 20 insertions(+), 10 deletions(-)

 diff --git a/tools/perf/util/data-convert-bt.c
 b/tools/perf/util/data-convert-bt.c
 index a5b89b9..718dc8a 100644
 --- a/tools/perf/util/data-convert-bt.c
 +++ b/tools/perf/util/data-convert-bt.c
 @@ -604,6 +604,22 @@ static int setup_events(struct ctf_writer *cw,
 struct perf_session *session)
 return 0;
   }
   +static int ctf_writer__setup_stream(struct ctf_writer *cw)
 +{
 +   struct bt_ctf_stream*stream;
 +
 +   /* CTF stream instance */
 +   stream = bt_ctf_writer_create_stream(cw-writer,
 cw-stream_class);
 +   if (!stream) {
 +   pr(Failed to create CTF stream.\n);
 +   return -1;
 +   }
 +
 +   cw-stream = stream;
 +
 +   return 0;
 +}
 +
   static int ctf_writer__setup_env(struct ctf_writer *cw,
  struct perf_session *session)
   {
 @@ -725,7 +741,6 @@ static int ctf_writer__init(struct ctf_writer *cw,
 const char *path)
   {
 struct bt_ctf_writer*writer;
 struct bt_ctf_stream_class  *stream_class;
 -   struct bt_ctf_stream*stream;
 struct bt_ctf_clock *clock;
 /* CTF writer */
 @@ -767,15 +782,6 @@ static int ctf_writer__init(struct ctf_writer *cw,
 const char *path)
 if (ctf_writer__init_data(cw))
 goto err_cleanup;
   - /* CTF stream instance */
 -   stream = bt_ctf_writer_create_stream(writer, stream_class);
 -   if (!stream) {
 -   pr(Failed to create CTF stream.\n);
 -   goto err_cleanup;
 -   }
 -
 -   cw-stream = stream;
 -
 /* CTF clock writer setup */
 if (bt_ctf_writer_add_clock(writer, clock)) {
 pr(Failed to assign CTF clock to writer.\n);
 @@ -830,6 +836,10 @@ int bt_convert__perf2ctf(const char *input, const
 char *path, bool force)
 if (ctf_writer__setup_env(cw, session))
 goto free_session;
   + /* CTF writer trace stream setup */
 +   if (ctf_writer__setup_stream(cw))
 +   goto free_session;
 +
 /* CTF events setup */
 if (setup_events(cw, session))
 goto free_session;
 --
 2.3.3.220.g9ab698f







-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2015-03-13 Thread Jérémie Galarneau
On Thu, Mar 12, 2015 at 3:17 PM, Arnaldo Carvalho de Melo
 wrote:
> Em Thu, Mar 12, 2015 at 09:40:09PM +0800, Wang Nan escreveu:
>> 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.
>
> Just reproduced this:
>
> [acme@ssdandy linux]$ perf data convert --to-ctf=./ctf-data/
> perf: event-types.c:1855: bt_ctf_field_type_set_native_byte_order:
> Assertion `byte_order == 1234 || byte_order == 4321' failed.
> Aborted (core dumped)
> [acme@ssdandy linux]$
>
>
> perf: event-types.c:1855: bt_ctf_field_type_set_native_byte_order: Assertion 
> `byte_order == 1234 || byte_order == 4321' failed.
>
> Program received signal SIGABRT, Aborted.
> 0x75b345d7 in raise () from /lib64/libc.so.6
> Missing separate debuginfos, use: debuginfo-install 
> audit-libs-2.4.1-5.el7.x86_64 bzip2-libs-1.0.6-12.el7.x86_64 
> elfutils-libelf-0.160-1.el7.x86_64 elfutils-libs-0.160-1.el7.x86_64 
> glib2-2.40.0-4.el7.x86_64 glibc-2.17-78.el7.x86_64 libgcc-4.8.3-9.el7.x86_64 
> libuuid-2.23.2-21.el7.x86_64 nss-softokn-freebl-3.16.2.3-9.el7.x86_64 
> numactl-libs-2.0.9-4.el7.x86_64 perl-libs-5.16.3-285.el7.x86_64 
> popt-1.13-16.el7.x86_64 python-libs-2.7.5-16.el7.x86_64 
> slang-2.2.4-11.el7.x86_64 xz-libs-5.1.2-9alpha.el7.x86_64 
> zlib-1.2.7-13.el7.x86_64
> (gdb) bt
> #0  0x75b345d7 in raise () from /lib64/libc.so.6
> #1  0x75b35cc8 in abort () from /lib64/libc.so.6
> #2  0x75b2d546 in __assert_fail_base () from /lib64/libc.so.6
> #3  0x75b2d5f2 in __assert_fail () from /lib64/libc.so.6
> #4  0x7510034a in bt_ctf_field_type_set_native_byte_order 
> (type=, byte_order=) at event-types.c:1855
> #5  0x75101b59 in bt_ctf_stream_class_freeze (stream_class=0x8acc20) 
> at stream-class.c:478
> #6  0x750fbdc5 in bt_ctf_event_create 
> (event_class=event_class@entry=0x133d590) at event.c:324
> #7  0x004e158d in process_sample_event (tool=0x7fffdc40, 
> _event=, sample=0x7fffd840, evsel=0x8b1040, 
> machine=) at util/data-convert-bt.c:518
> #8  0x004b011d in __ordered_events__flush (oe=oe@entry=0x8b0210) at 
> util/ordered-events.c:214
> #9  0x004b043a in ordered_events__flush (oe=oe@entry=0x8b0210, 
> how=how@entry=OE_FLUSH__FINAL) at util/ordered-events.c:279
> #10 0x004aee18 in __perf_session__process_events (file_size=139704, 
> data_size=, data_offset=, session=0x8b0020) at 
> util/session.c:1394
> #11 perf_session__process_events (session=session@entry=0x8b0020) at 
> util/session.c:1412
> #12 0x004e270e in bt_convert__perf2ctf (input=, 
> path=0x7fffe59d "./ctf-data/") at util/data-convert-bt.c:992
> #13 0x004479cf in cmd_data_convert (argc=, 
> argv=, prefix=) at builtin-data.c:77
> #14 0x0046f365 in run_builtin (p=p@entry=0x8345a0 , 
> argc=argc@entry=3, argv=argv@entry=0x7fffe2d0) at perf.c:370
> #15 0x0041def0 in handle_internal_command (argv=0x7fffe2d0, 
> argc=3) at perf.c:429
> #16 run_argv (argv=0x7fffe050, argcp=0x7fffe05c) at perf.c:473
> #17 main (argc=3, argv=0x7fffe2d0) at perf.c:588
> (gdb)
>

I was able to reproduce this on my end as well. I pushed a fix
addressing this issue in Babeltrace master as of 5ca83563.
This scenario has also been added to Babeltrace's regression test suite.

Jérémie

> Stopping at this to process other patches, will be back to this after 
> reducing the queue,
>
> - Arnaldo



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2015-03-13 Thread Jérémie Galarneau
On Thu, Mar 12, 2015 at 3:17 PM, Arnaldo Carvalho de Melo
a...@redhat.com wrote:
 Em Thu, Mar 12, 2015 at 09:40:09PM +0800, Wang Nan escreveu:
 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.

 Just reproduced this:

 [acme@ssdandy linux]$ perf data convert --to-ctf=./ctf-data/
 perf: event-types.c:1855: bt_ctf_field_type_set_native_byte_order:
 Assertion `byte_order == 1234 || byte_order == 4321' failed.
 Aborted (core dumped)
 [acme@ssdandy linux]$


 perf: event-types.c:1855: bt_ctf_field_type_set_native_byte_order: Assertion 
 `byte_order == 1234 || byte_order == 4321' failed.

 Program received signal SIGABRT, Aborted.
 0x75b345d7 in raise () from /lib64/libc.so.6
 Missing separate debuginfos, use: debuginfo-install 
 audit-libs-2.4.1-5.el7.x86_64 bzip2-libs-1.0.6-12.el7.x86_64 
 elfutils-libelf-0.160-1.el7.x86_64 elfutils-libs-0.160-1.el7.x86_64 
 glib2-2.40.0-4.el7.x86_64 glibc-2.17-78.el7.x86_64 libgcc-4.8.3-9.el7.x86_64 
 libuuid-2.23.2-21.el7.x86_64 nss-softokn-freebl-3.16.2.3-9.el7.x86_64 
 numactl-libs-2.0.9-4.el7.x86_64 perl-libs-5.16.3-285.el7.x86_64 
 popt-1.13-16.el7.x86_64 python-libs-2.7.5-16.el7.x86_64 
 slang-2.2.4-11.el7.x86_64 xz-libs-5.1.2-9alpha.el7.x86_64 
 zlib-1.2.7-13.el7.x86_64
 (gdb) bt
 #0  0x75b345d7 in raise () from /lib64/libc.so.6
 #1  0x75b35cc8 in abort () from /lib64/libc.so.6
 #2  0x75b2d546 in __assert_fail_base () from /lib64/libc.so.6
 #3  0x75b2d5f2 in __assert_fail () from /lib64/libc.so.6
 #4  0x7510034a in bt_ctf_field_type_set_native_byte_order 
 (type=optimized out, byte_order=optimized out) at event-types.c:1855
 #5  0x75101b59 in bt_ctf_stream_class_freeze (stream_class=0x8acc20) 
 at stream-class.c:478
 #6  0x750fbdc5 in bt_ctf_event_create 
 (event_class=event_class@entry=0x133d590) at event.c:324
 #7  0x004e158d in process_sample_event (tool=0x7fffdc40, 
 _event=optimized out, sample=0x7fffd840, evsel=0x8b1040, 
 machine=optimized out) at util/data-convert-bt.c:518
 #8  0x004b011d in __ordered_events__flush (oe=oe@entry=0x8b0210) at 
 util/ordered-events.c:214
 #9  0x004b043a in ordered_events__flush (oe=oe@entry=0x8b0210, 
 how=how@entry=OE_FLUSH__FINAL) at util/ordered-events.c:279
 #10 0x004aee18 in __perf_session__process_events (file_size=139704, 
 data_size=optimized out, data_offset=optimized out, session=0x8b0020) at 
 util/session.c:1394
 #11 perf_session__process_events (session=session@entry=0x8b0020) at 
 util/session.c:1412
 #12 0x004e270e in bt_convert__perf2ctf (input=optimized out, 
 path=0x7fffe59d ./ctf-data/) at util/data-convert-bt.c:992
 #13 0x004479cf in cmd_data_convert (argc=optimized out, 
 argv=optimized out, prefix=optimized out) at builtin-data.c:77
 #14 0x0046f365 in run_builtin (p=p@entry=0x8345a0 commands+576, 
 argc=argc@entry=3, argv=argv@entry=0x7fffe2d0) at perf.c:370
 #15 0x0041def0 in handle_internal_command (argv=0x7fffe2d0, 
 argc=3) at perf.c:429
 #16 run_argv (argv=0x7fffe050, argcp=0x7fffe05c) at perf.c:473
 #17 main (argc=3, argv=0x7fffe2d0) at perf.c:588
 (gdb)


I was able to reproduce this on my end as well. I pushed a fix
addressing this issue in Babeltrace master as of 5ca83563.
This scenario has also been added to Babeltrace's regression test suite.

Jérémie

 Stopping at this to process other patches, will be back to this after 
 reducing the queue,

 - Arnaldo



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2015-03-12 Thread Jérémie Galarneau
On Thu, Mar 12, 2015 at 3:17 PM, Arnaldo Carvalho de Melo
 wrote:
> Em Thu, Mar 12, 2015 at 09:40:09PM +0800, Wang Nan escreveu:
>> 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.
>
> Just reproduced this:
>
> [acme@ssdandy linux]$ perf data convert --to-ctf=./ctf-data/
> perf: event-types.c:1855: bt_ctf_field_type_set_native_byte_order:
> Assertion `byte_order == 1234 || byte_order == 4321' failed.
> Aborted (core dumped)
> [acme@ssdandy linux]$
>
>
> perf: event-types.c:1855: bt_ctf_field_type_set_native_byte_order: Assertion 
> `byte_order == 1234 || byte_order == 4321' failed.
>
> Program received signal SIGABRT, Aborted.
> 0x75b345d7 in raise () from /lib64/libc.so.6
> Missing separate debuginfos, use: debuginfo-install 
> audit-libs-2.4.1-5.el7.x86_64 bzip2-libs-1.0.6-12.el7.x86_64 
> elfutils-libelf-0.160-1.el7.x86_64 elfutils-libs-0.160-1.el7.x86_64 
> glib2-2.40.0-4.el7.x86_64 glibc-2.17-78.el7.x86_64 libgcc-4.8.3-9.el7.x86_64 
> libuuid-2.23.2-21.el7.x86_64 nss-softokn-freebl-3.16.2.3-9.el7.x86_64 
> numactl-libs-2.0.9-4.el7.x86_64 perl-libs-5.16.3-285.el7.x86_64 
> popt-1.13-16.el7.x86_64 python-libs-2.7.5-16.el7.x86_64 
> slang-2.2.4-11.el7.x86_64 xz-libs-5.1.2-9alpha.el7.x86_64 
> zlib-1.2.7-13.el7.x86_64
> (gdb) bt
> #0  0x75b345d7 in raise () from /lib64/libc.so.6
> #1  0x75b35cc8 in abort () from /lib64/libc.so.6
> #2  0x75b2d546 in __assert_fail_base () from /lib64/libc.so.6
> #3  0x75b2d5f2 in __assert_fail () from /lib64/libc.so.6
> #4  0x7510034a in bt_ctf_field_type_set_native_byte_order 
> (type=, byte_order=) at event-types.c:1855
> #5  0x75101b59 in bt_ctf_stream_class_freeze (stream_class=0x8acc20) 
> at stream-class.c:478
> #6  0x750fbdc5 in bt_ctf_event_create 
> (event_class=event_class@entry=0x133d590) at event.c:324
> #7  0x004e158d in process_sample_event (tool=0x7fffdc40, 
> _event=, sample=0x7fffd840, evsel=0x8b1040, 
> machine=) at util/data-convert-bt.c:518
> #8  0x004b011d in __ordered_events__flush (oe=oe@entry=0x8b0210) at 
> util/ordered-events.c:214
> #9  0x004b043a in ordered_events__flush (oe=oe@entry=0x8b0210, 
> how=how@entry=OE_FLUSH__FINAL) at util/ordered-events.c:279
> #10 0x004aee18 in __perf_session__process_events (file_size=139704, 
> data_size=, data_offset=, session=0x8b0020) at 
> util/session.c:1394
> #11 perf_session__process_events (session=session@entry=0x8b0020) at 
> util/session.c:1412
> #12 0x004e270e in bt_convert__perf2ctf (input=, 
> path=0x7fffe59d "./ctf-data/") at util/data-convert-bt.c:992
> #13 0x004479cf in cmd_data_convert (argc=, 
> argv=, prefix=) at builtin-data.c:77
> #14 0x0046f365 in run_builtin (p=p@entry=0x8345a0 , 
> argc=argc@entry=3, argv=argv@entry=0x7fffe2d0) at perf.c:370
> #15 0x0041def0 in handle_internal_command (argv=0x7fffe2d0, 
> argc=3) at perf.c:429
> #16 run_argv (argv=0x7fffe050, argcp=0x7fffe05c) at perf.c:473
> #17 main (argc=3, argv=0x7fffe2d0) at perf.c:588
> (gdb)

Thanks for providing this info, I'm looking into it and will keep you posted.

Jérémie

>
> Stopping at this to process other patches, will be back to this after 
> reducing the queue,
>
> - Arnaldo



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2015-03-12 Thread Jérémie Galarneau
On Thu, Mar 12, 2015 at 3:17 PM, Arnaldo Carvalho de Melo
a...@redhat.com wrote:
 Em Thu, Mar 12, 2015 at 09:40:09PM +0800, Wang Nan escreveu:
 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.

 Just reproduced this:

 [acme@ssdandy linux]$ perf data convert --to-ctf=./ctf-data/
 perf: event-types.c:1855: bt_ctf_field_type_set_native_byte_order:
 Assertion `byte_order == 1234 || byte_order == 4321' failed.
 Aborted (core dumped)
 [acme@ssdandy linux]$


 perf: event-types.c:1855: bt_ctf_field_type_set_native_byte_order: Assertion 
 `byte_order == 1234 || byte_order == 4321' failed.

 Program received signal SIGABRT, Aborted.
 0x75b345d7 in raise () from /lib64/libc.so.6
 Missing separate debuginfos, use: debuginfo-install 
 audit-libs-2.4.1-5.el7.x86_64 bzip2-libs-1.0.6-12.el7.x86_64 
 elfutils-libelf-0.160-1.el7.x86_64 elfutils-libs-0.160-1.el7.x86_64 
 glib2-2.40.0-4.el7.x86_64 glibc-2.17-78.el7.x86_64 libgcc-4.8.3-9.el7.x86_64 
 libuuid-2.23.2-21.el7.x86_64 nss-softokn-freebl-3.16.2.3-9.el7.x86_64 
 numactl-libs-2.0.9-4.el7.x86_64 perl-libs-5.16.3-285.el7.x86_64 
 popt-1.13-16.el7.x86_64 python-libs-2.7.5-16.el7.x86_64 
 slang-2.2.4-11.el7.x86_64 xz-libs-5.1.2-9alpha.el7.x86_64 
 zlib-1.2.7-13.el7.x86_64
 (gdb) bt
 #0  0x75b345d7 in raise () from /lib64/libc.so.6
 #1  0x75b35cc8 in abort () from /lib64/libc.so.6
 #2  0x75b2d546 in __assert_fail_base () from /lib64/libc.so.6
 #3  0x75b2d5f2 in __assert_fail () from /lib64/libc.so.6
 #4  0x7510034a in bt_ctf_field_type_set_native_byte_order 
 (type=optimized out, byte_order=optimized out) at event-types.c:1855
 #5  0x75101b59 in bt_ctf_stream_class_freeze (stream_class=0x8acc20) 
 at stream-class.c:478
 #6  0x750fbdc5 in bt_ctf_event_create 
 (event_class=event_class@entry=0x133d590) at event.c:324
 #7  0x004e158d in process_sample_event (tool=0x7fffdc40, 
 _event=optimized out, sample=0x7fffd840, evsel=0x8b1040, 
 machine=optimized out) at util/data-convert-bt.c:518
 #8  0x004b011d in __ordered_events__flush (oe=oe@entry=0x8b0210) at 
 util/ordered-events.c:214
 #9  0x004b043a in ordered_events__flush (oe=oe@entry=0x8b0210, 
 how=how@entry=OE_FLUSH__FINAL) at util/ordered-events.c:279
 #10 0x004aee18 in __perf_session__process_events (file_size=139704, 
 data_size=optimized out, data_offset=optimized out, session=0x8b0020) at 
 util/session.c:1394
 #11 perf_session__process_events (session=session@entry=0x8b0020) at 
 util/session.c:1412
 #12 0x004e270e in bt_convert__perf2ctf (input=optimized out, 
 path=0x7fffe59d ./ctf-data/) at util/data-convert-bt.c:992
 #13 0x004479cf in cmd_data_convert (argc=optimized out, 
 argv=optimized out, prefix=optimized out) at builtin-data.c:77
 #14 0x0046f365 in run_builtin (p=p@entry=0x8345a0 commands+576, 
 argc=argc@entry=3, argv=argv@entry=0x7fffe2d0) at perf.c:370
 #15 0x0041def0 in handle_internal_command (argv=0x7fffe2d0, 
 argc=3) at perf.c:429
 #16 run_argv (argv=0x7fffe050, argcp=0x7fffe05c) at perf.c:473
 #17 main (argc=3, argv=0x7fffe2d0) at perf.c:588
 (gdb)

Thanks for providing this info, I'm looking into it and will keep you posted.

Jérémie


 Stopping at this to process other patches, will be back to this after 
 reducing the queue,

 - Arnaldo



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] perf build: Fix libbabeltrace detection

2015-03-10 Thread Jérémie Galarneau
On Tue, Mar 10, 2015 at 10:11 AM, Jiri Olsa  wrote:
> On Tue, Mar 10, 2015 at 11:01:34AM -0300, Arnaldo Carvalho de Melo wrote:
>> Em Tue, Mar 10, 2015 at 01:00:35PM +0100, Jiri Olsa escreveu:
>> > On Mon, Mar 09, 2015 at 08:28:45PM -0300, Arnaldo Carvalho de Melo wrote:
>> > > Em Mon, Mar 09, 2015 at 08:11:19PM -0300, Arnaldo Carvalho de Melo 
>> > > escreveu:
>> > > > Em Mon, Mar 09, 2015 at 06:51:21PM -0300, Arnaldo Carvalho de Melo 
>> > > > escreveu:
>> > > [root@zoo ~]# find /opt/libbabeltrace/include/babeltrace/ -type f | 
>> > > xargs grep bt_ctf_stream_class_get_packet_context_type
>> > > /opt/libbabeltrace/include/babeltrace/ctf-ir/stream-class.h:extern 
>> > > struct bt_ctf_field_type *bt_ctf_stream_class_get_packet_context_type(
>>
>> > > That seems to be included from the file included in the feature test 
>> > > code :-\
>> > > Really ran out of time now...
>>
>> > ouch, thanks a lot for debugging.. the reason is indeed the -Werror added 
>> > by:
>> >   b49f1a4be701 perf tools: Improve feature test debuggability
>>
>> > following patch seems to fix this for me
>> > ---
>> > Following patch added -Werror for feature builds:
>> >   b49f1a4be701 perf tools: Improve feature test debuggability
>>
>> > and broke libbabeltrace feature build, because it was including
>> > wrong header and gcc couldn't find the used symbol definition.
>>
>> > Adding proper header and keeping the old one as it is needed
>> > also (libbabeltrace quirk).
>>
>> > +++ b/tools/perf/config/feature-checks/test-libbabeltrace.c
>> >  #include 
>> > +#include 
>>
>> Right, that was the fix I found as well, well, I was trying to include
>> _just_ babeltrace/ctf-ir/stream-class.h, but that is buggy in that it
>> doesn't include the header file with the uint32_t and int64_t types:
>
> yep, thats the 'libbabeltrace quirk' I mentioned in the changelog ;-)
>

Seems I missed that being discussed. Fixed in Babeltrace master as of 48d711aa2.

Jérémie

>>
>> [acme@zoo linux]$ cat 
>> /tmp/build/perf/config/feature-checks/make-libbabeltrace
>> make[1]: Entering directory 
>> `/home/git/linux/tools/perf/config/feature-checks'
>> gcc -MD -I/opt/libbabeltrace//include -Wall -Werror -o 
>> /tmp/build/perf/config/feature-checks/test-libbabeltrace.bin 
>> test-libbabeltrace.c -Wl,-z,noexecstack -L/opt/libbabeltrace//lib 
>> -lbabeltrace-ctf # -lbabeltrace provided by
>> In file included from test-libbabeltrace.c:2:0:
>> /opt/libbabeltrace//include/babeltrace/ctf-ir/stream-class.h:118:1: error: 
>> unknown type name ‘int64_t’
>>  extern int64_t bt_ctf_stream_class_get_id(
>>  ^
>> /opt/libbabeltrace//include/babeltrace/ctf-ir/stream-class.h:134:45: error: 
>> unknown type name ‘uint32_t’
>>struct bt_ctf_stream_class *stream_class, uint32_t id);
>>  ^
>> make[1]: *** [test-libbabeltrace.bin] Error 1
>> make[1]: Leaving directory `/home/git/linux/tools/perf/config/feature-checks'
>> [acme@zoo linux]$
>>
>> >
>> >  int main(void)
>> >  {
>> > --
>> > 1.9.3
>>
>> Ah, I found the following patch useful in debugging this, if you're ok with 
>> it,
>> I'll put it in my tree with your Acked-by, ok?
>>
>> - Arnaldo
>>
>> [acme@zoo linux]$ git diff tools/perf/config/Makefile
>> diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
>> index e2350ada6ccd..4992c39652e6 100644
>> --- a/tools/perf/config/Makefile
>> +++ b/tools/perf/config/Makefile
>> @@ -184,7 +184,7 @@ endif
>>
>>  feature_check = $(eval $(feature_check_code))
>>  define feature_check_code
>> -  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) 
>> CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) 
>> $(FEATURE_CHECK_LDFLAGS-$(1))" -C config/feature-checks test-$1.bin 
>> >/dev/null 2>/dev/null && echo 1 ||
>> +  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) 
>> CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) 
>> $(FEATURE_CHECK_LDFLAGS-$(1))" -C config/feature-checks test-$1.bin > 
>> $(OUTPUT_FEATURES)make-$(1) 2>&1
>>  endef
>
> ack, that seem usefull.. I always redirected this to '>> /tmp/krava'
> never got enough will to make it nice and generic ;-)
>
> thanks,
> jirka



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] perf build: Fix libbabeltrace detection

2015-03-10 Thread Jérémie Galarneau
On Tue, Mar 10, 2015 at 10:11 AM, Jiri Olsa jo...@redhat.com wrote:
 On Tue, Mar 10, 2015 at 11:01:34AM -0300, Arnaldo Carvalho de Melo wrote:
 Em Tue, Mar 10, 2015 at 01:00:35PM +0100, Jiri Olsa escreveu:
  On Mon, Mar 09, 2015 at 08:28:45PM -0300, Arnaldo Carvalho de Melo wrote:
   Em Mon, Mar 09, 2015 at 08:11:19PM -0300, Arnaldo Carvalho de Melo 
   escreveu:
Em Mon, Mar 09, 2015 at 06:51:21PM -0300, Arnaldo Carvalho de Melo 
escreveu:
   [root@zoo ~]# find /opt/libbabeltrace/include/babeltrace/ -type f | 
   xargs grep bt_ctf_stream_class_get_packet_context_type
   /opt/libbabeltrace/include/babeltrace/ctf-ir/stream-class.h:extern 
   struct bt_ctf_field_type *bt_ctf_stream_class_get_packet_context_type(

   That seems to be included from the file included in the feature test 
   code :-\
   Really ran out of time now...

  ouch, thanks a lot for debugging.. the reason is indeed the -Werror added 
  by:
b49f1a4be701 perf tools: Improve feature test debuggability

  following patch seems to fix this for me
  ---
  Following patch added -Werror for feature builds:
b49f1a4be701 perf tools: Improve feature test debuggability

  and broke libbabeltrace feature build, because it was including
  wrong header and gcc couldn't find the used symbol definition.

  Adding proper header and keeping the old one as it is needed
  also (libbabeltrace quirk).

  +++ b/tools/perf/config/feature-checks/test-libbabeltrace.c
   #include babeltrace/ctf-writer/writer.h
  +#include babeltrace/ctf-ir/stream-class.h

 Right, that was the fix I found as well, well, I was trying to include
 _just_ babeltrace/ctf-ir/stream-class.h, but that is buggy in that it
 doesn't include the header file with the uint32_t and int64_t types:

 yep, thats the 'libbabeltrace quirk' I mentioned in the changelog ;-)


Seems I missed that being discussed. Fixed in Babeltrace master as of 48d711aa2.

Jérémie


 [acme@zoo linux]$ cat 
 /tmp/build/perf/config/feature-checks/make-libbabeltrace
 make[1]: Entering directory 
 `/home/git/linux/tools/perf/config/feature-checks'
 gcc -MD -I/opt/libbabeltrace//include -Wall -Werror -o 
 /tmp/build/perf/config/feature-checks/test-libbabeltrace.bin 
 test-libbabeltrace.c -Wl,-z,noexecstack -L/opt/libbabeltrace//lib 
 -lbabeltrace-ctf # -lbabeltrace provided by
 In file included from test-libbabeltrace.c:2:0:
 /opt/libbabeltrace//include/babeltrace/ctf-ir/stream-class.h:118:1: error: 
 unknown type name ‘int64_t’
  extern int64_t bt_ctf_stream_class_get_id(
  ^
 /opt/libbabeltrace//include/babeltrace/ctf-ir/stream-class.h:134:45: error: 
 unknown type name ‘uint32_t’
struct bt_ctf_stream_class *stream_class, uint32_t id);
  ^
 make[1]: *** [test-libbabeltrace.bin] Error 1
 make[1]: Leaving directory `/home/git/linux/tools/perf/config/feature-checks'
 [acme@zoo linux]$

 
   int main(void)
   {
  --
  1.9.3

 Ah, I found the following patch useful in debugging this, if you're ok with 
 it,
 I'll put it in my tree with your Acked-by, ok?

 - Arnaldo

 [acme@zoo linux]$ git diff tools/perf/config/Makefile
 diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
 index e2350ada6ccd..4992c39652e6 100644
 --- a/tools/perf/config/Makefile
 +++ b/tools/perf/config/Makefile
 @@ -184,7 +184,7 @@ endif

  feature_check = $(eval $(feature_check_code))
  define feature_check_code
 -  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) 
 CFLAGS=$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1)) LDFLAGS=$(LDFLAGS) 
 $(FEATURE_CHECK_LDFLAGS-$(1)) -C config/feature-checks test-$1.bin 
 /dev/null 2/dev/null  echo 1 ||
 +  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) 
 CFLAGS=$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1)) LDFLAGS=$(LDFLAGS) 
 $(FEATURE_CHECK_LDFLAGS-$(1)) -C config/feature-checks test-$1.bin  
 $(OUTPUT_FEATURES)make-$(1) 21
  endef

 ack, that seem usefull.. I always redirected this to ' /tmp/krava'
 never got enough will to make it nice and generic ;-)

 thanks,
 jirka



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv3 0/8] perf tools: Add perf data CTF conversion

2015-01-28 Thread Jérémie Galarneau
On Sun, Jan 25, 2015 at 8:43 AM, Jiri Olsa  wrote:
> On Fri, Jan 16, 2015 at 11:46:36AM -0500, Jérémie Galarneau wrote:
>> On Fri, Jan 16, 2015 at 10:26 AM, Alexandre Montplaisir
>>  wrote:
>> > On 2015-01-15 03:57 PM, Alexandre Montplaisir wrote:
>> >>
>> >> Hi,
>> >>
>> >> I'm a developer for the Trace Compass tool (see links [3], [4] in Jiri's
>> >> email). I can confirm that the generated CTF can be read correctly by our
>> >> tool, which enables many views and analyses (Control Flow, CPU usage view,
>> >> etc.) that were previously only available for LTTng traces.
>> >>
>> >> Some of our users also use perf extensively, and are looking forward to
>> >> this feature! Is there any ETA as to when this will be merged upstream?
>> >>
>> >> Thanks,
>> >> Alexandre
>> >
>> >
>> > That was a bit too fast, it seems there are issues with very recent 
>> > versions
>> > of Babeltrace. You can follow the discussion at
>> > http://lists.linuxfoundation.org/pipermail/diamon-discuss/2015-January/07.html
>> >
>>
>> It's a regression introduced by a commit that was pushed to master
>> yesterday. I'm working on a fix.
>> In the meantime, testing against Babeltrace master 3baf0856 should be 
>> alright.
>
> even on this HEAD I'm still getting the 3rd issue I described in earlier 
> email:
>
> ---
> the bt_ctf_trace_create_stream function tries to set ID on
> stream_class which gets frozen just few moments ago in
> bt_ctf_stream_create call..
>
> this trigers failure and close up of stream fd which is not set yet:
>
> if (close(stream->pos.fd)) {
> perror("close");
> }
>
> hence the 'close: Bad file descriptor' message
> so this one looks like a bug to me, but we might be misusing the API 
> also..
> ---
>
> I need attached patch in perf code.. any idea?
>

I have merged a patch addressing this problem. Thanks for reporting!

commit 29d9d76c476cbf3fdf6fa709bfbdc24309974f06
Author: Jérémie Galarneau 
Date:   Wed Jan 28 16:52:28 2015 -0500

Fix: lock stream class after assigning stream id

Fixes a bug that was introduced by 2f100782 which made it possible
to set custom stream class IDs.

The stream class is frozen when a stream of its type is instanciated.
However, the trace or writer must still assign a unique ID to the stream
class if none were set prior. This modification moves the stream class
locking (freeze) after the ID assignment check.

Reported-by: Jiri Olsa 
Signed-off-by: Jérémie Galarneau 

Jérémie

> thanks,
> jirka
>
>
> ---
> diff --git a/tools/perf/util/data-convert-bt.c 
> b/tools/perf/util/data-convert-bt.c
> index bdb493febff6..0d75e1ed348c 100644
> --- a/tools/perf/util/data-convert-bt.c
> +++ b/tools/perf/util/data-convert-bt.c
> @@ -960,6 +960,11 @@ static int ctf_writer__init(struct ctf_writer *cw, const 
> char *path)
> goto err_cleanup;
> }
>
> +   if (bt_ctf_stream_class_set_id(stream_class, 0)) {
> +   pr("Failed to set CTF stream class ID.\n");
> +   goto err_cleanup;
> +   }
> +
> cw->stream_class = stream_class;
>
> /* CTF clock stream setup */



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv3 0/8] perf tools: Add perf data CTF conversion

2015-01-28 Thread Jérémie Galarneau
On Sun, Jan 25, 2015 at 8:43 AM, Jiri Olsa jo...@redhat.com wrote:
 On Fri, Jan 16, 2015 at 11:46:36AM -0500, Jérémie Galarneau wrote:
 On Fri, Jan 16, 2015 at 10:26 AM, Alexandre Montplaisir
 alexmon...@voxpopuli.im wrote:
  On 2015-01-15 03:57 PM, Alexandre Montplaisir wrote:
 
  Hi,
 
  I'm a developer for the Trace Compass tool (see links [3], [4] in Jiri's
  email). I can confirm that the generated CTF can be read correctly by our
  tool, which enables many views and analyses (Control Flow, CPU usage view,
  etc.) that were previously only available for LTTng traces.
 
  Some of our users also use perf extensively, and are looking forward to
  this feature! Is there any ETA as to when this will be merged upstream?
 
  Thanks,
  Alexandre
 
 
  That was a bit too fast, it seems there are issues with very recent 
  versions
  of Babeltrace. You can follow the discussion at
  http://lists.linuxfoundation.org/pipermail/diamon-discuss/2015-January/07.html
 

 It's a regression introduced by a commit that was pushed to master
 yesterday. I'm working on a fix.
 In the meantime, testing against Babeltrace master 3baf0856 should be 
 alright.

 even on this HEAD I'm still getting the 3rd issue I described in earlier 
 email:

 ---
 the bt_ctf_trace_create_stream function tries to set ID on
 stream_class which gets frozen just few moments ago in
 bt_ctf_stream_create call..

 this trigers failure and close up of stream fd which is not set yet:

 if (close(stream-pos.fd)) {
 perror(close);
 }

 hence the 'close: Bad file descriptor' message
 so this one looks like a bug to me, but we might be misusing the API 
 also..
 ---

 I need attached patch in perf code.. any idea?


I have merged a patch addressing this problem. Thanks for reporting!

commit 29d9d76c476cbf3fdf6fa709bfbdc24309974f06
Author: Jérémie Galarneau jeremie.galarn...@efficios.com
Date:   Wed Jan 28 16:52:28 2015 -0500

Fix: lock stream class after assigning stream id

Fixes a bug that was introduced by 2f100782 which made it possible
to set custom stream class IDs.

The stream class is frozen when a stream of its type is instanciated.
However, the trace or writer must still assign a unique ID to the stream
class if none were set prior. This modification moves the stream class
locking (freeze) after the ID assignment check.

Reported-by: Jiri Olsa jo...@redhat.com
Signed-off-by: Jérémie Galarneau jeremie.galarn...@efficios.com

Jérémie

 thanks,
 jirka


 ---
 diff --git a/tools/perf/util/data-convert-bt.c 
 b/tools/perf/util/data-convert-bt.c
 index bdb493febff6..0d75e1ed348c 100644
 --- a/tools/perf/util/data-convert-bt.c
 +++ b/tools/perf/util/data-convert-bt.c
 @@ -960,6 +960,11 @@ static int ctf_writer__init(struct ctf_writer *cw, const 
 char *path)
 goto err_cleanup;
 }

 +   if (bt_ctf_stream_class_set_id(stream_class, 0)) {
 +   pr(Failed to set CTF stream class ID.\n);
 +   goto err_cleanup;
 +   }
 +
 cw-stream_class = stream_class;

 /* CTF clock stream setup */



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC 2/2] perf: convert: fix duplicate field names and avoid reserved keywords.

2015-01-23 Thread Jérémie Galarneau
On Thu, Jan 22, 2015 at 8:57 PM, Wang Nan  wrote:
> On 2015/1/22 21:27, Jiri Olsa wrote:
>> On Thu, Jan 22, 2015 at 01:36:43PM +0800, Wang Nan wrote:
>>> (If Steven Rostedt accept the previous patch which introduce a priv
>>>  field to 'struct format_field', we can use a relative simple method
>>>  for name conversion. If not , perf must track name conversion by
>>>  itself.)
>>>
>>> Some parameters of syscall tracepoints named as 'nr', 'event', etc.
>>> When dealing with them, perf convert to ctf meets some problem:
>>>
>>>  1. If a parameter with name 'nr', it will duplicate syscall's
>>> common field 'nr'. One such syscall is io_submit().
>>>
>>>  2. If a parameter with name 'event', it is denied to be inserted
>>> because 'event' is a babeltrace keywork. One such syscall is
>>> epoll_ctl.
>>>
>>> This patch appends '_dupl_X' suffix to avoid problem 1, prepend a '_'
>>> prefix to avoid problem 2.
>>
>> I've got compilation error:
>>
>> util/data-convert-bt.c: In function ‘event_class_add_field’:
>> util/data-convert-bt.c:629:2: error: suggest parentheses around assignment 
>> used as truth value [-Werror=parentheses]
>>   while (t = bt_ctf_event_class_get_field_by_name(event_class, name)) {
>>
>> what's your gcc version? mine's caught that..
>>
>
> I also curious why you got so many Werror problems I'm not ever seen,
> until I found a '-w' in my gcc options, which is introduced by your commit
>
> 47810c1d429bc690e1f5e9467697538921962171: perf data: Disable Werror convert 
> object.
>
> I'll revert that commit in my tree.
>
>> [jolsa@krava perf]$ gcc --version
>> gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7)
>>
>> SNIP
>>
>>>
>>> +/* If dup < 0, add a prefix. Else, add _dupl_X suffix. */
>>> +static char *change_name(char *name, char *orig_name, int dup)
>>> +{
>>> +char *new_name = NULL;
>>> +size_t len;
>>> +
>>> +if (!name)
>>> +name = orig_name;
>>> +
>>> +if (dup >= 10)
>>> +goto out;
>>> +
>>> +if (dup < 0)
>>> +len = strlen(name) + sizeof("_");
>>> +else
>>> +len = strlen(orig_name) + sizeof("_dupl_X");
>>
>> if we allow for _dupl_10, should we use 'sizeof("_dupl_x")' ^^^ in here?
>>
>>> +
>>> +new_name = malloc(len);
>>> +if (!new_name)
>>> +goto out;
>>> +
>>> +if (dup < 0)
>>> +snprintf(new_name, len, "_%s", name);
>>> +else
>>> +snprintf(new_name, len, "%s_dupl_%d", orig_name, dup);
>>> +
>>> +out:
>>> +if (name != orig_name)
>>> +free(name);
>>> +return new_name;
>>
>> SNIP
>>
>>> +
>>> +name = field->name;
>>> +while (t = bt_ctf_event_class_get_field_by_name(event_class, name)) {
>>> +bt_ctf_field_type_put(t);
>>> +name = change_name(name, field->name, dup++);
>>> +if (!name) {
>>> +pr_err("Failed to create dup name for '%s'\n", 
>>> field->name);
>>> +return -1;
>>> +}
>>> +}
>>> +
>>> +ret = bt_ctf_event_class_add_field(event_class, type, name);
>>> +
>>> +/* if failed, we may hit a keywork. try again with a '_' prefix */
>>> +if (ret) {
>>> +name = change_name(name, field->name, -1);
>>> +if (!name) {
>>> +pr_err("Failed to alloc name for '_%s'\n", 
>>> field->name);
>>> +return -1;
>>> +}
>>> +ret = bt_ctf_event_class_add_field(event_class, type, name);
>>
>> so there's no other way on checking up with the blacklist right?
>>
>
> AFAIK there's no official method to check blacklist right now. Utilizing 
> existing
> functions to check blacklist is possible. For example, we can create a clock 
> using
> bt_ctf_clock_create() with the checked name and then free it. However, it is 
> hacky
> and I think you won't like it.

The prospect of seeing that code has convinced me to introduce
int bt_ctf_validate_identifier(const char *identifier);

commit 654c1444b546fd79b209288b93ed4e87d9bb8a2b
Author: Jérémie Galarneau 
Date:  

Re: [PATCH RFC 2/2] perf: convert: fix duplicate field names and avoid reserved keywords.

2015-01-23 Thread Jérémie Galarneau
On Thu, Jan 22, 2015 at 8:57 PM, Wang Nan wangn...@huawei.com wrote:
 On 2015/1/22 21:27, Jiri Olsa wrote:
 On Thu, Jan 22, 2015 at 01:36:43PM +0800, Wang Nan wrote:
 (If Steven Rostedt accept the previous patch which introduce a priv
  field to 'struct format_field', we can use a relative simple method
  for name conversion. If not , perf must track name conversion by
  itself.)

 Some parameters of syscall tracepoints named as 'nr', 'event', etc.
 When dealing with them, perf convert to ctf meets some problem:

  1. If a parameter with name 'nr', it will duplicate syscall's
 common field 'nr'. One such syscall is io_submit().

  2. If a parameter with name 'event', it is denied to be inserted
 because 'event' is a babeltrace keywork. One such syscall is
 epoll_ctl.

 This patch appends '_dupl_X' suffix to avoid problem 1, prepend a '_'
 prefix to avoid problem 2.

 I've got compilation error:

 util/data-convert-bt.c: In function ‘event_class_add_field’:
 util/data-convert-bt.c:629:2: error: suggest parentheses around assignment 
 used as truth value [-Werror=parentheses]
   while (t = bt_ctf_event_class_get_field_by_name(event_class, name)) {

 what's your gcc version? mine's caught that..


 I also curious why you got so many Werror problems I'm not ever seen,
 until I found a '-w' in my gcc options, which is introduced by your commit

 47810c1d429bc690e1f5e9467697538921962171: perf data: Disable Werror convert 
 object.

 I'll revert that commit in my tree.

 [jolsa@krava perf]$ gcc --version
 gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7)

 SNIP


 +/* If dup  0, add a prefix. Else, add _dupl_X suffix. */
 +static char *change_name(char *name, char *orig_name, int dup)
 +{
 +char *new_name = NULL;
 +size_t len;
 +
 +if (!name)
 +name = orig_name;
 +
 +if (dup = 10)
 +goto out;
 +
 +if (dup  0)
 +len = strlen(name) + sizeof(_);
 +else
 +len = strlen(orig_name) + sizeof(_dupl_X);

 if we allow for _dupl_10, should we use 'sizeof(_dupl_x)' ^^^ in here?

 +
 +new_name = malloc(len);
 +if (!new_name)
 +goto out;
 +
 +if (dup  0)
 +snprintf(new_name, len, _%s, name);
 +else
 +snprintf(new_name, len, %s_dupl_%d, orig_name, dup);
 +
 +out:
 +if (name != orig_name)
 +free(name);
 +return new_name;

 SNIP

 +
 +name = field-name;
 +while (t = bt_ctf_event_class_get_field_by_name(event_class, name)) {
 +bt_ctf_field_type_put(t);
 +name = change_name(name, field-name, dup++);
 +if (!name) {
 +pr_err(Failed to create dup name for '%s'\n, 
 field-name);
 +return -1;
 +}
 +}
 +
 +ret = bt_ctf_event_class_add_field(event_class, type, name);
 +
 +/* if failed, we may hit a keywork. try again with a '_' prefix */
 +if (ret) {
 +name = change_name(name, field-name, -1);
 +if (!name) {
 +pr_err(Failed to alloc name for '_%s'\n, 
 field-name);
 +return -1;
 +}
 +ret = bt_ctf_event_class_add_field(event_class, type, name);

 so there's no other way on checking up with the blacklist right?


 AFAIK there's no official method to check blacklist right now. Utilizing 
 existing
 functions to check blacklist is possible. For example, we can create a clock 
 using
 bt_ctf_clock_create() with the checked name and then free it. However, it is 
 hacky
 and I think you won't like it.

The prospect of seeing that code has convinced me to introduce
int bt_ctf_validate_identifier(const char *identifier);

commit 654c1444b546fd79b209288b93ed4e87d9bb8a2b
Author: Jérémie Galarneau jeremie.galarn...@efficios.com
Date:   Fri Jan 23 16:24:52 2015 -0500

Add utility function to validate CTF identifiers

Introduces bt_ctf_validate_identifier() which validates a given
identifier against the list of CTF reserved keywords.

This function may evolve to perform additional validity checks in
the future as the CTF specification moves forward.

Acked-by: Mathieu Desnoyers mathieu.desnoy...@efficios.com
Signed-off-by: Jérémie Galarneau jeremie.galarn...@efficios.com


Does that take care of the problem?

Jérémie


 I believe my solution should be acceptable before babeltrace export its
 validate_identifier() function to users. Jérémie Galarneau, do you have better
 idea on it?

 Thanks.

 thanks,
 jirka



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



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http

Re: [PATCH 1/2] perf: convert: fix duplicate field names and avoid reserved keywords.

2015-01-21 Thread Jérémie Galarneau
On Wed, Jan 21, 2015 at 8:38 PM, Wang Nan  wrote:
> On 2015/1/21 23:56, Jérémie Galarneau wrote:
>> On Wed, Jan 21, 2015 at 9:11 AM, Jiri Olsa  wrote:
>>> On Wed, Jan 21, 2015 at 11:23:54AM +0800, Wang Nan wrote:
>>>> Some parameters of syscall tracepoints named as 'nr', 'event', etc.
>>>> When dealing with them, perf convert to ctf meets some problem:
>>>>
>>>>  1. If a parameter with name 'nr', it will duplicate syscall's
>>>> common field 'nr'. One such syscall is io_submit().
>>>>
>>>>  2. If a parameter with name 'event', it is denied to be inserted
>>>> because 'event' is a babeltrace keywork. One such syscall is
>>>> epoll_ctl.
>>>
>>> hum, so this problem 2 is detectable only via bt_ctf_event_class_add_field 
>>> function?
>>>
>>> how big is the blaklist?
>>>
>>
>> The blacklist is defined by the CTF specification here [1].
>>
>> Jérémie
>>
>> [1] 
>> http://git.efficios.com/?p=ctf.git;a=blob;f=common-trace-format-specification.txt;h=abe4fb70fff7f17f6e8242f313fb74bff44cf89a;hb=HEAD#l1477
>
> Is there any possibility that the someone expand the list?
>

Good question. There is discussion around a v1.9 version of the CTF
spec going on at the moment (which should not affect the Babeltrace
API).

As far as I know, adding "__attribute__" has been discussed. CC'ing
Mathieu Desnoyer who may have other extensions in mind.

Jérémie

>>
>>> SNIP
>>>
>>>> +}
>>>> +
>>>>  static int add_tracepoint_fields_types(struct ctf_writer *cw,
>>>>  struct format_field *fields,
>>>>  struct bt_ctf_event_class 
>>>> *event_class)
>>>> @@ -577,6 +609,9 @@ static int add_tracepoint_fields_types(struct 
>>>> ctf_writer *cw,
>>>>   for (field = fields; field; field = field->next) {
>>>>   struct bt_ctf_field_type *type;
>>>>   unsigned long flags = field->flags;
>>>> + struct bt_ctf_field_type *f = NULL;
>>>> + char *name;
>>>> + int dup = 1;
>>>>
>>>>   pr2("  field '%s'\n", field->name);
>>>>
>>>> @@ -595,14 +630,36 @@ static int add_tracepoint_fields_types(struct 
>>>> ctf_writer *cw,
>>>>   if (flags & FIELD_IS_ARRAY)
>>>>   type = bt_ctf_field_type_array_create(type, 
>>>> field->arraylen);
>>>>
>>>> - ret = bt_ctf_event_class_add_field(event_class, type,
>>>> - field->name);
>>>> + /* Check name duplication */
>>>> + name = field->name;
>>>
>>> could you please put this in separated function like 'get_field_name(..)'
>>> so we dont polute this function even more
>>>
>>> name == get_field_name(...)
>>> if (!name)
>>> error path
>>>
>>>
>>> thanks,
>>> jirka
>>
>>
>>
>
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] perf: convert: fix duplicate field names and avoid reserved keywords.

2015-01-21 Thread Jérémie Galarneau
On Wed, Jan 21, 2015 at 9:11 AM, Jiri Olsa  wrote:
> On Wed, Jan 21, 2015 at 11:23:54AM +0800, Wang Nan wrote:
>> Some parameters of syscall tracepoints named as 'nr', 'event', etc.
>> When dealing with them, perf convert to ctf meets some problem:
>>
>>  1. If a parameter with name 'nr', it will duplicate syscall's
>> common field 'nr'. One such syscall is io_submit().
>>
>>  2. If a parameter with name 'event', it is denied to be inserted
>> because 'event' is a babeltrace keywork. One such syscall is
>> epoll_ctl.
>
> hum, so this problem 2 is detectable only via bt_ctf_event_class_add_field 
> function?
>
> how big is the blaklist?
>

The blacklist is defined by the CTF specification here [1].

Jérémie

[1] 
http://git.efficios.com/?p=ctf.git;a=blob;f=common-trace-format-specification.txt;h=abe4fb70fff7f17f6e8242f313fb74bff44cf89a;hb=HEAD#l1477

> SNIP
>
>> +}
>> +
>>  static int add_tracepoint_fields_types(struct ctf_writer *cw,
>>  struct format_field *fields,
>>  struct bt_ctf_event_class *event_class)
>> @@ -577,6 +609,9 @@ static int add_tracepoint_fields_types(struct ctf_writer 
>> *cw,
>>   for (field = fields; field; field = field->next) {
>>   struct bt_ctf_field_type *type;
>>   unsigned long flags = field->flags;
>> + struct bt_ctf_field_type *f = NULL;
>> + char *name;
>> + int dup = 1;
>>
>>   pr2("  field '%s'\n", field->name);
>>
>> @@ -595,14 +630,36 @@ static int add_tracepoint_fields_types(struct 
>> ctf_writer *cw,
>>   if (flags & FIELD_IS_ARRAY)
>>   type = bt_ctf_field_type_array_create(type, 
>> field->arraylen);
>>
>> - ret = bt_ctf_event_class_add_field(event_class, type,
>> - field->name);
>> + /* Check name duplication */
>> + name = field->name;
>
> could you please put this in separated function like 'get_field_name(..)'
> so we dont polute this function even more
>
> name == get_field_name(...)
> if (!name)
> error path
>
>
> thanks,
> jirka



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] perf: convert: fix duplicate field names and avoid reserved keywords.

2015-01-21 Thread Jérémie Galarneau
On Wed, Jan 21, 2015 at 9:11 AM, Jiri Olsa jo...@redhat.com wrote:
 On Wed, Jan 21, 2015 at 11:23:54AM +0800, Wang Nan wrote:
 Some parameters of syscall tracepoints named as 'nr', 'event', etc.
 When dealing with them, perf convert to ctf meets some problem:

  1. If a parameter with name 'nr', it will duplicate syscall's
 common field 'nr'. One such syscall is io_submit().

  2. If a parameter with name 'event', it is denied to be inserted
 because 'event' is a babeltrace keywork. One such syscall is
 epoll_ctl.

 hum, so this problem 2 is detectable only via bt_ctf_event_class_add_field 
 function?

 how big is the blaklist?


The blacklist is defined by the CTF specification here [1].

Jérémie

[1] 
http://git.efficios.com/?p=ctf.git;a=blob;f=common-trace-format-specification.txt;h=abe4fb70fff7f17f6e8242f313fb74bff44cf89a;hb=HEAD#l1477

 SNIP

 +}
 +
  static int add_tracepoint_fields_types(struct ctf_writer *cw,
  struct format_field *fields,
  struct bt_ctf_event_class *event_class)
 @@ -577,6 +609,9 @@ static int add_tracepoint_fields_types(struct ctf_writer 
 *cw,
   for (field = fields; field; field = field-next) {
   struct bt_ctf_field_type *type;
   unsigned long flags = field-flags;
 + struct bt_ctf_field_type *f = NULL;
 + char *name;
 + int dup = 1;

   pr2(  field '%s'\n, field-name);

 @@ -595,14 +630,36 @@ static int add_tracepoint_fields_types(struct 
 ctf_writer *cw,
   if (flags  FIELD_IS_ARRAY)
   type = bt_ctf_field_type_array_create(type, 
 field-arraylen);

 - ret = bt_ctf_event_class_add_field(event_class, type,
 - field-name);
 + /* Check name duplication */
 + name = field-name;

 could you please put this in separated function like 'get_field_name(..)'
 so we dont polute this function even more

 name == get_field_name(...)
 if (!name)
 error path


 thanks,
 jirka



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] perf: convert: fix duplicate field names and avoid reserved keywords.

2015-01-21 Thread Jérémie Galarneau
On Wed, Jan 21, 2015 at 8:38 PM, Wang Nan wangn...@huawei.com wrote:
 On 2015/1/21 23:56, Jérémie Galarneau wrote:
 On Wed, Jan 21, 2015 at 9:11 AM, Jiri Olsa jo...@redhat.com wrote:
 On Wed, Jan 21, 2015 at 11:23:54AM +0800, Wang Nan wrote:
 Some parameters of syscall tracepoints named as 'nr', 'event', etc.
 When dealing with them, perf convert to ctf meets some problem:

  1. If a parameter with name 'nr', it will duplicate syscall's
 common field 'nr'. One such syscall is io_submit().

  2. If a parameter with name 'event', it is denied to be inserted
 because 'event' is a babeltrace keywork. One such syscall is
 epoll_ctl.

 hum, so this problem 2 is detectable only via bt_ctf_event_class_add_field 
 function?

 how big is the blaklist?


 The blacklist is defined by the CTF specification here [1].

 Jérémie

 [1] 
 http://git.efficios.com/?p=ctf.git;a=blob;f=common-trace-format-specification.txt;h=abe4fb70fff7f17f6e8242f313fb74bff44cf89a;hb=HEAD#l1477

 Is there any possibility that the someone expand the list?


Good question. There is discussion around a v1.9 version of the CTF
spec going on at the moment (which should not affect the Babeltrace
API).

As far as I know, adding __attribute__ has been discussed. CC'ing
Mathieu Desnoyer who may have other extensions in mind.

Jérémie


 SNIP

 +}
 +
  static int add_tracepoint_fields_types(struct ctf_writer *cw,
  struct format_field *fields,
  struct bt_ctf_event_class 
 *event_class)
 @@ -577,6 +609,9 @@ static int add_tracepoint_fields_types(struct 
 ctf_writer *cw,
   for (field = fields; field; field = field-next) {
   struct bt_ctf_field_type *type;
   unsigned long flags = field-flags;
 + struct bt_ctf_field_type *f = NULL;
 + char *name;
 + int dup = 1;

   pr2(  field '%s'\n, field-name);

 @@ -595,14 +630,36 @@ static int add_tracepoint_fields_types(struct 
 ctf_writer *cw,
   if (flags  FIELD_IS_ARRAY)
   type = bt_ctf_field_type_array_create(type, 
 field-arraylen);

 - ret = bt_ctf_event_class_add_field(event_class, type,
 - field-name);
 + /* Check name duplication */
 + name = field-name;

 could you please put this in separated function like 'get_field_name(..)'
 so we dont polute this function even more

 name == get_field_name(...)
 if (!name)
 error path


 thanks,
 jirka








-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv3 0/8] perf tools: Add perf data CTF conversion

2015-01-16 Thread Jérémie Galarneau
 [23:32:20.165364686] (+0.00328) sched:sched_stat_runtime: { cpu_id
>>> = 0 }, { perf_ip = 0x810C8AE5, perf_tid = 5326, perf_pid = 5326,
>>> perf_id = 462610, perf_period = 11380, ...
>>>[23:32:20.165366067] (+0.01205) sched:sched_switch: { cpu_id = 0
>>> }, { perf_ip = 0x8172A110, perf_tid = 5326, perf_pid = 5326, perf_id
>>> = 462562, perf_period = 1, common_type ...
>>>[23:32:20.165723312] (+0.01479) sched:sched_stat_runtime: { cpu_id
>>> = 2 }, { perf_ip = 0x810C8AE5, perf_tid = 11821, perf_pid = 11821,
>>> perf_id = 462612, perf_period = 1000265, ...
>>>[23:32:20.065282391] (+?.?) raw_syscalls:sys_enter: { cpu_id =
>>> 1 }, { perf_ip = 0x810230AF, perf_tid = 26155, perf_pid = 26155,
>>> perf_id = 462635, perf_period = 1, ...
>>>[23:32:20.065286422] (+0.04031) raw_syscalls:sys_exit: { cpu_id =
>>> 1 }, { perf_ip = 0x810231D8, perf_tid = 26155, perf_pid = 26155,
>>> perf_id = 462639, perf_period = 1, ...
>>>
>>> - Or run tracecompass and open the CTF data ;-)
>>>
>>> Changes are also reachable in here:
>>>git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
>>>perf/core_ctf_convert
>>>
>>> thanks,
>>> jirka
>>>
>>> [1] Common Trace Format - http://www.efficios.com/ctf
>>> [2] babeltrace - http://www.efficios.com/babeltrace
>>> [3] Trace compass -
>>> http://projects.eclipse.org/projects/tools.tracecompass
>>> [4] screenshots - http://people.redhat.com/~jolsa/tracecompass-perf/
>>>
>>>
>>> Cc: Arnaldo Carvalho de Melo 
>>> Cc: David Ahern 
>>> Cc: Dominique Toupin 
>>> Cc: Frederic Weisbecker 
>>> Cc: Jeremie Galarneau 
>>> Cc: Jiri Olsa 
>>> Cc: Mathieu Desnoyers 
>>> Cc: Namhyung Kim 
>>> Cc: Paul Mackerras 
>>> Cc: Peter Zijlstra 
>>> Cc: Sebastian Andrzej Siewior 
>>> Cc: Tom Zanussi 
>>> ---
>>> Jiri Olsa (5):
>>>perf tools: Add feature check for libbabeltrace
>>>perf tools: Add new perf data command
>>>perf data: Add perf data to CTF conversion support
>>>perf data: Enable stream flush within processing
>>>perf data: Add support for setting ordered_events queue size
>>>
>>> Sebastian Andrzej Siewior (3):
>>>perf data: Add a 'perf' prefix to the generic fields
>>>perf data: Add tracepoint events fields CTF conversion support
>>>perf data: Switch to multiple cpu stream files
>>>
>>>   tools/perf/Documentation/perf-data.txt|   40 ++
>>>   tools/perf/Documentation/perf.txt |7 +-
>>>   tools/perf/Makefile.perf      |    9 +-
>>>   tools/perf/builtin-data.c |  119 ++
>>>   tools/perf/builtin.h  |1 +
>>>   tools/perf/command-list.txt   |1 +
>>>   tools/perf/config/Makefile|   24 ++
>>>   tools/perf/config/feature-checks/Makefile |8 +-
>>>   tools/perf/config/feature-checks/test-all.c   |5 +
>>>   tools/perf/config/feature-checks/test-libbabeltrace.c |8 +
>>>   tools/perf/perf.c |1 +
>>>   tools/perf/util/data-convert-bt.c | 1057
>>> +
>>>   tools/perf/util/data-convert-bt.h |8 +
>>>   tools/perf/util/debug.c   |2 +
>>>   tools/perf/util/debug.h   |1 +
>>>   15 files changed, 1287 insertions(+), 4 deletions(-)
>>>   create mode 100644 tools/perf/Documentation/perf-data.txt
>>>   create mode 100644 tools/perf/builtin-data.c
>>>   create mode 100644
>>> tools/perf/config/feature-checks/test-libbabeltrace.c
>>>   create mode 100644 tools/perf/util/data-convert-bt.c
>>>   create mode 100644 tools/perf/util/data-convert-bt.h
>>
>>
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv3 0/8] perf tools: Add perf data CTF conversion

2015-01-16 Thread Jérémie Galarneau
 and open the CTF data ;-)

 Changes are also reachable in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/core_ctf_convert

 thanks,
 jirka

 [1] Common Trace Format - http://www.efficios.com/ctf
 [2] babeltrace - http://www.efficios.com/babeltrace
 [3] Trace compass -
 http://projects.eclipse.org/projects/tools.tracecompass
 [4] screenshots - http://people.redhat.com/~jolsa/tracecompass-perf/


 Cc: Arnaldo Carvalho de Melo a...@redhat.com
 Cc: David Ahern dsah...@gmail.com
 Cc: Dominique Toupin dominique.tou...@ericsson.com
 Cc: Frederic Weisbecker fweis...@gmail.com
 Cc: Jeremie Galarneau jga...@efficios.com
 Cc: Jiri Olsa jo...@kernel.org
 Cc: Mathieu Desnoyers mathieu.desnoy...@efficios.com
 Cc: Namhyung Kim namhy...@gmail.com
 Cc: Paul Mackerras pau...@samba.org
 Cc: Peter Zijlstra pet...@infradead.org
 Cc: Sebastian Andrzej Siewior bige...@linutronix.de
 Cc: Tom Zanussi tzanu...@gmail.com
 ---
 Jiri Olsa (5):
perf tools: Add feature check for libbabeltrace
perf tools: Add new perf data command
perf data: Add perf data to CTF conversion support
perf data: Enable stream flush within processing
perf data: Add support for setting ordered_events queue size

 Sebastian Andrzej Siewior (3):
perf data: Add a 'perf' prefix to the generic fields
perf data: Add tracepoint events fields CTF conversion support
perf data: Switch to multiple cpu stream files

   tools/perf/Documentation/perf-data.txt|   40 ++
   tools/perf/Documentation/perf.txt |7 +-
   tools/perf/Makefile.perf  |9 +-
   tools/perf/builtin-data.c |  119 ++
   tools/perf/builtin.h  |1 +
   tools/perf/command-list.txt   |1 +
   tools/perf/config/Makefile|   24 ++
   tools/perf/config/feature-checks/Makefile |8 +-
   tools/perf/config/feature-checks/test-all.c   |5 +
   tools/perf/config/feature-checks/test-libbabeltrace.c |8 +
   tools/perf/perf.c |1 +
   tools/perf/util/data-convert-bt.c | 1057
 +
   tools/perf/util/data-convert-bt.h |8 +
   tools/perf/util/debug.c   |2 +
   tools/perf/util/debug.h   |1 +
   15 files changed, 1287 insertions(+), 4 deletions(-)
   create mode 100644 tools/perf/Documentation/perf-data.txt
   create mode 100644 tools/perf/builtin-data.c
   create mode 100644
 tools/perf/config/feature-checks/test-libbabeltrace.c
   create mode 100644 tools/perf/util/data-convert-bt.c
   create mode 100644 tools/perf/util/data-convert-bt.h






-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Support for Perf CTF traces now in master (was Re: FW: [RFC 0/5] perf tools: Add perf data CTF conversion)

2014-12-01 Thread Jérémie Galarneau
struct bt_ctf_field *pkt_ctx;
> -   struct bt_ctf_field *cpu_field;
> -   struct bt_ctf_stream *stream;
> -   u32 i = sample->cpu;
> -
> -   stream = bt_ctf_writer_create_stream(cw->writer, 
> cw->stream_class);
> -   if (!stream)
> -   return -1;
> -
> -   pkt_ctx = bt_ctf_stream_get_packet_context(stream);
> -   if (!pkt_ctx) {
> -   pr_err("Failed to obtain packet context\n");
> -   return -1;
> -   }
> -
> -   cpu_field = bt_ctf_field_structure_get_field(pkt_ctx, 
> "cpu_id");
> -   bt_ctf_field_put(pkt_ctx);
> -   if (!cpu_field) {
> -   pr_err("Failed to obtain cpu field\n");
> -   return -1;
> -   }
> +   if (!cw->stream[cpu] && create_stream(cw, cpu))
> +   return -1;
>
> -   ret = bt_ctf_field_unsigned_integer_set_value(cpu_field, i);
> -   if (ret) {
> -   pr_err("Failed to update CPU number\n");
> -   return -1;
> -   }
> -   bt_ctf_field_put(cpu_field);
> +   if (is_flush_needed(cw->stream[cpu]))
> +   flush_stream(cw, cpu);
>
> -   cw->stream[i] = stream;
> -   }
> -
> -   bt_ctf_stream_append_event(cw->stream[cpu], event);
> +   cw->stream[cpu]->count++;
> +   bt_ctf_stream_append_event(cw->stream[cpu]->stream, event);
> bt_ctf_event_put(event);
> return 0;
>  }
> @@ -745,8 +791,12 @@ static void ctf_writer__cleanup(struct ctf_writer *cw)
> ctf_writer__cleanup_data(cw);
>
> bt_ctf_clock_put(cw->clock);
> -   for (i = 0; i < MAX_CPUS; i++)
> -   bt_ctf_stream_put(cw->stream[i]);
> +   for (i = 0; i < MAX_CPUS; i++) {
> +   if (cw->stream[i]) {
> +   bt_ctf_stream_put(cw->stream[i]->stream);
> +   free(cw->stream[i]);
> +   }
> +   }
> bt_ctf_stream_class_put(cw->stream_class);
> bt_ctf_writer_put(cw->writer);
>
> @@ -862,6 +912,9 @@ int bt_convert__perf2ctf(const char *input, const char 
> *path)
> if (!session)
> goto free_writer;
>
> +   ordered_events__set_alloc_size(>ordered_events,
> +  100*1024*1024);
> +
>     /* CTF writer env/clock setup  */
> if (ctf_writer__setup_env(cw, session))
> goto free_session;
> @@ -872,15 +925,10 @@ int bt_convert__perf2ctf(const char *input, const char 
> *path)
>
> err = perf_session__process_events(session, );
> if (!err) {
> -   int i;
> +   int cpu;
>
> -   for (i = 0; i < MAX_CPUS; i++) {
> -   if (cw->stream[i]) {
> -   err = bt_ctf_stream_flush(cw->stream[i]);
> -   if (err)
> -   pr_err("CTF stream %d flush 
> failed\n", i);
> -   }
> -   }
> +   for (cpu = 0; cpu < MAX_CPUS; cpu++)
> +   flush_stream(cw, cpu);
> }
>
> fprintf(stderr,



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Support for Perf CTF traces now in master (was Re: FW: [RFC 0/5] perf tools: Add perf data CTF conversion)

2014-12-01 Thread Jérémie Galarneau
) {
 -   pr_err(Failed to obtain cpu field\n);
 -   return -1;
 -   }
 +   if (!cw-stream[cpu]  create_stream(cw, cpu))
 +   return -1;

 -   ret = bt_ctf_field_unsigned_integer_set_value(cpu_field, i);
 -   if (ret) {
 -   pr_err(Failed to update CPU number\n);
 -   return -1;
 -   }
 -   bt_ctf_field_put(cpu_field);
 +   if (is_flush_needed(cw-stream[cpu]))
 +   flush_stream(cw, cpu);

 -   cw-stream[i] = stream;
 -   }
 -
 -   bt_ctf_stream_append_event(cw-stream[cpu], event);
 +   cw-stream[cpu]-count++;
 +   bt_ctf_stream_append_event(cw-stream[cpu]-stream, event);
 bt_ctf_event_put(event);
 return 0;
  }
 @@ -745,8 +791,12 @@ static void ctf_writer__cleanup(struct ctf_writer *cw)
 ctf_writer__cleanup_data(cw);

 bt_ctf_clock_put(cw-clock);
 -   for (i = 0; i  MAX_CPUS; i++)
 -   bt_ctf_stream_put(cw-stream[i]);
 +   for (i = 0; i  MAX_CPUS; i++) {
 +   if (cw-stream[i]) {
 +   bt_ctf_stream_put(cw-stream[i]-stream);
 +   free(cw-stream[i]);
 +   }
 +   }
 bt_ctf_stream_class_put(cw-stream_class);
 bt_ctf_writer_put(cw-writer);

 @@ -862,6 +912,9 @@ int bt_convert__perf2ctf(const char *input, const char 
 *path)
 if (!session)
 goto free_writer;

 +   ordered_events__set_alloc_size(session-ordered_events,
 +  100*1024*1024);
 +
 /* CTF writer env/clock setup  */
 if (ctf_writer__setup_env(cw, session))
 goto free_session;
 @@ -872,15 +925,10 @@ int bt_convert__perf2ctf(const char *input, const char 
 *path)

 err = perf_session__process_events(session, c.tool);
 if (!err) {
 -   int i;
 +   int cpu;

 -   for (i = 0; i  MAX_CPUS; i++) {
 -   if (cw-stream[i]) {
 -   err = bt_ctf_stream_flush(cw-stream[i]);
 -   if (err)
 -   pr_err(CTF stream %d flush 
 failed\n, i);
 -   }
 -   }
 +   for (cpu = 0; cpu  MAX_CPUS; cpu++)
 +   flush_stream(cw, cpu);
 }

 fprintf(stderr,



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] btrfs: fix tracepoint namespacing

2014-10-17 Thread Jérémie Galarneau
Some btrfs tracepoints are not properly namespaced. The
tracepoint names should be prefixed with the subsystem's name
as suggested in tracepoint.h

Cc: Chris Mason 
Cc: Steven Rostedt 
Signed-off-by: Jérémie Galarneau 
---
 fs/btrfs/delayed-ref.c   |  6 +++---
 fs/btrfs/extent-tree.c   |  8 
 fs/btrfs/extent_io.c |  6 +++---
 include/trace/events/btrfs.h | 20 ++--
 4 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index 6d16bea..e075ba9 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -609,7 +609,7 @@ add_delayed_ref_head(struct btrfs_fs_info *fs_info,
spin_lock_init(_ref->lock);
mutex_init(_ref->mutex);
 
-   trace_add_delayed_ref_head(ref, head_ref, action);
+   trace_btrfs_add_delayed_ref_head(ref, head_ref, action);
 
existing = htree_insert(_refs->href_root,
_ref->href_node);
@@ -673,7 +673,7 @@ add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
ref->type = BTRFS_TREE_BLOCK_REF_KEY;
full_ref->level = level;
 
-   trace_add_delayed_tree_ref(ref, full_ref, action);
+   trace_btrfs_add_delayed_tree_ref(ref, full_ref, action);
 
spin_lock(_ref->lock);
existing = tree_insert(_ref->ref_root, >rb_node);
@@ -738,7 +738,7 @@ add_delayed_data_ref(struct btrfs_fs_info *fs_info,
full_ref->objectid = owner;
full_ref->offset = offset;
 
-   trace_add_delayed_data_ref(ref, full_ref, action);
+   trace_btrfs_add_delayed_data_ref(ref, full_ref, action);
 
spin_lock(_ref->lock);
existing = tree_insert(_ref->ref_root, >rb_node);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index d565895..8ca6e75 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2086,7 +2086,7 @@ static int run_delayed_data_ref(struct btrfs_trans_handle 
*trans,
ins.type = BTRFS_EXTENT_ITEM_KEY;
 
ref = btrfs_delayed_node_to_data_ref(node);
-   trace_run_delayed_data_ref(node, ref, node->action);
+   trace_btrfs_run_delayed_data_ref(node, ref, node->action);
 
if (node->type == BTRFS_SHARED_DATA_REF_KEY)
parent = ref->parent;
@@ -2243,7 +2243,7 @@ static int run_delayed_tree_ref(struct btrfs_trans_handle 
*trans,
 SKINNY_METADATA);
 
ref = btrfs_delayed_node_to_tree_ref(node);
-   trace_run_delayed_tree_ref(node, ref, node->action);
+   trace_btrfs_run_delayed_tree_ref(node, ref, node->action);
 
if (node->type == BTRFS_SHARED_BLOCK_REF_KEY)
parent = ref->parent;
@@ -2309,7 +2309,7 @@ static int run_one_delayed_ref(struct btrfs_trans_handle 
*trans,
 */
BUG_ON(extent_op);
head = btrfs_delayed_node_to_head(node);
-   trace_run_delayed_ref_head(node, head, node->action);
+   trace_btrfs_run_delayed_ref_head(node, head, node->action);
 
if (insert_reserved) {
btrfs_pin_extent(root, node->bytenr,
@@ -6490,7 +6490,7 @@ static noinline int find_free_extent(struct btrfs_root 
*orig_root,
ins->objectid = 0;
ins->offset = 0;
 
-   trace_find_free_extent(orig_root, num_bytes, empty_size, flags);
+   trace_btrfs_find_free_extent(orig_root, num_bytes, empty_size, flags);
 
space_info = __find_space_info(root->fs_info, flags);
if (!space_info) {
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index bf3f424..16d82c6 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -218,7 +218,7 @@ static struct extent_state *alloc_extent_state(gfp_t mask)
btrfs_leak_debug_add(>leak_list, );
atomic_set(>refs, 1);
init_waitqueue_head(>wq);
-   trace_alloc_extent_state(state, mask, _RET_IP_);
+   trace_btrfs_alloc_extent_state(state, mask, _RET_IP_);
return state;
 }
 
@@ -229,7 +229,7 @@ void free_extent_state(struct extent_state *state)
if (atomic_dec_and_test(>refs)) {
WARN_ON(extent_state_in_tree(state));
btrfs_leak_debug_del(>leak_list);
-   trace_free_extent_state(state, _RET_IP_);
+   trace_btrfs_free_extent_state(state, _RET_IP_);
kmem_cache_free(extent_state_cache, state);
}
 }
@@ -3461,7 +3461,7 @@ static int __extent_writepage(struct page *page, struct 
writeback_control *wbc,
else
write_flags = WRITE;
 
-   trace___extent_writepage(page, inode, wbc);
+   trace_btrfs__extent_writepage(page, inode, wbc);
 
WARN_ON(!PageLocked(page));
 
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h
index 1faecea..01c718c 100644
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events/btrfs.h

[PATCH] btrfs: fix tracepoint namespacing

2014-10-17 Thread Jérémie Galarneau
Some btrfs tracepoints are not properly namespaced. The
tracepoint names should be prefixed with the subsystem's name
as suggested in tracepoint.h

Cc: Chris Mason c...@fb.com
Cc: Steven Rostedt rost...@goodmis.org
Signed-off-by: Jérémie Galarneau jeremie.galarn...@efficios.com
---
 fs/btrfs/delayed-ref.c   |  6 +++---
 fs/btrfs/extent-tree.c   |  8 
 fs/btrfs/extent_io.c |  6 +++---
 include/trace/events/btrfs.h | 20 ++--
 4 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index 6d16bea..e075ba9 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -609,7 +609,7 @@ add_delayed_ref_head(struct btrfs_fs_info *fs_info,
spin_lock_init(head_ref-lock);
mutex_init(head_ref-mutex);
 
-   trace_add_delayed_ref_head(ref, head_ref, action);
+   trace_btrfs_add_delayed_ref_head(ref, head_ref, action);
 
existing = htree_insert(delayed_refs-href_root,
head_ref-href_node);
@@ -673,7 +673,7 @@ add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
ref-type = BTRFS_TREE_BLOCK_REF_KEY;
full_ref-level = level;
 
-   trace_add_delayed_tree_ref(ref, full_ref, action);
+   trace_btrfs_add_delayed_tree_ref(ref, full_ref, action);
 
spin_lock(head_ref-lock);
existing = tree_insert(head_ref-ref_root, ref-rb_node);
@@ -738,7 +738,7 @@ add_delayed_data_ref(struct btrfs_fs_info *fs_info,
full_ref-objectid = owner;
full_ref-offset = offset;
 
-   trace_add_delayed_data_ref(ref, full_ref, action);
+   trace_btrfs_add_delayed_data_ref(ref, full_ref, action);
 
spin_lock(head_ref-lock);
existing = tree_insert(head_ref-ref_root, ref-rb_node);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index d565895..8ca6e75 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2086,7 +2086,7 @@ static int run_delayed_data_ref(struct btrfs_trans_handle 
*trans,
ins.type = BTRFS_EXTENT_ITEM_KEY;
 
ref = btrfs_delayed_node_to_data_ref(node);
-   trace_run_delayed_data_ref(node, ref, node-action);
+   trace_btrfs_run_delayed_data_ref(node, ref, node-action);
 
if (node-type == BTRFS_SHARED_DATA_REF_KEY)
parent = ref-parent;
@@ -2243,7 +2243,7 @@ static int run_delayed_tree_ref(struct btrfs_trans_handle 
*trans,
 SKINNY_METADATA);
 
ref = btrfs_delayed_node_to_tree_ref(node);
-   trace_run_delayed_tree_ref(node, ref, node-action);
+   trace_btrfs_run_delayed_tree_ref(node, ref, node-action);
 
if (node-type == BTRFS_SHARED_BLOCK_REF_KEY)
parent = ref-parent;
@@ -2309,7 +2309,7 @@ static int run_one_delayed_ref(struct btrfs_trans_handle 
*trans,
 */
BUG_ON(extent_op);
head = btrfs_delayed_node_to_head(node);
-   trace_run_delayed_ref_head(node, head, node-action);
+   trace_btrfs_run_delayed_ref_head(node, head, node-action);
 
if (insert_reserved) {
btrfs_pin_extent(root, node-bytenr,
@@ -6490,7 +6490,7 @@ static noinline int find_free_extent(struct btrfs_root 
*orig_root,
ins-objectid = 0;
ins-offset = 0;
 
-   trace_find_free_extent(orig_root, num_bytes, empty_size, flags);
+   trace_btrfs_find_free_extent(orig_root, num_bytes, empty_size, flags);
 
space_info = __find_space_info(root-fs_info, flags);
if (!space_info) {
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index bf3f424..16d82c6 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -218,7 +218,7 @@ static struct extent_state *alloc_extent_state(gfp_t mask)
btrfs_leak_debug_add(state-leak_list, states);
atomic_set(state-refs, 1);
init_waitqueue_head(state-wq);
-   trace_alloc_extent_state(state, mask, _RET_IP_);
+   trace_btrfs_alloc_extent_state(state, mask, _RET_IP_);
return state;
 }
 
@@ -229,7 +229,7 @@ void free_extent_state(struct extent_state *state)
if (atomic_dec_and_test(state-refs)) {
WARN_ON(extent_state_in_tree(state));
btrfs_leak_debug_del(state-leak_list);
-   trace_free_extent_state(state, _RET_IP_);
+   trace_btrfs_free_extent_state(state, _RET_IP_);
kmem_cache_free(extent_state_cache, state);
}
 }
@@ -3461,7 +3461,7 @@ static int __extent_writepage(struct page *page, struct 
writeback_control *wbc,
else
write_flags = WRITE;
 
-   trace___extent_writepage(page, inode, wbc);
+   trace_btrfs__extent_writepage(page, inode, wbc);
 
WARN_ON(!PageLocked(page));
 
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h
index 1faecea..01c718c 100644
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events

Re: [lttng-dev] [RFC] perf to ctf converter

2014-08-05 Thread Jérémie Galarneau
On Fri, Jul 18, 2014 at 8:34 AM, Sebastian Andrzej Siewior
 wrote:
> On 07/14/2014 04:15 PM, Jiri Olsa wrote:
>>> for more data while reading the "events" traces. The latter will be
>>> probably replaced by https://lkml.org/lkml/2014/4/3/217.
>>> Babeltrace needs only
>>> "ctf-writer: Add support for the cpu_id field"
>>> https://www.mail-archive.com/lttng-dev@lists.lttng.org/msg06057.html
>>
>> any idea when this one will land in babeltrace git tree?
>
> Need to re-do them the way they asked. Could take some time. However I
> wanted first to make sure it make sense to continue that approach.
>

FYI, I have made the changes and they are now upstream in Babeltrace as of

commit 12c8a1a3121ed7125e8758065c44658d8eda1333
Author: Jérémie Galarneau 
Date:   Tue Jul 29 16:51:51 2014 -0400

Add stream packet header accessors

Stream packet contexts may now be modified to contain custom
fields. The events_discarded field is now handled like a generic
packet context field.

Signed-off-by: Jérémie Galarneau 


Regards,
Jérémie

>>>
>>> for the assignment of the CPU number.
>>>
>>> The pickle step is nice because I see all type of events before I
>>> start writing the CTF trace and can create the necessary objects. On
>>> the other hand it eats a lot of memory for huge traces so I will try to
>>> replace it with something that saves the data in a streaming like
>>> fashion.
>>> The other limitation is that babeltrace doesn't seem to work with
>>> python2 while perf doesn't compile against python3.
>>>
>>> What I haven't figured out yet is how to pass to the meta environment
>>> informations that is displayed by "perf script --header-only -I" and if
>>> that information is really important. Probably an optional python
>>> callback will do it.
>>>
>>> The required steps:
>>> |   perf record -e raw_syscalls:* w
>>> |   perf script -s ./to-pickle.py
>>> |   ./ctf_writer
>>
>> I made similar effort in C:
>>
>> ---
>> I made some *VERY* early perf convert example, mostly to try the ctf-writer
>> interface.. you can check in here:
>>   
>> https://git.kernel.org/cgit/linux/kernel/git/jolsa/perf.git/log/?h=perf/ctf_2
>
> Let me try it, maybe I can migrate my effort into one code basis.
>
>> It's able to convert single event (HW type) perf.data file into CTF data,
>> by adding just one integer field "period" and single stream, like:
>>
>>   [jolsa@krava perf]$ LD_LIBRARY_PATH=/opt/libbabeltrace/lib/ ./perf data 
>> convert --to-ctf=./ctf-data
>>   ...
>>   [jolsa@krava babeltrace]$ /opt/libbabeltrace/bin/babeltrace 
>> /home/jolsa/kernel.org/linux-perf/tools/perf/ctf-data
>>   [08:14:45.814456098] (+?.?) cycles: { }, { period = 1 }
>>   [08:14:45.814459237] (+0.03139) cycles: { }, { period = 1 }
>>   [08:14:45.814460684] (+0.01447) cycles: { }, { period = 9 }
>>   [08:14:45.814462073] (+0.01389) cycles: { }, { period = 182 }
>>   [08:14:45.814463491] (+0.01418) cycles: { }, { period = 4263 }
>>   [08:14:45.814465874] (+0.02383) cycles: { }, { period = 97878 }
>>   [08:14:45.814506385] (+0.40511) cycles: { }, { period = 1365965 }
>>   [08:14:45.815056528] (+0.000550143) cycles: { }, { period = 2250012 }
>> ---
>>
>> the goals for me is to have a convert tool, like in above example
>> perf data command and support in perf record/report to directl
>> write/read ctf data
>>
>> Using python for this seems nice.. I'm not experienced python coder,
>> so just small comments/questions
>
> python looked nice because I saw libraries / interfaces on both sides.
>
>> SNIP
>>
>>> +list_type_h_uint64 = [ "addr" ]
>>> +
>>> +int32_type = CTFWriter.IntegerFieldDeclaration(32)
>>> +int32_type.signed = True
>>> +
>>> +uint64_type = CTFWriter.IntegerFieldDeclaration(64)
>>> +uint64_type.signed = False
>>> +
>>> +hex_uint64_type = CTFWriter.IntegerFieldDeclaration(64)
>>> +hex_uint64_type.signed = False
>>> +hex_uint64_type.base = 16
>>> +
>>> +string_type = CTFWriter.StringFieldDeclaration()
>>> +
>>> +events = {}
>>> +last_cpu = -1
>>> +
>>> +list_ev_entry_ignore = [ "common_s", "common_ns", "common_cpu" ]
>>> +
>>> +# First create all possible event class-es
>>
>> this first iteration could be handled in the to-pickle step,
>> which could 

Re: [lttng-dev] [RFC] perf to ctf converter

2014-08-05 Thread Jérémie Galarneau
On Fri, Jul 18, 2014 at 8:34 AM, Sebastian Andrzej Siewior
bige...@linutronix.de wrote:
 On 07/14/2014 04:15 PM, Jiri Olsa wrote:
 for more data while reading the events traces. The latter will be
 probably replaced by https://lkml.org/lkml/2014/4/3/217.
 Babeltrace needs only
 ctf-writer: Add support for the cpu_id field
 https://www.mail-archive.com/lttng-dev@lists.lttng.org/msg06057.html

 any idea when this one will land in babeltrace git tree?

 Need to re-do them the way they asked. Could take some time. However I
 wanted first to make sure it make sense to continue that approach.


FYI, I have made the changes and they are now upstream in Babeltrace as of

commit 12c8a1a3121ed7125e8758065c44658d8eda1333
Author: Jérémie Galarneau jeremie.galarn...@efficios.com
Date:   Tue Jul 29 16:51:51 2014 -0400

Add stream packet header accessors

Stream packet contexts may now be modified to contain custom
fields. The events_discarded field is now handled like a generic
packet context field.

Signed-off-by: Jérémie Galarneau jeremie.galarn...@efficios.com


Regards,
Jérémie


 for the assignment of the CPU number.

 The pickle step is nice because I see all type of events before I
 start writing the CTF trace and can create the necessary objects. On
 the other hand it eats a lot of memory for huge traces so I will try to
 replace it with something that saves the data in a streaming like
 fashion.
 The other limitation is that babeltrace doesn't seem to work with
 python2 while perf doesn't compile against python3.

 What I haven't figured out yet is how to pass to the meta environment
 informations that is displayed by perf script --header-only -I and if
 that information is really important. Probably an optional python
 callback will do it.

 The required steps:
 |   perf record -e raw_syscalls:* w
 |   perf script -s ./to-pickle.py
 |   ./ctf_writer

 I made similar effort in C:

 ---
 I made some *VERY* early perf convert example, mostly to try the ctf-writer
 interface.. you can check in here:
   
 https://git.kernel.org/cgit/linux/kernel/git/jolsa/perf.git/log/?h=perf/ctf_2

 Let me try it, maybe I can migrate my effort into one code basis.

 It's able to convert single event (HW type) perf.data file into CTF data,
 by adding just one integer field period and single stream, like:

   [jolsa@krava perf]$ LD_LIBRARY_PATH=/opt/libbabeltrace/lib/ ./perf data 
 convert --to-ctf=./ctf-data
   ...
   [jolsa@krava babeltrace]$ /opt/libbabeltrace/bin/babeltrace 
 /home/jolsa/kernel.org/linux-perf/tools/perf/ctf-data
   [08:14:45.814456098] (+?.?) cycles: { }, { period = 1 }
   [08:14:45.814459237] (+0.03139) cycles: { }, { period = 1 }
   [08:14:45.814460684] (+0.01447) cycles: { }, { period = 9 }
   [08:14:45.814462073] (+0.01389) cycles: { }, { period = 182 }
   [08:14:45.814463491] (+0.01418) cycles: { }, { period = 4263 }
   [08:14:45.814465874] (+0.02383) cycles: { }, { period = 97878 }
   [08:14:45.814506385] (+0.40511) cycles: { }, { period = 1365965 }
   [08:14:45.815056528] (+0.000550143) cycles: { }, { period = 2250012 }
 ---

 the goals for me is to have a convert tool, like in above example
 perf data command and support in perf record/report to directl
 write/read ctf data

 Using python for this seems nice.. I'm not experienced python coder,
 so just small comments/questions

 python looked nice because I saw libraries / interfaces on both sides.

 SNIP

 +list_type_h_uint64 = [ addr ]
 +
 +int32_type = CTFWriter.IntegerFieldDeclaration(32)
 +int32_type.signed = True
 +
 +uint64_type = CTFWriter.IntegerFieldDeclaration(64)
 +uint64_type.signed = False
 +
 +hex_uint64_type = CTFWriter.IntegerFieldDeclaration(64)
 +hex_uint64_type.signed = False
 +hex_uint64_type.base = 16
 +
 +string_type = CTFWriter.StringFieldDeclaration()
 +
 +events = {}
 +last_cpu = -1
 +
 +list_ev_entry_ignore = [ common_s, common_ns, common_cpu ]
 +
 +# First create all possible event class-es

 this first iteration could be handled in the to-pickle step,
 which could gather events description and store/pickle it
 before the trace data

 yes.

 +for entry in trace:
 +event_name = entry[0]
 +event_record = entry[1]
 +
 +try:
 +event_class = events[event_name]
 +except:
 +event_class = CTFWriter.EventClass(event_name);
 +for ev_entry in sorted(event_record):
 +if ev_entry in list_ev_entry_ignore:
 +continue
 +val = event_record[ev_entry]
 +if isinstance(val, int):
 +if ev_entry in list_type_h_uint64:
 +event_class.add_field(hex_uint64_type, ev_entry)
 +else:
 +event_class.add_field(int32_type, ev_entry)
 +elif isinstance(val, str):
 +event_class.add_field(string_type, ev_entry)


 SNIP

 +
 +def process_event(event_fields_dict):
 +entry = []
 +entry.append(str