'\" t .\" Title: synchronize_sched_expedited .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.78.1 .\" Date: May 2018 .\" Manual: Driver Basics .\" Source: Kernel Hackers Manual 3.16.56 .\" Language: English .\" .TH "SYNCHRONIZE_SCHED_EX" "9" "May 2018" "Kernel Hackers Manual 3\&.16\&" "Driver Basics" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" synchronize_sched_expedited \- Brute\-force RCU\-sched grace period .SH "SYNOPSIS" .HP \w'void\ synchronize_sched_expedited('u .BI "void synchronize_sched_expedited(" "void" ");" .SH "ARGUMENTS" .PP \fIvoid\fR .RS 4 no arguments .RE .SH "DESCRIPTION" .PP .PP Wait for an RCU\-sched grace period to elapse, but use a \(lqbig hammer\(rq approach to force the grace period to end quickly\&. This consumes significant time on all CPUs and is unfriendly to real\-time workloads, so is thus not recommended for any sort of common\-case code\&. In fact, if you are using \fBsynchronize_sched_expedited\fR in a loop, please restructure your code to batch your updates, and then use a single \fBsynchronize_sched\fR instead\&. .PP Note that it is illegal to call this function while holding any lock that is acquired by a CPU\-hotplug notifier\&. And yes, it is also illegal to call this function from a CPU\-hotplug notifier\&. Failing to observe these restriction will result in deadlock\&. .PP This implementation can be thought of as an application of ticket locking to RCU, with sync_sched_expedited_started and sync_sched_expedited_done taking on the roles of the halves of the ticket\-lock word\&. Each task atomically increments sync_sched_expedited_started upon entry, snapshotting the old value, then attempts to stop all the CPUs\&. If this succeeds, then each CPU will have executed a context switch, resulting in an RCU\-sched grace period\&. We are then done, so we use \fBatomic_cmpxchg\fR to update sync_sched_expedited_done to match our snapshot \-\- but only if someone else has not already advanced past our snapshot\&. .PP On the other hand, if \fBtry_stop_cpus\fR fails, we check the value of sync_sched_expedited_done\&. If it has advanced past our initial snapshot, then someone else must have forced a grace period some time after we took our snapshot\&. In this case, our work is done for us, and we can simply return\&. Otherwise, we try again, but keep our initial snapshot for purposes of checking for someone doing our work for us\&. .PP If we fail too many times in a row, we fall back to \fBsynchronize_sched\fR\&. .SH "COPYRIGHT" .br