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


Groups > linux.kernel > #1503141

[RFC][PATCHv3 0/6] printk: use printk_safe to handle printk() recursive calls

From Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Newsgroups linux.kernel
Subject [RFC][PATCHv3 0/6] printk: use printk_safe to handle printk() recursive calls
Date 2016-10-18 17:50 +0200
Message-ID <stEOm-3Fs-11@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Hello,

        RFC

        This patch set extends a lock-less NMI per-cpu buffers idea to
handle recursive printk() calls. The basic mechanism is pretty much the
same -- at the beginning of a deadlock-prone section we switch to lock-less
printk callback, and return back to a default printk implementation at the
end; the messages are getting flushed to a logbuf buffer from a safer
context.

Deadlock scenarios that printk_safe can handle:

a) printk recursion from logbuf_lock spin_lock section in printk()
  printk()
    raw_spin_lock(&logbuf_lock);
    WARN_ON(1);
    raw_spin_unlock(&logbuf_lock);

b) printk from sem->lock spin_lock section
  printk()
    console_trylock()
      down_trylock()
        raw_spin_lock_irqsave(&sem->lock, flags);
        WARN_ON(1);
        raw_spin_unlock_irqrestore(&sem->lock, flags);

c) printk from logbuf_lock spin_lock section in console_unlock()
  printk()
    console_unlock()
      raw_spin_lock(&logbuf_lock);
      WARN_ON(1);
      raw_spin_unlock(&logbuf_lock);

d) printk from ->pi_lock from semaphore up
  printk()
    console_unlock()
      up()
        try_to_wake_up()
          raw_spin_lock_irqsave(&p->pi_lock, flags);
          WARN_ON(1);
          raw_spin_unlock_irqrestore(&p->pi_lock, flags);

[[against next-20161018]]

v3: (review by Petr)
-- renamed to printk_safe
-- !NMI config build fix
-- report lost messages for both printk_sae and printk_nmi
-- dropped recursion reporting patch
-- etc.

v2:
-- fix build error on !NMI configs, reported by Fengguang
-- reworked the series based on Petr's feedback
-- added a new patch to drop zap_locks()

Sergey Senozhatsky (6):
  printk: use vprintk_func in vprintk()
  printk: rename nmi.c and exported api
  printk: introduce per-cpu safe_print seq buffer
  printk: report lost messages in printk safe/nmi contexts
  printk: use printk_safe buffers
  printk: remove zap_locks() function

 arch/arm/kernel/smp.c                  |   4 +-
 include/linux/hardirq.h                |   4 +-
 include/linux/printk.h                 |  29 ++--
 init/Kconfig                           |  16 ++-
 init/main.c                            |   2 +-
 kernel/kexec_core.c                    |   2 +-
 kernel/panic.c                         |   4 +-
 kernel/printk/Makefile                 |   3 +-
 kernel/printk/internal.h               |  65 +++++----
 kernel/printk/printk.c                 | 116 ++++------------
 kernel/printk/{nmi.c => printk_safe.c} | 239 +++++++++++++++++++++++++--------
 lib/nmi_backtrace.c                    |   2 +-
 12 files changed, 277 insertions(+), 209 deletions(-)
 rename kernel/printk/{nmi.c => printk_safe.c} (54%)

-- 
2.10.1.382.ga23ca1b

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[RFC][PATCHv3 0/6] printk: use printk_safe to handle printk() recursive calls Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-10-18 17:50 +0200
  [RFC][PATCHv3 5/6] printk: use printk_safe buffers Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-10-18 17:50 +0200
  [RFC][PATCHv3 2/6] printk: rename nmi.c and exported api Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-10-18 17:50 +0200
    Re: [RFC][PATCHv3 2/6] printk: rename nmi.c and exported api Steven Rostedt <rostedt@goodmis.org> - 2016-10-18 18:50 +0200
      Re: [RFC][PATCHv3 2/6] printk: rename nmi.c and exported api Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-10-19 04:00 +0200
  [RFC][PATCHv3 6/6] printk: remove zap_locks() function Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-10-18 17:50 +0200
  [RFC][PATCHv3 4/6] printk: report lost messages in printk safe/nmi contexts Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-10-18 17:50 +0200
  Re: [RFC][PATCHv3 0/6] printk: use printk_safe to handle printk()  recursive calls Joe Perches <joe@perches.com> - 2016-10-18 18:50 +0200
    Re: [RFC][PATCHv3 0/6] printk: use printk_safe to handle printk()  recursive calls Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-10-19 03:20 +0200
  Re: [RFC][PATCHv3 0/6] printk: use printk_safe to handle printk()  recursive calls Peter Zijlstra <peterz@infradead.org> - 2016-10-18 19:10 +0200
    Re: [RFC][PATCHv3 0/6] printk: use printk_safe to handle printk()  recursive calls Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-10-19 04:00 +0200
      Re: [RFC][PATCHv3 0/6] printk: use printk_safe to handle printk()  recursive calls Peter Zijlstra <peterz@infradead.org> - 2016-10-19 18:20 +0200
    Re: [RFC][PATCHv3 0/6] printk: use printk_safe to handle printk()  recursive calls Peter Zijlstra <peterz@infradead.org> - 2016-10-19 16:30 +0200
      Re: [RFC][PATCHv3 0/6] printk: use printk_safe to handle printk()  recursive calls Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-10-20 15:20 +0200
    Re: [RFC][PATCHv3 0/6] printk: use printk_safe to handle printk()  recursive calls Petr Mladek <pmladek@suse.com> - 2016-10-19 16:40 +0200
  Re: [RFC][PATCHv3 0/6] printk: use printk_safe to handle printk()  recursive calls Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-10-19 06:40 +0200

csiph-web