tools/lib/traceevent: Some more library updates
cover tools/lib/traceevent: Some more library updates
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(-)
PATCH 1/6 tools/lib/traceevent: Initialize host_bigendian at tep_handle allocation
From: Tzvetomir Stoyanov <[email protected]>
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.
--- tools/lib/traceevent/event-parse.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +3 -1
@@ -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; }
Signature · 1 line
2.19.1
tip-bot for Tzvetomir Stoyanov
merge bot[tip:perf/urgent] tools lib traceevent: Initialize host_bigendian at tep_handle allocation
tools lib traceevent: Initialize host_bigendian at tep_handle allocation
Commit-ID: eed14f4b075ec594ac09921b998bf3dd61f5886b Gitweb: https://git.kernel.org/tip/eed14f4b075ec594ac09921b998bf3dd61f5886b Author: Tzvetomir Stoyanov <[email protected]> AuthorDate: Fri, 30 Nov 2018 23:08:08 -0500 Committer: Arnaldo Carvalho de Melo <[email protected]> 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.
--- tools/lib/traceevent/event-parse.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +3 -1
@@ -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; }
PATCH 2/6 tools/lib/traceevent: Rename struct cmdline to struct tep_cmdline
In reply to Steven RostedtFrom: Tzvetomir Stoyanov <[email protected]>
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.
--- 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(-)
tools/lib/traceevent/event-parse-local.h +2 -2
@@ -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;
tools/lib/traceevent/event-parse.c +18 -18
@@ -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 *newhile (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;
tools/lib/traceevent/event-parse.h +4 -4
@@ -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);
Signature · 1 line
2.19.1
tip-bot for Tzvetomir Stoyanov
merge bot[tip:perf/urgent] tools lib traceevent: Rename struct cmdline to struct tep_cmdline
tools lib traceevent: Rename struct cmdline to struct tep_cmdline
Commit-ID: 2e4318a287bdf815140462257ab8697f5289a12f Gitweb: https://git.kernel.org/tip/2e4318a287bdf815140462257ab8697f5289a12f Author: Tzvetomir Stoyanov <[email protected]> AuthorDate: Fri, 30 Nov 2018 23:08:09 -0500 Committer: Arnaldo Carvalho de Melo <[email protected]> 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'.
--- 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(-)
tools/lib/traceevent/event-parse-local.h +2 -2
@@ -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;
tools/lib/traceevent/event-parse.c +18 -18
@@ -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 *newhile (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;
tools/lib/traceevent/event-parse.h +4 -4
@@ -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);
PATCH 3/6 tools/lib/traceevent: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs
In reply to Steven RostedtFrom: Tzvetomir Stoyanov <[email protected]>
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.
--- tools/lib/traceevent/trace-seq.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
tools/lib/traceevent/trace-seq.c +12 -5
@@ -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; }/**
Signature · 1 line
2.19.1
tip-bot for Tzvetomir Stoyanov
merge bot[tip:perf/urgent] tools lib traceevent: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs
tools lib traceevent: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs
Commit-ID: 6d2d6fd7e3ee0daf0d8308741792b3ec41aafd0c Gitweb: https://git.kernel.org/tip/6d2d6fd7e3ee0daf0d8308741792b3ec41aafd0c Author: Tzvetomir Stoyanov <[email protected]> AuthorDate: Fri, 30 Nov 2018 23:08:10 -0500 Committer: Arnaldo Carvalho de Melo <[email protected]> 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.
--- tools/lib/traceevent/trace-seq.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
tools/lib/traceevent/trace-seq.c +12 -5
@@ -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; }/**
PATCH 4/6 tools/lib/traceevent: Changed return logic of tep_register_event_handler() API
In reply to Steven RostedtFrom: Tzvetomir Stoyanov <[email protected]>
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.
--- tools/lib/traceevent/event-parse.c | 10 ++++++++-- tools/lib/traceevent/event-parse.h | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-)
tools/lib/traceevent/event-parse.c +8 -2
@@ -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,
tools/lib/traceevent/event-parse.h +5 -0
@@ -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);
Signature · 1 line
2.19.1
tip-bot for Tzvetomir Stoyanov
merge bot[tip:perf/urgent] tools lib traceevent: Changed return logic of tep_register_event_handler() API
tools lib traceevent: Changed return logic of tep_register_event_handler() API
Commit-ID: f87ce7c43f36d4abff91b19edadd23939f99ff98 Gitweb: https://git.kernel.org/tip/f87ce7c43f36d4abff91b19edadd23939f99ff98 Author: Tzvetomir Stoyanov <[email protected]> AuthorDate: Fri, 30 Nov 2018 23:08:11 -0500 Committer: Arnaldo Carvalho de Melo <[email protected]> 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.
--- tools/lib/traceevent/event-parse.c | 10 ++++++++-- tools/lib/traceevent/event-parse.h | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-)
tools/lib/traceevent/event-parse.c +8 -2
@@ -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,
tools/lib/traceevent/event-parse.h +5 -0
@@ -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);
PATCH 5/6 tools/lib/traceevent: Rename tep_is_file_bigendian() to tep_file_bigendian()
In reply to Steven RostedtFrom: Tzvetomir Stoyanov <[email protected]>
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().
--- 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(-)
tools/lib/traceevent/event-parse-api.c +2 -2
@@ -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;
tools/lib/traceevent/event-parse.h +1 -1
@@ -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);
tools/lib/traceevent/plugin_kvm.c +1 -1
@@ -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",
Signature · 1 line
2.19.1
tip-bot for Tzvetomir Stoyanov
merge bot[tip:perf/urgent] tools lib traceevent: Rename tep_is_file_bigendian() to tep_file_bigendian()
tools lib traceevent: Rename tep_is_file_bigendian() to tep_file_bigendian()
Commit-ID: 4104e604277016b3e6a7d120368054f9d2716953 Gitweb: https://git.kernel.org/tip/4104e604277016b3e6a7d120368054f9d2716953 Author: Tzvetomir Stoyanov <[email protected]> AuthorDate: Fri, 30 Nov 2018 23:08:12 -0500 Committer: Arnaldo Carvalho de Melo <[email protected]> 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().
--- 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(-)
tools/lib/traceevent/event-parse-api.c +2 -2
@@ -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;
tools/lib/traceevent/event-parse.h +1 -1
@@ -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);
tools/lib/traceevent/plugin_kvm.c +1 -1
@@ -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",
PATCH 6/6 tools/lib/traceevent: Remove tep_data_event_from_type() API
In reply to Steven RostedtFrom: Tzvetomir Stoyanov <[email protected]>
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.
--- tools/lib/traceevent/event-parse.c | 12 ------------ tools/lib/traceevent/event-parse.h | 1 - 2 files changed, 13 deletions(-)
tools/lib/traceevent/event-parse.c +0 -12
@@ -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
tools/lib/traceevent/event-parse.h +0 -1
@@ -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);
Signature · 1 line
2.19.1
tip-bot for Tzvetomir Stoyanov
merge bot[tip:perf/urgent] tools lib traceevent: Remove tep_data_event_from_type() API
tools lib traceevent: Remove tep_data_event_from_type() API
Commit-ID: 9231967e2f515fce9e19687c0c40dfda416b3512 Gitweb: https://git.kernel.org/tip/9231967e2f515fce9e19687c0c40dfda416b3512 Author: Tzvetomir Stoyanov <[email protected]> AuthorDate: Fri, 30 Nov 2018 23:08:13 -0500 Committer: Arnaldo Carvalho de Melo <[email protected]> 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.
--- tools/lib/traceevent/event-parse.c | 12 ------------ tools/lib/traceevent/event-parse.h | 1 - 2 files changed, 13 deletions(-)
tools/lib/traceevent/event-parse.c +0 -12
@@ -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
tools/lib/traceevent/event-parse.h +0 -1
@@ -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);
Quoted 1 line · On Fri, 30 Nov 2018 23:08:07 -0500 Steven Rostedt <[email protected]> wrote:
Arnaldo and Jiri,
Ping. I think this slipped through the cracks.
-- Steve
Quoted 30 lines
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/coreHead SHA1:
5b2e18a71601544c4ae95e9ed1f953f3883714f5Tzvetomir Stoyanov (6):
tools/lib/traceevent: Initializehost_bigendianattep_handleallocationtools/lib/traceevent: Rename struct cmdline to structtep_cmdlinetools/lib/traceevent: Changed return logic oftrace_seq_printf()andtrace_seq_vprintf()APIstools/lib/traceevent: Changed return logic oftep_register_event_handler()APItools/lib/traceevent: Renametep_is_file_bigendian()totep_file_bigendian()tools/lib/traceevent: Removetep_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 Carvalho de Melo
AppliedEm Fri, Nov 30, 2018 at 11:08:07PM -0500, Steven Rostedt escreveu:
Quoted 5 lines
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
Quoted 25 lines
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/coreHead SHA1:
5b2e18a71601544c4ae95e9ed1f953f3883714f5Tzvetomir Stoyanov (6):
tools/lib/traceevent: Initializehost_bigendianattep_handleallocationtools/lib/traceevent: Rename struct cmdline to structtep_cmdlinetools/lib/traceevent: Changed return logic oftrace_seq_printf()andtrace_seq_vprintf()APIstools/lib/traceevent: Changed return logic oftep_register_event_handler()APItools/lib/traceevent: Renametep_is_file_bigendian()totep_file_bigendian()tools/lib/traceevent: Removetep_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(-)
Signature · 1 line
- Arnaldo