Skip to content

Commit d999297

Browse files
Jon Paul Maloydavem330
authored andcommitted
tipc: reduce locking scope during packet reception
We convert packet/message reception according to the same principle we have been using for message sending and timeout handling: We move the function tipc_rcv() to node.c, hence handling the initial packet reception at the link aggregation level. The function grabs the node lock, selects the receiving link, and accesses it via a new call tipc_link_rcv(). This function appends buffers to the input queue for delivery upwards, but it may also append outgoing packets to the xmit queue, just as we do during regular message sending. The latter will happen when buffers are forwarded from the link backlog, or when retransmission is requested. Upon return of this function, and after having released the node lock, tipc_rcv() delivers/tranmsits the contents of those queues, but it may also perform actions such as link activation or reset, as indicated by the return flags from the link. This reduces the number of cpu cycles spent inside the node spinlock, and reduces contention on that lock. Reviewed-by: Ying Xue <[email protected]> Signed-off-by: Jon Maloy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1a20cc2 commit d999297

File tree

8 files changed

+478
-389
lines changed

8 files changed

+478
-389
lines changed

net/tipc/bcast.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,29 @@ void tipc_bclink_update_link_state(struct tipc_node *n_ptr,
316316
}
317317
}
318318

319+
void tipc_bclink_sync_state(struct tipc_node *n, struct tipc_msg *hdr)
320+
{
321+
u16 last = msg_last_bcast(hdr);
322+
int mtyp = msg_type(hdr);
323+
324+
if (unlikely(msg_user(hdr) != LINK_PROTOCOL))
325+
return;
326+
if (mtyp == STATE_MSG) {
327+
tipc_bclink_update_link_state(n, last);
328+
return;
329+
}
330+
/* Compatibility: older nodes don't know BCAST_PROTOCOL synchronization,
331+
* and transfer synch info in LINK_PROTOCOL messages.
332+
*/
333+
if (tipc_node_is_up(n))
334+
return;
335+
if ((mtyp != RESET_MSG) && (mtyp != ACTIVATE_MSG))
336+
return;
337+
n->bclink.last_sent = last;
338+
n->bclink.last_in = last;
339+
n->bclink.oos_state = 0;
340+
}
341+
319342
/**
320343
* bclink_peek_nack - monitor retransmission requests sent by other nodes
321344
*

net/tipc/bcast.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,6 @@ void tipc_bclink_wakeup_users(struct net *net);
133133
int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg);
134134
int tipc_nl_bc_link_set(struct net *net, struct nlattr *attrs[]);
135135
void tipc_bclink_input(struct net *net);
136+
void tipc_bclink_sync_state(struct tipc_node *n, struct tipc_msg *msg);
136137

137138
#endif

net/tipc/core.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ static inline int less(u16 left, u16 right)
129129
return less_eq(left, right) && (mod(right) != mod(left));
130130
}
131131

132+
static inline int in_range(u16 val, u16 min, u16 max)
133+
{
134+
return !less(val, min) && !more(val, max);
135+
}
136+
132137
#ifdef CONFIG_SYSCTL
133138
int tipc_register_sysctl(void);
134139
void tipc_unregister_sysctl(void);

0 commit comments

Comments
 (0)