public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google•com>
To: "David S . Miller" <davem@davemloft•net>,
	Jakub Kicinski <kuba@kernel•org>,
	 Paolo Abeni <pabeni@redhat•com>
Cc: netdev@vger•kernel.org, eric.dumazet@gmail•com,
	 Soheil Hassas Yeganeh <soheil@google•com>,
	Neal Cardwell <ncardwell@google•com>,
	 Yuchung Cheng <ycheng@google•com>,
	Eric Dumazet <edumazet@google•com>
Subject: [RFC net-next 2/4] net: sock_release_ownership() cleanup
Date: Wed,  6 Sep 2023 20:10:44 +0000	[thread overview]
Message-ID: <20230906201046.463236-3-edumazet@google.com> (raw)
In-Reply-To: <20230906201046.463236-1-edumazet@google.com>

sock_release_ownership() should only be called by user
owning the socket lock.

After prior commit, we can remove one condition.

Signed-off-by: Eric Dumazet <edumazet@google•com>
---
 include/net/sock.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index b770261fbdaf59d4d1c0b30adb2592c56442e9e3..676146e9d18117e3a04fbbfb0a06e511a80d537c 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1823,12 +1823,11 @@ static inline bool sock_owned_by_user_nocheck(const struct sock *sk)
 
 static inline void sock_release_ownership(struct sock *sk)
 {
-	if (sock_owned_by_user_nocheck(sk)) {
-		sk->sk_lock.owned = 0;
+	DEBUG_NET_WARN_ON_ONCE(!sock_owned_by_user_nocheck(sk));
+	sk->sk_lock.owned = 0;
 
-		/* The sk_lock has mutex_unlock() semantics: */
-		mutex_release(&sk->sk_lock.dep_map, _RET_IP_);
-	}
+	/* The sk_lock has mutex_unlock() semantics: */
+	mutex_release(&sk->sk_lock.dep_map, _RET_IP_);
 }
 
 /* no reclassification while locks are held */
-- 
2.42.0.283.g2d96d420d3-goog


  parent reply	other threads:[~2023-09-06 20:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-06 20:10 [RFC net-next 0/4] tcp: backlog processing optims Eric Dumazet
2023-09-06 20:10 ` [RFC net-next 1/4] tcp: no longer release socket ownership in tcp_release_cb() Eric Dumazet
2023-09-06 20:10 ` Eric Dumazet [this message]
2023-09-06 20:10 ` [RFC net-next 3/4] net: call prot->release_cb() when processing backlog Eric Dumazet
2023-09-06 20:10 ` [RFC net-next 4/4] tcp: defer regular ACK while processing socket backlog Eric Dumazet
2023-09-06 20:31   ` Yuchung Cheng
2023-09-06 23:07     ` Stephen Hemminger
2023-09-07 14:07   ` Neal Cardwell
2023-09-07 14:35     ` Soheil Hassas Yeganeh
     [not found]   ` <CAA93jw7Fuov-vmxiZdW7My-AVWCOFQo4XVm9bNwAg4Td2CUNCA@mail.gmail.com>
2023-09-07 16:54     ` Eric Dumazet
2023-09-07 17:09   ` Jakub Kicinski
2023-09-07 17:16     ` Eric Dumazet
2023-09-07 18:00       ` Jakub Kicinski
2023-09-07 18:05         ` Eric Dumazet
2023-09-07 18:10           ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230906201046.463236-3-edumazet@google.com \
    --to=edumazet@google$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=eric.dumazet@gmail$(echo .)com \
    --cc=kuba@kernel$(echo .)org \
    --cc=ncardwell@google$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pabeni@redhat$(echo .)com \
    --cc=soheil@google$(echo .)com \
    --cc=ycheng@google$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox