1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>synchronize_sched_expedited</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Linux Device Drivers"><link rel="up" href="ch01s09.html" title="Kernel utility functions"><link rel="prev" href="API-cond-synchronize-rcu.html" title="cond_synchronize_rcu"><link rel="next" href="API-rcu-barrier-bh.html" title="rcu_barrier_bh"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">synchronize_sched_expedited</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-cond-synchronize-rcu.html">Prev</a>&#160;</td><th width="60%" align="center">Kernel utility functions</th><td width="20%" align="right">&#160;<a accesskey="n" href="API-rcu-barrier-bh.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-synchronize-sched-expedited"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>synchronize_sched_expedited &#8212; 
2     Brute-force RCU-sched grace period
3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">synchronize_sched_expedited </b>(</code></td><td> <var class="pdparam">void</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1"><a name="idp1108660380"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>void</code></em></span></dt><dd><p>
4     no arguments
5    </p></dd></dl></div></div><div class="refsect1"><a name="idp1108661988"></a><h2>Description</h2><p>
6   </p><p>
7
8   Wait for an RCU-sched grace period to elapse, but use a <span class="quote">&#8220;<span class="quote">big hammer</span>&#8221;</span>
9   approach to force the grace period to end quickly.  This consumes
10   significant time on all CPUs and is unfriendly to real-time workloads,
11   so is thus not recommended for any sort of common-case code.  In fact,
12   if you are using <code class="function">synchronize_sched_expedited</code> in a loop, please
13   restructure your code to batch your updates, and then use a single
14   <code class="function">synchronize_sched</code> instead.
15   </p><p>
16
17   This implementation can be thought of as an application of ticket
18   locking to RCU, with sync_sched_expedited_started and
19   sync_sched_expedited_done taking on the roles of the halves
20   of the ticket-lock word.  Each task atomically increments
21   sync_sched_expedited_started upon entry, snapshotting the old value,
22   then attempts to stop all the CPUs.  If this succeeds, then each
23   CPU will have executed a context switch, resulting in an RCU-sched
24   grace period.  We are then done, so we use <code class="function">atomic_cmpxchg</code> to
25   update sync_sched_expedited_done to match our snapshot -- but
26   only if someone else has not already advanced past our snapshot.
27   </p><p>
28
29   On the other hand, if <code class="function">try_stop_cpus</code> fails, we check the value
30   of sync_sched_expedited_done.  If it has advanced past our
31   initial snapshot, then someone else must have forced a grace period
32   some time after we took our snapshot.  In this case, our work is
33   done for us, and we can simply return.  Otherwise, we try again,
34   but keep our initial snapshot for purposes of checking for someone
35   doing our work for us.
36   </p><p>
37
38   If we fail too many times in a row, we fall back to <code class="function">synchronize_sched</code>.
39</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-cond-synchronize-rcu.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="ch01s09.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="API-rcu-barrier-bh.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">cond_synchronize_rcu</span>&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;<span class="phrase">rcu_barrier_bh</span></td></tr></table></div></body></html>
40