Sophie

Sophie

distrib > CentOS > 6 > i386 > by-pkgid > 2c51d8eb79f8810ada971ee8c30ce1e5 > files > 2217

kernel-doc-2.6.32-71.14.1.el6.noarch.rpm

<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>Data Which Mostly Used By An IRQ Handler</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="Unreliable Guide To Locking" /><link rel="up" href="ch09.html" title="Chapter&#160;9.&#160;Locking Speed" /><link rel="prev" href="ch09s03.html" title="Per-CPU Data" /><link rel="next" href="ch10.html" title="Chapter&#160;10.&#160;What Functions Are Safe To Call From Interrupts?" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Data Which Mostly Used By An IRQ Handler</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch09s03.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;9.&#160;Locking Speed</th><td width="20%" align="right">&#160;<a accesskey="n" href="ch10.html">Next</a></td></tr></table><hr /></div><div class="sect1" title="Data Which Mostly Used By An IRQ Handler"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="mostly-hardirq"></a>Data Which Mostly Used By An IRQ Handler</h2></div></div></div><p>
      If data is always accessed from within the same IRQ handler, you
      don't need a lock at all: the kernel already guarantees that the
      irq handler will not run simultaneously on multiple CPUs.
    </p><p>
      Manfred Spraul points out that you can still do this, even if
      the data is very occasionally accessed in user context or
      softirqs/tasklets.  The irq handler doesn't use a lock, and
      all other accesses are done as so:
    </p><pre class="programlisting">
	spin_lock(&amp;lock);
	disable_irq(irq);
	...
	enable_irq(irq);
	spin_unlock(&amp;lock);
</pre><p>
      The <code class="function">disable_irq()</code> prevents the irq handler
      from running (and waits for it to finish if it's currently
      running on other CPUs).  The spinlock prevents any other
      accesses happening at the same time.  Naturally, this is slower
      than just a <code class="function">spin_lock_irq()</code> call, so it
      only makes sense if this type of access happens extremely
      rarely.
    </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch09s03.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="ch09.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="ch10.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Per-CPU Data&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Chapter&#160;10.&#160;What Functions Are Safe To Call From Interrupts?</td></tr></table></div></body></html>