+/*
+ * synchronize_rcu() waiting. Single thread.
+ */
+static void wait_gp(struct reader_registry *index)
+{
+ uatomic_dec(&gp_futex);
+ smp_mb(); /* Write futex before read reader_gp */
+ if (!rcu_gp_ongoing(index->rcu_reader_qs_gp)) {
+ /* Read reader_gp before write futex */
+ smp_mb();
+ /* Callbacks are queued, don't wait. */
+ uatomic_set(&gp_futex, 0);
+ } else {
+ /* Read reader_gp before read futex */
+ smp_rmb();
+ if (uatomic_read(&gp_futex) == -1)
+ futex(&gp_futex, FUTEX_WAIT, -1,
+ NULL, NULL, 0);
+ }
+}
+