All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] tools/lib/traceevent: Some more library updates
@ 2018-12-01  4:08 Steven Rostedt
  2018-12-01  4:08 ` [PATCH 1/6] tools/lib/traceevent: Initialize host_bigendian at tep_handle allocation Steven Rostedt
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Steven Rostedt @ 2018-12-01  4:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
	Andrew Morton

Arnaldo and Jiri,

Here's another set of patches to get us closer to having a legitimate
standalone library for libtraceevent. There's still a lot of man pages
to come, but I need to continue reviewing them.

Please pull this tree (based on current tip/perf/core) or apply
the patches.

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
tip/perf/core

Head SHA1: 5b2e18a71601544c4ae95e9ed1f953f3883714f5


Tzvetomir Stoyanov (6):
      tools/lib/traceevent: Initialize host_bigendian at tep_handle allocation
      tools/lib/traceevent: Rename struct cmdline to struct tep_cmdline
      tools/lib/traceevent: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs
      tools/lib/traceevent: Changed return logic of tep_register_event_handler() API
      tools/lib/traceevent: Rename tep_is_file_bigendian() to tep_file_bigendian()
      tools/lib/traceevent: Remove tep_data_event_from_type() API

----
 tools/lib/traceevent/event-parse-api.c   |  4 +--
 tools/lib/traceevent/event-parse-local.h |  4 +--
 tools/lib/traceevent/event-parse.c       | 62 +++++++++++++++-----------------
 tools/lib/traceevent/event-parse.h       | 16 +++++----
 tools/lib/traceevent/plugin_kvm.c        |  2 +-
 tools/lib/traceevent/trace-seq.c         | 17 ++++++---
 6 files changed, 56 insertions(+), 49 deletions(-)

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

* [PATCH 1/6] tools/lib/traceevent: Initialize host_bigendian at tep_handle allocation
  2018-12-01  4:08 [PATCH 0/6] tools/lib/traceevent: Some more library updates Steven Rostedt
@ 2018-12-01  4:08 ` Steven Rostedt
  2019-01-09  7:13   ` [tip:perf/urgent] tools lib traceevent: " tip-bot for Tzvetomir Stoyanov
  2018-12-01  4:08 ` [PATCH 2/6] tools/lib/traceevent: Rename struct cmdline to struct tep_cmdline Steven Rostedt
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Steven Rostedt @ 2018-12-01  4:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
	Andrew Morton, Tzvetomir Stoyanov

From: Tzvetomir Stoyanov <tstoyanov@vmware.com>

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

Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tools/lib/traceevent/event-parse.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 0923e331441e..5cd99bdb0517 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -6761,8 +6761,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.19.1



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

* [PATCH 2/6] tools/lib/traceevent: Rename struct cmdline to struct tep_cmdline
  2018-12-01  4:08 [PATCH 0/6] tools/lib/traceevent: Some more library updates Steven Rostedt
  2018-12-01  4:08 ` [PATCH 1/6] tools/lib/traceevent: Initialize host_bigendian at tep_handle allocation Steven Rostedt
@ 2018-12-01  4:08 ` Steven Rostedt
  2019-01-09  7:13   ` [tip:perf/urgent] tools lib traceevent: " tip-bot for Tzvetomir Stoyanov
  2018-12-01  4:08 ` [PATCH 3/6] tools/lib/traceevent: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs Steven Rostedt
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Steven Rostedt @ 2018-12-01  4:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
	Andrew Morton, Tzvetomir Stoyanov

From: Tzvetomir Stoyanov <tstoyanov@vmware.com>

In order to make libtraceevent into a proper library, variables, data
structures and functions require 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>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tools/lib/traceevent/event-parse-local.h |  4 +--
 tools/lib/traceevent/event-parse.c       | 36 ++++++++++++------------
 tools/lib/traceevent/event-parse.h       |  8 +++---
 3 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/tools/lib/traceevent/event-parse-local.h b/tools/lib/traceevent/event-parse-local.h
index 9a092dd4a86d..35833ee32d6c 100644
--- a/tools/lib/traceevent/event-parse-local.h
+++ b/tools/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/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 5cd99bdb0517..c3d22d0a2935 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/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)
@@ -5330,8 +5330,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;
 
@@ -5343,7 +5343,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;
 }
 
 /**
@@ -5359,10 +5359,10 @@ pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *ne
  * next pid.
  * Also, it does a linear seach, 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
@@ -5401,7 +5401,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/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index e6f4249910e6..77a4a1dd4b4d 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -526,10 +526,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);
-- 
2.19.1



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

* [PATCH 3/6] tools/lib/traceevent: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs
  2018-12-01  4:08 [PATCH 0/6] tools/lib/traceevent: Some more library updates Steven Rostedt
  2018-12-01  4:08 ` [PATCH 1/6] tools/lib/traceevent: Initialize host_bigendian at tep_handle allocation Steven Rostedt
  2018-12-01  4:08 ` [PATCH 2/6] tools/lib/traceevent: Rename struct cmdline to struct tep_cmdline Steven Rostedt
@ 2018-12-01  4:08 ` Steven Rostedt
  2019-01-09  7:14   ` [tip:perf/urgent] tools lib traceevent: " tip-bot for Tzvetomir Stoyanov
  2018-12-01  4:08 ` [PATCH 4/6] tools/lib/traceevent: Changed return logic of tep_register_event_handler() API Steven Rostedt
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Steven Rostedt @ 2018-12-01  4:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
	Andrew Morton, Tzvetomir Stoyanov

From: Tzvetomir Stoyanov <tstoyanov@vmware.com>

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>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tools/lib/traceevent/trace-seq.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/tools/lib/traceevent/trace-seq.c b/tools/lib/traceevent/trace-seq.c
index 8ff1d55954d1..8d5ecd2bf877 100644
--- a/tools/lib/traceevent/trace-seq.c
+++ b/tools/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.19.1



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

* [PATCH 4/6] tools/lib/traceevent: Changed return logic of tep_register_event_handler() API
  2018-12-01  4:08 [PATCH 0/6] tools/lib/traceevent: Some more library updates Steven Rostedt
                   ` (2 preceding siblings ...)
  2018-12-01  4:08 ` [PATCH 3/6] tools/lib/traceevent: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs Steven Rostedt
@ 2018-12-01  4:08 ` Steven Rostedt
  2019-01-09  7:15   ` [tip:perf/urgent] tools lib traceevent: " tip-bot for Tzvetomir Stoyanov
  2018-12-01  4:08 ` [PATCH 5/6] tools/lib/traceevent: Rename tep_is_file_bigendian() to tep_file_bigendian() Steven Rostedt
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Steven Rostedt @ 2018-12-01  4:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
	Andrew Morton, Tzvetomir Stoyanov

From: Tzvetomir Stoyanov <tstoyanov@vmware.com>

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>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tools/lib/traceevent/event-parse.c | 10 ++++++++--
 tools/lib/traceevent/event-parse.h |  5 +++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index c3d22d0a2935..b3c00d6b524e 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -6631,6 +6631,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,
@@ -6648,7 +6654,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. */
@@ -6678,7 +6684,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,
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 77a4a1dd4b4d..ac377ae99008 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -485,6 +485,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);
-- 
2.19.1



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

* [PATCH 5/6] tools/lib/traceevent: Rename tep_is_file_bigendian() to tep_file_bigendian()
  2018-12-01  4:08 [PATCH 0/6] tools/lib/traceevent: Some more library updates Steven Rostedt
                   ` (3 preceding siblings ...)
  2018-12-01  4:08 ` [PATCH 4/6] tools/lib/traceevent: Changed return logic of tep_register_event_handler() API Steven Rostedt
@ 2018-12-01  4:08 ` Steven Rostedt
  2019-01-09  7:15   ` [tip:perf/urgent] tools lib traceevent: " tip-bot for Tzvetomir Stoyanov
  2018-12-01  4:08 ` [PATCH 6/6] tools/lib/traceevent: Remove tep_data_event_from_type() API Steven Rostedt
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Steven Rostedt @ 2018-12-01  4:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
	Andrew Morton, Tzvetomir Stoyanov

From: Tzvetomir Stoyanov <tstoyanov@vmware.com>

In order to make libtraceevent into a proper library, its API
should be straightforward. After 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>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tools/lib/traceevent/event-parse-api.c | 4 ++--
 tools/lib/traceevent/event-parse.h     | 2 +-
 tools/lib/traceevent/plugin_kvm.c      | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/lib/traceevent/event-parse-api.c b/tools/lib/traceevent/event-parse-api.c
index 8b31c0e00ba3..d463761a58f4 100644
--- a/tools/lib/traceevent/event-parse-api.c
+++ b/tools/lib/traceevent/event-parse-api.c
@@ -194,13 +194,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/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index ac377ae99008..bd1bd9a27839 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -559,7 +559,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/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c
index 637be7c18476..388a78a6035f 100644
--- a/tools/lib/traceevent/plugin_kvm.c
+++ b/tools/lib/traceevent/plugin_kvm.c
@@ -389,7 +389,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
 	 * endianess.
 	 */
-	if (tep_is_file_bigendian(event->pevent) ==
+	if (tep_file_bigendian(event->pevent) ==
 	    tep_is_host_bigendian(event->pevent)) {
 
 		trace_seq_printf(s, "%u q%u%s %s%s %spae %snxe %swp%s%s%s",
-- 
2.19.1



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

* [PATCH 6/6] tools/lib/traceevent: Remove tep_data_event_from_type() API
  2018-12-01  4:08 [PATCH 0/6] tools/lib/traceevent: Some more library updates Steven Rostedt
                   ` (4 preceding siblings ...)
  2018-12-01  4:08 ` [PATCH 5/6] tools/lib/traceevent: Rename tep_is_file_bigendian() to tep_file_bigendian() Steven Rostedt
@ 2018-12-01  4:08 ` Steven Rostedt
  2019-01-09  7:16   ` [tip:perf/urgent] tools lib traceevent: " tip-bot for Tzvetomir Stoyanov
  2019-01-07 22:51 ` [PATCH 0/6] tools/lib/traceevent: Some more library updates Steven Rostedt
  2019-01-08 13:45 ` Arnaldo Carvalho de Melo
  7 siblings, 1 reply; 15+ messages in thread
From: Steven Rostedt @ 2018-12-01  4:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
	Andrew Morton, Tzvetomir Stoyanov

From: Tzvetomir Stoyanov <tstoyanov@vmware.com>

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>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tools/lib/traceevent/event-parse.c | 12 ------------
 tools/lib/traceevent/event-parse.h |  1 -
 2 files changed, 13 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index b3c00d6b524e..f84ce3897ce6 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -5264,18 +5264,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/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index bd1bd9a27839..aec48f2aea8a 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -526,7 +526,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);
-- 
2.19.1



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

* Re: [PATCH 0/6] tools/lib/traceevent: Some more library updates
  2018-12-01  4:08 [PATCH 0/6] tools/lib/traceevent: Some more library updates Steven Rostedt
                   ` (5 preceding siblings ...)
  2018-12-01  4:08 ` [PATCH 6/6] tools/lib/traceevent: Remove tep_data_event_from_type() API Steven Rostedt
@ 2019-01-07 22:51 ` Steven Rostedt
  2019-01-08 13:45 ` Arnaldo Carvalho de Melo
  7 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2019-01-07 22:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
	Andrew Morton

On Fri, 30 Nov 2018 23:08:07 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> Arnaldo and Jiri,

Ping. I think this slipped through the cracks.

-- Steve

> 
> Here's another set of patches to get us closer to having a legitimate
> standalone library for libtraceevent. There's still a lot of man pages
> to come, but I need to continue reviewing them.
> 
> Please pull this tree (based on current tip/perf/core) or apply
> the patches.
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
> tip/perf/core
> 
> Head SHA1: 5b2e18a71601544c4ae95e9ed1f953f3883714f5
> 
> 
> Tzvetomir Stoyanov (6):
>       tools/lib/traceevent: Initialize host_bigendian at tep_handle allocation
>       tools/lib/traceevent: Rename struct cmdline to struct tep_cmdline
>       tools/lib/traceevent: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs
>       tools/lib/traceevent: Changed return logic of tep_register_event_handler() API
>       tools/lib/traceevent: Rename tep_is_file_bigendian() to tep_file_bigendian()
>       tools/lib/traceevent: Remove tep_data_event_from_type() API
> 
> ----
>  tools/lib/traceevent/event-parse-api.c   |  4 +--
>  tools/lib/traceevent/event-parse-local.h |  4 +--
>  tools/lib/traceevent/event-parse.c       | 62 +++++++++++++++-----------------
>  tools/lib/traceevent/event-parse.h       | 16 +++++----
>  tools/lib/traceevent/plugin_kvm.c        |  2 +-
>  tools/lib/traceevent/trace-seq.c         | 17 ++++++---
>  6 files changed, 56 insertions(+), 49 deletions(-)


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

* Re: [PATCH 0/6] tools/lib/traceevent: Some more library updates
  2018-12-01  4:08 [PATCH 0/6] tools/lib/traceevent: Some more library updates Steven Rostedt
                   ` (6 preceding siblings ...)
  2019-01-07 22:51 ` [PATCH 0/6] tools/lib/traceevent: Some more library updates Steven Rostedt
@ 2019-01-08 13:45 ` Arnaldo Carvalho de Melo
  7 siblings, 0 replies; 15+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-01-08 13:45 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Jiri Olsa, Namhyung Kim, Andrew Morton

Em Fri, Nov 30, 2018 at 11:08:07PM -0500, Steven Rostedt escreveu:
> Arnaldo and Jiri,
> 
> Here's another set of patches to get us closer to having a legitimate
> standalone library for libtraceevent. There's still a lot of man pages
> to come, but I need to continue reviewing them.

Thanks, applied.

- Arnaldo
 
> Please pull this tree (based on current tip/perf/core) or apply
> the patches.
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
> tip/perf/core
> 
> Head SHA1: 5b2e18a71601544c4ae95e9ed1f953f3883714f5
> 
> 
> Tzvetomir Stoyanov (6):
>       tools/lib/traceevent: Initialize host_bigendian at tep_handle allocation
>       tools/lib/traceevent: Rename struct cmdline to struct tep_cmdline
>       tools/lib/traceevent: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs
>       tools/lib/traceevent: Changed return logic of tep_register_event_handler() API
>       tools/lib/traceevent: Rename tep_is_file_bigendian() to tep_file_bigendian()
>       tools/lib/traceevent: Remove tep_data_event_from_type() API
> 
> ----
>  tools/lib/traceevent/event-parse-api.c   |  4 +--
>  tools/lib/traceevent/event-parse-local.h |  4 +--
>  tools/lib/traceevent/event-parse.c       | 62 +++++++++++++++-----------------
>  tools/lib/traceevent/event-parse.h       | 16 +++++----
>  tools/lib/traceevent/plugin_kvm.c        |  2 +-
>  tools/lib/traceevent/trace-seq.c         | 17 ++++++---
>  6 files changed, 56 insertions(+), 49 deletions(-)

-- 

- Arnaldo

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

* [tip:perf/urgent] tools lib traceevent: Initialize host_bigendian at tep_handle allocation
  2018-12-01  4:08 ` [PATCH 1/6] tools/lib/traceevent: Initialize host_bigendian at tep_handle allocation Steven Rostedt
@ 2019-01-09  7:13   ` tip-bot for Tzvetomir Stoyanov
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Tzvetomir Stoyanov @ 2019-01-09  7:13 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, mingo, hpa, tglx, rostedt, acme, akpm, namhyung,
	tstoyanov, linux-kernel

Commit-ID:  eed14f4b075ec594ac09921b998bf3dd61f5886b
Gitweb:     https://git.kernel.org/tip/eed14f4b075ec594ac09921b998bf3dd61f5886b
Author:     Tzvetomir Stoyanov <tstoyanov@vmware.com>
AuthorDate: Fri, 30 Nov 2018 23:08:08 -0500
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 8 Jan 2019 13:28:13 -0300

tools lib traceevent: Initialize host_bigendian at tep_handle allocation

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>
---
 tools/lib/traceevent/event-parse.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 156e513074b2..44b80471b024 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -6762,8 +6762,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;
 }

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

* [tip:perf/urgent] tools lib traceevent: Rename struct cmdline to struct tep_cmdline
  2018-12-01  4:08 ` [PATCH 2/6] tools/lib/traceevent: Rename struct cmdline to struct tep_cmdline Steven Rostedt
@ 2019-01-09  7:13   ` tip-bot for Tzvetomir Stoyanov
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Tzvetomir Stoyanov @ 2019-01-09  7:13 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: namhyung, rostedt, tglx, tstoyanov, linux-kernel, acme, hpa,
	mingo, jolsa, akpm

Commit-ID:  2e4318a287bdf815140462257ab8697f5289a12f
Gitweb:     https://git.kernel.org/tip/2e4318a287bdf815140462257ab8697f5289a12f
Author:     Tzvetomir Stoyanov <tstoyanov@vmware.com>
AuthorDate: Fri, 30 Nov 2018 23:08:09 -0500
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 8 Jan 2019 13:28:13 -0300

tools lib traceevent: Rename struct cmdline to struct tep_cmdline

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>
---
 tools/lib/traceevent/event-parse-local.h |  4 ++--
 tools/lib/traceevent/event-parse.c       | 36 ++++++++++++++++----------------
 tools/lib/traceevent/event-parse.h       |  8 +++----
 3 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/tools/lib/traceevent/event-parse-local.h b/tools/lib/traceevent/event-parse-local.h
index 9a092dd4a86d..35833ee32d6c 100644
--- a/tools/lib/traceevent/event-parse-local.h
+++ b/tools/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/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 44b80471b024..a850342baf86 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/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)
@@ -5331,8 +5331,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;
 
@@ -5344,7 +5344,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;
 }
 
 /**
@@ -5360,10 +5360,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
@@ -5402,7 +5402,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/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index e6f4249910e6..77a4a1dd4b4d 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -526,10 +526,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);

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

* [tip:perf/urgent] tools lib traceevent: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs
  2018-12-01  4:08 ` [PATCH 3/6] tools/lib/traceevent: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs Steven Rostedt
@ 2019-01-09  7:14   ` tip-bot for Tzvetomir Stoyanov
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Tzvetomir Stoyanov @ 2019-01-09  7:14 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tstoyanov, akpm, mingo, tglx, rostedt, jolsa, hpa, namhyung,
	acme, linux-kernel

Commit-ID:  6d2d6fd7e3ee0daf0d8308741792b3ec41aafd0c
Gitweb:     https://git.kernel.org/tip/6d2d6fd7e3ee0daf0d8308741792b3ec41aafd0c
Author:     Tzvetomir Stoyanov <tstoyanov@vmware.com>
AuthorDate: Fri, 30 Nov 2018 23:08:10 -0500
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 8 Jan 2019 13:28:13 -0300

tools lib traceevent: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs

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>
---
 tools/lib/traceevent/trace-seq.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/tools/lib/traceevent/trace-seq.c b/tools/lib/traceevent/trace-seq.c
index 8ff1d55954d1..8d5ecd2bf877 100644
--- a/tools/lib/traceevent/trace-seq.c
+++ b/tools/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;
 }
 
 /**

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

* [tip:perf/urgent] tools lib traceevent: Changed return logic of tep_register_event_handler() API
  2018-12-01  4:08 ` [PATCH 4/6] tools/lib/traceevent: Changed return logic of tep_register_event_handler() API Steven Rostedt
@ 2019-01-09  7:15   ` tip-bot for Tzvetomir Stoyanov
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Tzvetomir Stoyanov @ 2019-01-09  7:15 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, rostedt, namhyung, akpm, tstoyanov, mingo, jolsa,
	tglx, acme, hpa

Commit-ID:  f87ce7c43f36d4abff91b19edadd23939f99ff98
Gitweb:     https://git.kernel.org/tip/f87ce7c43f36d4abff91b19edadd23939f99ff98
Author:     Tzvetomir Stoyanov <tstoyanov@vmware.com>
AuthorDate: Fri, 30 Nov 2018 23:08:11 -0500
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 8 Jan 2019 13:28:13 -0300

tools lib traceevent: Changed return logic of tep_register_event_handler() API

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>
---
 tools/lib/traceevent/event-parse.c | 10 ++++++++--
 tools/lib/traceevent/event-parse.h |  5 +++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index a850342baf86..54d94054eef0 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -6632,6 +6632,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,
@@ -6649,7 +6655,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. */
@@ -6679,7 +6685,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,
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 77a4a1dd4b4d..ac377ae99008 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -485,6 +485,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);

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

* [tip:perf/urgent] tools lib traceevent: Rename tep_is_file_bigendian() to tep_file_bigendian()
  2018-12-01  4:08 ` [PATCH 5/6] tools/lib/traceevent: Rename tep_is_file_bigendian() to tep_file_bigendian() Steven Rostedt
@ 2019-01-09  7:15   ` tip-bot for Tzvetomir Stoyanov
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Tzvetomir Stoyanov @ 2019-01-09  7:15 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, tstoyanov, jolsa, hpa, mingo, rostedt, namhyung,
	acme, akpm, tglx

Commit-ID:  4104e604277016b3e6a7d120368054f9d2716953
Gitweb:     https://git.kernel.org/tip/4104e604277016b3e6a7d120368054f9d2716953
Author:     Tzvetomir Stoyanov <tstoyanov@vmware.com>
AuthorDate: Fri, 30 Nov 2018 23:08:12 -0500
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 8 Jan 2019 13:28:13 -0300

tools lib traceevent: Rename tep_is_file_bigendian() to tep_file_bigendian()

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>
---
 tools/lib/traceevent/event-parse-api.c | 4 ++--
 tools/lib/traceevent/event-parse.h     | 2 +-
 tools/lib/traceevent/plugin_kvm.c      | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/lib/traceevent/event-parse-api.c b/tools/lib/traceevent/event-parse-api.c
index 8b31c0e00ba3..d463761a58f4 100644
--- a/tools/lib/traceevent/event-parse-api.c
+++ b/tools/lib/traceevent/event-parse-api.c
@@ -194,13 +194,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/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index ac377ae99008..bd1bd9a27839 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -559,7 +559,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/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c
index 754050eea467..64b9c25a1fd3 100644
--- a/tools/lib/traceevent/plugin_kvm.c
+++ b/tools/lib/traceevent/plugin_kvm.c
@@ -389,7 +389,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 q%u%s %s%s %spae %snxe %swp%s%s%s",

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

* [tip:perf/urgent] tools lib traceevent: Remove tep_data_event_from_type() API
  2018-12-01  4:08 ` [PATCH 6/6] tools/lib/traceevent: Remove tep_data_event_from_type() API Steven Rostedt
@ 2019-01-09  7:16   ` tip-bot for Tzvetomir Stoyanov
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Tzvetomir Stoyanov @ 2019-01-09  7:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, jolsa, akpm, rostedt, mingo, namhyung, hpa, tglx,
	tstoyanov, acme

Commit-ID:  9231967e2f515fce9e19687c0c40dfda416b3512
Gitweb:     https://git.kernel.org/tip/9231967e2f515fce9e19687c0c40dfda416b3512
Author:     Tzvetomir Stoyanov <tstoyanov@vmware.com>
AuthorDate: Fri, 30 Nov 2018 23:08:13 -0500
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 8 Jan 2019 13:28:13 -0300

tools lib traceevent: Remove tep_data_event_from_type() API

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>
---
 tools/lib/traceevent/event-parse.c | 12 ------------
 tools/lib/traceevent/event-parse.h |  1 -
 2 files changed, 13 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 54d94054eef0..abd4fa5d3088 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -5265,18 +5265,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/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index bd1bd9a27839..aec48f2aea8a 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -526,7 +526,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);

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

end of thread, other threads:[~2019-01-09  7:16 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-01  4:08 [PATCH 0/6] tools/lib/traceevent: Some more library updates Steven Rostedt
2018-12-01  4:08 ` [PATCH 1/6] tools/lib/traceevent: Initialize host_bigendian at tep_handle allocation Steven Rostedt
2019-01-09  7:13   ` [tip:perf/urgent] tools lib traceevent: " tip-bot for Tzvetomir Stoyanov
2018-12-01  4:08 ` [PATCH 2/6] tools/lib/traceevent: Rename struct cmdline to struct tep_cmdline Steven Rostedt
2019-01-09  7:13   ` [tip:perf/urgent] tools lib traceevent: " tip-bot for Tzvetomir Stoyanov
2018-12-01  4:08 ` [PATCH 3/6] tools/lib/traceevent: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs Steven Rostedt
2019-01-09  7:14   ` [tip:perf/urgent] tools lib traceevent: " tip-bot for Tzvetomir Stoyanov
2018-12-01  4:08 ` [PATCH 4/6] tools/lib/traceevent: Changed return logic of tep_register_event_handler() API Steven Rostedt
2019-01-09  7:15   ` [tip:perf/urgent] tools lib traceevent: " tip-bot for Tzvetomir Stoyanov
2018-12-01  4:08 ` [PATCH 5/6] tools/lib/traceevent: Rename tep_is_file_bigendian() to tep_file_bigendian() Steven Rostedt
2019-01-09  7:15   ` [tip:perf/urgent] tools lib traceevent: " tip-bot for Tzvetomir Stoyanov
2018-12-01  4:08 ` [PATCH 6/6] tools/lib/traceevent: Remove tep_data_event_from_type() API Steven Rostedt
2019-01-09  7:16   ` [tip:perf/urgent] tools lib traceevent: " tip-bot for Tzvetomir Stoyanov
2019-01-07 22:51 ` [PATCH 0/6] tools/lib/traceevent: Some more library updates Steven Rostedt
2019-01-08 13:45 ` Arnaldo Carvalho de Melo

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.