Sophie

Sophie

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

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>Per-CPU Data</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="ch09s02.html" title="Avoiding Locks: Read Copy Update" /><link rel="next" href="ch09s04.html" title="Data Which Mostly Used By An IRQ Handler" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Per-CPU Data</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch09s02.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="ch09s04.html">Next</a></td></tr></table><hr /></div><div class="sect1" title="Per-CPU Data"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="per-cpu"></a>Per-CPU Data</h2></div></div></div><p>
      Another technique for avoiding locking which is used fairly
      widely is to duplicate information for each CPU.  For example,
      if you wanted to keep a count of a common condition, you could
      use a spin lock and a single counter.  Nice and simple.
    </p><p>
      If that was too slow (it's usually not, but if you've got a
      really big machine to test on and can show that it is), you
      could instead use a counter for each CPU, then none of them need
      an exclusive lock.  See <code class="function">DEFINE_PER_CPU()</code>,
      <code class="function">get_cpu_var()</code> and
      <code class="function">put_cpu_var()</code>
      (<code class="filename">include/linux/percpu.h</code>).
    </p><p>
      Of particular use for simple per-cpu counters is the
      <span class="type">local_t</span> type, and the
      <code class="function">cpu_local_inc()</code> and related functions,
      which are more efficient than simple code on some architectures
      (<code class="filename">include/asm/local.h</code>).
    </p><p>
      Note that there is no simple, reliable way of getting an exact
      value of such a counter, without introducing more locks.  This
      is not a problem for some uses.
    </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch09s02.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="ch09s04.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Avoiding Locks: Read Copy Update&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Data Which Mostly Used By An IRQ Handler</td></tr></table></div></body></html>