* [PATCH 0/3] [GIT PULL] update for tip/tracing/ftrace
@ 2009-03-17 3:48 Steven Rostedt
2009-03-17 3:48 ` [PATCH 1/3] tracing/ftrace: fix the check on nopped sites Steven Rostedt
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Steven Rostedt @ 2009-03-17 3:48 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, Peter Zijlstra,
Frederic Weisbecker
Ingo,
Please pull the latest tip/tracing/ftrace tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/ftrace
Frederic Weisbecker (1):
tracing/ftrace: fix the check on nopped sites
Steven Rostedt (2):
tracing: protect reader of cmdline output
tracing: stop comm recording on tracing off
----
kernel/trace/blktrace.c | 23 ++++++++++++++++++-----
kernel/trace/ftrace.c | 2 +-
kernel/trace/trace.c | 22 +++++++++++++---------
kernel/trace/trace.h | 2 +-
kernel/trace/trace_functions_graph.c | 12 ++++++------
kernel/trace/trace_output.c | 18 ++++++++++++------
6 files changed, 51 insertions(+), 28 deletions(-)
--
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] tracing/ftrace: fix the check on nopped sites
2009-03-17 3:48 [PATCH 0/3] [GIT PULL] update for tip/tracing/ftrace Steven Rostedt
@ 2009-03-17 3:48 ` Steven Rostedt
2009-03-17 3:48 ` [PATCH 2/3] tracing: protect reader of cmdline output Steven Rostedt
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2009-03-17 3:48 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, Peter Zijlstra,
Frederic Weisbecker, Steven Rostedt
[-- Attachment #1: 0001-tracing-ftrace-fix-the-check-on-nopped-sites.patch --]
[-- Type: text/plain, Size: 1198 bytes --]
From: Frederic Weisbecker <fweisbec@gmail.com>
Impact: fix a dynamic tracing failure
Recently, the function and function graph tracers failed to use dynamic
tracing after the following commit:
fa9d13cf135efbd454453a53b6299976bea245a9
(ftrace: don't try to __ftrace_replace_code on !FTRACE_FL_CONVERTED rec)
The patch is right except a mistake on the check for the FTRACE_FL_CONVERTED
flag. The code patching is aborted in case of successfully nopped sites.
What we want is the opposite: ignore the callsites that haven't been nopped.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
kernel/trace/ftrace.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 90d5729..7847806 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -537,7 +537,7 @@ static void ftrace_replace_code(int enable)
*/
if (rec->flags & FTRACE_FL_FREE ||
rec->flags & FTRACE_FL_FAILED ||
- rec->flags & FTRACE_FL_CONVERTED)
+ !(rec->flags & FTRACE_FL_CONVERTED))
continue;
/* ignore updates to this record's mcount site */
--
1.6.2
--
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] tracing: protect reader of cmdline output
2009-03-17 3:48 [PATCH 0/3] [GIT PULL] update for tip/tracing/ftrace Steven Rostedt
2009-03-17 3:48 ` [PATCH 1/3] tracing/ftrace: fix the check on nopped sites Steven Rostedt
@ 2009-03-17 3:48 ` Steven Rostedt
2009-03-17 3:48 ` [PATCH 3/3] tracing: stop comm recording on tracing off Steven Rostedt
2009-03-17 9:36 ` [PATCH 0/3] [GIT PULL] update for tip/tracing/ftrace Ingo Molnar
3 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2009-03-17 3:48 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, Peter Zijlstra,
Frederic Weisbecker, Steven Rostedt
[-- Attachment #1: 0002-tracing-protect-reader-of-cmdline-output.patch --]
[-- Type: text/plain, Size: 6376 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
Impact: fix to one cause of incorrect comm outputs in trace
The spinlock only protected the creation of a comm <=> pid pair.
But it was possible that a reader could look up a pid, and get the
wrong comm because it had no locking.
This also required changing trace_find_cmdline to copy the comm cache
and not just send back a pointer to it.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
kernel/trace/blktrace.c | 23 ++++++++++++++++++-----
kernel/trace/trace.c | 20 ++++++++++++--------
kernel/trace/trace.h | 2 +-
kernel/trace/trace_functions_graph.c | 12 ++++++------
kernel/trace/trace_output.c | 18 ++++++++++++------
5 files changed, 49 insertions(+), 26 deletions(-)
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 1f32e4e..b171778 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -1027,7 +1027,9 @@ static int blk_log_action_seq(struct trace_seq *s, const struct blk_io_trace *t,
static int blk_log_generic(struct trace_seq *s, const struct trace_entry *ent)
{
- const char *cmd = trace_find_cmdline(ent->pid);
+ char cmd[TASK_COMM_LEN];
+
+ trace_find_cmdline(ent->pid, cmd);
if (t_sec(ent))
return trace_seq_printf(s, "%llu + %u [%s]\n",
@@ -1057,19 +1059,30 @@ static int blk_log_remap(struct trace_seq *s, const struct trace_entry *ent)
static int blk_log_plug(struct trace_seq *s, const struct trace_entry *ent)
{
- return trace_seq_printf(s, "[%s]\n", trace_find_cmdline(ent->pid));
+ char cmd[TASK_COMM_LEN];
+
+ trace_find_cmdline(ent->pid, cmd);
+
+ return trace_seq_printf(s, "[%s]\n", cmd);
}
static int blk_log_unplug(struct trace_seq *s, const struct trace_entry *ent)
{
- return trace_seq_printf(s, "[%s] %llu\n", trace_find_cmdline(ent->pid),
- get_pdu_int(ent));
+ char cmd[TASK_COMM_LEN];
+
+ trace_find_cmdline(ent->pid, cmd);
+
+ return trace_seq_printf(s, "[%s] %llu\n", cmd, get_pdu_int(ent));
}
static int blk_log_split(struct trace_seq *s, const struct trace_entry *ent)
{
+ char cmd[TASK_COMM_LEN];
+
+ trace_find_cmdline(ent->pid, cmd);
+
return trace_seq_printf(s, "%llu / %llu [%s]\n", t_sector(ent),
- get_pdu_int(ent), trace_find_cmdline(ent->pid));
+ get_pdu_int(ent), cmd);
}
/*
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index efe3202..2796bd2 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -770,25 +770,29 @@ static void trace_save_cmdline(struct task_struct *tsk)
__raw_spin_unlock(&trace_cmdline_lock);
}
-char *trace_find_cmdline(int pid)
+void trace_find_cmdline(int pid, char comm[])
{
- char *cmdline = "<...>";
unsigned map;
- if (!pid)
- return "<idle>";
+ if (!pid) {
+ strcpy(comm, "<idle>");
+ return;
+ }
- if (pid > PID_MAX_DEFAULT)
- goto out;
+ if (pid > PID_MAX_DEFAULT) {
+ strcpy(comm, "<...>");
+ return;
+ }
+ __raw_spin_lock(&trace_cmdline_lock);
map = map_pid_to_cmdline[pid];
if (map >= SAVED_CMDLINES)
goto out;
- cmdline = saved_cmdlines[map];
+ strcpy(comm, saved_cmdlines[map]);
out:
- return cmdline;
+ __raw_spin_unlock(&trace_cmdline_lock);
}
void tracing_record_cmdline(struct task_struct *tsk)
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 56ce34d..b0ecad8 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -547,7 +547,7 @@ struct tracer_switch_ops {
};
#endif /* CONFIG_CONTEXT_SWITCH_TRACER */
-extern char *trace_find_cmdline(int pid);
+extern void trace_find_cmdline(int pid, char comm[]);
#ifdef CONFIG_DYNAMIC_FTRACE
extern unsigned long ftrace_update_tot_cnt;
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index 4c38860..6004cca 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -190,15 +190,15 @@ print_graph_cpu(struct trace_seq *s, int cpu)
static enum print_line_t
print_graph_proc(struct trace_seq *s, pid_t pid)
{
- int i;
- int ret;
- int len;
- char comm[8];
- int spaces = 0;
+ char comm[TASK_COMM_LEN];
/* sign + log10(MAX_INT) + '\0' */
char pid_str[11];
+ int spaces = 0;
+ int ret;
+ int len;
+ int i;
- strncpy(comm, trace_find_cmdline(pid), 7);
+ trace_find_cmdline(pid, comm);
comm[7] = '\0';
sprintf(pid_str, "%d", pid);
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index ea9d3b4..6a4c9de 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -309,9 +309,9 @@ static int
lat_print_generic(struct trace_seq *s, struct trace_entry *entry, int cpu)
{
int hardirq, softirq;
- char *comm;
+ char comm[TASK_COMM_LEN];
- comm = trace_find_cmdline(entry->pid);
+ trace_find_cmdline(entry->pid, comm);
hardirq = entry->flags & TRACE_FLAG_HARDIRQ;
softirq = entry->flags & TRACE_FLAG_SOFTIRQ;
@@ -346,10 +346,12 @@ int trace_print_context(struct trace_iterator *iter)
{
struct trace_seq *s = &iter->seq;
struct trace_entry *entry = iter->ent;
- char *comm = trace_find_cmdline(entry->pid);
unsigned long long t = ns2usecs(iter->ts);
unsigned long usec_rem = do_div(t, USEC_PER_SEC);
unsigned long secs = (unsigned long)t;
+ char comm[TASK_COMM_LEN];
+
+ trace_find_cmdline(entry->pid, comm);
return trace_seq_printf(s, "%16s-%-5d [%03d] %5lu.%06lu: ",
comm, entry->pid, iter->cpu, secs, usec_rem);
@@ -372,7 +374,10 @@ int trace_print_lat_context(struct trace_iterator *iter)
rel_usecs = ns2usecs(next_ts - iter->ts);
if (verbose) {
- char *comm = trace_find_cmdline(entry->pid);
+ char comm[TASK_COMM_LEN];
+
+ trace_find_cmdline(entry->pid, comm);
+
ret = trace_seq_printf(s, "%16s %5d %3d %d %08x %08lx [%08lx]"
" %ld.%03ldms (+%ld.%03ldms): ", comm,
entry->pid, iter->cpu, entry->flags,
@@ -577,14 +582,15 @@ static enum print_line_t trace_ctxwake_print(struct trace_iterator *iter,
char *delim)
{
struct ctx_switch_entry *field;
- char *comm;
+ char comm[TASK_COMM_LEN];
int S, T;
+
trace_assign_type(field, iter->ent);
T = task_state_char(field->next_state);
S = task_state_char(field->prev_state);
- comm = trace_find_cmdline(field->next_pid);
+ trace_find_cmdline(field->next_pid, comm);
if (!trace_seq_printf(&iter->seq,
" %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n",
field->prev_pid,
--
1.6.2
--
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] tracing: stop comm recording on tracing off
2009-03-17 3:48 [PATCH 0/3] [GIT PULL] update for tip/tracing/ftrace Steven Rostedt
2009-03-17 3:48 ` [PATCH 1/3] tracing/ftrace: fix the check on nopped sites Steven Rostedt
2009-03-17 3:48 ` [PATCH 2/3] tracing: protect reader of cmdline output Steven Rostedt
@ 2009-03-17 3:48 ` Steven Rostedt
2009-03-17 9:36 ` [PATCH 0/3] [GIT PULL] update for tip/tracing/ftrace Ingo Molnar
3 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2009-03-17 3:48 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, Peter Zijlstra,
Frederic Weisbecker, Steven Rostedt
[-- Attachment #1: 0003-tracing-stop-comm-recording-on-tracing-off.patch --]
[-- Type: text/plain, Size: 1071 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
Impact: fix for losing comms in trace
The command lines of tasks are cached at sched switch to not need
to record them at every trace point. Disabling the tracing on stops
the recording of traces, but does not stop the caching of command lines.
When the tracing is off the cache may overflow and cause the tracing
to show incorrect tasks matching the PIDs.
This patch disables prevents updates to the comm cache when the ring buffer
is off.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
kernel/trace/trace.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 2796bd2..8f89690 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -797,7 +797,7 @@ void trace_find_cmdline(int pid, char comm[])
void tracing_record_cmdline(struct task_struct *tsk)
{
- if (atomic_read(&trace_record_cmdline_disabled))
+ if (atomic_read(&trace_record_cmdline_disabled) || !tracing_is_on())
return;
trace_save_cmdline(tsk);
--
1.6.2
--
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] [GIT PULL] update for tip/tracing/ftrace
2009-03-17 3:48 [PATCH 0/3] [GIT PULL] update for tip/tracing/ftrace Steven Rostedt
` (2 preceding siblings ...)
2009-03-17 3:48 ` [PATCH 3/3] tracing: stop comm recording on tracing off Steven Rostedt
@ 2009-03-17 9:36 ` Ingo Molnar
3 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2009-03-17 9:36 UTC (permalink / raw)
To: Steven Rostedt
Cc: linux-kernel, Andrew Morton, Thomas Gleixner, Peter Zijlstra,
Frederic Weisbecker
* Steven Rostedt <rostedt@goodmis.org> wrote:
> Ingo,
>
> Please pull the latest tip/tracing/ftrace tree, which can be found at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
> tip/tracing/ftrace
>
>
> Frederic Weisbecker (1):
> tracing/ftrace: fix the check on nopped sites
>
> Steven Rostedt (2):
> tracing: protect reader of cmdline output
> tracing: stop comm recording on tracing off
>
> ----
> kernel/trace/blktrace.c | 23 ++++++++++++++++++-----
> kernel/trace/ftrace.c | 2 +-
> kernel/trace/trace.c | 22 +++++++++++++---------
> kernel/trace/trace.h | 2 +-
> kernel/trace/trace_functions_graph.c | 12 ++++++------
> kernel/trace/trace_output.c | 18 ++++++++++++------
> 6 files changed, 51 insertions(+), 28 deletions(-)
Pulled, thanks Steve!
Ingo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-03-17 9:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-17 3:48 [PATCH 0/3] [GIT PULL] update for tip/tracing/ftrace Steven Rostedt
2009-03-17 3:48 ` [PATCH 1/3] tracing/ftrace: fix the check on nopped sites Steven Rostedt
2009-03-17 3:48 ` [PATCH 2/3] tracing: protect reader of cmdline output Steven Rostedt
2009-03-17 3:48 ` [PATCH 3/3] tracing: stop comm recording on tracing off Steven Rostedt
2009-03-17 9:36 ` [PATCH 0/3] [GIT PULL] update for tip/tracing/ftrace Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox