diff mbox series

[net-next] sock: Use sock_owned_by_user_nocheck() instead of sk_lock.owned.

Message ID 20211208053924.51254-1-kuniyu@amazon.co.jp (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] sock: Use sock_owned_by_user_nocheck() instead of sk_lock.owned. | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 4706 this patch: 1301
netdev/cc_maintainers warning 1 maintainers not CCed: edumazet@google.com
netdev/build_clang fail Errors and warnings before: 826 this patch: 1130
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 4851 this patch: 768
netdev/checkpatch warning WARNING: Where possible, use lockdep_assert_held instead of assertions based on spin_is_locked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Iwashima, Kuniyuki Dec. 8, 2021, 5:39 a.m. UTC
Replace sk_lock.owned tests with sock_owned_by_user_nocheck().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
---
 include/net/sock.h | 5 +++--
 net/core/sock.c    | 4 ++--
 net/llc/llc_proc.c | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

Comments

Jakub Kicinski Dec. 8, 2021, 6:05 a.m. UTC | #1
On Wed, 8 Dec 2021 14:39:24 +0900 Kuniyuki Iwashima wrote:
>  static inline void sock_release_ownership(struct sock *sk)
>  {
> -	if (sk->sk_lock.owned) {
> +	if (sock_owned_by_user_nocheck(sk) {

ENOTBUILT
Iwashima, Kuniyuki Dec. 8, 2021, 6:15 a.m. UTC | #2
From:   Jakub Kicinski <kuba@kernel.org>
Date:   Tue, 7 Dec 2021 22:05:31 -0800
> On Wed, 8 Dec 2021 14:39:24 +0900 Kuniyuki Iwashima wrote:
> >  static inline void sock_release_ownership(struct sock *sk)
> >  {
> > -	if (sk->sk_lock.owned) {
> > +	if (sock_owned_by_user_nocheck(sk) {
> 
> ENOTBUILT

Oops, will move sock_release_ownership() down in v2.
Thank you!
diff mbox series

Patch

diff --git a/include/net/sock.h b/include/net/sock.h
index e7c231373875..6b4f818dd594 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1635,7 +1635,7 @@  static inline void sk_mem_uncharge(struct sock *sk, int size)
 
 static inline void sock_release_ownership(struct sock *sk)
 {
-	if (sk->sk_lock.owned) {
+	if (sock_owned_by_user_nocheck(sk) {
 		sk->sk_lock.owned = 0;
 
 		/* The sk_lock has mutex_unlock() semantics: */
@@ -1774,7 +1774,8 @@  static inline bool sock_allow_reclassification(const struct sock *csk)
 {
 	struct sock *sk = (struct sock *)csk;
 
-	return !sk->sk_lock.owned && !spin_is_locked(&sk->sk_lock.slock);
+	return !sock_owned_by_user_nocheck(sk) &&
+		!spin_is_locked(&sk->sk_lock.slock);
 }
 
 struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
diff --git a/net/core/sock.c b/net/core/sock.c
index 4a499d255f40..764205a4d8c8 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -3292,7 +3292,7 @@  void lock_sock_nested(struct sock *sk, int subclass)
 
 	might_sleep();
 	spin_lock_bh(&sk->sk_lock.slock);
-	if (sk->sk_lock.owned)
+	if (sock_owned_by_user_nocheck(sk))
 		__lock_sock(sk);
 	sk->sk_lock.owned = 1;
 	spin_unlock_bh(&sk->sk_lock.slock);
@@ -3323,7 +3323,7 @@  bool __lock_sock_fast(struct sock *sk) __acquires(&sk->sk_lock.slock)
 	might_sleep();
 	spin_lock_bh(&sk->sk_lock.slock);
 
-	if (!sk->sk_lock.owned) {
+	if (!sock_owned_by_user_nocheck(sk)) {
 		/*
 		 * Fast path return with bottom halves disabled and
 		 * sock::sk_lock.slock held.
diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c
index 0ff490a73fae..07e9abb5978a 100644
--- a/net/llc/llc_proc.c
+++ b/net/llc/llc_proc.c
@@ -195,7 +195,7 @@  static int llc_seq_core_show(struct seq_file *seq, void *v)
 		   timer_pending(&llc->pf_cycle_timer.timer),
 		   timer_pending(&llc->rej_sent_timer.timer),
 		   timer_pending(&llc->busy_state_timer.timer),
-		   !!sk->sk_backlog.tail, !!sk->sk_lock.owned);
+		   !!sk->sk_backlog.tail, sock_owned_by_user_nocheck(sk));
 out:
 	return 0;
 }