---
name: "synchronize_sched_expedited"
section: "9"
platform: "linux"
package: "linux-manual-3.16"
version: "3.16.56-1+deb8u1"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/synchronize_sched_expedited"
---

# synchronize\_sched\_expedited(9)

Brute-force RCU-sched grace period

## NAME

synchronize\_sched\_expedited - Brute-force RCU-sched grace period

## SYNOPSIS

**void synchronize\_sched\_expedited(***void***);**

## ARGUMENTS

*void*

no arguments

## DESCRIPTION

Wait for an RCU-sched grace period to elapse, but use a “big hammer” 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 **synchronize\_sched\_expedited** in a loop, please restructure your code to batch your updates, and then use a single **synchronize\_sched** instead.

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.

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 **atomic\_cmpxchg** to update sync\_sched\_expedited\_done to match our snapshot -- but only if someone else has not already advanced past our snapshot.

On the other hand, if **try\_stop\_cpus** 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.

If we fail too many times in a row, we fall back to **synchronize\_sched**.

## COPYRIGHT
