All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Greear <greearb@candelatech.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@oss.sgi.com
Subject: Re: local_bh_enable & hard_start_xmit
Date: Mon, 18 Apr 2005 15:59:05 -0700	[thread overview]
Message-ID: <42643BB9.6050705@candelatech.com> (raw)
In-Reply-To: <20050418151421.41a8f64a.davem@davemloft.net>

David S. Miller wrote:
> On Mon, 18 Apr 2005 14:37:22 -0700
> Ben Greear <greearb@candelatech.com> wrote:
> 
> 
>>So, two questions:
>>
>>1)  Why is it bad to have interrupts disabled when calling
>>     the local_bh_enable() method?
> 
> 
> Because it creates a deadlock.  You can always take hard IRQ disabling
> locks inside of BH disabling ones, but _never_ the other way around.
> 
> local_bh_enable() potentially runs BH handlers, and this must occur with
> hard IRQs enabled.

Ok.  It would be great if this explanation was in comments near the warning in the code.
The dev_start_xmit code in dev.c could also have a note mentioning that it
must never be called with IRQs disabled.

>>2)  Should there be a hard requirement that one must never have IRQs disabled
>>     when calling dev->hard_start_xmit  (this requirement seems to currently
>>     be in effect because VLANs can call dev_queue_xmit from their hard_start_xmit
>>     method, and it appears that dev_queue_xmit must not be called with IRQs disabled).
> 
> 
> Yes, it is another true requirement.

This would be a good addition to the Documentation/networking/netdevices.txt
file, or maybe to the dev.c file somewhere (I haven't found an complete list of
locking notes, though the comments in the dev.c file and the netdevices.txt file
are a big help.)

I should be able to fix my particular problem by using reference counting and
breaking up my big loop into smaller work units.

I assume that it is fine to nest calls to local_bh_enable/disable?  (This
seems to be required since you are supposed to have bh disabled when
calling hard_start_xmit, but hard_start_xmit can call dev_queue_xmit which
disables the bh again...)

Thanks,
Ben

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

  reply	other threads:[~2005-04-18 22:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-18 21:37 local_bh_enable & hard_start_xmit Ben Greear
2005-04-18 22:14 ` David S. Miller
2005-04-18 22:59   ` Ben Greear [this message]
2005-04-18 23:01     ` David S. Miller
2005-04-18 23:17       ` Ben Greear
2005-04-19  0:24       ` Ben Greear
     [not found]         ` <20050419231442.7e37b087.davem@davemloft.net>
2005-04-22 19:39           ` Ben Greear
2005-04-25  3:13             ` David S. Miller

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=42643BB9.6050705@candelatech.com \
    --to=greearb@candelatech.com \
    --cc=davem@davemloft.net \
    --cc=netdev@oss.sgi.com \
    /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.