linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [DOCUMENTATION] Revised Unreliable Kernel Locking Guide
@ 2003-12-12  5:24 Rusty Russell
  2003-12-12 15:44 ` Dave Jones
  2003-12-12 19:35 ` Paul E. McKenney
  0 siblings, 2 replies; 14+ messages in thread
From: Rusty Russell @ 2003-12-12  5:24 UTC (permalink / raw)
  To: linux-kernel; +Cc: Paul E. McKenney

OK, I've put the html version up for your reading pleasure: the diff
is quite extensive and hard to read.

http://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/

Feedback welcome,
Rusty.
--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [DOCUMENTATION] Revised Unreliable Kernel Locking Guide
@ 2003-12-13  3:15 Manfred Spraul
  0 siblings, 0 replies; 14+ messages in thread
From: Manfred Spraul @ 2003-12-13  3:15 UTC (permalink / raw)
  To: Rusty Russell; +Cc: linux-kernel

Hi Rusty,

 From Chapter 4.1:

> |spin_lock_irqsave()| (include/linux/spinlock.h) is a variant which 
> saves whether interrupts were on or off in a flags word, which is 
> passed to |spin_unlock_irqrestore()|. This means that the same code 
> can be used inside an hard irq handler (where interrupts are already 
> off) and in softirqs (where the irq disabling is required).

Interrupts are typically on within the hard irq handler.
spin_lock() is usually ok because an interrupt handler is never 
reentered. Thus if a lock is only accessed from a single irq handler, 
then spin_lock() is the faster approach. That's why many nic drivers use 
spin_lock instead of spin_lock_irqsave() in their irq handlers.
OTHO: if a driver lock is a global resource that is used from different 
irqs, then it must either use _irqsave(), or set SA_INTERRUPT.
Examples: rtc_lock relies on SA_INTERRUPT: it's touched from the rtc irq 
and the timer irq path, and both rtc and timer set SA_INTERRUPT.
I assume ide relies on _irqsave(), but the code is too difficult to follow.

Btw, perhaps you could add the 2nd synchronization approach for 
interrupts: if it's an extremely rare event, then no lock at all in the 
irq handler (no reentrancy guaranteed by the kernel), and 
spin_lock+disable_irq() in the softirq/tasklet. My network drivers use 
that to synchronize packet rx with close.

--
    Manfred


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

end of thread, other threads:[~2003-12-16 23:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-12  5:24 [DOCUMENTATION] Revised Unreliable Kernel Locking Guide Rusty Russell
2003-12-12 15:44 ` Dave Jones
2003-12-12 16:25   ` Keith Owens
2003-12-12 18:25     ` Dave Jones
2003-12-13  0:28       ` Keith Owens
2003-12-12 21:05   ` Rob Love
2003-12-15  2:28   ` Rusty Russell
2003-12-12 19:35 ` Paul E. McKenney
2003-12-13  3:16   ` Zwane Mwaikambo
2003-12-15  5:17     ` Rusty Russell
2003-12-15  5:17   ` Rusty Russell
2003-12-15 22:22     ` Paul E. McKenney
2003-12-16  6:32       ` Rusty Russell
2003-12-13  3:15 Manfred Spraul

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