Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1632233 > unrolled thread

Re: [PATCH v5 1/4] printk/nmi: generic solution for safe printk in NMI

Started bySteven Rostedt <rostedt@goodmis.org>
First post2017-04-27 18:20 +0200
Last post2017-04-28 16:20 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v5 1/4] printk/nmi: generic solution for safe printk in  NMI Steven Rostedt <rostedt@goodmis.org> - 2017-04-27 18:20 +0200
    Re: [PATCH v5 1/4] printk/nmi: generic solution for safe printk in  NMI Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-04-28 03:40 +0200
      Re: [PATCH v5 1/4] printk/nmi: generic solution for safe printk in  NMI Petr Mladek <pmladek@suse.com> - 2017-04-28 15:00 +0200
        Re: [PATCH v5 1/4] printk/nmi: generic solution for safe printk in  NMI Steven Rostedt <rostedt@goodmis.org> - 2017-04-28 16:20 +0200

#1632233 — Re: [PATCH v5 1/4] printk/nmi: generic solution for safe printk in NMI

FromSteven Rostedt <rostedt@goodmis.org>
Date2017-04-27 18:20 +0200
SubjectRe: [PATCH v5 1/4] printk/nmi: generic solution for safe printk in NMI
Message-ID<tAUj8-338-23@gated-at.bofh.it>
On Thu, 20 Apr 2017 15:11:54 +0200
Petr Mladek <pmladek@suse.com> wrote:



> 
> >From c530d9dee91c74db5e6a198479e2e63b24cb84a2 Mon Sep 17 00:00:00 2001  
> From: Petr Mladek <pmladek@suse.com>
> Date: Thu, 20 Apr 2017 10:52:31 +0200
> Subject: [PATCH] printk: Use the main logbuf in NMI when logbuf_lock is
>  available

I tried this patch. It's better because I get the end of the trace, but
I do lose the beginning of it:

** 196358 printk messages dropped ** [  102.321182]     perf-5981    0.... 12983650us : d_path <-seq_path

The way I tested it was by adding this:

Index: linux-trace.git/kernel/trace/trace_functions.c
===================================================================
--- linux-trace.git.orig/kernel/trace/trace_functions.c
+++ linux-trace.git/kernel/trace/trace_functions.c
@@ -469,8 +469,11 @@ ftrace_cpudump_probe(unsigned long ip, u
 		     struct trace_array *tr, struct ftrace_probe_ops *ops,
 		     void *data)
 {
-	if (update_count(ops, ip, data))
-		ftrace_dump(DUMP_ORIG);
+	char *killer = NULL;
+
+	panic_on_oops = 1;	/* force panic */
+	wmb();
+	*killer = 1;
 }
 
 static int


Then doing the following:

# echo 1 > /proc/sys/kernel/ftrace_dump_on_oops 
# trace-cmd start -p function
# echo nmi_handle:cpudump > /debug/tracing/set_ftrace_filter
# perf record -c 100 -a sleep 1

And that triggers the crash.

-- Steve

[toc] | [next] | [standalone]


#1632481

FromSergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Date2017-04-28 03:40 +0200
Message-ID<tB333-Ac-7@gated-at.bofh.it>
In reply to#1632233
On (04/27/17 12:14), Steven Rostedt wrote:
[..]
> I tried this patch. It's better because I get the end of the trace, but
> I do lose the beginning of it:
> 
> ** 196358 printk messages dropped ** [  102.321182]     perf-5981    0.... 12983650us : d_path <-seq_path

many thanks!

so we now drop messages from logbuf, not from per-CPU buffers. that
"queue printk_deferred irq_work on every online CPU when we bypass per-CPU
buffers from NMI" idea *probably* might help here - we need someone to emit
messages from the logbuf while we printk from NMI. there is still a
possibility that we can drop messages, though, since log_store() from NMI
CPU can be much-much faster than call_console_drivers() on other CPU.

	-ss

[toc] | [prev] | [next] | [standalone]


#1632853

FromPetr Mladek <pmladek@suse.com>
Date2017-04-28 15:00 +0200
Message-ID<tBdF8-7pE-13@gated-at.bofh.it>
In reply to#1632481
On Fri 2017-04-28 10:35:32, Sergey Senozhatsky wrote:
> On (04/27/17 12:14), Steven Rostedt wrote:
> [..]
> > I tried this patch. It's better because I get the end of the trace, but
> > I do lose the beginning of it:
> > 
> > ** 196358 printk messages dropped ** [  102.321182]     perf-5981    0.... 12983650us : d_path <-seq_path
>
> many thanks!
> 
> so we now drop messages from logbuf, not from per-CPU buffers. that
> "queue printk_deferred irq_work on every online CPU when we bypass per-CPU
> buffers from NMI" idea *probably* might help here - we need someone to emit
> messages from the logbuf while we printk from NMI. there is still a
> possibility that we can drop messages, though, since log_store() from NMI
> CPU can be much-much faster than call_console_drivers() on other CPU.

ftrace log is dumped via trace_panic_notifier. It is done after
smp_send_stop(). It means that only a single CPU is available and
it is NMI context at the moment.

One possibility might be to put printk into a special mode and
drop the last messages instead of the first ones. But this would
need to be configurable.

Of course, if the problem is reproducible, the easiest solution
is to use bigger main log buffer, for example boot with
log_buf_len=32M.

Best Regards,
Petr

[toc] | [prev] | [next] | [standalone]


#1632915

FromSteven Rostedt <rostedt@goodmis.org>
Date2017-04-28 16:20 +0200
Message-ID<tBeUy-8u3-5@gated-at.bofh.it>
In reply to#1632853
On Fri, 28 Apr 2017 14:57:25 +0200
Petr Mladek <pmladek@suse.com> wrote:


> Of course, if the problem is reproducible, the easiest solution
> is to use bigger main log buffer, for example boot with
> log_buf_len=32M.

Of course that may not be enough. Especially when I have a machine with
240 CPUs. But it also has a ton of RAM, I could easily do
log_buf_len=32G

-- Steve

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web