kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: mulyadi.santosa@gmail.com (Mulyadi Santosa)
To: kernelnewbies@lists.kernelnewbies.org
Subject: is it safe to call spin_lock_bh() from within a soft IRQ?
Date: Thu, 26 May 2011 10:45:58 +0700	[thread overview]
Message-ID: <BANLkTinoifb3DTv0xzigRg30Uwxi8mP=1Q@mail.gmail.com> (raw)
In-Reply-To: <6F5DE7538AFCDA45A114F5E7510424A702761A68@hq-exchange01.bytemobile.com>

Hi...

On 26/05/2011, Jeff Haran <jharan@bytemobile.com> wrote:
> What I have yet to find in the available documentation is whether in
> this scenario it would be safe to call spin_lock_bh() to acquire the
> lock from code that executes in soft IRQ context.

lxr tells me that eventually spin_lock_bh() will call:
static inline void __raw_spin_lock_bh(raw_spinlock_t *lock)
{
        local_bh_disable();
        preempt_disable();
        spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
        LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
}

seems nothing dangerous if you do it inside soft IRQ, but the question
is "do you absolutely need such locking?"

because , again, lock contention is soft irq IMHO is a big no. You
will likely put all the soft IRQs in queue, thus it might decrease
interactivity, perfomance, throughput and so on. Not to mention, to
some degree, process switching is delayed too.

So unless you could do microbenchmarking and absolutely sure the
effect is negligible, I suggest don't do it.

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

      reply	other threads:[~2011-05-26  3:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AcwbRcmWZS6kjw/RSSeBdYQPJk9zKQ==>
2011-05-26  1:57 ` is it safe to call spin_lock_bh() from within a soft IRQ? Jeff Haran
2011-05-26  3:45   ` Mulyadi Santosa [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='BANLkTinoifb3DTv0xzigRg30Uwxi8mP=1Q@mail.gmail.com' \
    --to=mulyadi.santosa@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).