+/*
+ * synchronize_rcu() waiting. Single thread.
+ */
+static void wait_gp(struct reader_registry *index)
+{
+ atomic_dec(&gp_futex);
+ force_mb_single_thread(index); /* Write futex before read reader_gp */
+ if (!rcu_old_gp_ongoing(index->urcu_active_readers)) {
+ /* Read reader_gp before write futex */
+ force_mb_single_thread(index);
+ /* Callbacks are queued, don't wait. */
+ atomic_set(&gp_futex, 0);
+ } else {
+ /* Read reader_gp before read futex */
+ force_mb_single_thread(index);
+ if (atomic_read(&gp_futex) == -1)
+ futex(&gp_futex, FUTEX_WAIT, -1,
+ NULL, NULL, 0);
+ }
+}
+