* [PATCH v2 net-next] sock: Use sock_owned_by_user_nocheck() instead of sk_lock.owned.
@ 2021-12-08 6:21 Kuniyuki Iwashima
2021-12-11 4:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Kuniyuki Iwashima @ 2021-12-08 6:21 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski
Cc: Benjamin Herrenschmidt, Kuniyuki Iwashima, Kuniyuki Iwashima,
netdev
This patch moves sock_release_ownership() down in include/net/sock.h and
replaces some sk_lock.owned tests with sock_owned_by_user_nocheck().
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
---
include/net/sock.h | 23 ++++++++++++-----------
net/core/sock.c | 4 ++--
net/llc/llc_proc.c | 2 +-
3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/include/net/sock.h b/include/net/sock.h
index ae61cd0b650d..923864791c87 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1633,16 +1633,6 @@ static inline void sk_mem_uncharge(struct sock *sk, int size)
__sk_mem_reclaim(sk, SK_RECLAIM_CHUNK);
}
-static inline void sock_release_ownership(struct sock *sk)
-{
- if (sk->sk_lock.owned) {
- sk->sk_lock.owned = 0;
-
- /* The sk_lock has mutex_unlock() semantics: */
- mutex_release(&sk->sk_lock.dep_map, _RET_IP_);
- }
-}
-
/*
* Macro so as to not evaluate some arguments when
* lockdep is not enabled.
@@ -1769,12 +1759,23 @@ static inline bool sock_owned_by_user_nocheck(const struct sock *sk)
return sk->sk_lock.owned;
}
+static inline void sock_release_ownership(struct sock *sk)
+{
+ if (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_);
+ }
+}
+
/* no reclassification while locks are held */
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;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 net-next] sock: Use sock_owned_by_user_nocheck() instead of sk_lock.owned.
2021-12-08 6:21 [PATCH v2 net-next] sock: Use sock_owned_by_user_nocheck() instead of sk_lock.owned Kuniyuki Iwashima
@ 2021-12-11 4:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-12-11 4:40 UTC (permalink / raw)
To: Kuniyuki Iwashima; +Cc: davem, kuba, benh, kuni1840, netdev
Hello:
This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 8 Dec 2021 15:21:58 +0900 you wrote:
> This patch moves sock_release_ownership() down in include/net/sock.h and
> replaces some sk_lock.owned tests with sock_owned_by_user_nocheck().
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
> ---
> include/net/sock.h | 23 ++++++++++++-----------
> net/core/sock.c | 4 ++--
> net/llc/llc_proc.c | 2 +-
> 3 files changed, 15 insertions(+), 14 deletions(-)
Here is the summary with links:
- [v2,net-next] sock: Use sock_owned_by_user_nocheck() instead of sk_lock.owned.
https://git.kernel.org/netdev/net-next/c/33d60fbd21fa
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-11 4:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-08 6:21 [PATCH v2 net-next] sock: Use sock_owned_by_user_nocheck() instead of sk_lock.owned Kuniyuki Iwashima
2021-12-11 4:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).