Sophie

Sophie

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

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>Chapter&#160;4.&#160;Hard IRQ Context</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="index.html" title="Unreliable Guide To Locking" /><link rel="prev" href="ch03s08.html" title="Locking Between Softirqs" /><link rel="next" href="ch04s02.html" title="Locking Between Two Hard IRQ Handlers" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&#160;4.&#160;Hard IRQ Context</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch03s08.html">Prev</a>&#160;</td><th width="60%" align="center">&#160;</th><td width="20%" align="right">&#160;<a accesskey="n" href="ch04s02.html">Next</a></td></tr></table><hr /></div><div class="chapter" title="Chapter&#160;4.&#160;Hard IRQ Context"><div class="titlepage"><div><div><h2 class="title"><a id="hardirq-context"></a>Chapter&#160;4.&#160;Hard IRQ Context</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ch04.html#hardirq-softirq">Locking Between Hard IRQ and Softirqs/Tasklets</a></span></dt><dt><span class="sect1"><a href="ch04s02.html">Locking Between Two Hard IRQ Handlers</a></span></dt></dl></div><p>
     Hardware interrupts usually communicate with a
     tasklet or softirq.  Frequently this involves putting work in a
     queue, which the softirq will take out.
   </p><div class="sect1" title="Locking Between Hard IRQ and Softirqs/Tasklets"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="hardirq-softirq"></a>Locking Between Hard IRQ and Softirqs/Tasklets</h2></div></div></div><p>
      If a hardware irq handler shares data with a softirq, you have
      two concerns.  Firstly, the softirq processing can be
      interrupted by a hardware interrupt, and secondly, the
      critical region could be entered by a hardware interrupt on
      another CPU.  This is where <code class="function">spin_lock_irq()</code> is 
      used.  It is defined to disable interrupts on that cpu, then grab 
      the lock. <code class="function">spin_unlock_irq()</code> does the reverse.
    </p><p>
      The irq handler does not to use
      <code class="function">spin_lock_irq()</code>, because the softirq cannot
      run while the irq handler is running: it can use
      <code class="function">spin_lock()</code>, which is slightly faster.  The
      only exception would be if a different hardware irq handler uses
      the same lock: <code class="function">spin_lock_irq()</code> will stop
      that from interrupting us.
    </p><p>
      This works perfectly for UP as well: the spin lock vanishes,
      and this macro simply becomes <code class="function">local_irq_disable()</code>
      (<code class="filename">include/asm/smp.h</code>), which
      protects you from the softirq/tasklet/BH being run.
    </p><p>
      <code class="function">spin_lock_irqsave()</code> 
      (<code class="filename">include/linux/spinlock.h</code>) is a variant
      which saves whether interrupts were on or off in a flags word,
      which is passed to <code class="function">spin_unlock_irqrestore()</code>.  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).
    </p><p>
      Note that softirqs (and hence tasklets and timers) are run on
      return from hardware interrupts, so
      <code class="function">spin_lock_irq()</code> also stops these.  In that
      sense, <code class="function">spin_lock_irqsave()</code> is the most
      general and powerful locking function.
    </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch03s08.html">Prev</a>&#160;</td><td width="20%" align="center">&#160;</td><td width="40%" align="right">&#160;<a accesskey="n" href="ch04s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Locking Between Softirqs&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Locking Between Two Hard IRQ Handlers</td></tr></table></div></body></html>