All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix BUG: Invalid wait context in hrtimer_interrupt()
@ 2021-01-23 23:37 Qais Yousef
  2021-01-23 23:37 ` [PATCH 1/2] printk: Add new pr_*_deferred_once() variants Qais Yousef
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Qais Yousef @ 2021-01-23 23:37 UTC (permalink / raw)
  To: Petr Mladek, Sergey Senozhatsky, Thomas Gleixner
  Cc: Steven Rostedt, John Ogness, Peter Zijlstra (Intel),
	linux-kernel, Qais Yousef

I hit a pr_warn() inside hrtimer_interrupt() which lead to a BUG: Invalid wait
context splat.

The problem wasn't reproducible but I think the cause is obvious, printk can't
be called from interrupt context.

AFAICU printk_deferred() is safe from NMI, so I assumed it is safe to be called
from hrtimer_interrupt() too. Adding a pr_warn_once() inside
hrtimer_interrupt() in a location where it is always hit produces the BUG
splat. Replacing it with pr_warn_deferred_once() generates the printk warning
without any splat.

I added a new pr_*_deferred_once() variants to avoid open coding; but the name
ended not much shorter and I'm not sure if the wrappers are a win overall.
Since I've already done it, I'm sticking to it in this post. But will be happy
to drop it and just open code the printk_deferred_once(KERN_WARN, ...) in
hrtimer_interrupt() instead.

Thanks

Qais Yousef (2):
  printk: Add new pr_*_deferred_once() variants
  hrtimer: Use pr_warn_deferred_once() in hrtimer_interrupt()

 include/linux/printk.h | 24 ++++++++++++++++++++++++
 kernel/time/hrtimer.c  |  3 ++-
 2 files changed, 26 insertions(+), 1 deletion(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-01-13 11:20 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-23 23:37 [PATCH 0/2] Fix BUG: Invalid wait context in hrtimer_interrupt() Qais Yousef
2021-01-23 23:37 ` [PATCH 1/2] printk: Add new pr_*_deferred_once() variants Qais Yousef
2021-01-25 10:37   ` Peter Zijlstra
2021-01-25 10:58     ` John Ogness
2021-01-25 19:46       ` Qais Yousef
2022-01-11 13:40       ` Andy Shevchenko
2022-01-13 11:20         ` Qais Yousef
2021-01-23 23:37 ` [PATCH 2/2] hrtimer: Use pr_warn_deferred_once() in hrtimer_interrupt() Qais Yousef
2021-01-26  4:46 ` [PATCH 0/2] Fix BUG: Invalid wait context " Sergey Senozhatsky
2021-01-26 14:59   ` Qais Yousef
2021-01-26 15:22     ` John Ogness
2021-01-26 16:18       ` Peter Zijlstra
2021-01-26 15:58     ` Sergey Senozhatsky
2021-01-26 16:23       ` Peter Zijlstra
2021-01-26 18:08         ` Qais Yousef
2021-01-26 16:58       ` Petr Mladek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.