• Sergey Senozhatsky's avatar
    printk: set may_schedule for some of console_trylock() callers · 6b97a20d
    Sergey Senozhatsky authored
    console_unlock() allows to cond_resched() if its caller has set
    `console_may_schedule' to 1, since 8d91f8b1
    
     ("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
    
    However, console_trylock() callers (among them is printk()) do not
    always call printk() from atomic contexts, and some of them can
    cond_resched() in console_unlock(), so console_trylock() can set
    `console_may_schedule' to 1 for such processes.
    
    For !CONFIG_PREEMPT_COUNT kernels, however, console_trylock() always
    sets `console_may_schedule' to 0.
    
    It's possible to drop explicit preempt_disable()/preempt_enable() in
    vprintk_emit(), because console_unlock() and console_trylock() are now
    smart enough:
     a) console_unlock() does not cond_resched() when it's unsafe
        (console_trylock() takes care of that)
     b) console_unlock() does can_use_console() check.
    Signed-off-by: default avatarSergey Senozhatsky <sergey.senozhatsky@gmail.com>
    Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
    Cc: Jan Kara <jack@suse.com>
    Cc: Tejun Heo <tj@kernel.org>
    Cc: Kyle McMartin <kyle@kernel.org>
    Cc: Dave Jones <davej@codemonkey.org.uk>
    Cc: Calvin Owens <calvinowens@fb.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    6b97a20d
printk.c 81.2 KB