netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Question] Kernel preemption of BH handler
@ 2012-03-26  9:20 Erik Hugne
  2012-03-26 14:56 ` Ben Hutchings
  0 siblings, 1 reply; 2+ messages in thread
From: Erik Hugne @ 2012-03-26  9:20 UTC (permalink / raw)
  To: netdev@vger.kernel.org

I have a BH handler that processes packets received from a netdevice.

my_bh_handler() {
   spin_lock_bh(my_lock);
   /*do stuff*/
   spin_unlock_bh(my_lock);
   /*do more stuff*/
}

First packet is received, and my_bh_handler() is currently processing it.
Now a new packet is received by the NIC and my_bh_handler() is preempted 
after my_lock have been released.

Is it possible that the second invocation of the BH routine is allowed 
to finish before the first?

//E

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Question] Kernel preemption of BH handler
  2012-03-26  9:20 [Question] Kernel preemption of BH handler Erik Hugne
@ 2012-03-26 14:56 ` Ben Hutchings
  0 siblings, 0 replies; 2+ messages in thread
From: Ben Hutchings @ 2012-03-26 14:56 UTC (permalink / raw)
  To: Erik Hugne; +Cc: netdev@vger.kernel.org

On Mon, 2012-03-26 at 11:20 +0200, Erik Hugne wrote:
> I have a BH handler that processes packets received from a netdevice.
> 
> my_bh_handler() {
>    spin_lock_bh(my_lock);
>    /*do stuff*/
>    spin_unlock_bh(my_lock);
>    /*do more stuff*/
> }

spin_lock_bh() means 'spin lock with contending soft-interrupts' and not
'spin lock from a soft-interrupt'.  You probably need to use it in
process context but not here.

> First packet is received, and my_bh_handler() is currently processing it.
> Now a new packet is received by the NIC and my_bh_handler() is preempted 
> after my_lock have been released.

You don't explain how this handler is invoked, but normally it would be
scheduled to run a second time and would not preempt the first call.

Ben.

> Is it possible that the second invocation of the BH routine is allowed 
> to finish before the first?

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-26 14:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-26  9:20 [Question] Kernel preemption of BH handler Erik Hugne
2012-03-26 14:56 ` Ben Hutchings

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).