]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - include/linux/srcutiny.h
Merge branch 'work.read_write' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[karo-tx-linux.git] / include / linux / srcutiny.h
index 42311ee0334fde629280f6b92cdc065853e3ba14..cfbfc540cafcb44ed564b03c5b37b127b08db10b 100644 (file)
 #include <linux/swait.h>
 
 struct srcu_struct {
-       int srcu_lock_nesting[2];       /* srcu_read_lock() nesting depth. */
+       short srcu_lock_nesting[2];     /* srcu_read_lock() nesting depth. */
+       short srcu_idx;                 /* Current reader array element. */
+       u8 srcu_gp_running;             /* GP workqueue running? */
+       u8 srcu_gp_waiting;             /* GP waiting for readers? */
        struct swait_queue_head srcu_wq;
                                        /* Last srcu_read_unlock() wakes GP. */
-       unsigned long srcu_gp_seq;      /* GP seq # for callback tagging. */
-       struct rcu_segcblist srcu_cblist;
-                                       /* Pending SRCU callbacks. */
-       int srcu_idx;                   /* Current reader array element. */
-       bool srcu_gp_running;           /* GP workqueue running? */
-       bool srcu_gp_waiting;           /* GP waiting for readers? */
+       struct rcu_head *srcu_cb_head;  /* Pending callbacks: Head. */
+       struct rcu_head **srcu_cb_tail; /* Pending callbacks: Tail. */
        struct work_struct srcu_work;   /* For driving grace periods. */
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
        struct lockdep_map dep_map;
@@ -47,7 +46,7 @@ void srcu_drive_gp(struct work_struct *wp);
 #define __SRCU_STRUCT_INIT(name)                                       \
 {                                                                      \
        .srcu_wq = __SWAIT_QUEUE_HEAD_INITIALIZER(name.srcu_wq),        \
-       .srcu_cblist = RCU_SEGCBLIST_INITIALIZER(name.srcu_cblist),     \
+       .srcu_cb_tail = &name.srcu_cb_head,                             \
        .srcu_work = __WORK_INITIALIZER(name.srcu_work, srcu_drive_gp), \
        __SRCU_DEP_MAP_INIT(name)                                       \
 }
@@ -63,31 +62,29 @@ void srcu_drive_gp(struct work_struct *wp);
 
 void synchronize_srcu(struct srcu_struct *sp);
 
-static inline void synchronize_srcu_expedited(struct srcu_struct *sp)
+/*
+ * Counts the new reader in the appropriate per-CPU element of the
+ * srcu_struct.  Can be invoked from irq/bh handlers, but the matching
+ * __srcu_read_unlock() must be in the same handler instance.  Returns an
+ * index that must be passed to the matching srcu_read_unlock().
+ */
+static inline int __srcu_read_lock(struct srcu_struct *sp)
 {
-       synchronize_srcu(sp);
-}
+       int idx;
 
-static inline void srcu_barrier(struct srcu_struct *sp)
-{
-       synchronize_srcu(sp);
+       idx = READ_ONCE(sp->srcu_idx);
+       WRITE_ONCE(sp->srcu_lock_nesting[idx], sp->srcu_lock_nesting[idx] + 1);
+       return idx;
 }
 
-static inline unsigned long srcu_batches_completed(struct srcu_struct *sp)
+static inline void synchronize_srcu_expedited(struct srcu_struct *sp)
 {
-       return 0;
+       synchronize_srcu(sp);
 }
 
-static inline void srcutorture_get_gp_data(enum rcutorture_type test_type,
-                                          struct srcu_struct *sp, int *flags,
-                                          unsigned long *gpnum,
-                                          unsigned long *completed)
+static inline void srcu_barrier(struct srcu_struct *sp)
 {
-       if (test_type != SRCU_FLAVOR)
-               return;
-       *flags = 0;
-       *completed = sp->srcu_gp_seq;
-       *gpnum = *completed;
+       synchronize_srcu(sp);
 }
 
 #endif