]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
locking: Remove smp_mb__before_spinlock()
authorPeter Zijlstra <peterz@infradead.org>
Wed, 7 Jun 2017 15:51:27 +0000 (17:51 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 10 Aug 2017 10:29:03 +0000 (12:29 +0200)
Now that there are no users of smp_mb__before_spinlock() left, remove
it entirely.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Documentation/memory-barriers.txt
Documentation/translations/ko_KR/memory-barriers.txt
arch/arm64/include/asm/spinlock.h
arch/powerpc/include/asm/barrier.h
fs/userfaultfd.c
include/linux/spinlock.h

index 9f34364922c8143f46b0eb7fc91445d4f0cf6976..d1d1716f904bb4a38e939c49def923000571c6f2 100644 (file)
@@ -1981,10 +1981,7 @@ for each construct.  These operations all imply certain barriers:
      ACQUIRE operation has completed.
 
      Memory operations issued before the ACQUIRE may be completed after
-     the ACQUIRE operation has completed.  An smp_mb__before_spinlock(),
-     combined with a following ACQUIRE, orders prior stores against
-     subsequent loads and stores.  Note that this is weaker than smp_mb()!
-     The smp_mb__before_spinlock() primitive is free on many architectures.
+     the ACQUIRE operation has completed.
 
  (2) RELEASE operation implication:
 
index 38310dcd66203b9a850c134e973af0b567ebecdc..bc80fc0e210f0634891b8252c48fcfc0350a712a 100644 (file)
@@ -1956,10 +1956,7 @@ MMIO 쓰기 배리어
      뒤에 완료됩니다.
 
      ACQUIRE 앞에서 요청된 메모리 오퍼레이션은 ACQUIRE 오퍼레이션이 완료된 후에
-     완료될 수 있습니다.  smp_mb__before_spinlock() 뒤에 ACQUIRE 가 실행되는
-     코드 블록은 블록 앞의 스토어를 블록 뒤의 로드와 스토어에 대해 순서
-     맞춥니다.  이건 smp_mb() 보다 완화된 것임을 기억하세요!  많은 아키텍쳐에서
-     smp_mb__before_spinlock() 은 사실 아무일도 하지 않습니다.
+     완료될 수 있습니다.
 
  (2) RELEASE 오퍼레이션의 영향:
 
index b103888b694a2f14db9978e8abf82873ed2965de..ae4241ab19a8a623c62d5a99df4914e3ee44a6e5 100644 (file)
@@ -358,15 +358,6 @@ static inline int arch_read_trylock(arch_rwlock_t *rw)
 #define arch_read_relax(lock)  cpu_relax()
 #define arch_write_relax(lock) cpu_relax()
 
-/*
- * Accesses appearing in program order before a spin_lock() operation
- * can be reordered with accesses inside the critical section, by virtue
- * of arch_spin_lock being constructed using acquire semantics.
- *
- * In cases where this is problematic (e.g. try_to_wake_up), an
- * smp_mb__before_spinlock() can restore the required ordering.
- */
-#define smp_mb__before_spinlock()      smp_mb()
 /* See include/linux/spinlock.h */
 #define smp_mb__after_spinlock()       smp_mb()
 
index 25d42bd3f1144c177110bb3235157d68b5b09583..9c601adfc50000dea26834f884cf4248952cee6e 100644 (file)
@@ -74,13 +74,6 @@ do {                                                                 \
        ___p1;                                                          \
 })
 
-/*
- * This must resolve to hwsync on SMP for the context switch path.
- * See _switch, and core scheduler context switch memory ordering
- * comments.
- */
-#define smp_mb__before_spinlock()   smp_mb()
-
 #include <asm-generic/barrier.h>
 
 #endif /* _ASM_POWERPC_BARRIER_H */
index 06ea26b8c996f3cc7a9d6fd177260f89394fb325..44fcbefd84a2008209bf48ecdd2321799ca452f0 100644 (file)
@@ -109,27 +109,24 @@ static int userfaultfd_wake_function(wait_queue_entry_t *wq, unsigned mode,
                goto out;
        WRITE_ONCE(uwq->waken, true);
        /*
-        * The implicit smp_mb__before_spinlock in try_to_wake_up()
-        * renders uwq->waken visible to other CPUs before the task is
-        * waken.
+        * The Program-Order guarantees provided by the scheduler
+        * ensure uwq->waken is visible before the task is woken.
         */
        ret = wake_up_state(wq->private, mode);
-       if (ret)
+       if (ret) {
                /*
                 * Wake only once, autoremove behavior.
                 *
-                * After the effect of list_del_init is visible to the
-                * other CPUs, the waitqueue may disappear from under
-                * us, see the !list_empty_careful() in
-                * handle_userfault(). try_to_wake_up() has an
-                * implicit smp_mb__before_spinlock, and the
-                * wq->private is read before calling the extern
-                * function "wake_up_state" (which in turns calls
-                * try_to_wake_up). While the spin_lock;spin_unlock;
-                * wouldn't be enough, the smp_mb__before_spinlock is
-                * enough to avoid an explicit smp_mb() here.
+                * After the effect of list_del_init is visible to the other
+                * CPUs, the waitqueue may disappear from under us, see the
+                * !list_empty_careful() in handle_userfault().
+                *
+                * try_to_wake_up() has an implicit smp_mb(), and the
+                * wq->private is read before calling the extern function
+                * "wake_up_state" (which in turns calls try_to_wake_up).
                 */
                list_del_init(&wq->entry);
+       }
 out:
        return ret;
 }
index 840281095933e41d41acdf16ff4e7fa7dae5e06d..4e8cce19b507b806fc55d71d6fc9e113fc8ca650 100644 (file)
@@ -117,19 +117,6 @@ do {                                                               \
 #endif /*arch_spin_is_contended*/
 #endif
 
-/*
- * Despite its name it doesn't necessarily has to be a full barrier.
- * It should only guarantee that a STORE before the critical section
- * can not be reordered with LOADs and STOREs inside this section.
- * spin_lock() is the one-way barrier, this LOAD can not escape out
- * of the region. So the default implementation simply ensures that
- * a STORE can not move into the critical section, smp_wmb() should
- * serialize it with another STORE done by spin_lock().
- */
-#ifndef smp_mb__before_spinlock
-#define smp_mb__before_spinlock()      smp_wmb()
-#endif
-
 /*
  * This barrier must provide two things:
  *