linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] Few patches, backported from Arnaldo's kernel repo
@ 2019-01-30 10:44 Tzvetomir Stoyanov
  2019-01-30 10:44 ` [PATCH 1/6] trace-cmd: Initialize host_bigendian at tep_handle allocation Tzvetomir Stoyanov
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Tzvetomir Stoyanov @ 2019-01-30 10:44 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

Few patches, backported from Arnaldo's kernel repo. The patch series 
was merged upstream on 8th of Januari.

Tzvetomir Stoyanov (6):
  trace-cmd: Initialize host_bigendian at tep_handle allocation
  trace_cmd: Rename struct cmdline to struct tep_cmdline
  trace-cmd: Changed return logic of trace_seq_printf() and
    trace_seq_vprintf() APIs
  trace-cmd: Changed return logic of tep_register_event_handler() API
  trace-cmd: Rename tep_is_file_bigendian() to tep_file_bigendian()
  trace-cmd: Remove tep_data_event_from_type() API

 include/traceevent/event-parse.h   | 16 +++++---
 kernel-shark/src/libkshark.c       |  7 ++--
 lib/trace-cmd/trace-input.c        |  8 ++--
 lib/traceevent/event-parse-api.c   |  4 +-
 lib/traceevent/event-parse-local.h |  4 +-
 lib/traceevent/event-parse.c       | 62 ++++++++++++++----------------
 lib/traceevent/trace-seq.c         | 17 +++++---
 plugins/plugin_kvm.c               |  2 +-
 python/tracecmd.py                 | 10 ++---
 tracecmd/trace-hist.c              |  4 +-
 tracecmd/trace-mem.c               |  2 +-
 tracecmd/trace-output.c            |  2 +-
 tracecmd/trace-read.c              |  7 ++--
 tracecmd/trace-record.c            |  2 +-
 tracecmd/trace-split.c             |  2 +-
 15 files changed, 78 insertions(+), 71 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/6] trace-cmd: Initialize host_bigendian at tep_handle allocation
  2019-01-30 10:44 [PATCH 0/6] Few patches, backported from Arnaldo's kernel repo Tzvetomir Stoyanov
@ 2019-01-30 10:44 ` Tzvetomir Stoyanov
  2019-01-30 10:44 ` [PATCH 2/6] trace_cmd: Rename struct cmdline to struct tep_cmdline Tzvetomir Stoyanov
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tzvetomir Stoyanov @ 2019-01-30 10:44 UTC (permalink / raw)
  To: rostedt
  Cc: linux-trace-devel, Andrew Morton, Jiri Olsa, Namhyung Kim,
	Arnaldo Carvalho de Melo

This patch initializes the host_bigendian member of the tep_handle
structure with the byte order of the current host, when this handler is
created - in tep_alloc() API. We need this in order to remove the
tep_set_host_bigendian() API.

Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20181201040852.216292134@goodmis.org
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 lib/traceevent/event-parse.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/traceevent/event-parse.c b/lib/traceevent/event-parse.c
index 3f85b94..b506dc7 100644
--- a/lib/traceevent/event-parse.c
+++ b/lib/traceevent/event-parse.c
@@ -6829,8 +6829,10 @@ struct tep_handle *tep_alloc(void)
 {
 	struct tep_handle *pevent = calloc(1, sizeof(*pevent));
 
-	if (pevent)
+	if (pevent) {
 		pevent->ref_count = 1;
+		pevent->host_bigendian = tep_host_bigendian();
+	}
 
 	return pevent;
 }
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/6] trace_cmd: Rename struct cmdline to struct tep_cmdline
  2019-01-30 10:44 [PATCH 0/6] Few patches, backported from Arnaldo's kernel repo Tzvetomir Stoyanov
  2019-01-30 10:44 ` [PATCH 1/6] trace-cmd: Initialize host_bigendian at tep_handle allocation Tzvetomir Stoyanov
@ 2019-01-30 10:44 ` Tzvetomir Stoyanov
  2019-01-30 10:44 ` [PATCH 3/6] trace-cmd: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs Tzvetomir Stoyanov
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tzvetomir Stoyanov @ 2019-01-30 10:44 UTC (permalink / raw)
  To: rostedt
  Cc: linux-trace-devel, Andrew Morton, Jiri Olsa, Namhyung Kim,
	Arnaldo Carvalho de Melo

In order to make libtraceevent a proper library, variables, data
structures and functions should have a unique prefix to prevent name
space conflicts. That prefix will be "tep_".

This patch renames 'struct cmdline' to 'struct tep_cmdline'.

Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20181201040852.358871851@goodmis.org
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 include/traceevent/event-parse.h   |  8 +++----
 lib/traceevent/event-parse-local.h |  4 ++--
 lib/traceevent/event-parse.c       | 36 +++++++++++++++---------------
 tracecmd/trace-read.c              |  3 ++-
 4 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/include/traceevent/event-parse.h b/include/traceevent/event-parse.h
index 3f2ae80..426b7eb 100644
--- a/include/traceevent/event-parse.h
+++ b/include/traceevent/event-parse.h
@@ -515,10 +515,10 @@ int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec);
 int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec);
 int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec);
 const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid);
-struct cmdline;
-struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm,
-				       struct cmdline *next);
-int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline);
+struct tep_cmdline;
+struct tep_cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm,
+					   struct tep_cmdline *next);
+int tep_cmdline_pid(struct tep_handle *pevent, struct tep_cmdline *cmdline);
 
 void tep_print_field(struct trace_seq *s, void *data,
 		     struct tep_format_field *field);
diff --git a/lib/traceevent/event-parse-local.h b/lib/traceevent/event-parse-local.h
index 70693b8..c5c8eb4 100644
--- a/lib/traceevent/event-parse-local.h
+++ b/lib/traceevent/event-parse-local.h
@@ -7,7 +7,7 @@
 #ifndef _PARSE_EVENTS_INT_H
 #define _PARSE_EVENTS_INT_H
 
-struct cmdline;
+struct tep_cmdline;
 struct cmdline_list;
 struct func_map;
 struct func_list;
@@ -36,7 +36,7 @@ struct tep_handle {
 	int long_size;
 	int page_size;
 
-	struct cmdline *cmdlines;
+	struct tep_cmdline *cmdlines;
 	struct cmdline_list *cmdlist;
 	int cmdline_count;
 
diff --git a/lib/traceevent/event-parse.c b/lib/traceevent/event-parse.c
index b506dc7..1f1821d 100644
--- a/lib/traceevent/event-parse.c
+++ b/lib/traceevent/event-parse.c
@@ -124,15 +124,15 @@ struct tep_print_arg *alloc_arg(void)
 	return calloc(1, sizeof(struct tep_print_arg));
 }
 
-struct cmdline {
+struct tep_cmdline {
 	char *comm;
 	int pid;
 };
 
 static int cmdline_cmp(const void *a, const void *b)
 {
-	const struct cmdline *ca = a;
-	const struct cmdline *cb = b;
+	const struct tep_cmdline *ca = a;
+	const struct tep_cmdline *cb = b;
 
 	if (ca->pid < cb->pid)
 		return -1;
@@ -152,7 +152,7 @@ static int cmdline_init(struct tep_handle *pevent)
 {
 	struct cmdline_list *cmdlist = pevent->cmdlist;
 	struct cmdline_list *item;
-	struct cmdline *cmdlines;
+	struct tep_cmdline *cmdlines;
 	int i;
 
 	cmdlines = malloc(sizeof(*cmdlines) * pevent->cmdline_count);
@@ -179,8 +179,8 @@ static int cmdline_init(struct tep_handle *pevent)
 
 static const char *find_cmdline(struct tep_handle *pevent, int pid)
 {
-	const struct cmdline *comm;
-	struct cmdline key;
+	const struct tep_cmdline *comm;
+	struct tep_cmdline key;
 
 	if (!pid)
 		return "<idle>";
@@ -208,8 +208,8 @@ static const char *find_cmdline(struct tep_handle *pevent, int pid)
  */
 int tep_pid_is_registered(struct tep_handle *pevent, int pid)
 {
-	const struct cmdline *comm;
-	struct cmdline key;
+	const struct tep_cmdline *comm;
+	struct tep_cmdline key;
 
 	if (!pid)
 		return 1;
@@ -235,9 +235,9 @@ int tep_pid_is_registered(struct tep_handle *pevent, int pid)
 static int add_new_comm(struct tep_handle *pevent,
 			const char *comm, int pid, bool override)
 {
-	struct cmdline *cmdlines = pevent->cmdlines;
-	struct cmdline *cmdline;
-	struct cmdline key;
+	struct tep_cmdline *cmdlines = pevent->cmdlines;
+	struct tep_cmdline *cmdline;
+	struct tep_cmdline key;
 	char *new_comm;
 
 	if (!pid)
@@ -5332,8 +5332,8 @@ const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid)
 	return comm;
 }
 
-static struct cmdline *
-pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *next)
+static struct tep_cmdline *
+pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct tep_cmdline *next)
 {
 	struct cmdline_list *cmdlist = (struct cmdline_list *)next;
 
@@ -5345,7 +5345,7 @@ pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *ne
 	while (cmdlist && strcmp(cmdlist->comm, comm) != 0)
 		cmdlist = cmdlist->next;
 
-	return (struct cmdline *)cmdlist;
+	return (struct tep_cmdline *)cmdlist;
 }
 
 /**
@@ -5361,10 +5361,10 @@ pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *ne
  * next pid.
  * Also, it does a linear search, so it may be slow.
  */
-struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm,
-				       struct cmdline *next)
+struct tep_cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm,
+					   struct tep_cmdline *next)
 {
-	struct cmdline *cmdline;
+	struct tep_cmdline *cmdline;
 
 	/*
 	 * If the cmdlines have not been converted yet, then use
@@ -5403,7 +5403,7 @@ struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *co
  * Returns the pid for a give cmdline. If @cmdline is NULL, then
  * -1 is returned.
  */
-int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline)
+int tep_cmdline_pid(struct tep_handle *pevent, struct tep_cmdline *cmdline)
 {
 	struct cmdline_list *cmdlist = (struct cmdline_list *)cmdline;
 
diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c
index 804022a..4cc1f61 100644
--- a/tracecmd/trace-read.c
+++ b/tracecmd/trace-read.c
@@ -419,9 +419,10 @@ static char *append_pid_filter(char *curr_filter, char *pid)
 
 static void convert_comm_filter(struct tracecmd_input *handle)
 {
+	struct tep_cmdline *cmdline;
 	struct tep_handle *pevent;
 	struct pid_list *list;
-	struct cmdline *cmdline;
+
 	char pidstr[100];
 
 	if (!comm_list)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/6] trace-cmd: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs
  2019-01-30 10:44 [PATCH 0/6] Few patches, backported from Arnaldo's kernel repo Tzvetomir Stoyanov
  2019-01-30 10:44 ` [PATCH 1/6] trace-cmd: Initialize host_bigendian at tep_handle allocation Tzvetomir Stoyanov
  2019-01-30 10:44 ` [PATCH 2/6] trace_cmd: Rename struct cmdline to struct tep_cmdline Tzvetomir Stoyanov
@ 2019-01-30 10:44 ` Tzvetomir Stoyanov
  2019-01-30 10:44 ` [PATCH 4/6] trace-cmd: Changed return logic of tep_register_event_handler() API Tzvetomir Stoyanov
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tzvetomir Stoyanov @ 2019-01-30 10:44 UTC (permalink / raw)
  To: rostedt
  Cc: linux-trace-devel, Andrew Morton, Jiri Olsa, Namhyung Kim,
	Arnaldo Carvalho de Melo

In order to make libtraceevent into a proper library, its API should be
straightforward.

The trace_seq_printf() and trace_seq_vprintf() APIs have inconsistent
returned values with the other trace_seq_* APIs.

This path changes the return logic of trace_seq_printf() and
trace_seq_vprintf() to return the number of printed characters, as the
other trace_seq_* related APIs.

Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20181201040852.485792891@goodmis.org
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 lib/traceevent/trace-seq.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/lib/traceevent/trace-seq.c b/lib/traceevent/trace-seq.c
index 7f0c2f0..a20dab1 100644
--- a/lib/traceevent/trace-seq.c
+++ b/lib/traceevent/trace-seq.c
@@ -100,7 +100,8 @@ static void expand_buffer(struct trace_seq *s)
  * @fmt: printf format string
  *
  * It returns 0 if the trace oversizes the buffer's free
- * space, 1 otherwise.
+ * space, the number of characters printed, or a negative
+ * value in case of an error.
  *
  * The tracer may use either sequence operations or its own
  * copy to user routines. To simplify formating of a trace
@@ -129,9 +130,10 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
 		goto try_again;
 	}
 
-	s->len += ret;
+	if (ret > 0)
+		s->len += ret;
 
-	return 1;
+	return ret;
 }
 
 /**
@@ -139,6 +141,10 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
  * @s: trace sequence descriptor
  * @fmt: printf format string
  *
+ * It returns 0 if the trace oversizes the buffer's free
+ * space, the number of characters printed, or a negative
+ * value in case of an error.
+ * *
  * The tracer may use either sequence operations or its own
  * copy to user routines. To simplify formating of a trace
  * trace_seq_printf is used to store strings into a special
@@ -163,9 +169,10 @@ trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args)
 		goto try_again;
 	}
 
-	s->len += ret;
+	if (ret > 0)
+		s->len += ret;
 
-	return len;
+	return ret;
 }
 
 /**
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/6] trace-cmd: Changed return logic of tep_register_event_handler() API
  2019-01-30 10:44 [PATCH 0/6] Few patches, backported from Arnaldo's kernel repo Tzvetomir Stoyanov
                   ` (2 preceding siblings ...)
  2019-01-30 10:44 ` [PATCH 3/6] trace-cmd: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs Tzvetomir Stoyanov
@ 2019-01-30 10:44 ` Tzvetomir Stoyanov
  2019-01-30 10:44 ` [PATCH 5/6] trace-cmd: Rename tep_is_file_bigendian() to tep_file_bigendian() Tzvetomir Stoyanov
  2019-01-30 10:44 ` [PATCH 6/6] trace-cmd: Remove tep_data_event_from_type() API Tzvetomir Stoyanov
  5 siblings, 0 replies; 7+ messages in thread
From: Tzvetomir Stoyanov @ 2019-01-30 10:44 UTC (permalink / raw)
  To: rostedt
  Cc: linux-trace-devel, Andrew Morton, Jiri Olsa, Namhyung Kim,
	Arnaldo Carvalho de Melo

In order to make libtraceevent into a proper library, its API
should be straightforward.

The tep_register_event_handler() functions returns -1 in case it
successfully registers the new event handler. Such return code is used
by the other library APIs in case of an error.

To unify the return logic of tep_register_event_handler() with the other
APIs, this patch introduces enum tep_reg_handler, which is used by this
function as return value, to handle all possible successful return
cases.

Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20181201040852.628034497@goodmis.org
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 include/traceevent/event-parse.h |  5 +++++
 lib/traceevent/event-parse.c     | 10 ++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/include/traceevent/event-parse.h b/include/traceevent/event-parse.h
index 426b7eb..b4fa2c7 100644
--- a/include/traceevent/event-parse.h
+++ b/include/traceevent/event-parse.h
@@ -473,6 +473,11 @@ int tep_print_func_field(struct trace_seq *s, const char *fmt,
 			 struct tep_event *event, const char *name,
 			 struct tep_record *record, int err);
 
+enum tep_reg_handler {
+	TEP_REGISTER_SUCCESS = 0,
+	TEP_REGISTER_SUCCESS_OVERWRITE,
+};
+
 int tep_register_event_handler(struct tep_handle *pevent, int id,
 			       const char *sys_name, const char *event_name,
 			       tep_event_handler_func func, void *context);
diff --git a/lib/traceevent/event-parse.c b/lib/traceevent/event-parse.c
index 1f1821d..8cdb5a3 100644
--- a/lib/traceevent/event-parse.c
+++ b/lib/traceevent/event-parse.c
@@ -6699,6 +6699,12 @@ static struct tep_event *search_event(struct tep_handle *pevent, int id,
  *
  * If @id is >= 0, then it is used to find the event.
  * else @sys_name and @event_name are used.
+ *
+ * Returns:
+ *  TEP_REGISTER_SUCCESS_OVERWRITE if an existing handler is overwritten
+ *  TEP_REGISTER_SUCCESS if a new handler is registered successfully
+ *  negative TEP_ERRNO_... in case of an error
+ *
  */
 int tep_register_event_handler(struct tep_handle *pevent, int id,
 			       const char *sys_name, const char *event_name,
@@ -6716,7 +6722,7 @@ int tep_register_event_handler(struct tep_handle *pevent, int id,
 
 	event->handler = func;
 	event->context = context;
-	return 0;
+	return TEP_REGISTER_SUCCESS_OVERWRITE;
 
  not_found:
 	/* Save for later use. */
@@ -6746,7 +6752,7 @@ int tep_register_event_handler(struct tep_handle *pevent, int id,
 	pevent->handlers = handle;
 	handle->context = context;
 
-	return -1;
+	return TEP_REGISTER_SUCCESS;
 }
 
 static int handle_matches(struct event_handler *handler, int id,
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/6] trace-cmd: Rename tep_is_file_bigendian() to tep_file_bigendian()
  2019-01-30 10:44 [PATCH 0/6] Few patches, backported from Arnaldo's kernel repo Tzvetomir Stoyanov
                   ` (3 preceding siblings ...)
  2019-01-30 10:44 ` [PATCH 4/6] trace-cmd: Changed return logic of tep_register_event_handler() API Tzvetomir Stoyanov
@ 2019-01-30 10:44 ` Tzvetomir Stoyanov
  2019-01-30 10:44 ` [PATCH 6/6] trace-cmd: Remove tep_data_event_from_type() API Tzvetomir Stoyanov
  5 siblings, 0 replies; 7+ messages in thread
From: Tzvetomir Stoyanov @ 2019-01-30 10:44 UTC (permalink / raw)
  To: rostedt
  Cc: linux-trace-devel, Andrew Morton, Jiri Olsa, Namhyung Kim,
	Arnaldo Carvalho de Melo

In order to make libtraceevent into a proper library, its API
should be straightforward.

After a discussion with Steven Rostedt, we decided to rename a few APIs,
to have more intuitive names.

This patch renames tep_is_file_bigendian() to tep_file_bigendian().

Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20181201040852.767549746@goodmis.org
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 include/traceevent/event-parse.h | 2 +-
 lib/trace-cmd/trace-input.c      | 8 ++++----
 lib/traceevent/event-parse-api.c | 4 ++--
 plugins/plugin_kvm.c             | 2 +-
 python/tracecmd.py               | 2 +-
 tracecmd/trace-output.c          | 2 +-
 tracecmd/trace-read.c            | 4 ++--
 tracecmd/trace-split.c           | 2 +-
 8 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/include/traceevent/event-parse.h b/include/traceevent/event-parse.h
index b4fa2c7..2dc5822 100644
--- a/include/traceevent/event-parse.h
+++ b/include/traceevent/event-parse.h
@@ -551,7 +551,7 @@ int tep_get_long_size(struct tep_handle *pevent);
 void tep_set_long_size(struct tep_handle *pevent, int long_size);
 int tep_get_page_size(struct tep_handle *pevent);
 void tep_set_page_size(struct tep_handle *pevent, int _page_size);
-int tep_is_file_bigendian(struct tep_handle *pevent);
+int tep_file_bigendian(struct tep_handle *pevent);
 void tep_set_file_bigendian(struct tep_handle *pevent, enum tep_endian endian);
 int tep_is_host_bigendian(struct tep_handle *pevent);
 void tep_set_host_bigendian(struct tep_handle *pevent, enum tep_endian endian);
diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index b628570..b161c75 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -1619,7 +1619,7 @@ tracecmd_translate_data(struct tracecmd_input *handle,
 	memset(record, 0, sizeof(*record));
 
 	record->ref_count = 1;
-	if (tep_is_host_bigendian(pevent) == tep_is_file_bigendian(pevent))
+	if (tep_is_host_bigendian(pevent) == tep_file_bigendian(pevent))
 		swap = 0;
 	record->data = kbuffer_translate_data(swap, ptr, &length);
 	record->size = length;
@@ -1661,7 +1661,7 @@ tracecmd_read_page_record(struct tep_handle *pevent, void *page, int size,
 	enum kbuffer_endian endian;
 	void *ptr;
 
-	if (tep_is_file_bigendian(pevent))
+	if (tep_file_bigendian(pevent))
 		endian = KBUFFER_ENDIAN_BIG;
 	else
 		endian = KBUFFER_ENDIAN_LITTLE;
@@ -2266,7 +2266,7 @@ static int read_cpu_data(struct tracecmd_input *handle)
 	else
 		long_size = KBUFFER_LSIZE_4;
 
-	if (tep_is_file_bigendian(handle->pevent))
+	if (tep_file_bigendian(handle->pevent))
 		endian = KBUFFER_ENDIAN_BIG;
 	else
 		endian = KBUFFER_ENDIAN_LITTLE;
@@ -2475,7 +2475,7 @@ int tracecmd_make_pipe(struct tracecmd_input *handle, int cpu, int fd, int cpus)
 	else
 		long_size = KBUFFER_LSIZE_4;
 
-	if (tep_is_file_bigendian(handle->pevent))
+	if (tep_file_bigendian(handle->pevent))
 		endian = KBUFFER_ENDIAN_BIG;
 	else
 		endian = KBUFFER_ENDIAN_LITTLE;
diff --git a/lib/traceevent/event-parse-api.c b/lib/traceevent/event-parse-api.c
index 347ff10..afafbc8 100644
--- a/lib/traceevent/event-parse-api.c
+++ b/lib/traceevent/event-parse-api.c
@@ -250,13 +250,13 @@ void tep_set_page_size(struct tep_handle *pevent, int _page_size)
 }
 
 /**
- * tep_is_file_bigendian - get if the file is in big endian order
+ * tep_file_bigendian - get if the file is in big endian order
  * @pevent: a handle to the tep_handle
  *
  * This returns if the file is in big endian order
  * If @pevent is NULL, 0 is returned.
  */
-int tep_is_file_bigendian(struct tep_handle *pevent)
+int tep_file_bigendian(struct tep_handle *pevent)
 {
 	if (pevent)
 		return pevent->file_bigendian;
diff --git a/plugins/plugin_kvm.c b/plugins/plugin_kvm.c
index f81d3c5..ddac21a 100644
--- a/plugins/plugin_kvm.c
+++ b/plugins/plugin_kvm.c
@@ -386,7 +386,7 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct tep_record *record,
 	 * We can only use the structure if file is of the same
 	 * endianness.
 	 */
-	if (tep_is_file_bigendian(event->pevent) ==
+	if (tep_file_bigendian(event->pevent) ==
 	    tep_is_host_bigendian(event->pevent)) {
 
 		trace_seq_printf(s, "%u/%u q%u%s %s%s %spge %snxe",
diff --git a/python/tracecmd.py b/python/tracecmd.py
index f4f241e..60a0d3e 100644
--- a/python/tracecmd.py
+++ b/python/tracecmd.py
@@ -166,7 +166,7 @@ class PEvent(object):
 
     @cached_property
     def file_endian(self):
-        if tep_is_file_bigendian(self._pevent):
+        if tep_file_bigendian(self._pevent):
             return '>'
         return '<'
 
diff --git a/tracecmd/trace-output.c b/tracecmd/trace-output.c
index 33d6ce3..1c2e92c 100644
--- a/tracecmd/trace-output.c
+++ b/tracecmd/trace-output.c
@@ -808,7 +808,7 @@ create_file_fd(int fd, struct tracecmd_input *ihandle,
 		/* Use the pevent of the ihandle for later writes */
 		handle->pevent = tracecmd_get_pevent(ihandle);
 		tep_ref(pevent);
-		if (tep_is_file_bigendian(pevent))
+		if (tep_file_bigendian(pevent))
 			buf[0] = 1;
 		else
 			buf[0] = 0;
diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c
index 4cc1f61..03c0978 100644
--- a/tracecmd/trace-read.c
+++ b/tracecmd/trace-read.c
@@ -1700,8 +1700,8 @@ void trace_report (int argc, char **argv)
 
 		if (show_endian) {
 			printf("file is %s endian and host is %s endian\n",
-			       tep_is_file_bigendian(pevent) ? "big" : "little",
-			       tep_is_host_bigendian(pevent) ? "big" : "little");
+				tep_file_bigendian(pevent) ? "big" : "little",
+				tep_is_host_bigendian(pevent) ? "big" : "little");
 			return;
 		}
 
diff --git a/tracecmd/trace-split.c b/tracecmd/trace-split.c
index d27b3c6..6043e97 100644
--- a/tracecmd/trace-split.c
+++ b/tracecmd/trace-split.c
@@ -64,7 +64,7 @@ static int create_type_len(struct tep_handle *pevent, int time, int len)
 			bigendian = 1;
 	}
 
-	if (tep_is_file_bigendian(pevent))
+	if (tep_file_bigendian(pevent))
 		time |= (len << 27);
 	else
 		time = (time << 5) | len;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 6/6] trace-cmd: Remove tep_data_event_from_type() API
  2019-01-30 10:44 [PATCH 0/6] Few patches, backported from Arnaldo's kernel repo Tzvetomir Stoyanov
                   ` (4 preceding siblings ...)
  2019-01-30 10:44 ` [PATCH 5/6] trace-cmd: Rename tep_is_file_bigendian() to tep_file_bigendian() Tzvetomir Stoyanov
@ 2019-01-30 10:44 ` Tzvetomir Stoyanov
  5 siblings, 0 replies; 7+ messages in thread
From: Tzvetomir Stoyanov @ 2019-01-30 10:44 UTC (permalink / raw)
  To: rostedt
  Cc: linux-trace-devel, Andrew Morton, Jiri Olsa, Namhyung Kim,
	Arnaldo Carvalho de Melo

In order to make libtraceevent into a proper library, its API
should be straightforward.

After discussion with Steven Rostedt, we decided to remove the
tep_data_event_from_type() API and to replace it with tep_find_event(),
as it does the same.

Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20181201040852.913841066@goodmis.org
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 include/traceevent/event-parse.h |  1 -
 kernel-shark/src/libkshark.c     |  7 +++----
 lib/traceevent/event-parse.c     | 12 ------------
 python/tracecmd.py               |  8 ++++----
 tracecmd/trace-hist.c            |  4 ++--
 tracecmd/trace-mem.c             |  2 +-
 tracecmd/trace-record.c          |  2 +-
 7 files changed, 11 insertions(+), 25 deletions(-)

diff --git a/include/traceevent/event-parse.h b/include/traceevent/event-parse.h
index 2dc5822..bdc6101 100644
--- a/include/traceevent/event-parse.h
+++ b/include/traceevent/event-parse.h
@@ -515,7 +515,6 @@ tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record);
 void tep_data_lat_fmt(struct tep_handle *pevent,
 		      struct trace_seq *s, struct tep_record *record);
 int tep_data_type(struct tep_handle *pevent, struct tep_record *rec);
-struct tep_event *tep_data_event_from_type(struct tep_handle *pevent, int type);
 int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec);
 int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec);
 int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec);
diff --git a/kernel-shark/src/libkshark.c b/kernel-shark/src/libkshark.c
index 5033e47..6a26f28 100644
--- a/kernel-shark/src/libkshark.c
+++ b/kernel-shark/src/libkshark.c
@@ -1187,7 +1187,7 @@ const char *kshark_get_event_name_easy(struct kshark_entry *entry)
 	 * Use a mutex to protect the access.
 	 */
 	pthread_mutex_lock(&kshark_ctx->input_mutex);
-	event = tep_data_event_from_type(kshark_ctx->pevent, event_id);
+	event = tep_find_event(kshark_ctx->pevent, event_id);
 	pthread_mutex_unlock(&kshark_ctx->input_mutex);
 
 	if (event)
@@ -1236,7 +1236,7 @@ const char *kshark_get_info_easy(struct kshark_entry *entry)
 
 	data = tracecmd_read_at(kshark_ctx->handle, entry->offset, NULL);
 	event_id = tep_data_type(kshark_ctx->pevent, data);
-	event = tep_data_event_from_type(kshark_ctx->pevent, event_id);
+	event = tep_find_event(kshark_ctx->pevent, event_id);
 	if (event)
 		info = kshark_get_info(kshark_ctx->pevent, data, event);
 
@@ -1330,8 +1330,7 @@ char* kshark_dump_entry(const struct kshark_entry *entry)
 		data = tracecmd_read_at(kshark_ctx->handle, entry->offset,
 					NULL);
 
-		event = tep_data_event_from_type(kshark_ctx->pevent,
-						 entry->event_id);
+		event = tep_find_event(kshark_ctx->pevent, entry->event_id);
 
 		event_name = event? event->name : "[UNKNOWN EVENT]";
 		lat = kshark_get_latency(kshark_ctx->pevent, data);
diff --git a/lib/traceevent/event-parse.c b/lib/traceevent/event-parse.c
index 8cdb5a3..ca2989b 100644
--- a/lib/traceevent/event-parse.c
+++ b/lib/traceevent/event-parse.c
@@ -5266,18 +5266,6 @@ int tep_data_type(struct tep_handle *pevent, struct tep_record *rec)
 	return trace_parse_common_type(pevent, rec->data);
 }
 
-/**
- * tep_data_event_from_type - find the event by a given type
- * @pevent: a handle to the pevent
- * @type: the type of the event.
- *
- * This returns the event form a given @type;
- */
-struct tep_event *tep_data_event_from_type(struct tep_handle *pevent, int type)
-{
-	return tep_find_event(pevent, type);
-}
-
 /**
  * tep_data_pid - parse the PID from record
  * @pevent: a handle to the pevent
diff --git a/python/tracecmd.py b/python/tracecmd.py
index 60a0d3e..a6671f6 100644
--- a/python/tracecmd.py
+++ b/python/tracecmd.py
@@ -204,7 +204,7 @@ class Trace(object):
         rec = tracecmd_read_data(self._handle, cpu)
         if rec:
             type = tep_data_type(self._pevent, rec)
-            format = tep_data_event_from_type(self._pevent, type)
+            format = tep_find_event(self._pevent, type)
             # rec ownership goes over to Event instance
             return Event(self._pevent, rec, format)
         return None
@@ -216,7 +216,7 @@ class Trace(object):
             return None
         rec, cpu = res
         type = tep_data_type(self._pevent, rec)
-        format = tep_data_event_from_type(self._pevent, type)
+        format = tep_find_event(self._pevent, type)
         # rec ownership goes over to Event instance
         return Event(self._pevent, rec, format)
 
@@ -226,7 +226,7 @@ class Trace(object):
             return None
         rec, cpu = res
         type = tep_data_type(self._pevent, rec)
-        format = tep_data_event_from_type(self._pevent, type)
+        format = tep_find_event(self._pevent, type)
         return Event(self._pevent, rec, format)
 
     def peek_event(self, cpu):
@@ -234,7 +234,7 @@ class Trace(object):
         if rec is None:
             return None
         type = tep_data_type(self._pevent, rec)
-        format = tep_data_event_from_type(self._pevent, type)
+        format = tep_find_event(self._pevent, type)
         # rec ownership goes over to Event instance
         return Event(self._pevent, rec, format)
 
diff --git a/tracecmd/trace-hist.c b/tracecmd/trace-hist.c
index bd47163..384a7ff 100644
--- a/tracecmd/trace-hist.c
+++ b/tracecmd/trace-hist.c
@@ -541,7 +541,7 @@ process_event(struct tep_handle *pevent, struct tep_record *record, int type)
 		reset_pending_stack();
 	}
 		
-	event = tep_data_event_from_type(pevent, type);
+	event = tep_find_event(pevent, type);
 	event_name = event->name;
 
 	ret = tep_read_number_field(common_pid_field, record->data, &val);
@@ -952,7 +952,7 @@ static void do_trace_hist(struct tracecmd_input *handle)
 		die("No records found in file");
 
 	ret = tep_data_type(pevent, record);
-	event = tep_data_event_from_type(pevent, ret);
+	event = tep_find_event(pevent, ret);
 
 	long_size = tracecmd_long_size(handle);
 
diff --git a/tracecmd/trace-mem.c b/tracecmd/trace-mem.c
index 059bf9a..078a61b 100644
--- a/tracecmd/trace-mem.c
+++ b/tracecmd/trace-mem.c
@@ -488,7 +488,7 @@ static void do_trace_mem(struct tracecmd_input *handle)
 		die("No records found in file");
 
 	ret = tep_data_type(pevent, record);
-	event = tep_data_event_from_type(pevent, ret);
+	event = tep_find_event(pevent, ret);
 
 	common_type_field = tep_find_common_field(event, "common_type");
 	if (!common_type_field)
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 3034a4b..71a407e 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -3402,7 +3402,7 @@ find_ts_in_page(struct tep_handle *pevent, void *page, int size)
 			break;
 		free_record(last_record);
 		id = tep_data_type(pevent, record);
-		event = tep_data_event_from_type(pevent, id);
+		event = tep_find_event(pevent, id);
 		if (event) {
 			/* Make sure this is our event */
 			field = tep_find_field(event, "buf");
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-01-30 10:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-30 10:44 [PATCH 0/6] Few patches, backported from Arnaldo's kernel repo Tzvetomir Stoyanov
2019-01-30 10:44 ` [PATCH 1/6] trace-cmd: Initialize host_bigendian at tep_handle allocation Tzvetomir Stoyanov
2019-01-30 10:44 ` [PATCH 2/6] trace_cmd: Rename struct cmdline to struct tep_cmdline Tzvetomir Stoyanov
2019-01-30 10:44 ` [PATCH 3/6] trace-cmd: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs Tzvetomir Stoyanov
2019-01-30 10:44 ` [PATCH 4/6] trace-cmd: Changed return logic of tep_register_event_handler() API Tzvetomir Stoyanov
2019-01-30 10:44 ` [PATCH 5/6] trace-cmd: Rename tep_is_file_bigendian() to tep_file_bigendian() Tzvetomir Stoyanov
2019-01-30 10:44 ` [PATCH 6/6] trace-cmd: Remove tep_data_event_from_type() API Tzvetomir Stoyanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).