Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH 0/6] perf ctf: Convert comm, fork and exit events to CTF

13 views
Skip to first unread message

Wang Nan

unread,
Jun 23, 2016, 5:20:05 AM6/23/16
to
After converting perf.data to CTF, we lost pid-tid-comm mapping. Which
makes inconvience. For example, in perf script output we know which
process issue an event like this:

compiz 19361 [001] 3275709.313929: raw_syscalls:sys_exit: NR 7 = 0

After converting to CTF, we only get this:

[3275709.313929985] (+0.110646118) raw_syscalls:sys_exit: { cpu_id = 1 }, { perf_ip = 0xFFFFFFFF8107B2E8, perf_tid = 19361, perf_pid = 19361, perf_id = 18920, perf_period = 1, common_type = 16, common_flags = 0, common_preempt_count = 1, common_pid = 19361, id = 7, ret = 0 }

Currently, if we want to find the name and parent of a process, we
have to collect 'sched:sched_switch' event.

This patch set add a '--all' option to 'perf convert', converts comm,
fork and exit events to CTF output. CTF user now can track the mapping
by their own.

Wang Nan (6):
perf ctf: Add value_set_string() helper
perf ctf: Pass convert options through structure
perf ctf: Add non_sample option
perf ctf: Generate comm event to CTF output
perf ctf: Add '--all' option for 'perf data convert'
perf ctf: Generate fork and exit events to CTF output

tools/perf/Documentation/perf-data.txt | 5 +-
tools/perf/builtin-data.c | 11 +-
tools/perf/util/data-convert-bt.c | 185 ++++++++++++++++++++++++++++++++-
tools/perf/util/data-convert-bt.h | 4 +-
tools/perf/util/data-convert.h | 9 ++
5 files changed, 207 insertions(+), 7 deletions(-)
create mode 100644 tools/perf/util/data-convert.h

--
1.8.3.4

Wang Nan

unread,
Jun 24, 2016, 7:30:06 AM6/24/16
to
Following commits are going to allow 'perf data convert' to collect not
only samples, but also non-sample events like comm and fork. In this
patch we count non-sample events using c.non_sample_count, and prepare
to print number of both type of events like:

# ~/perf data convert --all --to-ctf ./out.ctf
[ perf data convert: Converted 'perf.data' into CTF data './out.ctf' ]
[ perf data convert: Converted and wrote 0.846 MB (6508 samples, 686 non-samples) ]

Signed-off-by: Wang Nan <wang...@huawei.com>
Cc: Arnaldo Carvalho de Melo <ac...@redhat.com>
Cc: Jiri Olsa <jo...@redhat.com>
---
tools/perf/util/data-convert-bt.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index a5e0f68..bf4c15f 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -76,6 +76,7 @@ struct convert {

u64 events_size;
u64 events_count;
+ u64 non_sample_count;

/* Ordered events configured queue size. */
u64 queue_size;
@@ -1368,10 +1369,15 @@ int bt_convert__perf2ctf(const char *input, const char *path,
file.path, path);

fprintf(stderr,
- "[ perf data convert: Converted and wrote %.3f MB (%" PRIu64 " samples) ]\n",
+ "[ perf data convert: Converted and wrote %.3f MB (%" PRIu64 " samples",
(double) c.events_size / 1024.0 / 1024.0,
c.events_count);

+ if (!c.non_sample_count)
+ fprintf(stderr, ") ]\n");
+ else
+ fprintf(stderr, ", %" PRIu64 " non-samples) ]\n", c.non_sample_count);
+
cleanup_events(session);
perf_session__delete(session);
ctf_writer__cleanup(cw);
--
1.8.3.4

Wang Nan

unread,
Jun 24, 2016, 7:30:06 AM6/24/16
to
After converting perf.data to CTF, we lost pid-tid-comm mapping. Which
makes inconvience. For example, in perf script output we know which
process issue an event like this:

compiz 19361 [001] 3275709.313929: raw_syscalls:sys_exit: NR 7 = 0

After converting to CTF, we only get this:

[3275709.313929985] (+0.110646118) raw_syscalls:sys_exit: { cpu_id = 1 }, { perf_ip = 0xFFFFFFFF8107B2E8, perf_tid = 19361, perf_pid = 19361, perf_id = 18920, perf_period = 1, common_type = 16, common_flags = 0, common_preempt_count = 1, common_pid = 19361, id = 7, ret = 0 }

Currently, if we want to find the name and parent of a process, we
have to collect 'sched:sched_switch' event.

This patch set adds a '--all' option to 'perf convert', converts comm,
fork and exit events to CTF output. CTF user now can track the mapping
by their own.

v1 -> v2: Report number of sample and non-sample events when finish.
rename opts.non_sample to opts.all.

Wang Nan (7):
perf ctf: Add value_set_string() helper
perf ctf: Pass convert options through opts structure
perf ctf: Add 'all' option
perf ctf: Prepare collect non-sample events
perf ctf: Generate comm event to CTF output
perf ctf: Add '--all' option for 'perf data convert'
perf ctf: Generate fork and exit events to CTF output

tools/perf/Documentation/perf-data.txt | 4 +
tools/perf/builtin-data.c | 11 +-
tools/perf/util/data-convert-bt.c | 195 ++++++++++++++++++++++++++++++++-
tools/perf/util/data-convert-bt.h | 4 +-
tools/perf/util/data-convert.h | 9 ++
5 files changed, 216 insertions(+), 7 deletions(-)

Wang Nan

unread,
Jun 24, 2016, 7:30:06 AM6/24/16
to
If 'all' option is selected, 'perf data convert' should convert
not only samples, but non-sample events such as comm and fork. Add this
option in perf_data_convert_opts. Following commits will add cmdline
option to select it.

Signed-off-by: Wang Nan <wang...@huawei.com>
Cc: Arnaldo Carvalho de Melo <ac...@redhat.com>
Cc: Jiri Olsa <jo...@redhat.com>
---
tools/perf/builtin-data.c | 1 +
tools/perf/util/data-convert.h | 1 +
2 files changed, 2 insertions(+)

diff --git a/tools/perf/builtin-data.c b/tools/perf/builtin-data.c
index 38111a9..ddfe3ac4 100644
--- a/tools/perf/builtin-data.c
+++ b/tools/perf/builtin-data.c
@@ -56,6 +56,7 @@ static int cmd_data_convert(int argc, const char **argv,
const char *to_ctf = NULL;
struct perf_data_convert_opts opts = {
.force = false,
+ .all = false,
};
const struct option options[] = {
OPT_INCR('v', "verbose", &verbose, "be more verbose"),
diff --git a/tools/perf/util/data-convert.h b/tools/perf/util/data-convert.h
index 97cfd36..5314962 100644
--- a/tools/perf/util/data-convert.h
+++ b/tools/perf/util/data-convert.h
@@ -3,6 +3,7 @@

struct perf_data_convert_opts {
bool force;
+ bool all;
};

#endif /* __DATA_CONVERT_H */
--
1.8.3.4

Wang Nan

unread,
Jun 24, 2016, 7:30:06 AM6/24/16
to
There are many value_set_##x helper for integer, but only for integer.
This patch adds value_set_string() helper to help following commits
create string fields.

Signed-off-by: Wang Nan <wang...@huawei.com>
Cc: Arnaldo Carvalho de Melo <ac...@redhat.com>
Cc: Jiri Olsa <jo...@redhat.com>
---
tools/perf/util/data-convert-bt.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index 4b59879..7908278 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -140,6 +140,36 @@ FUNC_VALUE_SET(s64)
FUNC_VALUE_SET(u64)
__FUNC_VALUE_SET(u64_hex, u64)

+static int string_set_value(struct bt_ctf_field *field, const char *string);
+static __maybe_unused int
+value_set_string(struct ctf_writer *cw, struct bt_ctf_event *event,
+ const char *name, const char *string)
+{
+ struct bt_ctf_field_type *type = cw->data.string;
+ struct bt_ctf_field *field;
+ int ret = 0;
+
+ field = bt_ctf_field_create(type);
+ if (!field) {
+ pr_err("failed to create a field %s\n", name);
+ return -1;
+ }
+
+ ret = string_set_value(field, string);
+ if (ret) {
+ pr_err("failed to set value %s\n", name);
+ goto err_put_field;
+ }
+
+ ret = bt_ctf_event_set_payload(event, name, field);
+ if (ret)
+ pr_err("failed to set payload %s\n", name);
+
+err_put_field:
+ bt_ctf_field_put(field);
+ return ret;
+}
+
static struct bt_ctf_field_type*
get_tracepoint_field_type(struct ctf_writer *cw, struct format_field *field)
{
--
1.8.3.4

Wang Nan

unread,
Jun 24, 2016, 7:30:07 AM6/24/16
to
If 'all' is selected, convert comm event to output CTF stream.

setup_non_sample_events() is called if non_sample is selected. It creates
a comm_class for comm event.

Use macros to generate and process_comm_event and add_comm_event. These
macros can be reused for other non-sample events.

Signed-off-by: Wang Nan <wang...@huawei.com>
Cc: Arnaldo Carvalho de Melo <ac...@redhat.com>
Cc: Jiri Olsa <jo...@redhat.com>
---
tools/perf/util/data-convert-bt.c | 110 ++++++++++++++++++++++++++++++++++++++
1 file changed, 110 insertions(+)

diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index bf4c15f..31bc81a 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -68,6 +68,7 @@ struct ctf_writer {
};
struct bt_ctf_field_type *array[6];
} data;
+ struct bt_ctf_event_class *comm_class;
};

struct convert {
@@ -762,6 +763,57 @@ static int process_sample_event(struct perf_tool *tool,
return cs ? 0 : -1;
}

+#define __NON_SAMPLE_SET_FIELD(_name, _type, _field) \
+do { \
+ ret = value_set_##_type(cw, event, #_field, _event->_name._field);\
+ if (ret) \
+ return -1; \
+} while(0)
+
+#define __FUNC_PROCESS_NON_SAMPLE(_name, body) \
+static int process_##_name##_event(struct perf_tool *tool, \
+ union perf_event *_event, \
+ struct perf_sample *sample, \
+ struct machine *machine) \
+{ \
+ struct convert *c = container_of(tool, struct convert, tool);\
+ struct ctf_writer *cw = &c->writer; \
+ struct bt_ctf_event_class *event_class = cw->_name##_class;\
+ struct bt_ctf_event *event; \
+ struct ctf_stream *cs; \
+ int ret; \
+ \
+ c->non_sample_count++; \
+ c->events_size += _event->header.size; \
+ event = bt_ctf_event_create(event_class); \
+ if (!event) { \
+ pr_err("Failed to create an CTF event\n"); \
+ return -1; \
+ } \
+ \
+ bt_ctf_clock_set_time(cw->clock, sample->time); \
+ body \
+ cs = ctf_stream(cw, 0); \
+ if (cs) { \
+ if (is_flush_needed(cs)) \
+ ctf_stream__flush(cs); \
+ \
+ cs->count++; \
+ bt_ctf_stream_append_event(cs->stream, event); \
+ } \
+ bt_ctf_event_put(event); \
+ \
+ return perf_event__process_##_name(tool, _event, sample, machine);\
+}
+
+__FUNC_PROCESS_NON_SAMPLE(comm,
+ __NON_SAMPLE_SET_FIELD(comm, u32, pid);
+ __NON_SAMPLE_SET_FIELD(comm, u32, tid);
+ __NON_SAMPLE_SET_FIELD(comm, string, comm);
+)
+#undef __NON_SAMPLE_SET_FIELD
+#undef __FUNC_PROCESS_NON_SAMPLE
+
/* If dup < 0, add a prefix. Else, add _dupl_X suffix. */
static char *change_name(char *name, char *orig_name, int dup)
{
@@ -1036,6 +1088,58 @@ static int setup_events(struct ctf_writer *cw, struct perf_session *session)
return 0;
}

+#define __NON_SAMPLE_ADD_FIELD(t, n) \
+ do { \
+ pr2(" field '%s'\n", #n); \
+ if (bt_ctf_event_class_add_field(event_class, cw->data.t, #n)) {\
+ pr_err("Failed to add field '%s';\n", #n);\
+ return -1; \
+ } \
+ } while(0)
+
+#define __FUNC_ADD_NON_SAMPLE_EVENT_CLASS(_name, body) \
+static int add_##_name##_event(struct ctf_writer *cw) \
+{ \
+ struct bt_ctf_event_class *event_class; \
+ int ret; \
+ \
+ pr("Adding "#_name" event\n"); \
+ event_class = bt_ctf_event_class_create("perf_" #_name);\
+ if (!event_class) \
+ return -1; \
+ body \
+ \
+ ret = bt_ctf_stream_class_add_event_class(cw->stream_class, event_class);\
+ if (ret) { \
+ pr("Failed to add event class '"#_name"' into stream.\n");\
+ return ret; \
+ } \
+ \
+ cw->_name##_class = event_class; \
+ bt_ctf_event_class_put(event_class); \
+ return 0; \
+}
+
+__FUNC_ADD_NON_SAMPLE_EVENT_CLASS(comm,
+ __NON_SAMPLE_ADD_FIELD(u32, pid);
+ __NON_SAMPLE_ADD_FIELD(u32, tid);
+ __NON_SAMPLE_ADD_FIELD(string, comm);
+)
+
+#undef __NON_SAMPLE_ADD_FIELD
+#undef __FUNC_ADD_NON_SAMPLE_EVENT_CLASS
+
+static int setup_non_sample_events(struct ctf_writer *cw,
+ struct perf_session *session __maybe_unused)
+{
+ int ret;
+
+ ret = add_comm_event(cw);
+ if (ret)
+ return ret;
+ return 0;
+}
+
static void cleanup_events(struct perf_session *session)
{
struct perf_evlist *evlist = session->evlist;
@@ -1331,6 +1435,9 @@ int bt_convert__perf2ctf(const char *input, const char *path,
struct ctf_writer *cw = &c.writer;
int err = -1;

+ if (opts->all)
+ c.tool.comm = process_comm_event;
+
perf_config(convert__config, &c);

/* CTF writer */
@@ -1355,6 +1462,9 @@ int bt_convert__perf2ctf(const char *input, const char *path,
if (setup_events(cw, session))
goto free_session;

+ if (opts->all && setup_non_sample_events(cw, session))
+ goto free_session;
+
if (setup_streams(cw, session))
goto free_session;

--
1.8.3.4

Wang Nan

unread,
Jun 24, 2016, 7:30:07 AM6/24/16
to
After this patch, 'perf data convert' convert comm events to output
CTF stream.

Result:

# perf record -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.378 MB perf.data (73 samples) ]

# 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.003 MB (73 samples) ]

# babeltrace --clock-seconds ./out.ctf/
[10627.402515791] (+?.?????????) cycles:ppp: { cpu_id = 0 }, { perf_ip = 0xFFFFFFFF81065AF4, perf_tid = 0, perf_pid = 0, perf_period = 1 }
[10627.402518972] (+0.000003181) cycles:ppp: { cpu_id = 0 }, { perf_ip = 0xFFFFFFFF81065AF4, perf_tid = 0, perf_pid = 0, perf_period = 1 }
... // only sample event is converted

# perf data convert --all --to-ctf ./out.ctf
[ perf data convert: Converted 'perf.data' into CTF data './out.ctf' ]
[ perf data convert: Converted and wrote 0.023 MB (73 samples, 384 non-samples) ]

# babeltrace --clock-seconds ./out.ctf/
[ 0.000000000] (+?.?????????) perf_comm: { cpu_id = 0 }, { pid = 1, tid = 1, comm = "init" }
[ 0.000000000] (+0.000000000) perf_comm: { cpu_id = 0 }, { pid = 2, tid = 2, comm = "kthreadd" }
[ 0.000000000] (+0.000000000) perf_comm: { cpu_id = 0 }, { pid = 3, tid = 3, comm = "ksoftirqd/0" }
... // comm events are converted
[10627.402515791] (+10627.402515791) cycles:ppp: { cpu_id = 0 }, { perf_ip = 0xFFFFFFFF81065AF4, perf_tid = 0, perf_pid = 0, perf_period = 1 }
[10627.402518972] (+0.000003181) cycles:ppp: { cpu_id = 0 }, { perf_ip = 0xFFFFFFFF81065AF4, perf_tid = 0, perf_pid = 0, perf_period = 1 }
... // samples are also converted

Signed-off-by: Wang Nan <wang...@huawei.com>
Cc: Arnaldo Carvalho de Melo <ac...@redhat.com>
Cc: Jiri Olsa <jo...@redhat.com>
---
tools/perf/Documentation/perf-data.txt | 4 ++++
tools/perf/builtin-data.c | 1 +
2 files changed, 5 insertions(+)

diff --git a/tools/perf/Documentation/perf-data.txt b/tools/perf/Documentation/perf-data.txt
index be8fa1a..f0796a4 100644
--- a/tools/perf/Documentation/perf-data.txt
+++ b/tools/perf/Documentation/perf-data.txt
@@ -34,6 +34,10 @@ OPTIONS for 'convert'
--verbose::
Be more verbose (show counter open errors, etc).

+--all::
+ Convert all events, including non-sample events (comm, fork, ...), to output.
+ Default is off, only convert samples.
+
SEE ALSO
--------
linkperf:perf[1]
diff --git a/tools/perf/builtin-data.c b/tools/perf/builtin-data.c
index ddfe3ac4..7ad6e17 100644
--- a/tools/perf/builtin-data.c
+++ b/tools/perf/builtin-data.c
@@ -65,6 +65,7 @@ static int cmd_data_convert(int argc, const char **argv,
OPT_STRING(0, "to-ctf", &to_ctf, NULL, "Convert to CTF format"),
#endif
OPT_BOOLEAN('f', "force", &opts.force, "don't complain, do it"),
+ OPT_BOOLEAN(0, "all", &opts.all, "Convert all events"),
OPT_END()
};

--
1.8.3.4

Jiri Olsa

unread,
Jun 24, 2016, 8:30:06 AM6/24/16
to
On Fri, Jun 24, 2016 at 11:22:05AM +0000, Wang Nan wrote:
> After converting perf.data to CTF, we lost pid-tid-comm mapping. Which
> makes inconvience. For example, in perf script output we know which
> process issue an event like this:
>
> compiz 19361 [001] 3275709.313929: raw_syscalls:sys_exit: NR 7 = 0
>
> After converting to CTF, we only get this:
>
> [3275709.313929985] (+0.110646118) raw_syscalls:sys_exit: { cpu_id = 1 }, { perf_ip = 0xFFFFFFFF8107B2E8, perf_tid = 19361, perf_pid = 19361, perf_id = 18920, perf_period = 1, common_type = 16, common_flags = 0, common_preempt_count = 1, common_pid = 19361, id = 7, ret = 0 }
>
> Currently, if we want to find the name and parent of a process, we
> have to collect 'sched:sched_switch' event.
>
> This patch set adds a '--all' option to 'perf convert', converts comm,
> fork and exit events to CTF output. CTF user now can track the mapping
> by their own.
>
> v1 -> v2: Report number of sample and non-sample events when finish.
> rename opts.non_sample to opts.all.
>
> Wang Nan (7):
> perf ctf: Add value_set_string() helper
> perf ctf: Pass convert options through opts structure
> perf ctf: Add 'all' option
> perf ctf: Prepare collect non-sample events
> perf ctf: Generate comm event to CTF output
> perf ctf: Add '--all' option for 'perf data convert'
> perf ctf: Generate fork and exit events to CTF output

Acked-by: Jiri Olsa <jo...@kernel.org>

thanks,
jirka

Jiri Olsa

unread,
Jun 24, 2016, 8:30:06 AM6/24/16
to
On Fri, Jun 24, 2016 at 11:22:05AM +0000, Wang Nan wrote:
> After converting perf.data to CTF, we lost pid-tid-comm mapping. Which
> makes inconvience. For example, in perf script output we know which
> process issue an event like this:
>
> compiz 19361 [001] 3275709.313929: raw_syscalls:sys_exit: NR 7 = 0
>
> After converting to CTF, we only get this:
>
> [3275709.313929985] (+0.110646118) raw_syscalls:sys_exit: { cpu_id = 1 }, { perf_ip = 0xFFFFFFFF8107B2E8, perf_tid = 19361, perf_pid = 19361, perf_id = 18920, perf_period = 1, common_type = 16, common_flags = 0, common_preempt_count = 1, common_pid = 19361, id = 7, ret = 0 }
>
> Currently, if we want to find the name and parent of a process, we
> have to collect 'sched:sched_switch' event.
>
> This patch set adds a '--all' option to 'perf convert', converts comm,
> fork and exit events to CTF output. CTF user now can track the mapping
> by their own.
>
> v1 -> v2: Report number of sample and non-sample events when finish.
> rename opts.non_sample to opts.all.
>
> Wang Nan (7):
> perf ctf: Add value_set_string() helper
> perf ctf: Pass convert options through opts structure
> perf ctf: Add 'all' option
> perf ctf: Prepare collect non-sample events
> perf ctf: Generate comm event to CTF output
> perf ctf: Add '--all' option for 'perf data convert'
> perf ctf: Generate fork and exit events to CTF output

I can't compile unless I can include config.h

[jolsa@krava perf]$ make LIBBABELTRACE_DIR=/opt/libbabeltrace/ LIBBABELTRACE=1
BUILD: Doing 'make -j4' parallel build
CC util/data-convert-bt.o
util/data-convert-bt.c: In function ‘convert__config’:
util/data-convert-bt.c:1299:19: error: implicit declaration of function ‘perf_config_u64’ [-Werror=implicit-function-declaration]
c->queue_size = perf_config_u64(var, value);
^
util/data-convert-bt.c:1299:3: error: nested extern declaration of ‘perf_config_u64’ [-Werror=nested-externs]
c->queue_size = perf_config_u64(var, value);
^
util/data-convert-bt.c: In function ‘bt_convert__perf2ctf’:
util/data-convert-bt.c:1332:2: error: implicit declaration of function ‘perf_config’ [-Werror=implicit-function-declaration]
perf_config(convert__config, &c);
^
util/data-convert-bt.c:1332:2: error: nested extern declaration of ‘perf_config’ [-Werror=nested-externs]
cc1: all warnings being treated as errors


your compiler's not that strict I guess ;-)
I'll post it shortly

jirka

---
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index 79082782e7d2..4b68e7b9ee0c 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -26,6 +26,7 @@
#include "evlist.h"
#include "evsel.h"
#include "machine.h"
+#include "config.h"

#define pr_N(n, fmt, ...) \
eprintf(n, debug_data_convert, fmt, ##__VA_ARGS__)

pi3orama

unread,
Jun 24, 2016, 8:40:06 AM6/24/16
to


发自我的 iPhone
Strange.

The error message seems unrelated to my
patch, right?

Thank you.

Arnaldo Carvalho de Melo

unread,
Jun 24, 2016, 8:50:05 AM6/24/16
to
Em Fri, Jun 24, 2016 at 02:29:07PM +0200, Jiri Olsa escreveu:
> On Fri, Jun 24, 2016 at 11:22:05AM +0000, Wang Nan wrote:
> > After converting perf.data to CTF, we lost pid-tid-comm mapping. Which
> > makes inconvience. For example, in perf script output we know which
> > process issue an event like this:
> >
> > compiz 19361 [001] 3275709.313929: raw_syscalls:sys_exit: NR 7 = 0
> >
> > After converting to CTF, we only get this:
> >
> > [3275709.313929985] (+0.110646118) raw_syscalls:sys_exit: { cpu_id = 1 }, { perf_ip = 0xFFFFFFFF8107B2E8, perf_tid = 19361, perf_pid = 19361, perf_id = 18920, perf_period = 1, common_type = 16, common_flags = 0, common_preempt_count = 1, common_pid = 19361, id = 7, ret = 0 }
> >
> > Currently, if we want to find the name and parent of a process, we
> > have to collect 'sched:sched_switch' event.
> >
> > This patch set adds a '--all' option to 'perf convert', converts comm,
> > fork and exit events to CTF output. CTF user now can track the mapping
> > by their own.
> >
> > v1 -> v2: Report number of sample and non-sample events when finish.
> > rename opts.non_sample to opts.all.
> >
> > Wang Nan (7):
> > perf ctf: Add value_set_string() helper
> > perf ctf: Pass convert options through opts structure
> > perf ctf: Add 'all' option
> > perf ctf: Prepare collect non-sample events
> > perf ctf: Generate comm event to CTF output
> > perf ctf: Add '--all' option for 'perf data convert'
> > perf ctf: Generate fork and exit events to CTF output
>
> I can't compile unless I can include config.h

Waiting for this fix to proceed, but it seems we don't have this covered
in 'build-test', right? ;-)

- Arnaldo

Jiri Olsa

unread,
Jun 24, 2016, 8:50:07 AM6/24/16
to
just posted it ;-)

> in 'build-test', right? ;-)

right, but we dont cover babletrace stuff in tests/make

jirka

pi3orama

unread,
Jun 24, 2016, 8:50:07 AM6/24/16
to


发自我的 iPhone
CTF support is off by default. When can we
turn it on like other options?

Thank you.

Jiri Olsa

unread,
Jun 24, 2016, 9:00:05 AM6/24/16
to
On Fri, Jun 24, 2016 at 08:33:27PM +0800, pi3orama wrote:

SNIP

> > I can't compile unless I can include config.h
> >
> > [jolsa@krava perf]$ make LIBBABELTRACE_DIR=/opt/libbabeltrace/ LIBBABELTRACE=1
> > BUILD: Doing 'make -j4' parallel build
> > CC util/data-convert-bt.o
> > util/data-convert-bt.c: In function ‘convert__config’:
> > util/data-convert-bt.c:1299:19: error: implicit declaration of function ‘perf_config_u64’ [-Werror=implicit-function-declaration]
> > c->queue_size = perf_config_u64(var, value);
> > ^
> > util/data-convert-bt.c:1299:3: error: nested extern declaration of ‘perf_config_u64’ [-Werror=nested-externs]
> > c->queue_size = perf_config_u64(var, value);
> > ^
> > util/data-convert-bt.c: In function ‘bt_convert__perf2ctf’:
> > util/data-convert-bt.c:1332:2: error: implicit declaration of function ‘perf_config’ [-Werror=implicit-function-declaration]
> > perf_config(convert__config, &c);
> > ^
> > util/data-convert-bt.c:1332:2: error: nested extern declaration of ‘perf_config’ [-Werror=nested-externs]
> > cc1: all warnings being treated as errors
> >
>
> Strange.
>
> The error message seems unrelated to my
> patch, right?

yep, it's unrelated and I just posted the fix

I haven't enabled/compiled this code for a while and that's
what I've got.. I assume we're using different compilers

jirka

Jiri Olsa

unread,
Jun 24, 2016, 9:10:06 AM6/24/16
to
we switched it off because the latest version we needed
wasn't part of main distros.. it might have changed now

jirka

Arnaldo Carvalho de Melo

unread,
Jun 27, 2016, 3:10:06 PM6/27/16
to
Thanks, applied.

- Arnaldo
- Arnaldo

tip-bot for Wang Nan

unread,
Jun 29, 2016, 5:50:06 AM6/29/16
to
Commit-ID: f5a08ceda55bee91f879d2ac19edeb4a8916d04f
Gitweb: http://git.kernel.org/tip/f5a08ceda55bee91f879d2ac19edeb4a8916d04f
Author: Wang Nan <wang...@huawei.com>
AuthorDate: Fri, 24 Jun 2016 11:22:10 +0000
Committer: Arnaldo Carvalho de Melo <ac...@redhat.com>
CommitDate: Tue, 28 Jun 2016 10:54:57 -0300

perf data ctf: Generate comm event to CTF output

If 'all' is selected, convert comm event to output CTF stream.

setup_non_sample_events() is called if non_sample is selected. It
creates a comm_class for comm event.

Use macros to generate and process_comm_event and add_comm_event. These
macros can be reused for other non-sample events.

Signed-off-by: Wang Nan <wang...@huawei.com>
Acked-by: Jiri Olsa <jo...@kernel.org>
Cc: Zefan Li <liz...@huawei.com>
Cc: pi3o...@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-6-g...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <ac...@redhat.com>
---
tools/perf/util/data-convert-bt.c | 110 ++++++++++++++++++++++++++++++++++++++
1 file changed, 110 insertions(+)

diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index 3b3ac7c..5dd62ba 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -69,6 +69,7 @@ struct ctf_writer {
};
struct bt_ctf_field_type *array[6];
} data;
+ struct bt_ctf_event_class *comm_class;
};

struct convert {
@@ -763,6 +764,57 @@ static int process_sample_event(struct perf_tool *tool,
@@ -1037,6 +1089,58 @@ static int setup_events(struct ctf_writer *cw, struct perf_session *session)
@@ -1332,6 +1436,9 @@ int bt_convert__perf2ctf(const char *input, const char *path,
struct ctf_writer *cw = &c.writer;
int err = -1;

+ if (opts->all)
+ c.tool.comm = process_comm_event;
+
perf_config(convert__config, &c);

/* CTF writer */
@@ -1356,6 +1463,9 @@ int bt_convert__perf2ctf(const char *input, const char *path,

tip-bot for Wang Nan

unread,
Jun 29, 2016, 5:50:06 AM6/29/16
to
Commit-ID: 9e1a7ea19f9f8e3e40c5ad1a5cc3615c1746ae7b
Gitweb: http://git.kernel.org/tip/9e1a7ea19f9f8e3e40c5ad1a5cc3615c1746ae7b
Author: Wang Nan <wang...@huawei.com>
AuthorDate: Fri, 24 Jun 2016 11:22:11 +0000
Committer: Arnaldo Carvalho de Melo <ac...@redhat.com>
CommitDate: Tue, 28 Jun 2016 10:54:57 -0300

perf data ctf: Add '--all' option for 'perf data convert'
Acked-by: Jiri Olsa <jo...@kernel.org>
Cc: Zefan Li <liz...@huawei.com>
Cc: pi3o...@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-7-g...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <ac...@redhat.com>

tip-bot for Wang Nan

unread,
Jun 29, 2016, 5:50:06 AM6/29/16
to
Commit-ID: 069ee5c488d161f539bb897b1bc64b83f9773221
Gitweb: http://git.kernel.org/tip/069ee5c488d161f539bb897b1bc64b83f9773221
Author: Wang Nan <wang...@huawei.com>
AuthorDate: Fri, 24 Jun 2016 11:22:06 +0000
Committer: Arnaldo Carvalho de Melo <ac...@redhat.com>
CommitDate: Tue, 28 Jun 2016 10:54:55 -0300

perf data ctf: Add value_set_string() helper

There are many value_set_##x helper for integer, but only for integer.
This patch adds value_set_string() helper to help following commits
create string fields.

Signed-off-by: Wang Nan <wang...@huawei.com>
Acked-by: Jiri Olsa <jo...@kernel.org>
Cc: Zefan Li <liz...@huawei.com>
Cc: pi3o...@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-2-g...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <ac...@redhat.com>
---
tools/perf/util/data-convert-bt.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index 7b1bc24..4b68e7b 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -141,6 +141,36 @@ FUNC_VALUE_SET(s64)

tip-bot for Wang Nan

unread,
Jun 29, 2016, 5:50:11 AM6/29/16
to
Commit-ID: 8ee4c46c5ec2481dd18098c5604f791ff911d427
Gitweb: http://git.kernel.org/tip/8ee4c46c5ec2481dd18098c5604f791ff911d427
Author: Wang Nan <wang...@huawei.com>
AuthorDate: Fri, 24 Jun 2016 11:22:09 +0000
Committer: Arnaldo Carvalho de Melo <ac...@redhat.com>
CommitDate: Tue, 28 Jun 2016 10:54:56 -0300

perf data ctf: Prepare collect non-sample events

Following commits are going to allow 'perf data convert' to collect not
only samples, but also non-sample events like comm and fork. In this
patch we count non-sample events using c.non_sample_count, and prepare
to print number of both type of events like:

# ~/perf data convert --all --to-ctf ./out.ctf
[ perf data convert: Converted 'perf.data' into CTF data './out.ctf' ]
[ perf data convert: Converted and wrote 0.846 MB (6508 samples, 686 non-samples) ]

Signed-off-by: Wang Nan <wang...@huawei.com>
Acked-by: Jiri Olsa <jo...@kernel.org>
Cc: Zefan Li <liz...@huawei.com>
Cc: pi3o...@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-5-g...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <ac...@redhat.com>
---
tools/perf/util/data-convert-bt.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index 09571b3..3b3ac7c 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -77,6 +77,7 @@ struct convert {

u64 events_size;
u64 events_count;
+ u64 non_sample_count;

/* Ordered events configured queue size. */
u64 queue_size;
@@ -1369,10 +1370,15 @@ int bt_convert__perf2ctf(const char *input, const char *path,

tip-bot for Wang Nan

unread,
Jun 29, 2016, 5:50:26 AM6/29/16
to
Commit-ID: f02a6489d1e181c6c2731e80ff37024a130c326a
Gitweb: http://git.kernel.org/tip/f02a6489d1e181c6c2731e80ff37024a130c326a
Author: Wang Nan <wang...@huawei.com>
AuthorDate: Fri, 24 Jun 2016 11:22:08 +0000
Committer: Arnaldo Carvalho de Melo <ac...@redhat.com>
CommitDate: Tue, 28 Jun 2016 10:54:56 -0300

perf data ctf: Add 'all' option

If 'all' option is selected, 'perf data convert' should convert not only
samples, but non-sample events such as comm and fork. Add this option in
perf_data_convert_opts. Following commits will add cmdline option to
select it.

Signed-off-by: Wang Nan <wang...@huawei.com>
Acked-by: Jiri Olsa <jo...@kernel.org>
Cc: Zefan Li <liz...@huawei.com>
Cc: pi3o...@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-4-g...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <ac...@redhat.com>
0 new messages