From: tip-bot for Jiri Olsa <jolsa@redhat.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
rostedt@goodmis.org, tglx@linutronix.de, jolsa@redhat.com
Subject: [tip:perf/core] tracing: Avoid soft lockup in trace_pipe
Date: Wed, 27 Apr 2011 15:22:44 GMT [thread overview]
Message-ID: <tip-ee5e51f51be755830f57445e268ba50e88ccbdbb@git.kernel.org> (raw)
In-Reply-To: <20110325110518.GC1922@jolsa.brq.redhat.com>
Commit-ID: ee5e51f51be755830f57445e268ba50e88ccbdbb
Gitweb: http://git.kernel.org/tip/ee5e51f51be755830f57445e268ba50e88ccbdbb
Author: Jiri Olsa <jolsa@redhat.com>
AuthorDate: Fri, 25 Mar 2011 12:05:18 +0100
Committer: Steven Rostedt <rostedt@goodmis.org>
CommitDate: Mon, 4 Apr 2011 12:18:24 -0400
tracing: Avoid soft lockup in trace_pipe
running following commands:
# enable the binary option
echo 1 > ./options/bin
# disable context info option
echo 0 > ./options/context-info
# tracing only events
echo 1 > ./events/enable
cat trace_pipe
plus forcing system to generate many tracing events,
is causing lockup (in NON preemptive kernels) inside
tracing_read_pipe function.
The issue is also easily reproduced by running ltp stress test.
(ftrace_stress_test.sh)
The reasons are:
- bin/hex/raw output functions for events are set to
trace_nop_print function, which prints nothing and
returns TRACE_TYPE_HANDLED value
- LOST EVENT trace do not handle trace_seq overflow
These reasons force the while loop in tracing_read_pipe
function never to break.
The attached patch fixies handling of lost event trace, and
changes trace_nop_print to print minimal info, which is needed
for the correct tracing_read_pipe processing.
v2 changes:
- omit the cond_resched changes by trace_nop_print changes
- WARN changed to WARN_ONCE and added info to be able
to find out the culprit
v3 changes:
- make more accurate patch comment
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
LKML-Reference: <20110325110518.GC1922@jolsa.brq.redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace.c | 15 ++++++++++++---
kernel/trace/trace_output.c | 3 +++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 9541c27..5af42f4 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2013,9 +2013,10 @@ enum print_line_t print_trace_line(struct trace_iterator *iter)
{
enum print_line_t ret;
- if (iter->lost_events)
- trace_seq_printf(&iter->seq, "CPU:%d [LOST %lu EVENTS]\n",
- iter->cpu, iter->lost_events);
+ if (iter->lost_events &&
+ !trace_seq_printf(&iter->seq, "CPU:%d [LOST %lu EVENTS]\n",
+ iter->cpu, iter->lost_events))
+ return TRACE_TYPE_PARTIAL_LINE;
if (iter->trace && iter->trace->print_line) {
ret = iter->trace->print_line(iter);
@@ -3229,6 +3230,14 @@ waitagain:
if (iter->seq.len >= cnt)
break;
+
+ /*
+ * Setting the full flag means we reached the trace_seq buffer
+ * size and we should leave by partial output condition above.
+ * One of the trace_seq_* functions is not used properly.
+ */
+ WARN_ONCE(iter->seq.full, "full flag set for trace type %d",
+ iter->ent->type);
}
trace_access_unlock(iter->cpu_file);
trace_event_read_unlock();
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 456be90..cf535cc 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -830,6 +830,9 @@ EXPORT_SYMBOL_GPL(unregister_ftrace_event);
enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags,
struct trace_event *event)
{
+ if (!trace_seq_printf(&iter->seq, "type: %d\n", iter->ent->type))
+ return TRACE_TYPE_PARTIAL_LINE;
+
return TRACE_TYPE_HANDLED;
}
prev parent reply other threads:[~2011-04-27 15:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-12 22:59 [PATCH 0/2] tracing - avoid soft lockup in trace_pipe Jiri Olsa
2011-03-12 22:59 ` [PATCH 1/2] tracing - trace lost events properly Jiri Olsa
2011-03-12 22:59 ` [PATCH 2/2] tracing - putting cond_resched into tace_pipe loop Jiri Olsa
2011-03-13 14:58 ` Oleg Nesterov
2011-03-14 14:07 ` Steven Rostedt
2011-03-14 14:18 ` Jiri Olsa
2011-03-14 14:28 ` Steven Rostedt
2011-03-14 15:07 ` Jiri Olsa
2011-03-14 15:20 ` Steven Rostedt
2011-03-14 18:06 ` [PATCHv2] tracing - avoid soft lockup in trace_pipe Jiri Olsa
2011-03-21 12:10 ` Jiri Olsa
2011-03-25 2:23 ` Steven Rostedt
2011-03-25 3:14 ` Steven Rostedt
2011-03-25 11:05 ` [PATCHv3] " Jiri Olsa
2011-03-25 15:46 ` Steven Rostedt
2011-03-25 15:49 ` Steven Rostedt
2011-03-25 15:53 ` Jiri Olsa
2011-04-27 15:22 ` tip-bot for Jiri Olsa [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-ee5e51f51be755830f57445e268ba50e88ccbdbb@git.kernel.org \
--to=jolsa@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox