diff options
author | Paolo Abeni <pabeni@redhat.com> | 2020-11-17 21:43:49 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2020-11-20 21:00:54 +0300 |
commit | 12f4bd86225e348ef3a3c8d2bb42dc23ee0f0a4c (patch) | |
tree | 28f300cb67bffa2a9d8dae9d3b391c7e9002aba0 /include/net/sock.h | |
parent | c3bc2adb051b27ad1d7fcef6ff80673915c43b0d (diff) | |
download | linux-12f4bd86225e348ef3a3c8d2bb42dc23ee0f0a4c.tar.xz |
net: add annotation for sock_{lock,unlock}_fast
The static checker is fooled by the non-static locking scheme
implemented by the mentioned helpers.
Let's make its life easier adding some unconditional annotation
so that the helpers are now interpreted as a plain spinlock from
sparse.
v1 -> v2:
- add __releases() annotation to unlock_sock_fast()
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Link: https://lore.kernel.org/r/6ed7ae627d8271fb7f20e0a9c6750fbba1ac2635.1605634911.git.pabeni@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/net/sock.h')
-rw-r--r-- | include/net/sock.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 1d29aeae74fd..093b51719c69 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1595,7 +1595,8 @@ void release_sock(struct sock *sk); SINGLE_DEPTH_NESTING) #define bh_unlock_sock(__sk) spin_unlock(&((__sk)->sk_lock.slock)) -bool lock_sock_fast(struct sock *sk); +bool lock_sock_fast(struct sock *sk) __acquires(&sk->sk_lock.slock); + /** * unlock_sock_fast - complement of lock_sock_fast * @sk: socket @@ -1605,11 +1606,14 @@ bool lock_sock_fast(struct sock *sk); * If slow mode is on, we call regular release_sock() */ static inline void unlock_sock_fast(struct sock *sk, bool slow) + __releases(&sk->sk_lock.slock) { - if (slow) + if (slow) { release_sock(sk); - else + __release(&sk->sk_lock.slock); + } else { spin_unlock_bh(&sk->sk_lock.slock); + } } /* Used by processes to "lock" a socket state, so that |