<?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>Locking Between Softirqs</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /><link rel="home" href="index.html" title="Unreliable Guide To Locking" /><link rel="up" href="locks.html" title="Chapter 3. Locking in the Linux Kernel" /><link rel="prev" href="lock-tasklets.html" title="Locking Between Tasklets/Timers" /><link rel="next" href="hardirq-context.html" title="Chapter 4. Hard IRQ Context" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Locking Between Softirqs</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="lock-tasklets.html">Prev</a> </td><th width="60%" align="center">Chapter 3. Locking in the Linux Kernel</th><td width="20%" align="right"> <a accesskey="n" href="hardirq-context.html">Next</a></td></tr></table><hr /></div><div class="sect1" title="Locking Between Softirqs"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="lock-softirqs"></a>Locking Between Softirqs</h2></div></div></div><div class="toc"><dl><dt><span class="sect2"><a href="lock-softirqs.html#lock-softirqs-same">The Same Softirq</a></span></dt><dt><span class="sect2"><a href="lock-softirqs.html#lock-softirqs-different">Different Softirqs</a></span></dt></dl></div><p> Often a softirq might want to share data with itself or a tasklet/timer. </p><div class="sect2" title="The Same Softirq"><div class="titlepage"><div><div><h3 class="title"><a id="lock-softirqs-same"></a>The Same Softirq</h3></div></div></div><p> The same softirq can run on the other CPUs: you can use a per-CPU array (see <a class="xref" href="per-cpu.html" title="Per-CPU Data">the section called “Per-CPU Data”</a>) for better performance. If you're going so far as to use a softirq, you probably care about scalable performance enough to justify the extra complexity. </p><p> You'll need to use <code class="function">spin_lock()</code> and <code class="function">spin_unlock()</code> for shared data. </p></div><div class="sect2" title="Different Softirqs"><div class="titlepage"><div><div><h3 class="title"><a id="lock-softirqs-different"></a>Different Softirqs</h3></div></div></div><p> You'll need to use <code class="function">spin_lock()</code> and <code class="function">spin_unlock()</code> for shared data, whether it be a timer, tasklet, different softirq or the same or another softirq: any of them could be running on a different CPU. </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="lock-tasklets.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="locks.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="hardirq-context.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Locking Between Tasklets/Timers </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 4. Hard IRQ Context</td></tr></table></div></body></html>