diff options
author | Benoît Ganne <bganne@cisco.com> | 2020-09-15 10:58:07 +0200 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2020-09-18 10:40:47 +0000 |
commit | b6b484d01adb8ab2ef5a50d5a3d6f3f097df2e0c (patch) | |
tree | 62cf123032c0cfbc02ef31c8e7bea329af77e072 /src/vppinfra | |
parent | 1965f750bf5f399a11c75d7ba14a52a504c69227 (diff) |
virtio: fix txq locking
Initialize txq lock only if some txq are shared and check if another
worker is already operating on the txq before processing gro timeouts
in input node.
Type: fix
Change-Id: I89dab6c0e6eb6a7aa621fa1548b0a2c76e6c7581
Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src/vppinfra')
-rw-r--r-- | src/vppinfra/lock.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/vppinfra/lock.h b/src/vppinfra/lock.h index 3cfe11cba17..470890b6ec7 100644 --- a/src/vppinfra/lock.h +++ b/src/vppinfra/lock.h @@ -91,6 +91,15 @@ clib_spinlock_lock (clib_spinlock_t * p) CLIB_LOCK_DBG (p); } +static_always_inline int +clib_spinlock_trylock (clib_spinlock_t * p) +{ + if (PREDICT_FALSE (CLIB_SPINLOCK_IS_LOCKED (p))) + return 0; + clib_spinlock_lock (p); + return 1; +} + static_always_inline void clib_spinlock_lock_if_init (clib_spinlock_t * p) { @@ -98,6 +107,14 @@ clib_spinlock_lock_if_init (clib_spinlock_t * p) clib_spinlock_lock (p); } +static_always_inline int +clib_spinlock_trylock_if_init (clib_spinlock_t * p) +{ + if (PREDICT_FALSE (*p != 0)) + return clib_spinlock_trylock (p); + return 1; +} + static_always_inline void clib_spinlock_unlock (clib_spinlock_t * p) { |