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


Groups > linux.kernel > #1530273 > unrolled thread

Re: [RFC][PATCHv4 5/6] printk: use printk_safe buffers

Started byPetr Mladek <pmladek@suse.com>
First post2016-11-25 15:30 +0100
Last post2016-12-01 03:20 +0100
Articles 2 — 2 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: [RFC][PATCHv4 5/6] printk: use printk_safe buffers Petr Mladek <pmladek@suse.com> - 2016-11-25 15:30 +0100
    Re: [RFC][PATCHv4 5/6] printk: use printk_safe buffers Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-12-01 03:20 +0100

#1530273 — Re: [RFC][PATCHv4 5/6] printk: use printk_safe buffers

FromPetr Mladek <pmladek@suse.com>
Date2016-11-25 15:30 +0100
SubjectRe: [RFC][PATCHv4 5/6] printk: use printk_safe buffers
Message-ID<sHpFL-1In-13@gated-at.bofh.it>
On Fri 2016-10-28 00:49:32, Sergey Senozhatsky wrote:
> Use printk_safe per-CPU buffers in in printk recursion-prone blocks:
> -- around logbuf_lock protected sections in vprintk_emit() and
>    console_unlock()
> -- around down_trylock_console_sem() and up_console_sem()
> 
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 4675b8d..5907e92 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1823,13 +1837,12 @@ asmlinkage int vprintk_emit(int facility, int level,
>  		 */
>  		if (!oops_in_progress && !lockdep_recursing(current))
> {
>  			recursion_bug = true;
> -			local_irq_restore(flags);
> +			printk_safe_exit(flags);
>  			return 0;
>  		}
>  		zap_locks();
>  	}
>  
> -	lockdep_off();

I really like this patch. The only small problem is that it enables
lockdep and it does not explain why it is safe. The change itself
looks fine but it took me some time to prove why. IMHO, it is
worth a comment.

One thing is printk() recursion caused by lockdep warning
triggered from inside vprintk_emit(). It is safe because
the critical sections are guarded by printk_safe_enter()/exit()
now.

Another thing is lockdep recursion caused by catching another lockdep
issue when printing warning about the first one. This is safe
because lockdep protects itself. First, it sets and checks
current->lockdep_recursion around the critical sections.
Second, further checks are disabled entirely once first
lockdep issue is found.

If you add some comments about lockdep, feel free to use:

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr

[toc] | [next] | [standalone]


#1533747

FromSergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Date2016-12-01 03:20 +0100
Message-ID<sJp8B-612-1@gated-at.bofh.it>
In reply to#1530273
On (11/25/16 15:28), Petr Mladek wrote:
[..]
> I really like this patch. The only small problem is that it enables
> lockdep and it does not explain why it is safe. The change itself
> looks fine but it took me some time to prove why. IMHO, it is
> worth a comment.
> 
> One thing is printk() recursion caused by lockdep warning
> triggered from inside vprintk_emit(). It is safe because
> the critical sections are guarded by printk_safe_enter()/exit()
> now.
> 
> Another thing is lockdep recursion caused by catching another lockdep
> issue when printing warning about the first one. This is safe
> because lockdep protects itself. First, it sets and checks
> current->lockdep_recursion around the critical sections.
> Second, further checks are disabled entirely once first
> lockdep issue is found.
> 
> If you add some comments about lockdep, feel free to use:

ok, I'll try to.

	-ss

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web