From d1b67fe4517c5a5b78858f79007ecbde706168bd Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 31 Mar 2022 02:09:11 +0000 Subject: [PATCH 25/49] linux: Convert various API shims to use membar_release/acquire. --- sys/external/bsd/common/include/asm/barrier.h | 4 +-- .../bsd/common/include/linux/compiler.h | 2 +- sys/external/bsd/common/linux/linux_tasklet.c | 28 +++++++++---------- sys/external/bsd/common/linux/linux_work.c | 4 +-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/sys/external/bsd/common/include/asm/barrier.h b/sys/external/bsd/common/include/asm/barrier.h index de0405ae2b45..d6aa0523d726 100644 --- a/sys/external/bsd/common/include/asm/barrier.h +++ b/sys/external/bsd/common/include/asm/barrier.h @@ -68,8 +68,8 @@ #endif #if defined(MULTIPROCESSOR) && !defined(__HAVE_ATOMIC_AS_MEMBAR) -# define smp_mb__before_atomic() membar_exit() -# define smp_mb__after_atomic() membar_sync() /* XXX acquire */ +# define smp_mb__before_atomic() membar_release() +# define smp_mb__after_atomic() membar_acquire() #else # define smp_mb__before_atomic() __insn_barrier() # define smp_mb__after_atomic() __insn_barrier() diff --git a/sys/external/bsd/common/include/linux/compiler.h b/sys/external/bsd/common/include/linux/compiler.h index 5f4e8cd2abad..c0b288e7ddec 100644 --- a/sys/external/bsd/common/include/linux/compiler.h +++ b/sys/external/bsd/common/include/linux/compiler.h @@ -80,7 +80,7 @@ #define smp_store_release(X, V) do { \ typeof(X) __smp_store_release_tmp = (V); \ - membar_exit(); \ + membar_release(); \ (X) = __write_once_tmp; \ } while (0) diff --git a/sys/external/bsd/common/linux/linux_tasklet.c b/sys/external/bsd/common/linux/linux_tasklet.c index 5288a01c1543..4ccf9231f722 100644 --- a/sys/external/bsd/common/linux/linux_tasklet.c +++ b/sys/external/bsd/common/linux/linux_tasklet.c @@ -245,7 +245,7 @@ tasklet_softintr(void *cookie) /* * Check whether it's currently disabled. * - * Pairs with membar_exit in __tasklet_enable. + * Pairs with membar_release in __tasklet_enable. */ if (atomic_load_acquire(&tasklet->tl_disablecount)) { /* @@ -394,9 +394,9 @@ tasklet_disable_nosync(struct tasklet_struct *tasklet) KASSERT(disablecount < UINT_MAX); KASSERT(disablecount != 0); - /* Pairs with membar_exit in __tasklet_enable. */ + /* Pairs with membar_release in __tasklet_enable. */ #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif } @@ -514,9 +514,9 @@ tasklet_trylock(struct tasklet_struct *tasklet) } while (atomic_cas_uint(&tasklet->tl_state, state, state | TASKLET_RUNNING) != state); - /* Pairs with membar_exit in tasklet_unlock. */ + /* Pairs with membar_release in tasklet_unlock. */ #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif return true; @@ -536,11 +536,11 @@ tasklet_unlock(struct tasklet_struct *tasklet) KASSERT(atomic_load_relaxed(&tasklet->tl_state) & TASKLET_RUNNING); /* - * Pairs with membar_enter in tasklet_trylock and with + * Pairs with membar_acquire in tasklet_trylock and with * atomic_load_acquire in tasklet_unlock_wait. */ #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif atomic_and_uint(&tasklet->tl_state, ~TASKLET_RUNNING); } @@ -556,7 +556,7 @@ void tasklet_unlock_wait(const struct tasklet_struct *tasklet) { - /* Pairs with membar_exit in tasklet_unlock. */ + /* Pairs with membar_release in tasklet_unlock. */ while (atomic_load_acquire(&tasklet->tl_state) & TASKLET_RUNNING) SPINLOCK_BACKOFF_HOOK; } @@ -589,9 +589,9 @@ __tasklet_disable_sync_once(struct tasklet_struct *tasklet) KASSERT(disablecount < UINT_MAX); KASSERT(disablecount != 0); - /* Pairs with membar_exit in __tasklet_enable_sync_once. */ + /* Pairs with membar_release in __tasklet_enable_sync_once. */ #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif /* @@ -613,9 +613,9 @@ __tasklet_enable_sync_once(struct tasklet_struct *tasklet) { unsigned int disablecount; - /* Pairs with membar_enter in __tasklet_disable_sync_once. */ + /* Pairs with membar_acquire in __tasklet_disable_sync_once. */ #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif /* Decrement the disable count. */ @@ -681,10 +681,10 @@ __tasklet_enable(struct tasklet_struct *tasklet) * decrementing the disable count. * * Pairs with atomic_load_acquire in tasklet_softintr and with - * membar_enter in tasklet_disable. + * membar_acquire in tasklet_disable. */ #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif /* Decrement the disable count. */ diff --git a/sys/external/bsd/common/linux/linux_work.c b/sys/external/bsd/common/linux/linux_work.c index 978dd4c1e780..016947c10e9e 100644 --- a/sys/external/bsd/common/linux/linux_work.c +++ b/sys/external/bsd/common/linux/linux_work.c @@ -639,7 +639,7 @@ acquire_work(struct work_struct *work, struct workqueue_struct *wq) owner0); KASSERT(work_queue(work) == wq); - membar_enter(); + membar_acquire(); SDT_PROBE2(sdt, linux, work, acquire, work, wq); return true; } @@ -660,7 +660,7 @@ release_work(struct work_struct *work, struct workqueue_struct *wq) KASSERT(mutex_owned(&wq->wq_lock)); SDT_PROBE2(sdt, linux, work, release, work, wq); - membar_exit(); + membar_release(); /* * Non-interlocked r/m/w is safe here because nobody else can