From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Petr Mladek <pmladek@suse.com>
Subject: [for-linus][PATCH 11/11] tracing: Initialize iter->seq after zeroing in tracing_read_pipe()
Date: Sun, 13 Oct 2019 13:43:53 -0400 [thread overview]
Message-ID: <20191013174419.917699324@goodmis.org> (raw)
In-Reply-To: <20191013174342.381019558@goodmis.org>
From: Petr Mladek <pmladek@suse.com>
A customer reported the following softlockup:
[899688.160002] NMI watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [test.sh:16464]
[899688.160002] CPU: 0 PID: 16464 Comm: test.sh Not tainted 4.12.14-6.23-azure #1 SLE12-SP4
[899688.160002] RIP: 0010:up_write+0x1a/0x30
[899688.160002] Kernel panic - not syncing: softlockup: hung tasks
[899688.160002] RIP: 0010:up_write+0x1a/0x30
[899688.160002] RSP: 0018:ffffa86784d4fde8 EFLAGS: 00000257 ORIG_RAX: ffffffffffffff12
[899688.160002] RAX: ffffffff970fea00 RBX: 0000000000000001 RCX: 0000000000000000
[899688.160002] RDX: ffffffff00000001 RSI: 0000000000000080 RDI: ffffffff970fea00
[899688.160002] RBP: ffffffffffffffff R08: ffffffffffffffff R09: 0000000000000000
[899688.160002] R10: 0000000000000000 R11: 0000000000000000 R12: ffff8b59014720d8
[899688.160002] R13: ffff8b59014720c0 R14: ffff8b5901471090 R15: ffff8b5901470000
[899688.160002] tracing_read_pipe+0x336/0x3c0
[899688.160002] __vfs_read+0x26/0x140
[899688.160002] vfs_read+0x87/0x130
[899688.160002] SyS_read+0x42/0x90
[899688.160002] do_syscall_64+0x74/0x160
It caught the process in the middle of trace_access_unlock(). There is
no loop. So, it must be looping in the caller tracing_read_pipe()
via the "waitagain" label.
Crashdump analyze uncovered that iter->seq was completely zeroed
at this point, including iter->seq.seq.size. It means that
print_trace_line() was never able to print anything and
there was no forward progress.
The culprit seems to be in the code:
/* reset all but tr, trace, and overruns */
memset(&iter->seq, 0,
sizeof(struct trace_iterator) -
offsetof(struct trace_iterator, seq));
It was added by the commit 53d0aa773053ab182877 ("ftrace:
add logic to record overruns"). It was v2.6.27-rc1.
It was the time when iter->seq looked like:
struct trace_seq {
unsigned char buffer[PAGE_SIZE];
unsigned int len;
};
There was no "size" variable and zeroing was perfectly fine.
The solution is to reinitialize the structure after or without
zeroing.
Link: http://lkml.kernel.org/r/20191011142134.11997-1-pmladek@suse.com
Signed-off-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
kernel/trace/trace.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 2b4eff383505..6a0ee9178365 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6036,6 +6036,7 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
sizeof(struct trace_iterator) -
offsetof(struct trace_iterator, seq));
cpumask_clear(iter->started);
+ trace_seq_init(&iter->seq);
iter->pos = -1;
trace_event_read_lock();
--
2.23.0
next prev parent reply other threads:[~2019-10-13 17:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-13 17:43 [for-linus][PATCH 00/11] tracing: Fixes for v5.4-rc2 Steven Rostedt
2019-10-13 17:43 ` [for-linus][PATCH 01/11] tracefs: Revert ccbd54ff54e8 ("tracefs: Restrict tracefs when the kernel is locked down") Steven Rostedt
2019-10-13 17:43 ` [for-linus][PATCH 02/11] ftrace: Get a reference counter for the trace_array on filter files Steven Rostedt
2019-10-13 17:43 ` [for-linus][PATCH 03/11] tracing: Get trace_array reference for available_tracers files Steven Rostedt
2019-10-13 17:43 ` [for-linus][PATCH 04/11] tracing: Have trace events system open call tracing_open_generic_tr() Steven Rostedt
2019-10-13 17:43 ` [for-linus][PATCH 05/11] tracing: Add tracing_check_open_get_tr() Steven Rostedt
2019-10-13 17:43 ` [for-linus][PATCH 06/11] tracing: Add locked_down checks to the open calls of files created for tracefs Steven Rostedt
2019-10-13 17:43 ` [for-linus][PATCH 07/11] tracing: Do not create tracefs files if tracefs lockdown is in effect Steven Rostedt
2019-10-13 17:43 ` [for-linus][PATCH 09/11] tracing/hwlat: Report total time spent in all NMIs during the sample Steven Rostedt
2019-10-13 17:43 ` [for-linus][PATCH 10/11] tracing/hwlat: Dont ignore outer-loop duration when calculating max_latency Steven Rostedt
2019-10-13 17:43 ` Steven Rostedt [this message]
[not found] ` <20191013174419.228868312@goodmis.org>
2019-10-13 18:57 ` [for-linus][PATCH 08/11] recordmcount: Fix nop_mcount() function Steven Rostedt
2019-10-13 19:14 ` Uwe Kleine-König
2019-10-13 19:53 ` Steven Rostedt
2019-10-13 20:03 ` Steven Rostedt
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=20191013174419.917699324@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=pmladek@suse.com \
/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
Powered by JetHome