All of lore.kernel.org
 help / color / mirror / Atom feed
From: michi1@michaelblizek.twilightparadox.com (michi1 at michaelblizek.twilightparadox.com)
To: kernelnewbies@lists.kernelnewbies.org
Subject: When is to preempt safe?
Date: Sun, 9 Oct 2011 15:44:54 +0200	[thread overview]
Message-ID: <20111009134454.GB10358@grml> (raw)
In-Reply-To: <CABi1daHRB0QPMYvFnwFBxpbeUHm1SC4_PxiO36Q4+JgoUaQtDw@mail.gmail.com>

Hi!

On 23:53 Sat 08 Oct     , Dave Hylands wrote:
> Hi Michi,
> 
> On Sat, Oct 8, 2011 at 11:29 PM, Michael Blizek
> <michi1@michaelblizek.twilightparadox.com> wrote:
...
> > Disabling interrupts actually disables preemption as well. Preemption is
> > triggered by a timer interrupt, which cannot arrive in this case. Spinlocks
> > can be aquired both by disabling interrupts (spin_lock_irqsave) or by
> > disabling preemption (spin_lock_bh). However, you cannot use spin_lock_bh if
> > the same spin_lock is aquired in an interrupt handler. spin_lock_bh allows
> > interrupt handlers to be invoked while you are still in the critical section.
> > If the interrupt handler is processed on the same CPU as the critical section,
> > you are stuck in a deadlock.
> 
> Disabling interrupts DOES NOT disable preemption on an SMP machine. It
> only disables preemption on the core that interrupts are disabled on.

AFAIK there is no "global" preemption disable in linux. This operation would
be very slow. There is stop_machine for stuff like module loading, but I guess
this is not what you mean.

spin_lock_bh also disables preemption only on the local cpu.

	-Michi
-- 
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com

      reply	other threads:[~2011-10-09 13:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-07 11:27 When is to preempt safe? Parmenides
2011-10-07 16:32 ` Chetan Nanda
2011-10-08 16:19   ` Parmenides
2011-10-08 17:09     ` Daniel Baluta
2011-10-08 17:32       ` Dave Hylands
2011-10-09 11:52       ` Parmenides
2011-10-09 13:52         ` michi1 at michaelblizek.twilightparadox.com
2011-10-09  6:42     ` Michael Blizek
2011-10-07 16:44 ` Jonathan Neuschäfer
2011-10-07 19:39 ` Michael Blizek
2011-10-08 16:24   ` Parmenides
2011-10-09  6:29     ` Michael Blizek
2011-10-09  6:53       ` Dave Hylands
2011-10-09 13:44         ` michi1 at michaelblizek.twilightparadox.com [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111009134454.GB10358@grml \
    --to=michi1@michaelblizek.twilightparadox.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.