Re: question about preempt_disable()

From: Matthias Urlichs (smurf_at_smurf.noris.de)
Date: 11/30/03

  • Next message: Luis Miguel García: "Re: Silicon Image 3112A SATA trouble"
    To: linux-kernel@vger.kernel.org
    Date:	Sun, 30 Nov 2003 18:39:48 +0100
    
    

    Hi, Chris Peterson wrote:

    > My question is: if the code is already SMP-safe and holding the necessary
    > spinlocks, why is the preempt count necessary? Why must preemption be
    > disabled and re-enabled as spinlocks are acquired and released?

    You need to prevent deadlocks. Imagine process A grabbing a spinlock, then
    getting preempted. Process B now sits there and waits on the spinlock.
    Forward progress may or may not happen when the scheduler preempts B and
    restarts A, some indeterminate time later.

    Scheduling when waiting for a spinlock doesn't make sense because usually
    the spinlock is held for just a few cycles (that's why it's a spin lock
    and not a semaphore / wait queue / whatever), and rescheduling would take
    more time than just waiting.

    -- 
    Matthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  smurf@smurf.noris.de
    Disclaimer: The quote was selected randomly. Really. | http://smurf.noris.de
     - -
    You will have many recoverable tape errors.
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Luis Miguel García: "Re: Silicon Image 3112A SATA trouble"

    Relevant Pages

    • [RFC][PATCH 2/4] change mnt_writers underflow protection logic
      ... underflow protection mechanism uses preempt disabling from ... I can't use that with a mutex. ... Without the preempt disabling, there is no limit to the ... because they get preempted once the spinlock is unlocked. ...
      (Linux-Kernel)
    • Re: Concurrent access to /dev/urandom
      ... And I'd be leery of your get_cputrick due to preempt ... I'm concerned that turning off interrupts during even a single SHA-1 ... We could use a separate spinlock that only ... So I've come up with another trick which I think avoids needing to add ...
      (Linux-Kernel)
    • Re: 2.6.4-rc1-mm1: queue-congestion-dm-implementation patch
      ... it must wait on an internal semaphore ... > problem is that the higher-level caller is holding a spinlock at the same ... reproduce it I can try a few things.. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [PATCH]: Clean up of __alloc_pages
      ... Not to mention that a spinlock is an atomic op (though that is getting ... cheaper these days) + 2 memory barriers. ... Send instant messages to your online friends http://au.messenger.yahoo.com ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: serial driver / tty issues
      ... we should drop the spinlock and re-acquire it afterwards. ... and eventually cancel the work queue. ... > won't call the ldisc functions after we've closed them down. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)