Skip to content

Commit 82d9e6b

Browse files
Sebastian Andrzej SiewiorPaolo Abeni
authored andcommitted
mptcp: Use nested-BH locking for hmac_storage
mptcp_delegated_actions is a per-CPU variable and relies on disabled BH for its locking. Without per-CPU locking in local_bh_disable() on PREEMPT_RT this data structure requires explicit locking. Add a local_lock_t to the data structure and use local_lock_nested_bh() for locking. This change adds only lockdep coverage and does not alter the functional behaviour for !PREEMPT_RT. Cc: Matthieu Baerts <[email protected]> Cc: Mat Martineau <[email protected]> Cc: Geliang Tang <[email protected]> Cc: [email protected] Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 20d677d commit 82d9e6b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

net/mptcp/protocol.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ static struct percpu_counter mptcp_sockets_allocated ____cacheline_aligned_in_sm
4646
static void __mptcp_destroy_sock(struct sock *sk);
4747
static void mptcp_check_send_data_fin(struct sock *sk);
4848

49-
DEFINE_PER_CPU(struct mptcp_delegated_action, mptcp_delegated_actions);
49+
DEFINE_PER_CPU(struct mptcp_delegated_action, mptcp_delegated_actions) = {
50+
.bh_lock = INIT_LOCAL_LOCK(bh_lock),
51+
};
5052
static struct net_device *mptcp_napi_dev;
5153

5254
/* Returns end sequence number of the receiver's advertised window */

net/mptcp/protocol.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ mptcp_subflow_rsk(const struct request_sock *rsk)
479479

480480
struct mptcp_delegated_action {
481481
struct napi_struct napi;
482+
local_lock_t bh_lock;
482483
struct list_head head;
483484
};
484485

@@ -670,9 +671,11 @@ static inline void mptcp_subflow_delegate(struct mptcp_subflow_context *subflow,
670671
if (WARN_ON_ONCE(!list_empty(&subflow->delegated_node)))
671672
return;
672673

674+
local_lock_nested_bh(&mptcp_delegated_actions.bh_lock);
673675
delegated = this_cpu_ptr(&mptcp_delegated_actions);
674676
schedule = list_empty(&delegated->head);
675677
list_add_tail(&subflow->delegated_node, &delegated->head);
678+
local_unlock_nested_bh(&mptcp_delegated_actions.bh_lock);
676679
sock_hold(mptcp_subflow_tcp_sock(subflow));
677680
if (schedule)
678681
napi_schedule(&delegated->napi);
@@ -684,11 +687,15 @@ mptcp_subflow_delegated_next(struct mptcp_delegated_action *delegated)
684687
{
685688
struct mptcp_subflow_context *ret;
686689

687-
if (list_empty(&delegated->head))
690+
local_lock_nested_bh(&mptcp_delegated_actions.bh_lock);
691+
if (list_empty(&delegated->head)) {
692+
local_unlock_nested_bh(&mptcp_delegated_actions.bh_lock);
688693
return NULL;
694+
}
689695

690696
ret = list_first_entry(&delegated->head, struct mptcp_subflow_context, delegated_node);
691697
list_del_init(&ret->delegated_node);
698+
local_unlock_nested_bh(&mptcp_delegated_actions.bh_lock);
692699
return ret;
693700
}
694701

0 commit comments

Comments
 (0)