]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - kernel/rcu/sync.c
Merge remote-tracking branch 'rdma/for-next'
[karo-tx-linux.git] / kernel / rcu / sync.c
index 01c9807a7f730c5a5981e0d1742059857a4b6ab9..be922c9f3d37256fc060d5b9ba0aaf6a2d1f085c 100644 (file)
@@ -32,6 +32,7 @@
 static const struct {
        void (*sync)(void);
        void (*call)(struct rcu_head *, void (*)(struct rcu_head *));
+       void (*wait)(void);
 #ifdef CONFIG_PROVE_RCU
        int  (*held)(void);
 #endif
@@ -39,16 +40,19 @@ static const struct {
        [RCU_SYNC] = {
                .sync = synchronize_rcu,
                .call = call_rcu,
+               .wait = rcu_barrier,
                __INIT_HELD(rcu_read_lock_held)
        },
        [RCU_SCHED_SYNC] = {
                .sync = synchronize_sched,
                .call = call_rcu_sched,
+               .wait = rcu_barrier_sched,
                __INIT_HELD(rcu_read_lock_sched_held)
        },
        [RCU_BH_SYNC] = {
                .sync = synchronize_rcu_bh,
                .call = call_rcu_bh,
+               .wait = rcu_barrier_bh,
                __INIT_HELD(rcu_read_lock_bh_held)
        },
 };
@@ -59,10 +63,10 @@ enum { CB_IDLE = 0, CB_PENDING, CB_REPLAY };
 #define        rss_lock        gp_wait.lock
 
 #ifdef CONFIG_PROVE_RCU
-bool __rcu_sync_is_idle(struct rcu_sync *rsp)
+void rcu_sync_lockdep_assert(struct rcu_sync *rsp)
 {
-       WARN_ON(!gp_ops[rsp->gp_type].held());
-       return rsp->gp_state == GP_IDLE;
+       RCU_LOCKDEP_WARN(!gp_ops[rsp->gp_type].held(),
+                        "suspicious rcu_sync_is_idle() usage");
 }
 #endif
 
@@ -195,3 +199,25 @@ void rcu_sync_exit(struct rcu_sync *rsp)
        }
        spin_unlock_irq(&rsp->rss_lock);
 }
+
+/**
+ * rcu_sync_dtor() - Clean up an rcu_sync structure
+ * @rsp: Pointer to rcu_sync structure to be cleaned up
+ */
+void rcu_sync_dtor(struct rcu_sync *rsp)
+{
+       int cb_state;
+
+       BUG_ON(rsp->gp_count);
+
+       spin_lock_irq(&rsp->rss_lock);
+       if (rsp->cb_state == CB_REPLAY)
+               rsp->cb_state = CB_PENDING;
+       cb_state = rsp->cb_state;
+       spin_unlock_irq(&rsp->rss_lock);
+
+       if (cb_state != CB_IDLE) {
+               gp_ops[rsp->gp_type].wait();
+               BUG_ON(rsp->cb_state != CB_IDLE);
+       }
+}