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


Groups > linux.kernel > #1325015

Re: [PATCH v2] lock/semaphore: Avoid an unnecessary deadlock within up()

From Ingo Molnar <mingo@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v2] lock/semaphore: Avoid an unnecessary deadlock within up()
Date 2016-02-03 09:10 +0100
Message-ID <qY0FI-7K9-15@gated-at.bofh.it> (permalink)
References <qXYNz-6z9-15@gated-at.bofh.it> <qY030-7gg-19@gated-at.bofh.it> <qY0mn-7ok-35@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


* Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> wrote:

> On (02/03/16 08:28), Ingo Molnar wrote:
> [..]
> > So why not move printk away from semaphores? Semaphores are classical constructs 
> > that have legacies and are somewhat non-obvious to use, compared to modern, 
> > simpler locking primitives. I'd not touch their implementation, unless we are 
> > absolutely sure this is a safe optimization.
> 
> semaphore's spin_lock is not the only spin lock that printk acquires. it also 
> takes the logbuf_lock (and different locks in console drivers (up to console 
> driver)).
>
> Jan Kara posted a patch that offloads printing job 
> (console_trylock()-console_unlock()) from printk() call (when printk can offload 
> it). so semaphore and console driver's locks will go away (mostly) with Jan's 
> patch. logbug spin_lock, however, will stay.

Well, but this patch of yours only affects the semaphore code, so it does not 
change the logbuf_lock situation.

Furthermore, logbuf_lock already has recursion protection:

        /*
         * Ouch, printk recursed into itself!
         */
        if (unlikely(logbuf_cpu == this_cpu)) {

so it should not be possible to re-enter the printk() logbuf_lock critical section 
from the spinlock code. (There are other ways to get the logbuf_lock - if those 
are still triggerable then they should be fixed.)

In any case, recursion protection is generally done in the debugging facilities 
trying to behave lockless.

Thanks,

	Ingo

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


Thread

[PATCH v2] lock/semaphore: Avoid an unnecessary deadlock within up() Byungchul Park <byungchul.park@lge.com> - 2016-02-03 07:10 +0100
  Re: [PATCH v2] lock/semaphore: Avoid an unnecessary deadlock within  up() Ingo Molnar <mingo@kernel.org> - 2016-02-03 08:30 +0100
    Re: [PATCH v2] lock/semaphore: Avoid an unnecessary deadlock within  up() Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-02-03 08:50 +0100
      Re: [PATCH v2] lock/semaphore: Avoid an unnecessary deadlock within  up() Ingo Molnar <mingo@kernel.org> - 2016-02-03 09:10 +0100
        Re: [PATCH v2] lock/semaphore: Avoid an unnecessary deadlock within  up() Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-02-03 09:30 +0100
          Re: [PATCH v2] lock/semaphore: Avoid an unnecessary deadlock within  up() Ingo Molnar <mingo@kernel.org> - 2016-02-03 10:10 +0100
      Re: [PATCH v2] lock/semaphore: Avoid an unnecessary deadlock within  up() Byungchul Park <byungchul.park@lge.com> - 2016-02-03 09:20 +0100
        Re: [PATCH v2] lock/semaphore: Avoid an unnecessary deadlock within  up() Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-02-03 09:30 +0100

csiph-web