Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1410063

[PATCH -v3 3/8] locking: Introduce smp_acquire__after_ctrl_dep

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject [PATCH -v3 3/8] locking: Introduce smp_acquire__after_ctrl_dep
Date 2016-05-31 12:00 +0200
Message-ID <rEOCT-11o-55@gated-at.bofh.it> (permalink)
References <rEOCR-11o-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Introduce smp_acquire__after_ctrl_dep(), this construct is not
uncommen, but the lack of this barrier is.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 include/linux/compiler.h |   18 +++++++++++++-----
 ipc/sem.c                |   14 ++------------
 2 files changed, 15 insertions(+), 17 deletions(-)

--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -305,6 +305,18 @@ static __always_inline void __write_once
 })
 
 /**
+ * smp_acquire__after_ctrl_dep() - Provide ACQUIRE ordering after a control dependency
+ *
+ * A control dependency provides a LOAD->STORE order, the additional RMB
+ * provides LOAD->LOAD order, together they provide LOAD->{LOAD,STORE} order,
+ * aka. (load)-ACQUIRE.
+ *
+ * Architectures that do not do load speculation can have this be barrier().
+ * XXX move into asm/barrier.h
+ */
+#define smp_acquire__after_ctrl_dep()		smp_rmb()
+
+/**
  * cmpwait - compare and wait for a variable to change
  * @ptr: pointer to the variable to wait on
  * @val: the value it should change from
@@ -331,10 +343,6 @@ static __always_inline void __write_once
  *
  * Due to C lacking lambda expressions we load the value of *ptr into a
  * pre-named variable @VAL to be used in @cond.
- *
- * The control dependency provides a LOAD->STORE order, the additional RMB
- * provides LOAD->LOAD order, together they provide LOAD->{LOAD,STORE} order,
- * aka. ACQUIRE.
  */
 #ifndef smp_cond_load_acquire
 #define smp_cond_load_acquire(ptr, cond_expr) ({		\
@@ -346,7 +354,7 @@ static __always_inline void __write_once
 			break;					\
 		cmpwait(__PTR, VAL);				\
 	}							\
-	smp_rmb(); /* ctrl + rmb := acquire */			\
+	smp_acquire__after_ctrl_dep();				\
 	VAL;							\
 })
 #endif
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -260,16 +260,6 @@ static void sem_rcu_free(struct rcu_head
 }
 
 /*
- * spin_unlock_wait() and !spin_is_locked() are not memory barriers, they
- * are only control barriers.
- * The code must pair with spin_unlock(&sem->lock) or
- * spin_unlock(&sem_perm.lock), thus just the control barrier is insufficient.
- *
- * smp_rmb() is sufficient, as writes cannot pass the control barrier.
- */
-#define ipc_smp_acquire__after_spin_is_unlocked()	smp_rmb()
-
-/*
  * Wait until all currently ongoing simple ops have completed.
  * Caller must own sem_perm.lock.
  * New simple ops cannot start, because simple ops first check
@@ -292,7 +282,7 @@ static void sem_wait_array(struct sem_ar
 		sem = sma->sem_base + i;
 		spin_unlock_wait(&sem->lock);
 	}
-	ipc_smp_acquire__after_spin_is_unlocked();
+	smp_acquire__after_ctrl_dep();
 }
 
 /*
@@ -350,7 +340,7 @@ static inline int sem_lock(struct sem_ar
 			 *	complex_count++;
 			 *	spin_unlock(sem_perm.lock);
 			 */
-			ipc_smp_acquire__after_spin_is_unlocked();
+			smp_acquire__after_ctrl_dep();
 
 			/*
 			 * Now repeat the test of complex_count:

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH -v3 0/8] spin_unlock_wait borkage and assorted bits Peter Zijlstra <peterz@infradead.org> - 2016-05-31 12:00 +0200
  [PATCH -v3 1/8] locking: Replace smp_cond_acquire with smp_cond_load_acquire Peter Zijlstra <peterz@infradead.org> - 2016-05-31 12:00 +0200
  [PATCH -v3 6/8] locking,netfilter: Fix nf_conntrack_lock() Peter Zijlstra <peterz@infradead.org> - 2016-05-31 12:00 +0200
  [PATCH -v3 4/8] locking, arch: Update spin_unlock_wait() Peter Zijlstra <peterz@infradead.org> - 2016-05-31 12:00 +0200
    Re: [PATCH -v3 4/8] locking, arch: Update spin_unlock_wait() Will Deacon <will.deacon@arm.com> - 2016-06-01 13:30 +0200
      Re: [PATCH -v3 4/8] locking, arch: Update spin_unlock_wait() Peter Zijlstra <peterz@infradead.org> - 2016-06-01 13:40 +0200
  [PATCH -v3 5/8] locking: Update spin_unlock_wait users Peter Zijlstra <peterz@infradead.org> - 2016-05-31 12:00 +0200
  [PATCH -v3 8/8] locking, tile: Provide TILE specific smp_acquire__after_ctrl_dep Peter Zijlstra <peterz@infradead.org> - 2016-05-31 12:00 +0200
  [PATCH -v3 7/8] locking: Move smp_cond_load_acquire() and friends into asm-generic/barrier.h Peter Zijlstra <peterz@infradead.org> - 2016-05-31 12:00 +0200
    Re: [PATCH -v3 7/8] locking: Move smp_cond_load_acquire() and friends  into asm-generic/barrier.h Waiman Long <waiman.long@hpe.com> - 2016-05-31 22:10 +0200
      Re: [PATCH -v3 7/8] locking: Move smp_cond_load_acquire() and  friends into asm-generic/barrier.h Peter Zijlstra <peterz@infradead.org> - 2016-06-01 11:40 +0200
        Re: [PATCH -v3 7/8] locking: Move smp_cond_load_acquire() and  friends into asm-generic/barrier.h Peter Zijlstra <peterz@infradead.org> - 2016-06-01 14:10 +0200
          Re: [PATCH -v3 7/8] locking: Move smp_cond_load_acquire() and  friends into asm-generic/barrier.h Will Deacon <will.deacon@arm.com> - 2016-06-01 14:20 +0200
            Re: [PATCH -v3 7/8] locking: Move smp_cond_load_acquire() and  friends into asm-generic/barrier.h Peter Zijlstra <peterz@infradead.org> - 2016-06-01 14:50 +0200
              Re: [PATCH -v3 7/8] locking: Move smp_cond_load_acquire() and  friends into asm-generic/barrier.h Will Deacon <will.deacon@arm.com> - 2016-06-01 16:10 +0200
                Re: [PATCH -v3 7/8] locking: Move smp_cond_load_acquire() and  friends into asm-generic/barrier.h Peter Zijlstra <peterz@infradead.org> - 2016-06-01 19:20 +0200
        Re: [PATCH -v3 7/8] locking: Move smp_cond_load_acquire() and  friends into asm-generic/barrier.h Will Deacon <will.deacon@arm.com> - 2016-06-01 14:10 +0200
        Re: [PATCH -v3 7/8] locking: Move smp_cond_load_acquire() and friends  into asm-generic/barrier.h Waiman Long <waiman.long@hpe.com> - 2016-06-01 19:00 +0200
  [PATCH -v3 3/8] locking: Introduce smp_acquire__after_ctrl_dep Peter Zijlstra <peterz@infradead.org> - 2016-05-31 12:00 +0200
    Re: [PATCH -v3 3/8] locking: Introduce smp_acquire__after_ctrl_dep Boqun Feng <boqun.feng@gmail.com> - 2016-06-01 15:50 +0200
      Re: [PATCH -v3 3/8] locking: Introduce smp_acquire__after_ctrl_dep Peter Zijlstra <peterz@infradead.org> - 2016-06-01 18:30 +0200
        Re: [PATCH -v3 3/8] locking: Introduce smp_acquire__after_ctrl_dep Boqun Feng <boqun.feng@gmail.com> - 2016-06-02 01:20 +0200

csiph-web