* [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd
@ 2015-03-24 13:57 Steven Rostedt
2015-03-24 13:57 ` [PATCH 1/9] tools lib traceevent: Handle NULL comm name Steven Rostedt
` (9 more replies)
0 siblings, 10 replies; 31+ messages in thread
From: Steven Rostedt @ 2015-03-24 13:57 UTC (permalink / raw)
To: linux-kernel
Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
Andrew Morton
Arnaldo,
I took a look at the differences between what I have in trace-cmd and
what is sitting in tools/lib/traceevent, and I put together a patch set
that brings in fixes and updates to libtraceevent.
-- Steve
Local SHA1: bd9d9602719a24d0843bb04e52b6bf98d9e90881
Josef Bacik (1):
tools lib traceevent: Handle NULL comm name
Steven Rostedt (1):
tools lib traceevent: Make plugin options either string or boolean
Steven Rostedt (Red Hat) (7):
tools lib traceevent: Copy trace_clock and free it
tools lib traceevent: Handle '%z' in bprint format
tools lib traceevent: Add pevent_data_pid_from_comm()
tools lib traceevent: Fix whitespace error
tools lib traceevent kbuffer: Remove extra update to data pointer in PADDING
tools lib traceevent: Add way to find sub buffer boundary
tools lib traceevent: Free filter tokens in process_filter()
----
tools/lib/traceevent/event-parse.c | 109 ++++++++++++++++++++++++++++++++++-
tools/lib/traceevent/event-parse.h | 13 ++++-
tools/lib/traceevent/event-plugin.c | 60 +++++++++++++++++--
tools/lib/traceevent/kbuffer-parse.c | 12 +++-
tools/lib/traceevent/kbuffer.h | 1 +
tools/lib/traceevent/parse-filter.c | 2 +
6 files changed, 185 insertions(+), 12 deletions(-)
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 1/9] tools lib traceevent: Handle NULL comm name
2015-03-24 13:57 [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd Steven Rostedt
@ 2015-03-24 13:57 ` Steven Rostedt
2015-03-24 16:33 ` [tip:perf/core] " tip-bot for Josef Bacik
2015-03-24 13:57 ` [PATCH 2/9] tools lib traceevent: Copy trace_clock and free it Steven Rostedt
` (8 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Steven Rostedt @ 2015-03-24 13:57 UTC (permalink / raw)
To: linux-kernel
Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
Andrew Morton, Josef Bacik
[-- Attachment #1: 0001-tools-lib-traceevent-Handle-NULL-comm-name.patch --]
[-- Type: text/plain, Size: 1085 bytes --]
From: Josef Bacik <jbacik@fb.com>
It is possible that a pid has no associated comm attached to it, although it
can still be passed to pevent_register_comm(). But if comm is NULL, it will
cause strdup() to segfault. To prevent this from happening, if comm is NULL
use the default "<...>" name for the pid.
Link: http://lkml.kernel.org/p/1403799732-30308-1-git-send-email-jbacik@fb.com
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
tools/lib/traceevent/event-parse.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index d7c37a7d9255..fdcb89be5e67 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -304,7 +304,10 @@ int pevent_register_comm(struct pevent *pevent, const char *comm, int pid)
if (!item)
return -1;
- item->comm = strdup(comm);
+ if (comm)
+ item->comm = strdup(comm);
+ else
+ item->comm = strdup("<...>");
if (!item->comm) {
free(item);
return -1;
--
2.1.4
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 2/9] tools lib traceevent: Copy trace_clock and free it
2015-03-24 13:57 [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd Steven Rostedt
2015-03-24 13:57 ` [PATCH 1/9] tools lib traceevent: Handle NULL comm name Steven Rostedt
@ 2015-03-24 13:57 ` Steven Rostedt
2015-03-24 15:14 ` Arnaldo Carvalho de Melo
2015-03-24 16:33 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
2015-03-24 13:57 ` [PATCH 3/9] tools lib traceevent: Handle %z in bprint format Steven Rostedt
` (7 subsequent siblings)
9 siblings, 2 replies; 31+ messages in thread
From: Steven Rostedt @ 2015-03-24 13:57 UTC (permalink / raw)
To: linux-kernel
Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
Andrew Morton
[-- Attachment #1: 0002-tools-lib-traceevent-Copy-trace_clock-and-free-it.patch --]
[-- Type: text/plain, Size: 2139 bytes --]
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
The pevent->trace_clock should not be a direct pointer to what
was given. It should be copied and freed.
Note, valgrind pointed this out when a caller passed in a pointer
that needed to be freed and it never was. Ideally, pevent should
copy it (which this change does), and free the copy. It's up
to the caller to free the clock string passed in.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
tools/lib/traceevent/event-parse.c | 10 ++++++++--
tools/lib/traceevent/event-parse.h | 2 +-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index fdcb89be5e67..9709e202a7e5 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -321,9 +321,14 @@ int pevent_register_comm(struct pevent *pevent, const char *comm, int pid)
return 0;
}
-void pevent_register_trace_clock(struct pevent *pevent, char *trace_clock)
+int pevent_register_trace_clock(struct pevent *pevent, const char *trace_clock)
{
- pevent->trace_clock = trace_clock;
+ pevent->trace_clock = strdup(trace_clock);
+ if (!pevent->trace_clock) {
+ errno = ENOMEM;
+ return -1;
+ }
+ return 0;
}
struct func_map {
@@ -6349,6 +6354,7 @@ void pevent_free(struct pevent *pevent)
free_handler(handle);
}
+ free(pevent->trace_clock);
free(pevent->events);
free(pevent->sort_events);
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 6abda54d76f2..84e554f84574 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -599,7 +599,7 @@ enum trace_flag_type {
};
int pevent_register_comm(struct pevent *pevent, const char *comm, int pid);
-void pevent_register_trace_clock(struct pevent *pevent, char *trace_clock);
+int pevent_register_trace_clock(struct pevent *pevent, const char *trace_clock);
int pevent_register_function(struct pevent *pevent, char *name,
unsigned long long addr, char *mod);
int pevent_register_print_string(struct pevent *pevent, const char *fmt,
--
2.1.4
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 3/9] tools lib traceevent: Handle %z in bprint format
2015-03-24 13:57 [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd Steven Rostedt
2015-03-24 13:57 ` [PATCH 1/9] tools lib traceevent: Handle NULL comm name Steven Rostedt
2015-03-24 13:57 ` [PATCH 2/9] tools lib traceevent: Copy trace_clock and free it Steven Rostedt
@ 2015-03-24 13:57 ` Steven Rostedt
2015-03-24 16:33 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
2015-03-24 13:57 ` [PATCH 4/9] tools lib traceevent: Add pevent_data_pid_from_comm() Steven Rostedt
` (6 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Steven Rostedt @ 2015-03-24 13:57 UTC (permalink / raw)
To: linux-kernel
Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
Andrew Morton, Shawn Bohrer
[-- Attachment #1: 0003-tools-lib-traceevent-Handle-z-in-bprint-format.patch --]
[-- Type: text/plain, Size: 856 bytes --]
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
The %z printf specifier was not handled making trace_printk()s in
the kernel that used this break on output.
Reported-by: Shawn Bohrer <shawn.bohrer@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
tools/lib/traceevent/event-parse.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 9709e202a7e5..5795d9451063 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -4005,6 +4005,10 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc
goto process_again;
case '.':
goto process_again;
+ case 'z':
+ case 'Z':
+ ls = 1;
+ goto process_again;
case 'p':
ls = 1;
/* fall through */
--
2.1.4
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 4/9] tools lib traceevent: Add pevent_data_pid_from_comm()
2015-03-24 13:57 [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd Steven Rostedt
` (2 preceding siblings ...)
2015-03-24 13:57 ` [PATCH 3/9] tools lib traceevent: Handle %z in bprint format Steven Rostedt
@ 2015-03-24 13:57 ` Steven Rostedt
2015-03-24 15:16 ` Arnaldo Carvalho de Melo
2015-03-24 16:34 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
2015-03-24 13:57 ` [PATCH 5/9] tools lib traceevent: Fix whitespace error Steven Rostedt
` (5 subsequent siblings)
9 siblings, 2 replies; 31+ messages in thread
From: Steven Rostedt @ 2015-03-24 13:57 UTC (permalink / raw)
To: linux-kernel
Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
Andrew Morton
[-- Attachment #1: 0004-tools-lib-traceevent-Add-pevent_data_pid_from_comm.patch --]
[-- Type: text/plain, Size: 4564 bytes --]
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
There is a pevent_data_comm_from_pid() that returns the cmdline stored for
a given pid in order for users to map pids to comms, but there's no method
to convert a comm back to a pid. This is useful for filters that specify
a comm instead of a PID (it's faster than searching each individual event).
Add a way to retrieve a comm from a pid. Since there can be more than one
pid associated to a comm, it returns a data structure that lets the user
iterate over all the saved comms for a given pid.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
tools/lib/traceevent/event-parse.c | 90 ++++++++++++++++++++++++++++++++++++++
tools/lib/traceevent/event-parse.h | 5 +++
2 files changed, 95 insertions(+)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 5795d9451063..8cc3e894ff46 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -4951,6 +4951,96 @@ const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid)
return comm;
}
+static struct cmdline *
+pid_from_cmdlist(struct pevent *pevent, const char *comm, struct cmdline *next)
+{
+ struct cmdline_list *cmdlist = (struct cmdline_list *)next;
+
+ if (cmdlist)
+ cmdlist = cmdlist->next;
+ else
+ cmdlist = pevent->cmdlist;
+
+ while (cmdlist && strcmp(cmdlist->comm, comm) != 0)
+ cmdlist = cmdlist->next;
+
+ return (struct cmdline *)cmdlist;
+}
+
+/**
+ * pevent_data_pid_from_comm - return the pid from a given comm
+ * @pevent: a handle to the pevent
+ * @comm: the cmdline to find the pid from
+ * @next: the cmdline structure to find the next comm
+ *
+ * This returns the cmdline structure that holds a pid for a given
+ * comm, or NULL if none found. As there may be more than one pid for
+ * a given comm, the result of this call can be passed back into
+ * a recurring call in the @next paramater, and then it will find the
+ * next pid.
+ * Also, it does a linear seach, so it may be slow.
+ */
+struct cmdline *pevent_data_pid_from_comm(struct pevent *pevent, const char *comm,
+ struct cmdline *next)
+{
+ struct cmdline *cmdline;
+
+ /*
+ * If the cmdlines have not been converted yet, then use
+ * the list.
+ */
+ if (!pevent->cmdlines)
+ return pid_from_cmdlist(pevent, comm, next);
+
+ if (next) {
+ /*
+ * The next pointer could have been still from
+ * a previous call before cmdlines were created
+ */
+ if (next < pevent->cmdlines ||
+ next >= pevent->cmdlines + pevent->cmdline_count)
+ next = NULL;
+ else
+ cmdline = next++;
+ }
+
+ if (!next)
+ cmdline = pevent->cmdlines;
+
+ while (cmdline < pevent->cmdlines + pevent->cmdline_count) {
+ if (strcmp(cmdline->comm, comm) == 0)
+ return cmdline;
+ cmdline++;
+ }
+ return NULL;
+}
+
+/**
+ * pevent_cmdline_pid - return the pid associated to a given cmdline
+ * @cmdline: The cmdline structure to get the pid from
+ *
+ * Returns the pid for a give cmdline. If @cmdline is NULL, then
+ * -1 is returned.
+ */
+int pevent_cmdline_pid(struct pevent *pevent, struct cmdline *cmdline)
+{
+ struct cmdline_list *cmdlist = (struct cmdline_list *)cmdline;
+
+ if (!cmdline)
+ return -1;
+
+ /*
+ * If cmdlines have not been created yet, or cmdline is
+ * not part of the array, then treat it as a cmdlist instead.
+ */
+ if (!pevent->cmdlines ||
+ cmdline < pevent->cmdlines ||
+ cmdline >= pevent->cmdlines + pevent->cmdline_count)
+ return cmdlist->pid;
+
+ return cmdline->pid;
+}
+
/**
* pevent_data_comm_from_pid - parse the data into the print format
* @s: the trace_seq to write to
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 84e554f84574..8bd7c6a4cbd7 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -678,6 +678,11 @@ int pevent_data_type(struct pevent *pevent, struct pevent_record *rec);
struct event_format *pevent_data_event_from_type(struct pevent *pevent, int type);
int pevent_data_pid(struct pevent *pevent, struct pevent_record *rec);
const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid);
+struct cmdline;
+struct cmdline *pevent_data_pid_from_comm(struct pevent *pevent, const char *comm,
+ struct cmdline *next);
+int pevent_cmdline_pid(struct pevent *pevent, struct cmdline *cmdline);
+
void pevent_event_info(struct trace_seq *s, struct event_format *event,
struct pevent_record *record);
int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum,
--
2.1.4
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5/9] tools lib traceevent: Fix whitespace error
2015-03-24 13:57 [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd Steven Rostedt
` (3 preceding siblings ...)
2015-03-24 13:57 ` [PATCH 4/9] tools lib traceevent: Add pevent_data_pid_from_comm() Steven Rostedt
@ 2015-03-24 13:57 ` Steven Rostedt
2015-03-24 15:19 ` Arnaldo Carvalho de Melo
2015-03-24 13:57 ` [PATCH 6/9] tools lib traceevent: Make plugin options either string or boolean Steven Rostedt
` (4 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Steven Rostedt @ 2015-03-24 13:57 UTC (permalink / raw)
To: linux-kernel
Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
Andrew Morton
[-- Attachment #1: 0005-tools-lib-traceevent-Fix-whitespace-error.patch --]
[-- Type: text/plain, Size: 817 bytes --]
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
tools/lib/traceevent/event-parse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 8cc3e894ff46..aff743710001 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -5033,7 +5033,7 @@ int pevent_cmdline_pid(struct pevent *pevent, struct cmdline *cmdline)
* If cmdlines have not been created yet, or cmdline is
* not part of the array, then treat it as a cmdlist instead.
*/
- if (!pevent->cmdlines ||
+ if (!pevent->cmdlines ||
cmdline < pevent->cmdlines ||
cmdline >= pevent->cmdlines + pevent->cmdline_count)
return cmdlist->pid;
--
2.1.4
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 6/9] tools lib traceevent: Make plugin options either string or boolean
2015-03-24 13:57 [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd Steven Rostedt
` (4 preceding siblings ...)
2015-03-24 13:57 ` [PATCH 5/9] tools lib traceevent: Fix whitespace error Steven Rostedt
@ 2015-03-24 13:57 ` Steven Rostedt
2015-03-24 16:34 ` [tip:perf/core] " tip-bot for Steven Rostedt
2015-03-24 13:57 ` [PATCH 7/9] tools lib traceevent kbuffer: Remove extra update to data pointer in PADDING Steven Rostedt
` (3 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Steven Rostedt @ 2015-03-24 13:57 UTC (permalink / raw)
To: linux-kernel
Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
Andrew Morton
[-- Attachment #1: 0006-tools-lib-traceevent-Make-plugin-options-either-stri.patch --]
[-- Type: text/plain, Size: 3811 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
When a plugin option is defined, by default it is a boolean (true or false).
If the option is something else, then it needs to set its "value" field to
a default string other than NULL (can be just ""). If the value is not set
then the option is considered boolean, and the updating of the option value
will be handled accordingly.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
tools/lib/traceevent/event-parse.h | 6 +++-
tools/lib/traceevent/event-plugin.c | 60 +++++++++++++++++++++++++++++++++----
2 files changed, 59 insertions(+), 7 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 8bd7c6a4cbd7..8ca1b8ee50da 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -116,7 +116,7 @@ struct pevent_plugin_option {
char *name;
char *plugin_alias;
char *description;
- char *value;
+ const char *value;
void *priv;
int set;
};
@@ -154,6 +154,10 @@ struct pevent_plugin_option {
* .plugin_alias is used to give a shorter name to access
* the vairable. Useful if a plugin handles more than one event.
*
+ * If .value is not set, then it is considered a boolean and only
+ * .set will be processed. If .value is defined, then it is considered
+ * a string option and .set will be ignored.
+ *
* PEVENT_PLUGIN_ALIAS: (optional)
* The name to use for finding options (uses filename if not defined)
*/
diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c
index 136162c03af1..a16756ae3526 100644
--- a/tools/lib/traceevent/event-plugin.c
+++ b/tools/lib/traceevent/event-plugin.c
@@ -18,6 +18,7 @@
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
+#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <dlfcn.h>
@@ -49,6 +50,52 @@ struct plugin_list {
void *handle;
};
+static void lower_case(char *str)
+{
+ if (!str)
+ return;
+ for (; *str; str++)
+ *str = tolower(*str);
+}
+
+static int update_option_value(struct pevent_plugin_option *op, const char *val)
+{
+ char *op_val;
+
+ if (!val) {
+ /* toggle, only if option is boolean */
+ if (op->value)
+ /* Warn? */
+ return 0;
+ op->set ^= 1;
+ return 0;
+ }
+
+ /*
+ * If the option has a value then it takes a string
+ * otherwise the option is a boolean.
+ */
+ if (op->value) {
+ op->value = val;
+ return 0;
+ }
+
+ /* Option is boolean, must be either "1", "0", "true" or "false" */
+
+ op_val = strdup(val);
+ if (!op_val)
+ return -1;
+ lower_case(op_val);
+
+ if (strcmp(val, "1") == 0 || strcmp(val, "true") == 0)
+ op->set = 1;
+ else if (strcmp(val, "0") == 0 || strcmp(val, "false") == 0)
+ op->set = 0;
+ free(op_val);
+
+ return 0;
+}
+
/**
* traceevent_plugin_list_options - get list of plugin options
*
@@ -120,6 +167,7 @@ update_option(const char *file, struct pevent_plugin_option *option)
{
struct trace_plugin_options *op;
char *plugin;
+ int ret = 0;
if (option->plugin_alias) {
plugin = strdup(option->plugin_alias);
@@ -144,9 +192,10 @@ update_option(const char *file, struct pevent_plugin_option *option)
if (strcmp(op->option, option->name) != 0)
continue;
- option->value = op->value;
- option->set ^= 1;
- goto out;
+ ret = update_option_value(option, op->value);
+ if (ret)
+ goto out;
+ break;
}
/* first look for unnamed options */
@@ -156,14 +205,13 @@ update_option(const char *file, struct pevent_plugin_option *option)
if (strcmp(op->option, option->name) != 0)
continue;
- option->value = op->value;
- option->set ^= 1;
+ ret = update_option_value(option, op->value);
break;
}
out:
free(plugin);
- return 0;
+ return ret;
}
/**
--
2.1.4
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 7/9] tools lib traceevent kbuffer: Remove extra update to data pointer in PADDING
2015-03-24 13:57 [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd Steven Rostedt
` (5 preceding siblings ...)
2015-03-24 13:57 ` [PATCH 6/9] tools lib traceevent: Make plugin options either string or boolean Steven Rostedt
@ 2015-03-24 13:57 ` Steven Rostedt
2015-03-24 16:34 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
2015-03-24 13:57 ` [PATCH 8/9] tools lib traceevent: Add way to find sub buffer boundary Steven Rostedt
` (2 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Steven Rostedt @ 2015-03-24 13:57 UTC (permalink / raw)
To: linux-kernel
Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
Andrew Morton, stable
[-- Attachment #1: 0007-tools-lib-traceevent-kbuffer-Remove-extra-update-to-.patch --]
[-- Type: text/plain, Size: 1044 bytes --]
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
When a event PADDING is hit (a deleted event that is still in the ring
buffer), translate_data() sets the length of the padding and also updates
the data pointer which is passed back to the caller. This is unneeded
because the caller also updates the data pointer with the passed back
length. translate_data() should not update the pointer, only set the
length.
Cc: stable@vger.kernel.org # 3.12+
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
tools/lib/traceevent/kbuffer-parse.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/tools/lib/traceevent/kbuffer-parse.c b/tools/lib/traceevent/kbuffer-parse.c
index dcc665228c71..deb3569ab004 100644
--- a/tools/lib/traceevent/kbuffer-parse.c
+++ b/tools/lib/traceevent/kbuffer-parse.c
@@ -372,7 +372,6 @@ translate_data(struct kbuffer *kbuf, void *data, void **rptr,
switch (type_len) {
case KBUFFER_TYPE_PADDING:
*length = read_4(kbuf, data);
- data += *length;
break;
case KBUFFER_TYPE_TIME_EXTEND:
--
2.1.4
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 8/9] tools lib traceevent: Add way to find sub buffer boundary
2015-03-24 13:57 [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd Steven Rostedt
` (6 preceding siblings ...)
2015-03-24 13:57 ` [PATCH 7/9] tools lib traceevent kbuffer: Remove extra update to data pointer in PADDING Steven Rostedt
@ 2015-03-24 13:57 ` Steven Rostedt
2015-03-24 16:35 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
2015-03-24 13:57 ` [PATCH 9/9] tools lib traceevent: Free filter tokens in process_filter() Steven Rostedt
2015-03-24 14:57 ` [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd Arnaldo Carvalho de Melo
9 siblings, 1 reply; 31+ messages in thread
From: Steven Rostedt @ 2015-03-24 13:57 UTC (permalink / raw)
To: linux-kernel
Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
Andrew Morton
[-- Attachment #1: 0008-tools-lib-traceevent-Add-way-to-find-sub-buffer-boun.patch --]
[-- Type: text/plain, Size: 1391 bytes --]
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
For debugging purposes, it may be helpful for the kbuffer library to flag
when crossing a sub buffer.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
tools/lib/traceevent/kbuffer-parse.c | 11 +++++++++++
tools/lib/traceevent/kbuffer.h | 1 +
2 files changed, 12 insertions(+)
diff --git a/tools/lib/traceevent/kbuffer-parse.c b/tools/lib/traceevent/kbuffer-parse.c
index deb3569ab004..3bcada3ae05a 100644
--- a/tools/lib/traceevent/kbuffer-parse.c
+++ b/tools/lib/traceevent/kbuffer-parse.c
@@ -729,3 +729,14 @@ void kbuffer_set_old_format(struct kbuffer *kbuf)
kbuf->next_event = __old_next_event;
}
+
+/**
+ * kbuffer_start_of_data - return offset of where data starts on subbuffer
+ * @kbuf: The kbuffer
+ *
+ * Returns the location on the subbuffer where the data starts.
+ */
+int kbuffer_start_of_data(struct kbuffer *kbuf)
+{
+ return kbuf->start;
+}
diff --git a/tools/lib/traceevent/kbuffer.h b/tools/lib/traceevent/kbuffer.h
index c831f64b17a0..03dce757553f 100644
--- a/tools/lib/traceevent/kbuffer.h
+++ b/tools/lib/traceevent/kbuffer.h
@@ -63,5 +63,6 @@ int kbuffer_missed_events(struct kbuffer *kbuf);
int kbuffer_subbuffer_size(struct kbuffer *kbuf);
void kbuffer_set_old_format(struct kbuffer *kbuf);
+int kbuffer_start_of_data(struct kbuffer *kbuf);
#endif /* _K_BUFFER_H */
--
2.1.4
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 9/9] tools lib traceevent: Free filter tokens in process_filter()
2015-03-24 13:57 [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd Steven Rostedt
` (7 preceding siblings ...)
2015-03-24 13:57 ` [PATCH 8/9] tools lib traceevent: Add way to find sub buffer boundary Steven Rostedt
@ 2015-03-24 13:57 ` Steven Rostedt
2015-03-24 16:35 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
2015-03-24 14:57 ` [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd Arnaldo Carvalho de Melo
9 siblings, 1 reply; 31+ messages in thread
From: Steven Rostedt @ 2015-03-24 13:57 UTC (permalink / raw)
To: linux-kernel
Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
Andrew Morton
[-- Attachment #1: 0009-tools-lib-traceevent-Free-filter-tokens-in-process_f.patch --]
[-- Type: text/plain, Size: 894 bytes --]
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
valgrind showed that the filter token wasn't being freed properly
in process_filter().
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
tools/lib/traceevent/parse-filter.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index b50234402fc2..0144b3d1bb77 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1058,6 +1058,7 @@ process_filter(struct event_format *event, struct filter_arg **parg,
*parg = current_op;
else
*parg = current_exp;
+ free(token);
return PEVENT_ERRNO__UNBALANCED_PAREN;
}
break;
@@ -1168,6 +1169,7 @@ process_filter(struct event_format *event, struct filter_arg **parg,
*parg = current_op;
+ free(token);
return 0;
fail_alloc:
--
2.1.4
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd
2015-03-24 13:57 [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd Steven Rostedt
` (8 preceding siblings ...)
2015-03-24 13:57 ` [PATCH 9/9] tools lib traceevent: Free filter tokens in process_filter() Steven Rostedt
@ 2015-03-24 14:57 ` Arnaldo Carvalho de Melo
2015-03-24 15:04 ` Steven Rostedt
9 siblings, 1 reply; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-03-24 14:57 UTC (permalink / raw)
To: Steven Rostedt
Cc: linux-kernel, Ingo Molnar, Jiri Olsa, Namhyung Kim, Andrew Morton
Em Tue, Mar 24, 2015 at 09:57:48AM -0400, Steven Rostedt escreveu:
> Arnaldo,
>
> I took a look at the differences between what I have in trace-cmd and
> what is sitting in tools/lib/traceevent, and I put together a patch set
> that brings in fixes and updates to libtraceevent.
Thanks, will process now.
> -- Steve
>
> Local SHA1: bd9d9602719a24d0843bb04e52b6bf98d9e90881
>
>
> Josef Bacik (1):
> tools lib traceevent: Handle NULL comm name
>
> Steven Rostedt (1):
> tools lib traceevent: Make plugin options either string or boolean
>
> Steven Rostedt (Red Hat) (7):
> tools lib traceevent: Copy trace_clock and free it
> tools lib traceevent: Handle '%z' in bprint format
> tools lib traceevent: Add pevent_data_pid_from_comm()
> tools lib traceevent: Fix whitespace error
> tools lib traceevent kbuffer: Remove extra update to data pointer in PADDING
> tools lib traceevent: Add way to find sub buffer boundary
> tools lib traceevent: Free filter tokens in process_filter()
>
> ----
> tools/lib/traceevent/event-parse.c | 109 ++++++++++++++++++++++++++++++++++-
> tools/lib/traceevent/event-parse.h | 13 ++++-
> tools/lib/traceevent/event-plugin.c | 60 +++++++++++++++++--
> tools/lib/traceevent/kbuffer-parse.c | 12 +++-
> tools/lib/traceevent/kbuffer.h | 1 +
> tools/lib/traceevent/parse-filter.c | 2 +
> 6 files changed, 185 insertions(+), 12 deletions(-)
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd
2015-03-24 14:57 ` [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd Arnaldo Carvalho de Melo
@ 2015-03-24 15:04 ` Steven Rostedt
2015-03-24 15:25 ` Arnaldo Carvalho de Melo
2015-03-24 15:26 ` Arnaldo Carvalho de Melo
0 siblings, 2 replies; 31+ messages in thread
From: Steven Rostedt @ 2015-03-24 15:04 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: linux-kernel, Ingo Molnar, Jiri Olsa, Namhyung Kim, Andrew Morton,
Guilherme Cox
On Tue, 24 Mar 2015 11:57:27 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> Em Tue, Mar 24, 2015 at 09:57:48AM -0400, Steven Rostedt escreveu:
> > Arnaldo,
> >
> > I took a look at the differences between what I have in trace-cmd and
> > what is sitting in tools/lib/traceevent, and I put together a patch set
> > that brings in fixes and updates to libtraceevent.
>
> Thanks, will process now.
I just added this one too...
-- Steve
>From fe80b2e9396fa6b8dc66a6dfd4c7a426e1685424 Mon Sep 17 00:00:00 2001
From: Guilherme Cox <cox@computer.org>
Date: Fri, 20 Feb 2015 19:10:34 -0500
Subject: [PATCH] tools lib traceevent: Zero should not be considered "not
found" in eval_flag()
Guilherme Cox found that:
There is, however, a potential bug if there is an item with code zero
that is not the first one in the symbol list, since eval_flag(..)
returns 0 when it doesn't find anything.
Reported-by: Guilherme Cox <cox@computer.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
tools/lib/traceevent/event-parse.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index aff743710001..f2fb50141703 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3576,7 +3576,7 @@ static const struct flag flags[] = {
{ "HRTIMER_RESTART", 1 },
};
-static unsigned long long eval_flag(const char *flag)
+static long long eval_flag(const char *flag)
{
int i;
@@ -3592,7 +3592,7 @@ static unsigned long long eval_flag(const char *flag)
if (strcmp(flags[i].name, flag) == 0)
return flags[i].value;
- return 0;
+ return -1LL;
}
static void print_str_to_seq(struct trace_seq *s, const char *format,
@@ -3666,7 +3666,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
struct print_flag_sym *flag;
struct format_field *field;
struct printk_map *printk;
- unsigned long long val, fval;
+ long long val, fval;
unsigned long addr;
char *str;
unsigned char *hex;
@@ -3725,11 +3725,11 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
print = 0;
for (flag = arg->flags.flags; flag; flag = flag->next) {
fval = eval_flag(flag->value);
- if (!val && !fval) {
+ if (!val && fval < 0) {
print_str_to_seq(s, format, len_arg, flag->str);
break;
}
- if (fval && (val & fval) == fval) {
+ if (fval > 0 && (val & fval) == fval) {
if (print && arg->flags.delim)
trace_seq_puts(s, arg->flags.delim);
print_str_to_seq(s, format, len_arg, flag->str);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 2/9] tools lib traceevent: Copy trace_clock and free it
2015-03-24 13:57 ` [PATCH 2/9] tools lib traceevent: Copy trace_clock and free it Steven Rostedt
@ 2015-03-24 15:14 ` Arnaldo Carvalho de Melo
2015-03-24 15:43 ` Steven Rostedt
2015-03-24 16:33 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
1 sibling, 1 reply; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-03-24 15:14 UTC (permalink / raw)
To: Steven Rostedt
Cc: linux-kernel, Ingo Molnar, Jiri Olsa, Namhyung Kim, Andrew Morton
Em Tue, Mar 24, 2015 at 09:57:50AM -0400, Steven Rostedt escreveu:
> From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
>
> The pevent->trace_clock should not be a direct pointer to what
> was given. It should be copied and freed.
>
> Note, valgrind pointed this out when a caller passed in a pointer
> that needed to be freed and it never was. Ideally, pevent should
> copy it (which this change does), and free the copy. It's up
> to the caller to free the clock string passed in.
> +++ b/tools/lib/traceevent/event-parse.c
> @@ -321,9 +321,14 @@ int pevent_register_comm(struct pevent *pevent, const char *comm, int pid)
> return 0;
> }
>
> -void pevent_register_trace_clock(struct pevent *pevent, char *trace_clock)
> +int pevent_register_trace_clock(struct pevent *pevent, const char *trace_clock)
> {
> - pevent->trace_clock = trace_clock;
> + pevent->trace_clock = strdup(trace_clock);
> + if (!pevent->trace_clock) {
> + errno = ENOMEM;
> + return -1;
Humm, strdup actually sets errno already, from its man page:
-------------------
RETURN VALUE
On success, the strdup() function returns a pointer to the
duplicated string. It returns NULL if insufficient memory was
available, with errno set to indicate the cause of the error.
-------------------
Applying anyway, as this doesn't introduces a problem, right?
- ARnaldo
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 4/9] tools lib traceevent: Add pevent_data_pid_from_comm()
2015-03-24 13:57 ` [PATCH 4/9] tools lib traceevent: Add pevent_data_pid_from_comm() Steven Rostedt
@ 2015-03-24 15:16 ` Arnaldo Carvalho de Melo
2015-03-24 16:34 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
1 sibling, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-03-24 15:16 UTC (permalink / raw)
To: Steven Rostedt
Cc: linux-kernel, Ingo Molnar, Jiri Olsa, Namhyung Kim, Andrew Morton
Em Tue, Mar 24, 2015 at 09:57:52AM -0400, Steven Rostedt escreveu:
> From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
>
> There is a pevent_data_comm_from_pid() that returns the cmdline stored for
> a given pid in order for users to map pids to comms, but there's no method
> to convert a comm back to a pid. This is useful for filters that specify
> a comm instead of a PID (it's faster than searching each individual event).
>
> Add a way to retrieve a comm from a pid. Since there can be more than one
> pid associated to a comm, it returns a data structure that lets the user
> iterate over all the saved comms for a given pid.
>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
> tools/lib/traceevent/event-parse.c | 90 ++++++++++++++++++++++++++++++++++++++
> tools/lib/traceevent/event-parse.h | 5 +++
> 2 files changed, 95 insertions(+)
>
> diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> index 5795d9451063..8cc3e894ff46 100644
> --- a/tools/lib/traceevent/event-parse.c
> +++ b/tools/lib/traceevent/event-parse.c
> @@ -4951,6 +4951,96 @@ const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid)
> return comm;
> }
>
I am fixing this up:
[acme@ssdandy linux]$ am /wb/1.patch && make -C tools/perf
LIBBABELTRACE_DIR=/opt/libbabeltrace/ O=/tmp/build/perf install-bin
Applying: tools lib traceevent: Add pevent_data_pid_from_comm()
/home/acme/git/linux/.git/rebase-apply/patch:96: trailing whitespace.
if (!pevent->cmdlines ||
warning: 1 line adds whitespace errors.
tools/lib/traceevent/event-parse.c:5039: trailing whitespace.
+ if (!pevent->cmdlines ||
[acme@ssdandy linux]$
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 5/9] tools lib traceevent: Fix whitespace error
2015-03-24 13:57 ` [PATCH 5/9] tools lib traceevent: Fix whitespace error Steven Rostedt
@ 2015-03-24 15:19 ` Arnaldo Carvalho de Melo
2015-03-24 15:37 ` Steven Rostedt
0 siblings, 1 reply; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-03-24 15:19 UTC (permalink / raw)
To: Steven Rostedt
Cc: linux-kernel, Ingo Molnar, Jiri Olsa, Namhyung Kim, Andrew Morton
Em Tue, Mar 24, 2015 at 09:57:53AM -0400, Steven Rostedt escreveu:
> From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
Ok, you caught me on this one, squashed with the previous one :-)
- Arnaldo
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
> tools/lib/traceevent/event-parse.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> index 8cc3e894ff46..aff743710001 100644
> --- a/tools/lib/traceevent/event-parse.c
> +++ b/tools/lib/traceevent/event-parse.c
> @@ -5033,7 +5033,7 @@ int pevent_cmdline_pid(struct pevent *pevent, struct cmdline *cmdline)
> * If cmdlines have not been created yet, or cmdline is
> * not part of the array, then treat it as a cmdlist instead.
> */
> - if (!pevent->cmdlines ||
> + if (!pevent->cmdlines ||
> cmdline < pevent->cmdlines ||
> cmdline >= pevent->cmdlines + pevent->cmdline_count)
> return cmdlist->pid;
> --
> 2.1.4
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd
2015-03-24 15:04 ` Steven Rostedt
@ 2015-03-24 15:25 ` Arnaldo Carvalho de Melo
2015-03-24 15:26 ` Arnaldo Carvalho de Melo
1 sibling, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-03-24 15:25 UTC (permalink / raw)
To: Steven Rostedt
Cc: linux-kernel, Ingo Molnar, Jiri Olsa, Namhyung Kim, Andrew Morton,
Guilherme Cox
Em Tue, Mar 24, 2015 at 11:04:28AM -0400, Steven Rostedt escreveu:
> On Tue, 24 Mar 2015 11:57:27 -0300
> Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
>
> > Em Tue, Mar 24, 2015 at 09:57:48AM -0400, Steven Rostedt escreveu:
> > > Arnaldo,
> > >
> > > I took a look at the differences between what I have in trace-cmd and
> > > what is sitting in tools/lib/traceevent, and I put together a patch set
> > > that brings in fixes and updates to libtraceevent.
> >
> > Thanks, will process now.
>
> I just added this one too...
ok, adding this one as well.
> -- Steve
>
> From fe80b2e9396fa6b8dc66a6dfd4c7a426e1685424 Mon Sep 17 00:00:00 2001
> From: Guilherme Cox <cox@computer.org>
> Date: Fri, 20 Feb 2015 19:10:34 -0500
> Subject: [PATCH] tools lib traceevent: Zero should not be considered "not
> found" in eval_flag()
>
> Guilherme Cox found that:
> There is, however, a potential bug if there is an item with code zero
> that is not the first one in the symbol list, since eval_flag(..)
> returns 0 when it doesn't find anything.
>
> Reported-by: Guilherme Cox <cox@computer.org>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
> tools/lib/traceevent/event-parse.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> index aff743710001..f2fb50141703 100644
> --- a/tools/lib/traceevent/event-parse.c
> +++ b/tools/lib/traceevent/event-parse.c
> @@ -3576,7 +3576,7 @@ static const struct flag flags[] = {
> { "HRTIMER_RESTART", 1 },
> };
>
> -static unsigned long long eval_flag(const char *flag)
> +static long long eval_flag(const char *flag)
> {
> int i;
>
> @@ -3592,7 +3592,7 @@ static unsigned long long eval_flag(const char *flag)
> if (strcmp(flags[i].name, flag) == 0)
> return flags[i].value;
>
> - return 0;
> + return -1LL;
> }
>
> static void print_str_to_seq(struct trace_seq *s, const char *format,
> @@ -3666,7 +3666,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
> struct print_flag_sym *flag;
> struct format_field *field;
> struct printk_map *printk;
> - unsigned long long val, fval;
> + long long val, fval;
> unsigned long addr;
> char *str;
> unsigned char *hex;
> @@ -3725,11 +3725,11 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
> print = 0;
> for (flag = arg->flags.flags; flag; flag = flag->next) {
> fval = eval_flag(flag->value);
> - if (!val && !fval) {
> + if (!val && fval < 0) {
> print_str_to_seq(s, format, len_arg, flag->str);
> break;
> }
> - if (fval && (val & fval) == fval) {
> + if (fval > 0 && (val & fval) == fval) {
> if (print && arg->flags.delim)
> trace_seq_puts(s, arg->flags.delim);
> print_str_to_seq(s, format, len_arg, flag->str);
> --
> 1.8.3.1
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd
2015-03-24 15:04 ` Steven Rostedt
2015-03-24 15:25 ` Arnaldo Carvalho de Melo
@ 2015-03-24 15:26 ` Arnaldo Carvalho de Melo
2015-03-24 15:44 ` Steven Rostedt
1 sibling, 1 reply; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-03-24 15:26 UTC (permalink / raw)
To: Steven Rostedt
Cc: linux-kernel, Ingo Molnar, Jiri Olsa, Namhyung Kim, Andrew Morton,
Guilherme Cox
Em Tue, Mar 24, 2015 at 11:04:28AM -0400, Steven Rostedt escreveu:
> On Tue, 24 Mar 2015 11:57:27 -0300
> Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
>
> > Em Tue, Mar 24, 2015 at 09:57:48AM -0400, Steven Rostedt escreveu:
> > > Arnaldo,
> > >
> > > I took a look at the differences between what I have in trace-cmd and
> > > what is sitting in tools/lib/traceevent, and I put together a patch set
> > > that brings in fixes and updates to libtraceevent.
> >
> > Thanks, will process now.
>
> I just added this one too...
ok, but who is the author? Is Guilherme just the reporter or was it him
that sent the patch but hasn't provided a S-o-B?
- Arnaldo
> -- Steve
>
> From fe80b2e9396fa6b8dc66a6dfd4c7a426e1685424 Mon Sep 17 00:00:00 2001
> From: Guilherme Cox <cox@computer.org>
> Date: Fri, 20 Feb 2015 19:10:34 -0500
> Subject: [PATCH] tools lib traceevent: Zero should not be considered "not
> found" in eval_flag()
>
> Guilherme Cox found that:
> There is, however, a potential bug if there is an item with code zero
> that is not the first one in the symbol list, since eval_flag(..)
> returns 0 when it doesn't find anything.
>
> Reported-by: Guilherme Cox <cox@computer.org>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
> tools/lib/traceevent/event-parse.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> index aff743710001..f2fb50141703 100644
> --- a/tools/lib/traceevent/event-parse.c
> +++ b/tools/lib/traceevent/event-parse.c
> @@ -3576,7 +3576,7 @@ static const struct flag flags[] = {
> { "HRTIMER_RESTART", 1 },
> };
>
> -static unsigned long long eval_flag(const char *flag)
> +static long long eval_flag(const char *flag)
> {
> int i;
>
> @@ -3592,7 +3592,7 @@ static unsigned long long eval_flag(const char *flag)
> if (strcmp(flags[i].name, flag) == 0)
> return flags[i].value;
>
> - return 0;
> + return -1LL;
> }
>
> static void print_str_to_seq(struct trace_seq *s, const char *format,
> @@ -3666,7 +3666,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
> struct print_flag_sym *flag;
> struct format_field *field;
> struct printk_map *printk;
> - unsigned long long val, fval;
> + long long val, fval;
> unsigned long addr;
> char *str;
> unsigned char *hex;
> @@ -3725,11 +3725,11 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
> print = 0;
> for (flag = arg->flags.flags; flag; flag = flag->next) {
> fval = eval_flag(flag->value);
> - if (!val && !fval) {
> + if (!val && fval < 0) {
> print_str_to_seq(s, format, len_arg, flag->str);
> break;
> }
> - if (fval && (val & fval) == fval) {
> + if (fval > 0 && (val & fval) == fval) {
> if (print && arg->flags.delim)
> trace_seq_puts(s, arg->flags.delim);
> print_str_to_seq(s, format, len_arg, flag->str);
> --
> 1.8.3.1
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 5/9] tools lib traceevent: Fix whitespace error
2015-03-24 15:19 ` Arnaldo Carvalho de Melo
@ 2015-03-24 15:37 ` Steven Rostedt
0 siblings, 0 replies; 31+ messages in thread
From: Steven Rostedt @ 2015-03-24 15:37 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: linux-kernel, Ingo Molnar, Jiri Olsa, Namhyung Kim, Andrew Morton
On Tue, 24 Mar 2015 12:19:04 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> Em Tue, Mar 24, 2015 at 09:57:53AM -0400, Steven Rostedt escreveu:
> > From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
>
> Ok, you caught me on this one, squashed with the previous one :-)
Heh, if I noticed that this fixed a previous patch in the series, I
would have squashed it myself :-)
-- Steve
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 2/9] tools lib traceevent: Copy trace_clock and free it
2015-03-24 15:14 ` Arnaldo Carvalho de Melo
@ 2015-03-24 15:43 ` Steven Rostedt
0 siblings, 0 replies; 31+ messages in thread
From: Steven Rostedt @ 2015-03-24 15:43 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: linux-kernel, Ingo Molnar, Jiri Olsa, Namhyung Kim, Andrew Morton
On Tue, 24 Mar 2015 12:14:49 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> Humm, strdup actually sets errno already, from its man page:
>
> -------------------
>
> RETURN VALUE
> On success, the strdup() function returns a pointer to the
> duplicated string. It returns NULL if insufficient memory was
> available, with errno set to indicate the cause of the error.
>
> -------------------
>
>
> Applying anyway, as this doesn't introduces a problem, right?
>
Ah, I didn't realize that. I probably should of. The original code just
had a "die()" in it. But I know how much Namhyung loves those ;-)
I removed the die() and noticed that the other removed "die()"s also
set errno = ENOMEM. Those probably could also be removed as they happen
after "remalloc" and such.
-- Steve
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd
2015-03-24 15:26 ` Arnaldo Carvalho de Melo
@ 2015-03-24 15:44 ` Steven Rostedt
2015-03-24 15:45 ` Steven Rostedt
0 siblings, 1 reply; 31+ messages in thread
From: Steven Rostedt @ 2015-03-24 15:44 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: linux-kernel, Ingo Molnar, Jiri Olsa, Namhyung Kim, Andrew Morton,
Guilherme Cox
On Tue, 24 Mar 2015 12:26:37 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> Em Tue, Mar 24, 2015 at 11:04:28AM -0400, Steven Rostedt escreveu:
> > On Tue, 24 Mar 2015 11:57:27 -0300
> > Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> >
> > > Em Tue, Mar 24, 2015 at 09:57:48AM -0400, Steven Rostedt escreveu:
> > > > Arnaldo,
> > > >
> > > > I took a look at the differences between what I have in trace-cmd and
> > > > what is sitting in tools/lib/traceevent, and I put together a patch set
> > > > that brings in fixes and updates to libtraceevent.
> > >
> > > Thanks, will process now.
> >
> > I just added this one too...
>
> ok, but who is the author? Is Guilherme just the reporter or was it him
> that sent the patch but hasn't provided a S-o-B?
>
He just reported it.
-- Steve
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd
2015-03-24 15:44 ` Steven Rostedt
@ 2015-03-24 15:45 ` Steven Rostedt
2015-03-24 15:51 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 31+ messages in thread
From: Steven Rostedt @ 2015-03-24 15:45 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: linux-kernel, Ingo Molnar, Jiri Olsa, Namhyung Kim, Andrew Morton,
Guilherme Cox
On Tue, 24 Mar 2015 11:44:06 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> On Tue, 24 Mar 2015 12:26:37 -0300
> Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
>
> > Em Tue, Mar 24, 2015 at 11:04:28AM -0400, Steven Rostedt escreveu:
> > > On Tue, 24 Mar 2015 11:57:27 -0300
> > > Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> > >
> > > > Em Tue, Mar 24, 2015 at 09:57:48AM -0400, Steven Rostedt escreveu:
> > > > > Arnaldo,
> > > > >
> > > > > I took a look at the differences between what I have in trace-cmd and
> > > > > what is sitting in tools/lib/traceevent, and I put together a patch set
> > > > > that brings in fixes and updates to libtraceevent.
> > > >
> > > > Thanks, will process now.
> > >
> > > I just added this one too...
> >
> > ok, but who is the author? Is Guilherme just the reporter or was it him
> > that sent the patch but hasn't provided a S-o-B?
> >
>
> He just reported it.
Actually, hold off on applying it. I want to test it a bit more. I
really just applied it today :-) and sent it to you. It was only in a
quilt queue before that. Not my git repo.
-- Steve
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd
2015-03-24 15:45 ` Steven Rostedt
@ 2015-03-24 15:51 ` Arnaldo Carvalho de Melo
2015-03-24 16:19 ` Steven Rostedt
0 siblings, 1 reply; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-03-24 15:51 UTC (permalink / raw)
To: Steven Rostedt
Cc: linux-kernel, Ingo Molnar, Jiri Olsa, Namhyung Kim, Andrew Morton,
Guilherme Cox
Em Tue, Mar 24, 2015 at 11:45:26AM -0400, Steven Rostedt escreveu:
> On Tue, 24 Mar 2015 11:44:06 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
> > On Tue, 24 Mar 2015 12:26:37 -0300 Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> > > Em Tue, Mar 24, 2015 at 11:04:28AM -0400, Steven Rostedt escreveu:
> > > > On Tue, 24 Mar 2015 11:57:27 -0300
> > > > Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> > > > > Em Tue, Mar 24, 2015 at 09:57:48AM -0400, Steven Rostedt escreveu:
> > > > > > I took a look at the differences between what I have in trace-cmd and
> > > > > > what is sitting in tools/lib/traceevent, and I put together a patch set
> > > > > > that brings in fixes and updates to libtraceevent.
> > > > > Thanks, will process now.
> > > > I just added this one too...
> > > ok, but who is the author? Is Guilherme just the reporter or was it him
> > > that sent the patch but hasn't provided a S-o-B?
> > He just reported it.
> Actually, hold off on applying it. I want to test it a bit more. I
> really just applied it today :-) and sent it to you. It was only in a
> quilt queue before that. Not my git repo.
Ok, its just that if it comes like that it will appear as being authored
by him, no?
- Arnaldo
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd
2015-03-24 15:51 ` Arnaldo Carvalho de Melo
@ 2015-03-24 16:19 ` Steven Rostedt
0 siblings, 0 replies; 31+ messages in thread
From: Steven Rostedt @ 2015-03-24 16:19 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: linux-kernel, Ingo Molnar, Jiri Olsa, Namhyung Kim, Andrew Morton,
Guilherme Cox
On Tue, 24 Mar 2015 12:51:41 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> > Actually, hold off on applying it. I want to test it a bit more. I
> > really just applied it today :-) and sent it to you. It was only in a
> > quilt queue before that. Not my git repo.
>
> Ok, its just that if it comes like that it will appear as being authored
> by him, no?
Crap, you're right. Thanks for pointing that out to me. Instead of cut
and pasting his text and his email address, and creating a change log
from scratch, I saved the email and appending my patch to it, then
modified the rest. But I never took out the "From:".
OK, I'll fix that too. Thanks for mentioning it.
-- Steve
^ permalink raw reply [flat|nested] 31+ messages in thread
* [tip:perf/core] tools lib traceevent: Handle NULL comm name
2015-03-24 13:57 ` [PATCH 1/9] tools lib traceevent: Handle NULL comm name Steven Rostedt
@ 2015-03-24 16:33 ` tip-bot for Josef Bacik
0 siblings, 0 replies; 31+ messages in thread
From: tip-bot for Josef Bacik @ 2015-03-24 16:33 UTC (permalink / raw)
To: linux-tip-commits
Cc: namhyung, acme, mingo, jolsa, linux-kernel, jbacik, akpm, rostedt,
hpa, tglx
Commit-ID: deab6f55a2fe6fe044af61c9aad6a8e90cda6499
Gitweb: http://git.kernel.org/tip/deab6f55a2fe6fe044af61c9aad6a8e90cda6499
Author: Josef Bacik <jbacik@fb.com>
AuthorDate: Tue, 24 Mar 2015 09:57:49 -0400
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 24 Mar 2015 12:10:26 -0300
tools lib traceevent: Handle NULL comm name
It is possible that a pid has no associated comm attached to it, although it
can still be passed to pevent_register_comm().
But if comm is NULL, it will cause strdup() to segfault. To prevent this
from happening, if comm is NULL use the default "<...>" name for the
pid.
Signed-off-by: Josef Bacik <jbacik@fb.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/20150324135922.549965495@goodmis.org
Link: http://lkml.kernel.org/p/1403799732-30308-1-git-send-email-jbacik@fb.com
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/lib/traceevent/event-parse.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 8e5e4f6..31d4e7d 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -304,7 +304,10 @@ int pevent_register_comm(struct pevent *pevent, const char *comm, int pid)
if (!item)
return -1;
- item->comm = strdup(comm);
+ if (comm)
+ item->comm = strdup(comm);
+ else
+ item->comm = strdup("<...>");
if (!item->comm) {
free(item);
return -1;
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [tip:perf/core] tools lib traceevent: Copy trace_clock and free it
2015-03-24 13:57 ` [PATCH 2/9] tools lib traceevent: Copy trace_clock and free it Steven Rostedt
2015-03-24 15:14 ` Arnaldo Carvalho de Melo
@ 2015-03-24 16:33 ` tip-bot for Steven Rostedt (Red Hat)
1 sibling, 0 replies; 31+ messages in thread
From: tip-bot for Steven Rostedt (Red Hat) @ 2015-03-24 16:33 UTC (permalink / raw)
To: linux-tip-commits
Cc: tglx, rostedt, mingo, namhyung, acme, jolsa, linux-kernel, akpm,
hpa
Commit-ID: 99ad1417db2e83530b88e3eff1a40285d6ebfee9
Gitweb: http://git.kernel.org/tip/99ad1417db2e83530b88e3eff1a40285d6ebfee9
Author: Steven Rostedt (Red Hat) <rostedt@goodmis.org>
AuthorDate: Tue, 24 Mar 2015 09:57:50 -0400
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 24 Mar 2015 12:11:19 -0300
tools lib traceevent: Copy trace_clock and free it
The pevent->trace_clock should not be a direct pointer to what was
given. It should be copied and freed.
Note, valgrind pointed this out when a caller passed in a pointer that
needed to be freed and it never was. Ideally, pevent should copy it
(which this change does), and free the copy. It's up to the caller to
free the clock string passed in.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
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/20150324135922.695906738@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 | 2 +-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 31d4e7d..e71c472 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -321,9 +321,14 @@ int pevent_register_comm(struct pevent *pevent, const char *comm, int pid)
return 0;
}
-void pevent_register_trace_clock(struct pevent *pevent, char *trace_clock)
+int pevent_register_trace_clock(struct pevent *pevent, const char *trace_clock)
{
- pevent->trace_clock = trace_clock;
+ pevent->trace_clock = strdup(trace_clock);
+ if (!pevent->trace_clock) {
+ errno = ENOMEM;
+ return -1;
+ }
+ return 0;
}
struct func_map {
@@ -6352,6 +6357,7 @@ void pevent_free(struct pevent *pevent)
free_handler(handle);
}
+ free(pevent->trace_clock);
free(pevent->events);
free(pevent->sort_events);
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 6abda54..84e554f 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -599,7 +599,7 @@ enum trace_flag_type {
};
int pevent_register_comm(struct pevent *pevent, const char *comm, int pid);
-void pevent_register_trace_clock(struct pevent *pevent, char *trace_clock);
+int pevent_register_trace_clock(struct pevent *pevent, const char *trace_clock);
int pevent_register_function(struct pevent *pevent, char *name,
unsigned long long addr, char *mod);
int pevent_register_print_string(struct pevent *pevent, const char *fmt,
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [tip:perf/core] tools lib traceevent: Handle %z in bprint format
2015-03-24 13:57 ` [PATCH 3/9] tools lib traceevent: Handle %z in bprint format Steven Rostedt
@ 2015-03-24 16:33 ` tip-bot for Steven Rostedt (Red Hat)
0 siblings, 0 replies; 31+ messages in thread
From: tip-bot for Steven Rostedt (Red Hat) @ 2015-03-24 16:33 UTC (permalink / raw)
To: linux-tip-commits
Cc: tglx, rostedt, akpm, jolsa, shawn.bohrer, namhyung, hpa, acme,
linux-kernel, mingo
Commit-ID: 55426296963c678650e26fc5e61ea75a5598ef5a
Gitweb: http://git.kernel.org/tip/55426296963c678650e26fc5e61ea75a5598ef5a
Author: Steven Rostedt (Red Hat) <rostedt@goodmis.org>
AuthorDate: Tue, 24 Mar 2015 09:57:51 -0400
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 24 Mar 2015 12:15:12 -0300
tools lib traceevent: Handle %z in bprint format
The %z printf specifier was not handled making trace_printk()s in the
kernel that used this break on output.
Reported-by: Shawn Bohrer <shawn.bohrer@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Shawn Bohrer <shawn.bohrer@gmail.com>
Link: http://lkml.kernel.org/r/20150324135922.844361717@goodmis.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/lib/traceevent/event-parse.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index e71c472..bdb1dd6 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -4008,6 +4008,10 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc
goto process_again;
case '.':
goto process_again;
+ case 'z':
+ case 'Z':
+ ls = 1;
+ goto process_again;
case 'p':
ls = 1;
/* fall through */
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [tip:perf/core] tools lib traceevent: Add pevent_data_pid_from_comm()
2015-03-24 13:57 ` [PATCH 4/9] tools lib traceevent: Add pevent_data_pid_from_comm() Steven Rostedt
2015-03-24 15:16 ` Arnaldo Carvalho de Melo
@ 2015-03-24 16:34 ` tip-bot for Steven Rostedt (Red Hat)
1 sibling, 0 replies; 31+ messages in thread
From: tip-bot for Steven Rostedt (Red Hat) @ 2015-03-24 16:34 UTC (permalink / raw)
To: linux-tip-commits
Cc: akpm, jolsa, namhyung, rostedt, tglx, linux-kernel, mingo, hpa,
acme
Commit-ID: 2771984c7f5e6cab812e86ec152da4fb5f6df908
Gitweb: http://git.kernel.org/tip/2771984c7f5e6cab812e86ec152da4fb5f6df908
Author: Steven Rostedt (Red Hat) <rostedt@goodmis.org>
AuthorDate: Tue, 24 Mar 2015 09:57:52 -0400
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 24 Mar 2015 12:19:06 -0300
tools lib traceevent: Add pevent_data_pid_from_comm()
There is a pevent_data_comm_from_pid() that returns the cmdline stored for
a given pid in order for users to map pids to comms, but there's no method
to convert a comm back to a pid. This is useful for filters that specify
a comm instead of a PID (it's faster than searching each individual event).
Add a way to retrieve a comm from a pid. Since there can be more than one
pid associated to a comm, it returns a data structure that lets the user
iterate over all the saved comms for a given pid.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
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/20150324135923.001103479@goodmis.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/lib/traceevent/event-parse.c | 90 ++++++++++++++++++++++++++++++++++++++
tools/lib/traceevent/event-parse.h | 5 +++
2 files changed, 95 insertions(+)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index bdb1dd6..bc22722 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -4954,6 +4954,96 @@ const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid)
return comm;
}
+static struct cmdline *
+pid_from_cmdlist(struct pevent *pevent, const char *comm, struct cmdline *next)
+{
+ struct cmdline_list *cmdlist = (struct cmdline_list *)next;
+
+ if (cmdlist)
+ cmdlist = cmdlist->next;
+ else
+ cmdlist = pevent->cmdlist;
+
+ while (cmdlist && strcmp(cmdlist->comm, comm) != 0)
+ cmdlist = cmdlist->next;
+
+ return (struct cmdline *)cmdlist;
+}
+
+/**
+ * pevent_data_pid_from_comm - return the pid from a given comm
+ * @pevent: a handle to the pevent
+ * @comm: the cmdline to find the pid from
+ * @next: the cmdline structure to find the next comm
+ *
+ * This returns the cmdline structure that holds a pid for a given
+ * comm, or NULL if none found. As there may be more than one pid for
+ * a given comm, the result of this call can be passed back into
+ * a recurring call in the @next paramater, and then it will find the
+ * next pid.
+ * Also, it does a linear seach, so it may be slow.
+ */
+struct cmdline *pevent_data_pid_from_comm(struct pevent *pevent, const char *comm,
+ struct cmdline *next)
+{
+ struct cmdline *cmdline;
+
+ /*
+ * If the cmdlines have not been converted yet, then use
+ * the list.
+ */
+ if (!pevent->cmdlines)
+ return pid_from_cmdlist(pevent, comm, next);
+
+ if (next) {
+ /*
+ * The next pointer could have been still from
+ * a previous call before cmdlines were created
+ */
+ if (next < pevent->cmdlines ||
+ next >= pevent->cmdlines + pevent->cmdline_count)
+ next = NULL;
+ else
+ cmdline = next++;
+ }
+
+ if (!next)
+ cmdline = pevent->cmdlines;
+
+ while (cmdline < pevent->cmdlines + pevent->cmdline_count) {
+ if (strcmp(cmdline->comm, comm) == 0)
+ return cmdline;
+ cmdline++;
+ }
+ return NULL;
+}
+
+/**
+ * pevent_cmdline_pid - return the pid associated to a given cmdline
+ * @cmdline: The cmdline structure to get the pid from
+ *
+ * Returns the pid for a give cmdline. If @cmdline is NULL, then
+ * -1 is returned.
+ */
+int pevent_cmdline_pid(struct pevent *pevent, struct cmdline *cmdline)
+{
+ struct cmdline_list *cmdlist = (struct cmdline_list *)cmdline;
+
+ if (!cmdline)
+ return -1;
+
+ /*
+ * If cmdlines have not been created yet, or cmdline is
+ * not part of the array, then treat it as a cmdlist instead.
+ */
+ if (!pevent->cmdlines ||
+ cmdline < pevent->cmdlines ||
+ cmdline >= pevent->cmdlines + pevent->cmdline_count)
+ return cmdlist->pid;
+
+ return cmdline->pid;
+}
+
/**
* pevent_data_comm_from_pid - parse the data into the print format
* @s: the trace_seq to write to
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 84e554f..8bd7c6a 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -678,6 +678,11 @@ int pevent_data_type(struct pevent *pevent, struct pevent_record *rec);
struct event_format *pevent_data_event_from_type(struct pevent *pevent, int type);
int pevent_data_pid(struct pevent *pevent, struct pevent_record *rec);
const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid);
+struct cmdline;
+struct cmdline *pevent_data_pid_from_comm(struct pevent *pevent, const char *comm,
+ struct cmdline *next);
+int pevent_cmdline_pid(struct pevent *pevent, struct cmdline *cmdline);
+
void pevent_event_info(struct trace_seq *s, struct event_format *event,
struct pevent_record *record);
int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum,
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [tip:perf/core] tools lib traceevent: Make plugin options either string or boolean
2015-03-24 13:57 ` [PATCH 6/9] tools lib traceevent: Make plugin options either string or boolean Steven Rostedt
@ 2015-03-24 16:34 ` tip-bot for Steven Rostedt
0 siblings, 0 replies; 31+ messages in thread
From: tip-bot for Steven Rostedt @ 2015-03-24 16:34 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, akpm, linux-kernel, jolsa, tglx, hpa, rostedt, srostedt,
mingo, namhyung
Commit-ID: 5dbcfd930e430b33fb4dfded9c1af0cf432772b9
Gitweb: http://git.kernel.org/tip/5dbcfd930e430b33fb4dfded9c1af0cf432772b9
Author: Steven Rostedt <srostedt@redhat.com>
AuthorDate: Tue, 24 Mar 2015 09:57:54 -0400
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 24 Mar 2015 12:20:09 -0300
tools lib traceevent: Make plugin options either string or boolean
When a plugin option is defined, by default it is a boolean (true or false).
If the option is something else, then it needs to set its "value" field to
a default string other than NULL (can be just "").
If the value is not set then the option is considered boolean, and the
updating of the option value will be handled accordingly.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
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/20150324135923.308372986@goodmis.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/lib/traceevent/event-parse.h | 6 +++-
tools/lib/traceevent/event-plugin.c | 60 +++++++++++++++++++++++++++++++++----
2 files changed, 59 insertions(+), 7 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 8bd7c6a..8ca1b8e 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -116,7 +116,7 @@ struct pevent_plugin_option {
char *name;
char *plugin_alias;
char *description;
- char *value;
+ const char *value;
void *priv;
int set;
};
@@ -154,6 +154,10 @@ struct pevent_plugin_option {
* .plugin_alias is used to give a shorter name to access
* the vairable. Useful if a plugin handles more than one event.
*
+ * If .value is not set, then it is considered a boolean and only
+ * .set will be processed. If .value is defined, then it is considered
+ * a string option and .set will be ignored.
+ *
* PEVENT_PLUGIN_ALIAS: (optional)
* The name to use for finding options (uses filename if not defined)
*/
diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c
index 136162c..a16756a 100644
--- a/tools/lib/traceevent/event-plugin.c
+++ b/tools/lib/traceevent/event-plugin.c
@@ -18,6 +18,7 @@
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
+#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <dlfcn.h>
@@ -49,6 +50,52 @@ struct plugin_list {
void *handle;
};
+static void lower_case(char *str)
+{
+ if (!str)
+ return;
+ for (; *str; str++)
+ *str = tolower(*str);
+}
+
+static int update_option_value(struct pevent_plugin_option *op, const char *val)
+{
+ char *op_val;
+
+ if (!val) {
+ /* toggle, only if option is boolean */
+ if (op->value)
+ /* Warn? */
+ return 0;
+ op->set ^= 1;
+ return 0;
+ }
+
+ /*
+ * If the option has a value then it takes a string
+ * otherwise the option is a boolean.
+ */
+ if (op->value) {
+ op->value = val;
+ return 0;
+ }
+
+ /* Option is boolean, must be either "1", "0", "true" or "false" */
+
+ op_val = strdup(val);
+ if (!op_val)
+ return -1;
+ lower_case(op_val);
+
+ if (strcmp(val, "1") == 0 || strcmp(val, "true") == 0)
+ op->set = 1;
+ else if (strcmp(val, "0") == 0 || strcmp(val, "false") == 0)
+ op->set = 0;
+ free(op_val);
+
+ return 0;
+}
+
/**
* traceevent_plugin_list_options - get list of plugin options
*
@@ -120,6 +167,7 @@ update_option(const char *file, struct pevent_plugin_option *option)
{
struct trace_plugin_options *op;
char *plugin;
+ int ret = 0;
if (option->plugin_alias) {
plugin = strdup(option->plugin_alias);
@@ -144,9 +192,10 @@ update_option(const char *file, struct pevent_plugin_option *option)
if (strcmp(op->option, option->name) != 0)
continue;
- option->value = op->value;
- option->set ^= 1;
- goto out;
+ ret = update_option_value(option, op->value);
+ if (ret)
+ goto out;
+ break;
}
/* first look for unnamed options */
@@ -156,14 +205,13 @@ update_option(const char *file, struct pevent_plugin_option *option)
if (strcmp(op->option, option->name) != 0)
continue;
- option->value = op->value;
- option->set ^= 1;
+ ret = update_option_value(option, op->value);
break;
}
out:
free(plugin);
- return 0;
+ return ret;
}
/**
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [tip:perf/core] tools lib traceevent kbuffer: Remove extra update to data pointer in PADDING
2015-03-24 13:57 ` [PATCH 7/9] tools lib traceevent kbuffer: Remove extra update to data pointer in PADDING Steven Rostedt
@ 2015-03-24 16:34 ` tip-bot for Steven Rostedt (Red Hat)
0 siblings, 0 replies; 31+ messages in thread
From: tip-bot for Steven Rostedt (Red Hat) @ 2015-03-24 16:34 UTC (permalink / raw)
To: linux-tip-commits
Cc: tglx, namhyung, akpm, jolsa, rostedt, hpa, linux-kernel, mingo,
acme
Commit-ID: c5e691928bf166ac03430e957038b60adba3cf6c
Gitweb: http://git.kernel.org/tip/c5e691928bf166ac03430e957038b60adba3cf6c
Author: Steven Rostedt (Red Hat) <rostedt@goodmis.org>
AuthorDate: Tue, 24 Mar 2015 09:57:55 -0400
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 24 Mar 2015 12:22:04 -0300
tools lib traceevent kbuffer: Remove extra update to data pointer in PADDING
When a event PADDING is hit (a deleted event that is still in the ring
buffer), translate_data() sets the length of the padding and also updates
the data pointer which is passed back to the caller.
This is unneeded because the caller also updates the data pointer with
the passed back length. translate_data() should not update the pointer,
only set the length.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: stable@vger.kernel.org # 3.12+
Link: http://lkml.kernel.org/r/20150324135923.461431960@goodmis.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/lib/traceevent/kbuffer-parse.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/tools/lib/traceevent/kbuffer-parse.c b/tools/lib/traceevent/kbuffer-parse.c
index dcc6652..deb3569 100644
--- a/tools/lib/traceevent/kbuffer-parse.c
+++ b/tools/lib/traceevent/kbuffer-parse.c
@@ -372,7 +372,6 @@ translate_data(struct kbuffer *kbuf, void *data, void **rptr,
switch (type_len) {
case KBUFFER_TYPE_PADDING:
*length = read_4(kbuf, data);
- data += *length;
break;
case KBUFFER_TYPE_TIME_EXTEND:
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [tip:perf/core] tools lib traceevent: Add way to find sub buffer boundary
2015-03-24 13:57 ` [PATCH 8/9] tools lib traceevent: Add way to find sub buffer boundary Steven Rostedt
@ 2015-03-24 16:35 ` tip-bot for Steven Rostedt (Red Hat)
0 siblings, 0 replies; 31+ messages in thread
From: tip-bot for Steven Rostedt (Red Hat) @ 2015-03-24 16:35 UTC (permalink / raw)
To: linux-tip-commits
Cc: jolsa, linux-kernel, akpm, hpa, rostedt, mingo, namhyung, acme,
tglx
Commit-ID: 82ac952be6348dc072dcfd80a2dcb511d0cd6bea
Gitweb: http://git.kernel.org/tip/82ac952be6348dc072dcfd80a2dcb511d0cd6bea
Author: Steven Rostedt (Red Hat) <rostedt@goodmis.org>
AuthorDate: Tue, 24 Mar 2015 09:57:56 -0400
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 24 Mar 2015 12:22:09 -0300
tools lib traceevent: Add way to find sub buffer boundary
For debugging purposes, it may be helpful for the kbuffer library to flag
when crossing a sub buffer.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
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/20150324135923.650983637@goodmis.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/lib/traceevent/kbuffer-parse.c | 11 +++++++++++
tools/lib/traceevent/kbuffer.h | 1 +
2 files changed, 12 insertions(+)
diff --git a/tools/lib/traceevent/kbuffer-parse.c b/tools/lib/traceevent/kbuffer-parse.c
index deb3569..3bcada3 100644
--- a/tools/lib/traceevent/kbuffer-parse.c
+++ b/tools/lib/traceevent/kbuffer-parse.c
@@ -729,3 +729,14 @@ void kbuffer_set_old_format(struct kbuffer *kbuf)
kbuf->next_event = __old_next_event;
}
+
+/**
+ * kbuffer_start_of_data - return offset of where data starts on subbuffer
+ * @kbuf: The kbuffer
+ *
+ * Returns the location on the subbuffer where the data starts.
+ */
+int kbuffer_start_of_data(struct kbuffer *kbuf)
+{
+ return kbuf->start;
+}
diff --git a/tools/lib/traceevent/kbuffer.h b/tools/lib/traceevent/kbuffer.h
index c831f64..03dce75 100644
--- a/tools/lib/traceevent/kbuffer.h
+++ b/tools/lib/traceevent/kbuffer.h
@@ -63,5 +63,6 @@ int kbuffer_missed_events(struct kbuffer *kbuf);
int kbuffer_subbuffer_size(struct kbuffer *kbuf);
void kbuffer_set_old_format(struct kbuffer *kbuf);
+int kbuffer_start_of_data(struct kbuffer *kbuf);
#endif /* _K_BUFFER_H */
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [tip:perf/core] tools lib traceevent: Free filter tokens in process_filter()
2015-03-24 13:57 ` [PATCH 9/9] tools lib traceevent: Free filter tokens in process_filter() Steven Rostedt
@ 2015-03-24 16:35 ` tip-bot for Steven Rostedt (Red Hat)
0 siblings, 0 replies; 31+ messages in thread
From: tip-bot for Steven Rostedt (Red Hat) @ 2015-03-24 16:35 UTC (permalink / raw)
To: linux-tip-commits
Cc: rostedt, akpm, linux-kernel, acme, namhyung, hpa, tglx, mingo,
jolsa
Commit-ID: e1644aae4589274223c1ab9072ddbda98dd97f6a
Gitweb: http://git.kernel.org/tip/e1644aae4589274223c1ab9072ddbda98dd97f6a
Author: Steven Rostedt (Red Hat) <rostedt@goodmis.org>
AuthorDate: Tue, 24 Mar 2015 09:57:57 -0400
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 24 Mar 2015 12:23:03 -0300
tools lib traceevent: Free filter tokens in process_filter()
valgrind showed that the filter token wasn't being freed properly in
process_filter().
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
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/20150324135923.817723903@goodmis.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/lib/traceevent/parse-filter.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index b502344..0144b3d 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1058,6 +1058,7 @@ process_filter(struct event_format *event, struct filter_arg **parg,
*parg = current_op;
else
*parg = current_exp;
+ free(token);
return PEVENT_ERRNO__UNBALANCED_PAREN;
}
break;
@@ -1168,6 +1169,7 @@ process_filter(struct event_format *event, struct filter_arg **parg,
*parg = current_op;
+ free(token);
return 0;
fail_alloc:
^ permalink raw reply related [flat|nested] 31+ messages in thread
end of thread, other threads:[~2015-03-24 16:35 UTC | newest]
Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-24 13:57 [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd Steven Rostedt
2015-03-24 13:57 ` [PATCH 1/9] tools lib traceevent: Handle NULL comm name Steven Rostedt
2015-03-24 16:33 ` [tip:perf/core] " tip-bot for Josef Bacik
2015-03-24 13:57 ` [PATCH 2/9] tools lib traceevent: Copy trace_clock and free it Steven Rostedt
2015-03-24 15:14 ` Arnaldo Carvalho de Melo
2015-03-24 15:43 ` Steven Rostedt
2015-03-24 16:33 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
2015-03-24 13:57 ` [PATCH 3/9] tools lib traceevent: Handle %z in bprint format Steven Rostedt
2015-03-24 16:33 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
2015-03-24 13:57 ` [PATCH 4/9] tools lib traceevent: Add pevent_data_pid_from_comm() Steven Rostedt
2015-03-24 15:16 ` Arnaldo Carvalho de Melo
2015-03-24 16:34 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
2015-03-24 13:57 ` [PATCH 5/9] tools lib traceevent: Fix whitespace error Steven Rostedt
2015-03-24 15:19 ` Arnaldo Carvalho de Melo
2015-03-24 15:37 ` Steven Rostedt
2015-03-24 13:57 ` [PATCH 6/9] tools lib traceevent: Make plugin options either string or boolean Steven Rostedt
2015-03-24 16:34 ` [tip:perf/core] " tip-bot for Steven Rostedt
2015-03-24 13:57 ` [PATCH 7/9] tools lib traceevent kbuffer: Remove extra update to data pointer in PADDING Steven Rostedt
2015-03-24 16:34 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
2015-03-24 13:57 ` [PATCH 8/9] tools lib traceevent: Add way to find sub buffer boundary Steven Rostedt
2015-03-24 16:35 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
2015-03-24 13:57 ` [PATCH 9/9] tools lib traceevent: Free filter tokens in process_filter() Steven Rostedt
2015-03-24 16:35 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
2015-03-24 14:57 ` [PATCH 0/9] tools lib traceevent: Pulling in updates from trace-cmd Arnaldo Carvalho de Melo
2015-03-24 15:04 ` Steven Rostedt
2015-03-24 15:25 ` Arnaldo Carvalho de Melo
2015-03-24 15:26 ` Arnaldo Carvalho de Melo
2015-03-24 15:44 ` Steven Rostedt
2015-03-24 15:45 ` Steven Rostedt
2015-03-24 15:51 ` Arnaldo Carvalho de Melo
2015-03-24 16:19 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox