Skip to content

Commit ad80b0f

Browse files
Paolo Abenikuba-moo
authored andcommitted
mptcp: open code mptcp variant for lock_sock
This allows invoking an additional callback under the socket spin lock. Will be used by the next patches to avoid additional spin lock contention. Acked-by: Florian Westphal <[email protected]> Signed-off-by: Paolo Abeni <[email protected]> Reviewed-by: Mat Martineau <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent be57242 commit ad80b0f

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

include/net/sock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,7 @@ static inline void lock_sock(struct sock *sk)
15901590
lock_sock_nested(sk, 0);
15911591
}
15921592

1593+
void __lock_sock(struct sock *sk);
15931594
void __release_sock(struct sock *sk);
15941595
void release_sock(struct sock *sk);
15951596

net/core/sock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2486,7 +2486,7 @@ bool sk_page_frag_refill(struct sock *sk, struct page_frag *pfrag)
24862486
}
24872487
EXPORT_SYMBOL(sk_page_frag_refill);
24882488

2489-
static void __lock_sock(struct sock *sk)
2489+
void __lock_sock(struct sock *sk)
24902490
__releases(&sk->sk_lock.slock)
24912491
__acquires(&sk->sk_lock.slock)
24922492
{

net/mptcp/protocol.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,19 @@ struct mptcp_sock {
253253
} rcvq_space;
254254
};
255255

256+
#define mptcp_lock_sock(___sk, cb) do { \
257+
struct sock *__sk = (___sk); /* silence macro reuse warning */ \
258+
might_sleep(); \
259+
spin_lock_bh(&__sk->sk_lock.slock); \
260+
if (__sk->sk_lock.owned) \
261+
__lock_sock(__sk); \
262+
cb; \
263+
__sk->sk_lock.owned = 1; \
264+
spin_unlock(&__sk->sk_lock.slock); \
265+
mutex_acquire(&__sk->sk_lock.dep_map, 0, 0, _RET_IP_); \
266+
local_bh_enable(); \
267+
} while (0)
268+
256269
#define mptcp_for_each_subflow(__msk, __subflow) \
257270
list_for_each_entry(__subflow, &((__msk)->conn_list), node)
258271

0 commit comments

Comments
 (0)