public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/2] let printk()/console_trylock() callers to cond_resched()
@ 2016-02-12 18:37 Sergey Senozhatsky
  2016-02-12 18:37 ` [PATCH v4 1/3] printk: move can_use_console out of console_trylock_for_printk Sergey Senozhatsky
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Sergey Senozhatsky @ 2016-02-12 18:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Petr Mladek, Jan Kara, Tejun Heo, Kyle McMartin, Dave Jones,
	Calvin Owens, linux-kernel, Sergey Senozhatsky,
	Sergey Senozhatsky

Hello,

console_unlock() allows to cond_resched() if its caller has
set `console_may_schedule' to 1 (this functionality present
since commit 'printk: do cond_resched() between lines while
outputting to consoles').

The rules are:
-- console_lock() always sets `console_may_schedule' to 1
-- console_trylock() always sets `console_may_schedule' to 0

printk() calls console_unlock() with preemption desabled, which
basically can lead to RCU stalls, watchdog soft lockups, etc. if
something is simultaneously calling printk() frequent enough (IOW,
console_sem owner always has new data to send to console divers
and can't leave console_unlock() for a long time).

printk()->console_trylock() callers do not necessarily execute in
atomic contexts, and some of them can cond_resched() in
console_unlock(). console_trylock() can set `console_may_schedule'
to 1 (allow cond_resched() later in consoe_unlock()) when it's safe.

v4:
-- added "printk: check CON_ENABLED in have_callable_console()" patch
-- drop a "optional optimization" patch from the series (Petr Mladek)
-- merge 0001 and "drop console_trylock_for_printk" patches (Petr Mladek)
-- tweak console_trylock() comment (Petr Mladek)

v2-v3 (thanks to Petr Mladek for reviews):
-- do not call can_use_console() on every iteration in console_unlock() (Petr Mladek)
-- move "This stops the holder of console_sem.." comment (noted by Petr Mladek)
-- take extra care of !PREEMPT_COUNT kernels (Petr Mladek)
-- call_console_drivers() still must check cpu_online && CON_ANYTIME (Petr Mladek)
-- removed console_trylock_for_printk() (noted by Petr Mladek)

v1-v2:
-- make have_callable_console() available for !PRINTK configs (lkp@intel.com)
-- take care of RCU preempt kernels in console_trylock()


Sergey Senozhatsky (3):
  printk: move can_use_console out of console_trylock_for_printk
  printk: set may_schedule for some of console_trylock callers
  printk: check CON_ENABLED in have_callable_console()

 kernel/printk/printk.c | 121 +++++++++++++++++++++++--------------------------
 1 file changed, 57 insertions(+), 64 deletions(-)

-- 
2.7.1

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

end of thread, other threads:[~2016-02-16 15:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-12 18:37 [PATCH v4 0/2] let printk()/console_trylock() callers to cond_resched() Sergey Senozhatsky
2016-02-12 18:37 ` [PATCH v4 1/3] printk: move can_use_console out of console_trylock_for_printk Sergey Senozhatsky
2016-02-12 18:37 ` [PATCH v4 2/3] printk: set may_schedule for some of console_trylock callers Sergey Senozhatsky
2016-02-16 14:43   ` Petr Mladek
2016-02-16 15:45     ` Sergey Senozhatsky
2016-02-12 18:37 ` [PATCH v4 3/3] printk: check CON_ENABLED in have_callable_console() Sergey Senozhatsky
2016-02-16 14:44   ` Petr Mladek
2016-02-16 15:44     ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox