[PATCH mptcp-next] mptcp: use lockdep_assert_held_once() instead of open-codying it

Paolo Abeni posted 1 patch 3 weeks, 1 day ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/dcaratti/mptcp_net-next tags/patchew/837dc50592c4843c4de722a4b9cbad6663458a07.1630680563.git.pabeni@redhat.com
Maintainers: Mat Martineau <mathew.j.martineau@linux.intel.com>, Jakub Kicinski <kuba@kernel.org>, Matthieu Baerts <matthieu.baerts@tessares.net>, "David S. Miller" <davem@davemloft.net>
net/mptcp/protocol.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

[PATCH mptcp-next] mptcp: use lockdep_assert_held_once() instead of open-codying it

Posted by Paolo Abeni 3 weeks, 1 day ago
We have a few more places where the mptcp code duplicates
lockdep_assert_held_once(). Let's use the existing macro and
avoid a bunch of compiler's conditional.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/mptcp/protocol.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 101e61bb2a80..472319b7e046 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -956,9 +956,7 @@ static void __mptcp_update_wmem(struct sock *sk)
 {
 	struct mptcp_sock *msk = mptcp_sk(sk);
 
-#ifdef CONFIG_LOCKDEP
-	WARN_ON_ONCE(!lockdep_is_held(&sk->sk_lock.slock));
-#endif
+	lockdep_assert_held_once(&sk->sk_lock.slock);
 
 	if (!msk->wmem_reserved)
 		return;
@@ -1117,9 +1115,8 @@ static void __mptcp_clean_una(struct sock *sk)
 
 static void __mptcp_clean_una_wakeup(struct sock *sk)
 {
-#ifdef CONFIG_LOCKDEP
-	WARN_ON_ONCE(!lockdep_is_held(&sk->sk_lock.slock));
-#endif
+	lockdep_assert_held_once(&sk->sk_lock.slock);
+
 	__mptcp_clean_una(sk);
 	mptcp_write_space(sk);
 }
-- 
2.26.3


Re: [PATCH mptcp-next] mptcp: use lockdep_assert_held_once() instead of open-codying it

Posted by Matthieu Baerts 3 weeks, 1 day ago
Hi Paolo,

On 03/09/2021 16:49, Paolo Abeni wrote:
> We have a few more places where the mptcp code duplicates
> lockdep_assert_held_once(). Let's use the existing macro and
> avoid a bunch of compiler's conditional.

Good idea!

Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>

Now in our tree:

- 63afb2abe5ae: mptcp: use lockdep_assert_held_once() instead of
open-codying it
- Results: 396fa2905e69..7755d2ada382

Builds and tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20210903T145841
https://github.com/multipath-tcp/mptcp_net-next/actions/workflows/build-validation.yml?query=branch:export/20210903T145841

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net