]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - include/linux/rwsem.h
Merge tag 'm68k-for-v5.3-tag2' of git://git.kernel.org/pub/scm/linux/kernel/git/geert...
[linux.git] / include / linux / rwsem.h
index 2ea18a3def045b4f71ccea1cf428a92d8d50734b..e401358c4e7eb5be64626e0c73c12a8d1bed366c 100644 (file)
  */
 struct rw_semaphore {
        atomic_long_t count;
-#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
        /*
-        * Write owner. Used as a speculative check to see
-        * if the owner is running on the cpu.
+        * Write owner or one of the read owners as well flags regarding
+        * the current state of the rwsem. Can be used as a speculative
+        * check to see if the write owner is running on the cpu.
         */
-       struct task_struct *owner;
+       atomic_long_t owner;
+#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
        struct optimistic_spin_queue osq; /* spinner MCS lock */
 #endif
        raw_spinlock_t wait_lock;
@@ -50,10 +51,10 @@ struct rw_semaphore {
 };
 
 /*
- * Setting bit 1 of the owner field but not bit 0 will indicate
+ * Setting all bits of the owner field except bit 0 will indicate
  * that the rwsem is writer-owned with an unknown owner.
  */
-#define RWSEM_OWNER_UNKNOWN    ((struct task_struct *)-2L)
+#define RWSEM_OWNER_UNKNOWN    (-2L)
 
 /* In all implementations count != 0 means locked */
 static inline int rwsem_is_locked(struct rw_semaphore *sem)
@@ -73,13 +74,14 @@ static inline int rwsem_is_locked(struct rw_semaphore *sem)
 #endif
 
 #ifdef CONFIG_RWSEM_SPIN_ON_OWNER
-#define __RWSEM_OPT_INIT(lockname) , .osq = OSQ_LOCK_UNLOCKED, .owner = NULL
+#define __RWSEM_OPT_INIT(lockname) , .osq = OSQ_LOCK_UNLOCKED
 #else
 #define __RWSEM_OPT_INIT(lockname)
 #endif
 
 #define __RWSEM_INITIALIZER(name)                              \
        { __RWSEM_INIT_COUNT(name),                             \
+         .owner = ATOMIC_LONG_INIT(0),                         \
          .wait_list = LIST_HEAD_INIT((name).wait_list),        \
          .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock) \
          __RWSEM_OPT_INIT(name)                                \