All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tobias DiPasquale <codeslinger@gmail.com>
To: Damon Gray <dgray@internap.com>
Cc: netfilter-devel@lists.netfilter.org
Subject: Re: why spin_lock_bh() in match routine?
Date: Fri, 1 Jul 2005 19:33:32 -0400	[thread overview]
Message-ID: <876ef97a0507011633c02bd9e@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.62.0506301333510.2222@dgray-test.acs.internap.com>

On 6/30/05, Damon Gray <dgray@internap.com> wrote: 
> If I'm not mistaken, and I possibly am, the match section of a netfilter
> module is run in softirq context, and the same softirq (not tasklet) can
> run on a *different* CPU but not the same CPU twice. So why is it being
> suggested here that we need to disable bottom halves for match targets.
> Seems to me you will be safe with spin_lock() in match() and possibly need
> spin_lock_bh() in at least destroy() and maybe in checkentry(). Am I
> missing some?

You wouldn't need to disable BH's in the match() function itself, but
rather in other contexts where the protected data may be accessed.
This serves to prevent the softirq in the process of running the
match() function, from pre-empting another context and deadlocking by
attempting to acquire a lock that is already held.

An example of this kind of mistake would be to use
spin_lock()/unlock() in the match() function to access/modify a
variable x and to ALSO use spin_lock()/unlock() (i.e. NOT disabling
BH's) in a proc file read function to access the same variable x. A
softirq could preempt the proc read function after the lock has been
acquired and cause a deadlock b/c the match() function would be unable
to acquire the lock held by the proc read function and the proc read
function is unable to return to the CPU because it was preempted by a
function that will never return.

-- 
[ Tobias DiPasquale ]
0x636f6465736c696e67657240676d61696c2e636f6d

      reply	other threads:[~2005-07-01 23:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-30 17:49 why spin_lock_bh() in match routine? Damon Gray
2005-07-01 23:33 ` Tobias DiPasquale [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=876ef97a0507011633c02bd9e@mail.gmail.com \
    --to=codeslinger@gmail.com \
    --cc=dgray@internap.com \
    --cc=netfilter-devel@lists.netfilter.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.