* [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF
@ 2016-06-24 11:22 Wang Nan
2016-06-24 11:22 ` [PATCH v2 1/7] perf ctf: Add value_set_string() helper Wang Nan
` (8 more replies)
0 siblings, 9 replies; 24+ messages in thread
From: Wang Nan @ 2016-06-24 11:22 UTC (permalink / raw)
To: acme, jolsa; +Cc: linux-kernel, pi3orama, lizefan, Wang Nan
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(-)
create mode 100644 tools/perf/util/data-convert.h
--
1.8.3.4
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v2 1/7] perf ctf: Add value_set_string() helper
2016-06-24 11:22 [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF Wang Nan
@ 2016-06-24 11:22 ` Wang Nan
2016-06-29 9:45 ` [tip:perf/core] perf data " tip-bot for Wang Nan
2016-06-24 11:22 ` [PATCH v2 2/7] perf ctf: Pass convert options through opts structure Wang Nan
` (7 subsequent siblings)
8 siblings, 1 reply; 24+ messages in thread
From: Wang Nan @ 2016-06-24 11:22 UTC (permalink / raw)
To: acme, jolsa
Cc: linux-kernel, pi3orama, lizefan, Wang Nan, Arnaldo Carvalho de Melo
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 <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@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
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 2/7] perf ctf: Pass convert options through opts structure
2016-06-24 11:22 [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF Wang Nan
2016-06-24 11:22 ` [PATCH v2 1/7] perf ctf: Add value_set_string() helper Wang Nan
@ 2016-06-24 11:22 ` Wang Nan
2016-06-29 9:45 ` [tip:perf/core] perf data " tip-bot for Wang Nan
2016-06-24 11:22 ` [PATCH v2 3/7] perf ctf: Add 'all' option Wang Nan
` (6 subsequent siblings)
8 siblings, 1 reply; 24+ messages in thread
From: Wang Nan @ 2016-06-24 11:22 UTC (permalink / raw)
To: acme, jolsa
Cc: linux-kernel, pi3orama, lizefan, Wang Nan, Arnaldo Carvalho de Melo
Following commits will add new option to 'perf data convert'. All options
should be grouped into a structure and passed to low level converter
(currently there's only one converter).
Introduce data-convert.h and define 'struct perf_data_convert_opts' in
it. Pass 'force' through opts.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
---
tools/perf/builtin-data.c | 9 ++++++---
tools/perf/util/data-convert-bt.c | 5 +++--
tools/perf/util/data-convert-bt.h | 4 +++-
tools/perf/util/data-convert.h | 8 ++++++++
4 files changed, 20 insertions(+), 6 deletions(-)
create mode 100644 tools/perf/util/data-convert.h
diff --git a/tools/perf/builtin-data.c b/tools/perf/builtin-data.c
index b97bc15..38111a9 100644
--- a/tools/perf/builtin-data.c
+++ b/tools/perf/builtin-data.c
@@ -3,6 +3,7 @@
#include "perf.h"
#include "debug.h"
#include <subcmd/parse-options.h>
+#include "data-convert.h"
#include "data-convert-bt.h"
typedef int (*data_cmd_fn_t)(int argc, const char **argv, const char *prefix);
@@ -53,14 +54,16 @@ static int cmd_data_convert(int argc, const char **argv,
const char *prefix __maybe_unused)
{
const char *to_ctf = NULL;
- bool force = false;
+ struct perf_data_convert_opts opts = {
+ .force = false,
+ };
const struct option options[] = {
OPT_INCR('v', "verbose", &verbose, "be more verbose"),
OPT_STRING('i', "input", &input_name, "file", "input file name"),
#ifdef HAVE_LIBBABELTRACE_SUPPORT
OPT_STRING(0, "to-ctf", &to_ctf, NULL, "Convert to CTF format"),
#endif
- OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
+ OPT_BOOLEAN('f', "force", &opts.force, "don't complain, do it"),
OPT_END()
};
@@ -78,7 +81,7 @@ static int cmd_data_convert(int argc, const char **argv,
if (to_ctf) {
#ifdef HAVE_LIBBABELTRACE_SUPPORT
- return bt_convert__perf2ctf(input_name, to_ctf, force);
+ return bt_convert__perf2ctf(input_name, to_ctf, &opts);
#else
pr_err("The libbabeltrace support is not compiled in.\n");
return -1;
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index 7908278..a5e0f68 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -1303,13 +1303,14 @@ static int convert__config(const char *var, const char *value, void *cb)
return 0;
}
-int bt_convert__perf2ctf(const char *input, const char *path, bool force)
+int bt_convert__perf2ctf(const char *input, const char *path,
+ struct perf_data_convert_opts *opts)
{
struct perf_session *session;
struct perf_data_file file = {
.path = input,
.mode = PERF_DATA_MODE_READ,
- .force = force,
+ .force = opts->force,
};
struct convert c = {
.tool = {
diff --git a/tools/perf/util/data-convert-bt.h b/tools/perf/util/data-convert-bt.h
index 4c20434..9a3b587 100644
--- a/tools/perf/util/data-convert-bt.h
+++ b/tools/perf/util/data-convert-bt.h
@@ -1,8 +1,10 @@
#ifndef __DATA_CONVERT_BT_H
#define __DATA_CONVERT_BT_H
+#include "data-convert.h"
#ifdef HAVE_LIBBABELTRACE_SUPPORT
-int bt_convert__perf2ctf(const char *input_name, const char *to_ctf, bool force);
+int bt_convert__perf2ctf(const char *input_name, const char *to_ctf,
+ struct perf_data_convert_opts *opts);
#endif /* HAVE_LIBBABELTRACE_SUPPORT */
#endif /* __DATA_CONVERT_BT_H */
diff --git a/tools/perf/util/data-convert.h b/tools/perf/util/data-convert.h
new file mode 100644
index 0000000..97cfd36
--- /dev/null
+++ b/tools/perf/util/data-convert.h
@@ -0,0 +1,8 @@
+#ifndef __DATA_CONVERT_H
+#define __DATA_CONVERT_H
+
+struct perf_data_convert_opts {
+ bool force;
+};
+
+#endif /* __DATA_CONVERT_H */
--
1.8.3.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 3/7] perf ctf: Add 'all' option
2016-06-24 11:22 [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF Wang Nan
2016-06-24 11:22 ` [PATCH v2 1/7] perf ctf: Add value_set_string() helper Wang Nan
2016-06-24 11:22 ` [PATCH v2 2/7] perf ctf: Pass convert options through opts structure Wang Nan
@ 2016-06-24 11:22 ` Wang Nan
2016-06-29 9:46 ` [tip:perf/core] perf data " tip-bot for Wang Nan
2016-06-24 11:22 ` [PATCH v2 4/7] perf ctf: Prepare collect non-sample events Wang Nan
` (5 subsequent siblings)
8 siblings, 1 reply; 24+ messages in thread
From: Wang Nan @ 2016-06-24 11:22 UTC (permalink / raw)
To: acme, jolsa
Cc: linux-kernel, pi3orama, lizefan, Wang Nan, Arnaldo Carvalho de Melo
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 <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@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
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 4/7] perf ctf: Prepare collect non-sample events
2016-06-24 11:22 [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF Wang Nan
` (2 preceding siblings ...)
2016-06-24 11:22 ` [PATCH v2 3/7] perf ctf: Add 'all' option Wang Nan
@ 2016-06-24 11:22 ` Wang Nan
2016-06-29 9:46 ` [tip:perf/core] perf data " tip-bot for Wang Nan
2016-06-24 11:22 ` [PATCH v2 5/7] perf ctf: Generate comm event to CTF output Wang Nan
` (4 subsequent siblings)
8 siblings, 1 reply; 24+ messages in thread
From: Wang Nan @ 2016-06-24 11:22 UTC (permalink / raw)
To: acme, jolsa
Cc: linux-kernel, pi3orama, lizefan, Wang Nan, Arnaldo Carvalho de Melo
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 <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@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
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 5/7] perf ctf: Generate comm event to CTF output
2016-06-24 11:22 [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF Wang Nan
` (3 preceding siblings ...)
2016-06-24 11:22 ` [PATCH v2 4/7] perf ctf: Prepare collect non-sample events Wang Nan
@ 2016-06-24 11:22 ` Wang Nan
2016-06-29 9:46 ` [tip:perf/core] perf data " tip-bot for Wang Nan
2016-06-24 11:22 ` [PATCH v2 6/7] perf ctf: Add '--all' option for 'perf data convert' Wang Nan
` (3 subsequent siblings)
8 siblings, 1 reply; 24+ messages in thread
From: Wang Nan @ 2016-06-24 11:22 UTC (permalink / raw)
To: acme, jolsa
Cc: linux-kernel, pi3orama, lizefan, Wang Nan, Arnaldo Carvalho de Melo
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 <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@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
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 6/7] perf ctf: Add '--all' option for 'perf data convert'
2016-06-24 11:22 [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF Wang Nan
` (4 preceding siblings ...)
2016-06-24 11:22 ` [PATCH v2 5/7] perf ctf: Generate comm event to CTF output Wang Nan
@ 2016-06-24 11:22 ` Wang Nan
2016-06-29 9:47 ` [tip:perf/core] perf data " tip-bot for Wang Nan
2016-06-24 11:22 ` [PATCH v2 7/7] perf ctf: Generate fork and exit events to CTF output Wang Nan
` (2 subsequent siblings)
8 siblings, 1 reply; 24+ messages in thread
From: Wang Nan @ 2016-06-24 11:22 UTC (permalink / raw)
To: acme, jolsa
Cc: linux-kernel, pi3orama, lizefan, Wang Nan, Arnaldo Carvalho de Melo
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 <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@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
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 7/7] perf ctf: Generate fork and exit events to CTF output
2016-06-24 11:22 [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF Wang Nan
` (5 preceding siblings ...)
2016-06-24 11:22 ` [PATCH v2 6/7] perf ctf: Add '--all' option for 'perf data convert' Wang Nan
@ 2016-06-24 11:22 ` Wang Nan
2016-06-29 9:47 ` [tip:perf/core] perf data " tip-bot for Wang Nan
2016-06-24 12:28 ` [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF Jiri Olsa
2016-06-24 12:29 ` Jiri Olsa
8 siblings, 1 reply; 24+ messages in thread
From: Wang Nan @ 2016-06-24 11:22 UTC (permalink / raw)
To: acme, jolsa
Cc: linux-kernel, pi3orama, lizefan, Wang Nan, Arnaldo Carvalho de Melo
If 'all' is selected, convert fork and exit events to output CTF stream.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
---
tools/perf/util/data-convert-bt.c | 44 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index 31bc81a..acd11d4 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -69,6 +69,8 @@ struct ctf_writer {
struct bt_ctf_field_type *array[6];
} data;
struct bt_ctf_event_class *comm_class;
+ struct bt_ctf_event_class *exit_class;
+ struct bt_ctf_event_class *fork_class;
};
struct convert {
@@ -811,6 +813,21 @@ __FUNC_PROCESS_NON_SAMPLE(comm,
__NON_SAMPLE_SET_FIELD(comm, u32, tid);
__NON_SAMPLE_SET_FIELD(comm, string, comm);
)
+__FUNC_PROCESS_NON_SAMPLE(fork,
+ __NON_SAMPLE_SET_FIELD(fork, u32, pid);
+ __NON_SAMPLE_SET_FIELD(fork, u32, ppid);
+ __NON_SAMPLE_SET_FIELD(fork, u32, tid);
+ __NON_SAMPLE_SET_FIELD(fork, u32, ptid);
+ __NON_SAMPLE_SET_FIELD(fork, u64, time);
+)
+
+__FUNC_PROCESS_NON_SAMPLE(exit,
+ __NON_SAMPLE_SET_FIELD(fork, u32, pid);
+ __NON_SAMPLE_SET_FIELD(fork, u32, ppid);
+ __NON_SAMPLE_SET_FIELD(fork, u32, tid);
+ __NON_SAMPLE_SET_FIELD(fork, u32, ptid);
+ __NON_SAMPLE_SET_FIELD(fork, u64, time);
+)
#undef __NON_SAMPLE_SET_FIELD
#undef __FUNC_PROCESS_NON_SAMPLE
@@ -1126,6 +1143,22 @@ __FUNC_ADD_NON_SAMPLE_EVENT_CLASS(comm,
__NON_SAMPLE_ADD_FIELD(string, comm);
)
+__FUNC_ADD_NON_SAMPLE_EVENT_CLASS(fork,
+ __NON_SAMPLE_ADD_FIELD(u32, pid);
+ __NON_SAMPLE_ADD_FIELD(u32, ppid);
+ __NON_SAMPLE_ADD_FIELD(u32, tid);
+ __NON_SAMPLE_ADD_FIELD(u32, ptid);
+ __NON_SAMPLE_ADD_FIELD(u64, time);
+)
+
+__FUNC_ADD_NON_SAMPLE_EVENT_CLASS(exit,
+ __NON_SAMPLE_ADD_FIELD(u32, pid);
+ __NON_SAMPLE_ADD_FIELD(u32, ppid);
+ __NON_SAMPLE_ADD_FIELD(u32, tid);
+ __NON_SAMPLE_ADD_FIELD(u32, ptid);
+ __NON_SAMPLE_ADD_FIELD(u64, time);
+)
+
#undef __NON_SAMPLE_ADD_FIELD
#undef __FUNC_ADD_NON_SAMPLE_EVENT_CLASS
@@ -1137,6 +1170,12 @@ static int setup_non_sample_events(struct ctf_writer *cw,
ret = add_comm_event(cw);
if (ret)
return ret;
+ ret = add_exit_event(cw);
+ if (ret)
+ return ret;
+ ret = add_fork_event(cw);
+ if (ret)
+ return ret;
return 0;
}
@@ -1435,8 +1474,11 @@ int bt_convert__perf2ctf(const char *input, const char *path,
struct ctf_writer *cw = &c.writer;
int err = -1;
- if (opts->all)
+ if (opts->all) {
c.tool.comm = process_comm_event;
+ c.tool.exit = process_exit_event;
+ c.tool.fork = process_fork_event;
+ }
perf_config(convert__config, &c);
--
1.8.3.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF
2016-06-24 11:22 [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF Wang Nan
` (6 preceding siblings ...)
2016-06-24 11:22 ` [PATCH v2 7/7] perf ctf: Generate fork and exit events to CTF output Wang Nan
@ 2016-06-24 12:28 ` Jiri Olsa
2016-06-27 19:03 ` Arnaldo Carvalho de Melo
2016-06-24 12:29 ` Jiri Olsa
8 siblings, 1 reply; 24+ messages in thread
From: Jiri Olsa @ 2016-06-24 12:28 UTC (permalink / raw)
To: Wang Nan; +Cc: acme, linux-kernel, pi3orama, lizefan
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 <jolsa@kernel.org>
thanks,
jirka
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF
2016-06-24 11:22 [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF Wang Nan
` (7 preceding siblings ...)
2016-06-24 12:28 ` [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF Jiri Olsa
@ 2016-06-24 12:29 ` Jiri Olsa
2016-06-24 12:33 ` pi3orama
2016-06-24 12:41 ` Arnaldo Carvalho de Melo
8 siblings, 2 replies; 24+ messages in thread
From: Jiri Olsa @ 2016-06-24 12:29 UTC (permalink / raw)
To: Wang Nan; +Cc: acme, linux-kernel, pi3orama, lizefan
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__)
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF
2016-06-24 12:29 ` Jiri Olsa
@ 2016-06-24 12:33 ` pi3orama
2016-06-24 12:55 ` Jiri Olsa
2016-06-24 12:41 ` Arnaldo Carvalho de Melo
1 sibling, 1 reply; 24+ messages in thread
From: pi3orama @ 2016-06-24 12:33 UTC (permalink / raw)
To: Jiri Olsa; +Cc: Wang Nan, acme, linux-kernel, lizefan
发自我的 iPhone
> 在 2016年6月24日,下午8:29,Jiri Olsa <jolsa@redhat.com> 写道:
>
>> 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
>
Strange.
The error message seems unrelated to my
patch, right?
Thank you.
>
> 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__)
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF
2016-06-24 12:29 ` Jiri Olsa
2016-06-24 12:33 ` pi3orama
@ 2016-06-24 12:41 ` Arnaldo Carvalho de Melo
2016-06-24 12:43 ` pi3orama
2016-06-24 12:44 ` Jiri Olsa
1 sibling, 2 replies; 24+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-06-24 12:41 UTC (permalink / raw)
To: Jiri Olsa; +Cc: Wang Nan, linux-kernel, pi3orama, lizefan
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
> [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__)
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF
2016-06-24 12:41 ` Arnaldo Carvalho de Melo
@ 2016-06-24 12:43 ` pi3orama
2016-06-24 13:08 ` Jiri Olsa
2016-06-24 12:44 ` Jiri Olsa
1 sibling, 1 reply; 24+ messages in thread
From: pi3orama @ 2016-06-24 12:43 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, Wang Nan, linux-kernel, lizefan
发自我的 iPhone
> 在 2016年6月24日,下午8:41,Arnaldo Carvalho de Melo <acme@kernel.org> 写道:
>
> 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? ;-)
>
CTF support is off by default. When can we
turn it on like other options?
Thank you.
> - Arnaldo
>
>> [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__)
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF
2016-06-24 12:41 ` Arnaldo Carvalho de Melo
2016-06-24 12:43 ` pi3orama
@ 2016-06-24 12:44 ` Jiri Olsa
1 sibling, 0 replies; 24+ messages in thread
From: Jiri Olsa @ 2016-06-24 12:44 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: Wang Nan, linux-kernel, pi3orama, lizefan
On Fri, Jun 24, 2016 at 09:41:13AM -0300, Arnaldo Carvalho de Melo wrote:
> 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
just posted it ;-)
> in 'build-test', right? ;-)
right, but we dont cover babletrace stuff in tests/make
jirka
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF
2016-06-24 12:33 ` pi3orama
@ 2016-06-24 12:55 ` Jiri Olsa
0 siblings, 0 replies; 24+ messages in thread
From: Jiri Olsa @ 2016-06-24 12:55 UTC (permalink / raw)
To: pi3orama; +Cc: Wang Nan, acme, linux-kernel, lizefan
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
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF
2016-06-24 12:43 ` pi3orama
@ 2016-06-24 13:08 ` Jiri Olsa
0 siblings, 0 replies; 24+ messages in thread
From: Jiri Olsa @ 2016-06-24 13:08 UTC (permalink / raw)
To: pi3orama; +Cc: Arnaldo Carvalho de Melo, Wang Nan, linux-kernel, lizefan
On Fri, Jun 24, 2016 at 08:43:56PM +0800, pi3orama wrote:
>
>
> 发自我的 iPhone
>
> > 在 2016年6月24日,下午8:41,Arnaldo Carvalho de Melo <acme@kernel.org> 写道:
> >
> > 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? ;-)
> >
>
> CTF support is off by default. When can we
> turn it on like other options?
we switched it off because the latest version we needed
wasn't part of main distros.. it might have changed now
jirka
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF
2016-06-24 12:28 ` [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF Jiri Olsa
@ 2016-06-27 19:03 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 24+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-06-27 19:03 UTC (permalink / raw)
To: Jiri Olsa; +Cc: Wang Nan, linux-kernel, pi3orama, lizefan
Em Fri, Jun 24, 2016 at 02:28:51PM +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
>
> Acked-by: Jiri Olsa <jolsa@kernel.org>
Thanks, applied.
- Arnaldo
- Arnaldo
^ permalink raw reply [flat|nested] 24+ messages in thread
* [tip:perf/core] perf data ctf: Add value_set_string() helper
2016-06-24 11:22 ` [PATCH v2 1/7] perf ctf: Add value_set_string() helper Wang Nan
@ 2016-06-29 9:45 ` tip-bot for Wang Nan
0 siblings, 0 replies; 24+ messages in thread
From: tip-bot for Wang Nan @ 2016-06-29 9:45 UTC (permalink / raw)
To: linux-tip-commits
Cc: lizefan, linux-kernel, wangnan0, tglx, jolsa, mingo, hpa, acme
Commit-ID: 069ee5c488d161f539bb897b1bc64b83f9773221
Gitweb: http://git.kernel.org/tip/069ee5c488d161f539bb897b1bc64b83f9773221
Author: Wang Nan <wangnan0@huawei.com>
AuthorDate: Fri, 24 Jun 2016 11:22:06 +0000
Committer: Arnaldo Carvalho de Melo <acme@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 <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@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)
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)
{
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [tip:perf/core] perf data ctf: Pass convert options through opts structure
2016-06-24 11:22 ` [PATCH v2 2/7] perf ctf: Pass convert options through opts structure Wang Nan
@ 2016-06-29 9:45 ` tip-bot for Wang Nan
0 siblings, 0 replies; 24+ messages in thread
From: tip-bot for Wang Nan @ 2016-06-29 9:45 UTC (permalink / raw)
To: linux-tip-commits
Cc: jolsa, wangnan0, lizefan, mingo, tglx, acme, linux-kernel, hpa
Commit-ID: 3275f68e50290acd04612c6af41173fe83fdf4b0
Gitweb: http://git.kernel.org/tip/3275f68e50290acd04612c6af41173fe83fdf4b0
Author: Wang Nan <wangnan0@huawei.com>
AuthorDate: Fri, 24 Jun 2016 11:22:07 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 28 Jun 2016 10:54:55 -0300
perf data ctf: Pass convert options through opts structure
Following commits will add new option to 'perf data convert'. All options
should be grouped into a structure and passed to low level converter
(currently there's only one converter).
Introduce data-convert.h and define 'struct perf_data_convert_opts' in
it. Pass 'force' through opts.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-3-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-data.c | 9 ++++++---
tools/perf/util/data-convert-bt.c | 5 +++--
tools/perf/util/data-convert-bt.h | 4 +++-
tools/perf/util/data-convert.h | 8 ++++++++
4 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/tools/perf/builtin-data.c b/tools/perf/builtin-data.c
index b97bc15..38111a9 100644
--- a/tools/perf/builtin-data.c
+++ b/tools/perf/builtin-data.c
@@ -3,6 +3,7 @@
#include "perf.h"
#include "debug.h"
#include <subcmd/parse-options.h>
+#include "data-convert.h"
#include "data-convert-bt.h"
typedef int (*data_cmd_fn_t)(int argc, const char **argv, const char *prefix);
@@ -53,14 +54,16 @@ static int cmd_data_convert(int argc, const char **argv,
const char *prefix __maybe_unused)
{
const char *to_ctf = NULL;
- bool force = false;
+ struct perf_data_convert_opts opts = {
+ .force = false,
+ };
const struct option options[] = {
OPT_INCR('v', "verbose", &verbose, "be more verbose"),
OPT_STRING('i', "input", &input_name, "file", "input file name"),
#ifdef HAVE_LIBBABELTRACE_SUPPORT
OPT_STRING(0, "to-ctf", &to_ctf, NULL, "Convert to CTF format"),
#endif
- OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
+ OPT_BOOLEAN('f', "force", &opts.force, "don't complain, do it"),
OPT_END()
};
@@ -78,7 +81,7 @@ static int cmd_data_convert(int argc, const char **argv,
if (to_ctf) {
#ifdef HAVE_LIBBABELTRACE_SUPPORT
- return bt_convert__perf2ctf(input_name, to_ctf, force);
+ return bt_convert__perf2ctf(input_name, to_ctf, &opts);
#else
pr_err("The libbabeltrace support is not compiled in.\n");
return -1;
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index 4b68e7b..09571b3 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -1304,13 +1304,14 @@ static int convert__config(const char *var, const char *value, void *cb)
return 0;
}
-int bt_convert__perf2ctf(const char *input, const char *path, bool force)
+int bt_convert__perf2ctf(const char *input, const char *path,
+ struct perf_data_convert_opts *opts)
{
struct perf_session *session;
struct perf_data_file file = {
.path = input,
.mode = PERF_DATA_MODE_READ,
- .force = force,
+ .force = opts->force,
};
struct convert c = {
.tool = {
diff --git a/tools/perf/util/data-convert-bt.h b/tools/perf/util/data-convert-bt.h
index 4c20434..9a3b587 100644
--- a/tools/perf/util/data-convert-bt.h
+++ b/tools/perf/util/data-convert-bt.h
@@ -1,8 +1,10 @@
#ifndef __DATA_CONVERT_BT_H
#define __DATA_CONVERT_BT_H
+#include "data-convert.h"
#ifdef HAVE_LIBBABELTRACE_SUPPORT
-int bt_convert__perf2ctf(const char *input_name, const char *to_ctf, bool force);
+int bt_convert__perf2ctf(const char *input_name, const char *to_ctf,
+ struct perf_data_convert_opts *opts);
#endif /* HAVE_LIBBABELTRACE_SUPPORT */
#endif /* __DATA_CONVERT_BT_H */
diff --git a/tools/perf/util/data-convert.h b/tools/perf/util/data-convert.h
new file mode 100644
index 0000000..97cfd36
--- /dev/null
+++ b/tools/perf/util/data-convert.h
@@ -0,0 +1,8 @@
+#ifndef __DATA_CONVERT_H
+#define __DATA_CONVERT_H
+
+struct perf_data_convert_opts {
+ bool force;
+};
+
+#endif /* __DATA_CONVERT_H */
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [tip:perf/core] perf data ctf: Add 'all' option
2016-06-24 11:22 ` [PATCH v2 3/7] perf ctf: Add 'all' option Wang Nan
@ 2016-06-29 9:46 ` tip-bot for Wang Nan
0 siblings, 0 replies; 24+ messages in thread
From: tip-bot for Wang Nan @ 2016-06-29 9:46 UTC (permalink / raw)
To: linux-tip-commits
Cc: hpa, mingo, lizefan, tglx, wangnan0, linux-kernel, acme, jolsa
Commit-ID: f02a6489d1e181c6c2731e80ff37024a130c326a
Gitweb: http://git.kernel.org/tip/f02a6489d1e181c6c2731e80ff37024a130c326a
Author: Wang Nan <wangnan0@huawei.com>
AuthorDate: Fri, 24 Jun 2016 11:22:08 +0000
Committer: Arnaldo Carvalho de Melo <acme@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 <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-4-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@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 */
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [tip:perf/core] perf data ctf: Prepare collect non-sample events
2016-06-24 11:22 ` [PATCH v2 4/7] perf ctf: Prepare collect non-sample events Wang Nan
@ 2016-06-29 9:46 ` tip-bot for Wang Nan
0 siblings, 0 replies; 24+ messages in thread
From: tip-bot for Wang Nan @ 2016-06-29 9:46 UTC (permalink / raw)
To: linux-tip-commits
Cc: hpa, acme, lizefan, mingo, wangnan0, linux-kernel, tglx, jolsa
Commit-ID: 8ee4c46c5ec2481dd18098c5604f791ff911d427
Gitweb: http://git.kernel.org/tip/8ee4c46c5ec2481dd18098c5604f791ff911d427
Author: Wang Nan <wangnan0@huawei.com>
AuthorDate: Fri, 24 Jun 2016 11:22:09 +0000
Committer: Arnaldo Carvalho de Melo <acme@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 <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-5-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@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,
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);
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [tip:perf/core] perf data ctf: Generate comm event to CTF output
2016-06-24 11:22 ` [PATCH v2 5/7] perf ctf: Generate comm event to CTF output Wang Nan
@ 2016-06-29 9:46 ` tip-bot for Wang Nan
0 siblings, 0 replies; 24+ messages in thread
From: tip-bot for Wang Nan @ 2016-06-29 9:46 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, acme, jolsa, tglx, wangnan0, mingo, hpa, lizefan
Commit-ID: f5a08ceda55bee91f879d2ac19edeb4a8916d04f
Gitweb: http://git.kernel.org/tip/f5a08ceda55bee91f879d2ac19edeb4a8916d04f
Author: Wang Nan <wangnan0@huawei.com>
AuthorDate: Fri, 24 Jun 2016 11:22:10 +0000
Committer: Arnaldo Carvalho de Melo <acme@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 <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-6-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@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,
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)
{
@@ -1037,6 +1089,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;
@@ -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,
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;
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [tip:perf/core] perf data ctf: Add '--all' option for 'perf data convert'
2016-06-24 11:22 ` [PATCH v2 6/7] perf ctf: Add '--all' option for 'perf data convert' Wang Nan
@ 2016-06-29 9:47 ` tip-bot for Wang Nan
0 siblings, 0 replies; 24+ messages in thread
From: tip-bot for Wang Nan @ 2016-06-29 9:47 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, jolsa, wangnan0, tglx, mingo, lizefan, linux-kernel, hpa
Commit-ID: 9e1a7ea19f9f8e3e40c5ad1a5cc3615c1746ae7b
Gitweb: http://git.kernel.org/tip/9e1a7ea19f9f8e3e40c5ad1a5cc3615c1746ae7b
Author: Wang Nan <wangnan0@huawei.com>
AuthorDate: Fri, 24 Jun 2016 11:22:11 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 28 Jun 2016 10:54:57 -0300
perf data ctf: Add '--all' option for 'perf data convert'
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 <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-7-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@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()
};
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [tip:perf/core] perf data ctf: Generate fork and exit events to CTF output
2016-06-24 11:22 ` [PATCH v2 7/7] perf ctf: Generate fork and exit events to CTF output Wang Nan
@ 2016-06-29 9:47 ` tip-bot for Wang Nan
0 siblings, 0 replies; 24+ messages in thread
From: tip-bot for Wang Nan @ 2016-06-29 9:47 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, tglx, hpa, mingo, lizefan, wangnan0, acme, jolsa
Commit-ID: ebccba3fe0a02f622f80e6be0e8ecb1a9a3ed983
Gitweb: http://git.kernel.org/tip/ebccba3fe0a02f622f80e6be0e8ecb1a9a3ed983
Author: Wang Nan <wangnan0@huawei.com>
AuthorDate: Fri, 24 Jun 2016 11:22:12 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 28 Jun 2016 10:54:58 -0300
perf data ctf: Generate fork and exit events to CTF output
If 'all' is selected, convert fork and exit events to output CTF stream.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-8-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/data-convert-bt.c | 44 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index 5dd62ba..4f979bb 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -70,6 +70,8 @@ struct ctf_writer {
struct bt_ctf_field_type *array[6];
} data;
struct bt_ctf_event_class *comm_class;
+ struct bt_ctf_event_class *exit_class;
+ struct bt_ctf_event_class *fork_class;
};
struct convert {
@@ -812,6 +814,21 @@ __FUNC_PROCESS_NON_SAMPLE(comm,
__NON_SAMPLE_SET_FIELD(comm, u32, tid);
__NON_SAMPLE_SET_FIELD(comm, string, comm);
)
+__FUNC_PROCESS_NON_SAMPLE(fork,
+ __NON_SAMPLE_SET_FIELD(fork, u32, pid);
+ __NON_SAMPLE_SET_FIELD(fork, u32, ppid);
+ __NON_SAMPLE_SET_FIELD(fork, u32, tid);
+ __NON_SAMPLE_SET_FIELD(fork, u32, ptid);
+ __NON_SAMPLE_SET_FIELD(fork, u64, time);
+)
+
+__FUNC_PROCESS_NON_SAMPLE(exit,
+ __NON_SAMPLE_SET_FIELD(fork, u32, pid);
+ __NON_SAMPLE_SET_FIELD(fork, u32, ppid);
+ __NON_SAMPLE_SET_FIELD(fork, u32, tid);
+ __NON_SAMPLE_SET_FIELD(fork, u32, ptid);
+ __NON_SAMPLE_SET_FIELD(fork, u64, time);
+)
#undef __NON_SAMPLE_SET_FIELD
#undef __FUNC_PROCESS_NON_SAMPLE
@@ -1127,6 +1144,22 @@ __FUNC_ADD_NON_SAMPLE_EVENT_CLASS(comm,
__NON_SAMPLE_ADD_FIELD(string, comm);
)
+__FUNC_ADD_NON_SAMPLE_EVENT_CLASS(fork,
+ __NON_SAMPLE_ADD_FIELD(u32, pid);
+ __NON_SAMPLE_ADD_FIELD(u32, ppid);
+ __NON_SAMPLE_ADD_FIELD(u32, tid);
+ __NON_SAMPLE_ADD_FIELD(u32, ptid);
+ __NON_SAMPLE_ADD_FIELD(u64, time);
+)
+
+__FUNC_ADD_NON_SAMPLE_EVENT_CLASS(exit,
+ __NON_SAMPLE_ADD_FIELD(u32, pid);
+ __NON_SAMPLE_ADD_FIELD(u32, ppid);
+ __NON_SAMPLE_ADD_FIELD(u32, tid);
+ __NON_SAMPLE_ADD_FIELD(u32, ptid);
+ __NON_SAMPLE_ADD_FIELD(u64, time);
+)
+
#undef __NON_SAMPLE_ADD_FIELD
#undef __FUNC_ADD_NON_SAMPLE_EVENT_CLASS
@@ -1138,6 +1171,12 @@ static int setup_non_sample_events(struct ctf_writer *cw,
ret = add_comm_event(cw);
if (ret)
return ret;
+ ret = add_exit_event(cw);
+ if (ret)
+ return ret;
+ ret = add_fork_event(cw);
+ if (ret)
+ return ret;
return 0;
}
@@ -1436,8 +1475,11 @@ int bt_convert__perf2ctf(const char *input, const char *path,
struct ctf_writer *cw = &c.writer;
int err = -1;
- if (opts->all)
+ if (opts->all) {
c.tool.comm = process_comm_event;
+ c.tool.exit = process_exit_event;
+ c.tool.fork = process_fork_event;
+ }
perf_config(convert__config, &c);
^ permalink raw reply related [flat|nested] 24+ messages in thread
end of thread, other threads:[~2016-06-29 9:47 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-24 11:22 [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF Wang Nan
2016-06-24 11:22 ` [PATCH v2 1/7] perf ctf: Add value_set_string() helper Wang Nan
2016-06-29 9:45 ` [tip:perf/core] perf data " tip-bot for Wang Nan
2016-06-24 11:22 ` [PATCH v2 2/7] perf ctf: Pass convert options through opts structure Wang Nan
2016-06-29 9:45 ` [tip:perf/core] perf data " tip-bot for Wang Nan
2016-06-24 11:22 ` [PATCH v2 3/7] perf ctf: Add 'all' option Wang Nan
2016-06-29 9:46 ` [tip:perf/core] perf data " tip-bot for Wang Nan
2016-06-24 11:22 ` [PATCH v2 4/7] perf ctf: Prepare collect non-sample events Wang Nan
2016-06-29 9:46 ` [tip:perf/core] perf data " tip-bot for Wang Nan
2016-06-24 11:22 ` [PATCH v2 5/7] perf ctf: Generate comm event to CTF output Wang Nan
2016-06-29 9:46 ` [tip:perf/core] perf data " tip-bot for Wang Nan
2016-06-24 11:22 ` [PATCH v2 6/7] perf ctf: Add '--all' option for 'perf data convert' Wang Nan
2016-06-29 9:47 ` [tip:perf/core] perf data " tip-bot for Wang Nan
2016-06-24 11:22 ` [PATCH v2 7/7] perf ctf: Generate fork and exit events to CTF output Wang Nan
2016-06-29 9:47 ` [tip:perf/core] perf data " tip-bot for Wang Nan
2016-06-24 12:28 ` [PATCH v2 0/7] perf ctf: Convert comm, fork and exit events to CTF Jiri Olsa
2016-06-27 19:03 ` Arnaldo Carvalho de Melo
2016-06-24 12:29 ` Jiri Olsa
2016-06-24 12:33 ` pi3orama
2016-06-24 12:55 ` Jiri Olsa
2016-06-24 12:41 ` Arnaldo Carvalho de Melo
2016-06-24 12:43 ` pi3orama
2016-06-24 13:08 ` Jiri Olsa
2016-06-24 12:44 ` Jiri Olsa
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.