Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Feng Tang <feng.tang@intel.com>
To: Petr Mladek <pmladek@suse.com>
Cc: akpm@linux-foundation.org, bp@suse.de, keescook@chromium.org,
	mm-commits@vger.kernel.org, sergey.senozhatsky@gmail.com,
	stable@vger.kernel.org, tglx@linutronix.de,
	Steven Rostedt <rostedt@goodmis.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Sasha Levin <sashal@kernel.org>
Subject: Re: + panic-avoid-the-extra-noise-dmesg.patch added to -mm tree
Date: Wed, 5 Dec 2018 09:53:38 +0800	[thread overview]
Message-ID: <20181205015338.djdmnph4nrw3ua6u@shbuild888> (raw)
In-Reply-To: <20181204160152.375vymcau4lnejx4@pathway.suse.cz>

Hi Petr,

On Tue, Dec 04, 2018 at 05:01:52PM +0100, Petr Mladek wrote:
> On Tue 2018-12-04 23:49:36, Feng Tang wrote:
> > + Sasha 
> > 
> > Thanks Petr and Sergey for the reviews.
> > 
> > 
> > On Tue, Dec 04, 2018 at 11:20:33AM +0100, Petr Mladek wrote:
> > > On Mon 2018-12-03 23:15:31, Andrew Morton wrote:
> > > > 
> > > > ------------------------------------------------------
> > > > From: Feng Tang <feng.tang@intel.com>
> > > > Subject: panic: Avoid the extra noise dmesg
> > > > 
> > > > When kernel panic happens, it will first print the panic call stack,
> > > > then the ending msg like:
> > > > 
> > > > [   35.743249] ---[ end Kernel panic - not syncing: Fatal exception
> > > > [   35.749975] ------------[ cut here ]------------
> > > > 
> > > > The above message are very useful for debugging.
> > > > 
> > > > But if system is configured to not reboot on panic, say the "panic_timeout"
> > > > parameter equals 0, it will likely print out many noisy message like
> > > > WARN() call stack for each and every CPU except the panic one, messages
> > > > like below:
> > > > 
> > > > 	WARNING: CPU: 1 PID: 280 at kernel/sched/core.c:1198 set_task_cpu+0x183/0x190
> > > > 	Call Trace:
> > > > 	<IRQ>
> > > > 	try_to_wake_up
> > > > 	default_wake_function
> > > > 	autoremove_wake_function
> > > > 	__wake_up_common
> > > > 	__wake_up_common_lock
> > > > 	__wake_up
> > > > 	wake_up_klogd_work_func
> > > > 	irq_work_run_list
> > > > 	irq_work_tick
> > > > 	update_process_times
> > > > 	tick_sched_timer
> > > > 	__hrtimer_run_queues
> > > > 	hrtimer_interrupt
> > > > 	smp_apic_timer_interrupt
> > > > 	apic_timer_interrupt
> > > 
> > > I guess that it is a warning about migrating tasks to an offline CPU.
> >  
> > My v1 patch was trying to add some hacky code into architecture code to
> > address several WARN()s directly, but that turns out to be very hacky and
> > involve much code for many archs.
> > 
> > > > For people working in console mode, the screen will first show the panic
> > > > call stack, but immediately overridded by these noisy extra messages, which
> > > > makes debugging much more difficult, as the original context gets lost on
> > > > screen.
> > > > 
> > > > Also these noisy messages will confuse some users, as I have seen many bug
> > > > reporters posted the noisy message into bugzilla, instead of the real panic
> > > > call stack and context.
> > > > 
> > > > Removing the "local_irq_enable" will avoid the noisy message.
> > > > 
> > > > The justification for the removing is: when code runs to this point, it
> > > > means user has chosed to not reboot, or do any special handling by using
> > > > the panic notifier method, no much point in re-enabling the interrupt.
> > > > 
> > > > Link: http://lkml.kernel.org/r/1543902228-23834-1-git-send-email-feng.tang@intel.com
> > > > Signed-off-by: Feng Tang <feng.tang@intel.com>
> > > > Cc: Thomas Gleixner <tglx@linutronix.de>
> > > > Cc: Kees Cook <keescook@chromium.org>
> > > > Cc: Borislav Petkov <bp@suse.de>
> > > > Cc: Petr Mladek <pmladek@suse.com>
> > > > Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> > > > Cc: <stable@vger.kernel.org>
> > > > Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> > > > ---
> > > > 
> > > > 
> > > > --- a/kernel/panic.c~panic-avoid-the-extra-noise-dmesg
> > > > +++ a/kernel/panic.c
> > > > @@ -322,7 +322,6 @@ void panic(const char *fmt, ...)
> > > >  	}
> > > >  #endif
> > > >  	pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
> > > > -	local_irq_enable();
> > > >  	for (i = 0; ; i += PANIC_TIMER_STEP) {
> > > >  		touch_softlockup_watchdog();
> > > >  		if (i >= i_next) {
> > > 
> > > Hmm, this calls panic_blink(). It seems that it depends on workqueues
> > > and the scheduler:
> > > 
> > >   + led_panic_blink()
> > >     + led_trigger_event()
> > >       + led_set_brightness()
> > >         + schedule_work(set_brightness_work)
> > > 
> > > I guess that blinking might be important in some situations and
> > > on some devices. On the other hand, we are interested only into
> > > blinking from this point on.
> > > 
> > > The easiest solution seems to be to make a noop from printk().
> > > For example, we could add a global flag:
> > > 
> > > int panic_blinking;
> > > 
> > > and add the following into vprintk_func()
> > > 
> > > 	/*
> > > 	 * Do not push away real panic() message by warnings from led
> > > 	 * blinking code.
> > > 	 */
> > > 	if (panic_blinking)
> > > 		return 0;
> > > 
> > > How does that sound?
> > 
> > This should be able to achieve the same goal. 
> > 
> > One thing I can think of is what mentioned by Sergey that some sysrq
> > handler may want to print out something, but it should mostly be
> > covered by 2 other panic debug print patches, which will print out
> > task/mem/timer/lock/ftrace info runtime on demand.
> 
> I think that we could simply clear panic_blinking from
> __handle_sysrq(). The user will still be able to capture the screen
> before touching the keyboard. But it will keep the things simple.
> 
> I hope that we did not miss anything else. Anyway, the approach with
> making printk a nop still looks like the best maintainable solution
> to me.
 
I will setup a platform which can handle sysrq request and try your
suggestion. thanks,

- Feng

  reply	other threads:[~2018-12-05  1:53 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-04  7:15 + panic-avoid-the-extra-noise-dmesg.patch added to -mm tree akpm
2018-12-04 10:10 ` Sergey Senozhatsky
2018-12-04 10:20 ` Petr Mladek
2018-12-04 15:49   ` Feng Tang
2018-12-04 16:01     ` Petr Mladek
2018-12-05  1:53       ` Feng Tang [this message]
2018-12-05  2:50         ` Sergey Senozhatsky
2018-12-05  3:05           ` Sergey Senozhatsky
2018-12-05  3:27             ` Feng Tang
2018-12-05  2:26     ` Sergey Senozhatsky
2018-12-05  2:47       ` Feng Tang
2018-12-05  2:57         ` Sergey Senozhatsky
2018-12-05  5:29           ` Sergey Senozhatsky
2018-12-05  8:00             ` Sergey Senozhatsky
2018-12-05 15:46               ` Feng Tang
2018-12-06  3:58                 ` Feng Tang
2018-12-07  9:50                   ` Sergey Senozhatsky
2018-12-10  9:45                     ` Feng Tang
2018-12-10 15:57                       ` Petr Mladek
2018-12-11  8:07                         ` Sergey Senozhatsky
2018-12-11  8:22                           ` Petr Mladek
2018-12-11  8:26                             ` Sergey Senozhatsky
2018-12-11  8:32                           ` Feng Tang
2018-12-11  9:08                             ` Sergey Senozhatsky
2018-12-11  8:00                       ` Sergey Senozhatsky

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=20181205015338.djdmnph4nrw3ua6u@shbuild888 \
    --to=feng.tang@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@suse.de \
    --cc=keescook@chromium.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sashal@kernel.org \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=stable@vger.kernel.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