On Fri 2018-11-02 22:31:57, Tetsuo Handa wrote:
> syzbot is sometimes getting mixed output like below due to concurrent
> printk(). Mitigate such output by using line-buffered printk() API.
> 
> @@ -2421,18 +2458,20 @@ static void check_chain_key(struct task_struct *curr)
>  print_usage_bug_scenario(struct held_lock *lock)
>  {
>       struct lock_class *class = hlock_class(lock);
> +     struct printk_buffer *buf = get_printk_buffer();
>  
>       printk(" Possible unsafe locking scenario:\n\n");
>       printk("       CPU0\n");
>       printk("       ----\n");
> -     printk("  lock(");
> -     __print_lock_name(class);
> -     printk(KERN_CONT ");\n");
> +     printk_buffered(buf, "  lock(");
> +     __print_lock_name(class, buf);
> +     printk_buffered(buf, ");\n");
>       printk("  <Interrupt>\n");
> -     printk("    lock(");
> -     __print_lock_name(class);
> -     printk(KERN_CONT ");\n");
> +     printk_buffered(buf, "    lock(");
> +     __print_lock_name(class, buf);
> +     printk_buffered(buf, ");\n");
>       printk("\n *** DEADLOCK ***\n\n");
> +     put_printk_buffer(buf);
>  }
>  
>  static int

I really hope that the maze of pr_cont() calls in lockdep.c is the most
complicated one that we would meet.

Anyway, the following comes to my mind:

1. The mixing of normal and buffered printk calls is a bit confusing
   and error prone. It would make sense to use the buffered printk
   everywhere in the given section of code even when it is not
   strictly needed.

2. I would replace "buf" with "pbuf" or "prbuf" to distinguish it a
   bit from other eventual buffers.


Best Regards,
Petr

Reply via email to