tipc: improve broadcast NACK mechanism
Subsystems (3)
cover tipc: improve broadcast NACK mechanism
The broadcast protocol has turned out to not scale well beyond 70-80 nodes, while it is now possible to build TIPC clusters of at least ten times that size. This commit series improves the NACK/retransmission mechanism of the broadcast protocol to make is at scalable as the rest of TIPC.
Jon Maloy (3):
tipc: transfer broadcast nacks in link state messages
tipc: rate limit broadcast retransmissions
tipc: send broadcast nack directly upon sequence gap detection
net/tipc/bcast.c | 8 ++-- net/tipc/bcast.h | 4 +- net/tipc/link.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++--------- net/tipc/link.h | 6 +-- net/tipc/msg.h | 10 +++++ net/tipc/node.c | 32 +++++++++++++- net/tipc/node.h | 11 +++-- 7 files changed, 167 insertions(+), 35 deletions(-)
Signature · 4 lines
2.7.4 ------------------------------------------------------------------------------
PATCH 1/3 tipc: transfer broadcast nacks in link state messages
When we send broadcasts in clusters of more 70-80 nodes, we sometimes see the broadcast link resetting because of an excessive number of retransmissions. This is caused by a combination of two factors:
1) A 'NACK crunch", where loss of broadcast packets is discovered and NACK'ed by several nodes simultaneously, leading to multiple redundant broadcast retransmissions.
2) The fact that the NACKS as such also are sent as broadcast, leading to excessive load and packet loss on the transmitting switch/bridge.
This commit deals with the latter problem, by moving sending of broadcast nacks from the dedicated BCAST_PROTOCOL/NACK message type to regular unicast LINK_PROTOCOL/STATE messages. We allocate 10 unused bits in word 8 of the said message for this purpose, and introduce a new capability bit, TIPC_BCAST_STATE_NACK in order to keep the change backwards compatible.
--- net/tipc/bcast.c | 8 ++++--- net/tipc/bcast.h | 4 ++-- net/tipc/link.c | 64 ++++++++++++++++++++++++++++++++++++++++++++------------ net/tipc/link.h | 6 +++--- net/tipc/msg.h | 10 +++++++++ net/tipc/node.c | 32 ++++++++++++++++++++++++++-- net/tipc/node.h | 11 ++++++---- 7 files changed, 108 insertions(+), 27 deletions(-)
net/tipc/bcast.c +5 -3
@@ -269,18 +269,19 @@ void tipc_bcast_ack_rcv(struct net *net, struct tipc_link *l, u32 acked)* * RCU is locked, no other locks set */ -void tipc_bcast_sync_rcv (struct net *net,struct tipc_link *l, -struct tipc_msg *hdr) +int tipc_bcast_sync_rcv (struct net *net,struct tipc_link *l, +struct tipc_msg *hdr) {struct sk_buff_head *inputq = &tipc_bc_base (net)->inputq;struct sk_buff_head xmitq; +int rc =0 ;__skb_queue_head_init (&xmitq);tipc_bcast_lock (net);if (msg_type (hdr) ==STATE_MSG ) {tipc_link_bc_ack_rcv (l,msg_bcast_ack (hdr), &xmitq); -tipc_link_bc_sync_rcv (l, hdr, &xmitq); + rc =tipc_link_bc_sync_rcv (l, hdr, &xmitq); }else {tipc_link_bc_init_rcv (l, hdr); }
@@ -291,6 +292,7 @@ void tipc_bcast_sync_rcv(struct net *net, struct tipc_link *l,/* Any socket wakeup messages ? */ if (!skb_queue_empty (inputq))tipc_sk_rcv (net, inputq); +return rc; }/* tipc_bcast_add_peer - add a peer node to broadcast link and bearer
net/tipc/bcast.h +2 -2
@@ -56,8 +56,8 @@ int tipc_bcast_get_mtu(struct net *net);int tipc_bcast_xmit (struct net *net,struct sk_buff_head *list);int tipc_bcast_rcv (struct net *net,struct tipc_link *l,struct sk_buff *skb);void tipc_bcast_ack_rcv (struct net *net,struct tipc_link *l,u32 acked); -void tipc_bcast_sync_rcv (struct net *net,struct tipc_link *l, -struct tipc_msg *hdr); +int tipc_bcast_sync_rcv (struct net *net,struct tipc_link *l, +struct tipc_msg *hdr);int tipc_nl_add_bc_link (struct net *net,struct tipc_nl_msg *msg);int tipc_nl_bc_link_set (struct net *net,struct nlattr *attrs[]);int tipc_bclink_reset_stats (struct net *net);
net/tipc/link.c +51 -13
149 lines not on this page · raw message
net/tipc/link.h +3 -3
@@ -63,7 +63,7 @@ enum {enum {TIPC_LINK_UP_EVT =1 ,TIPC_LINK_DOWN_EVT = (1 <<1 ), -TIPC_LINK_SND_BC_ACK = (1 <<2 ) +TIPC_LINK_SND_STATE = (1 <<2 ) };/* Starting value for maximum packet size negotiation on unicast links
@@ -138,8 +138,8 @@ void tipc_link_bc_ack_rcv(struct tipc_link *l, u16 acked,void tipc_link_build_bc_sync_msg (struct tipc_link *l,struct sk_buff_head *xmitq);void tipc_link_bc_init_rcv (struct tipc_link *l,struct tipc_msg *hdr); -void tipc_link_bc_sync_rcv (struct tipc_link *l,struct tipc_msg *hdr, -struct sk_buff_head *xmitq); +int tipc_link_bc_sync_rcv (struct tipc_link *l,struct tipc_msg *hdr, +struct sk_buff_head *xmitq);int tipc_link_bc_nack_rcv (struct tipc_link *l,struct sk_buff *skb,struct sk_buff_head *xmitq);#endif
net/tipc/msg.h +10 -0
@@ -719,6 +719,16 @@ static inline char *msg_media_addr(struct tipc_msg *m)return (char *)&m->hdr[TIPC_MEDIA_INFO_OFFSET ]; } +static inline u32 msg_bc_gap (struct tipc_msg *m) +{ +return msg_bits (m,8 ,0 ,0x3ff ); +} + +static inline void msg_set_bc_gap (struct tipc_msg *m,u32 n) +{ +msg_set_bits (m,8 ,0 ,0x3ff , n); +} +/* * Word 9 */
net/tipc/node.c +30 -2
@@ -1262,6 +1262,34 @@ void tipc_node_broadcast(struct net *net, struct sk_buff *skb)kfree_skb (skb); } +static void tipc_node_bc_sync_rcv (struct tipc_node *n,struct tipc_msg *hdr, +int bearer_id,struct sk_buff_head *xmitq) +{ +struct tipc_link *ucl; +int rc; + + rc =tipc_bcast_sync_rcv (n->net, n->bc_entry.link, hdr); + +if (rc &TIPC_LINK_DOWN_EVT ) { +tipc_bearer_reset_all (n->net); +return ; + } + +if (!(rc &TIPC_LINK_SND_STATE )) +return ; + +/* If probe message, a STATE response will be sent anyway */ +if (msg_probe (hdr)) +return ; + +/* Produce a STATE message carrying broadcast NACK */ +tipc_node_read_lock (n); + ucl = n->links[bearer_id].link; +if (ucl) +tipc_link_build_state_msg (ucl, xmitq); +tipc_node_read_unlock (n); +} +/** * tipc_node_bc_rcv - process TIPC broadcast packet arriving from off-node * @net: the applicable net namespace
@@ -1298,7 +1326,7 @@ static void tipc_node_bc_rcv(struct net *net, struct sk_buff *skb, int bearer_id rc =tipc_bcast_rcv (net, be->link, skb);/* Broadcast ACKs are sent on a unicast link */ -if (rc &TIPC_LINK_SND_BC_ACK ) { +if (rc &TIPC_LINK_SND_STATE ) {tipc_node_read_lock (n);tipc_link_build_state_msg (le->link, &xmitq);tipc_node_read_unlock (n);
@@ -1505,7 +1533,7 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b)/* Ensure broadcast reception is in synch with peer's send state */ if (unlikely (usr ==LINK_PROTOCOL )) -tipc_bcast_sync_rcv (net, n->bc_entry.link, hdr); +tipc_node_bc_sync_rcv (n, hdr, bearer_id, &xmitq);else if (unlikely (tipc_link_acked (n->bc_entry.link) != bc_ack))tipc_bcast_ack_rcv (net, n->bc_entry.link, bc_ack);
net/tipc/node.h +7 -4
@@ -1,7 +1,7 @@/* * net/tipc/node.h: Include file for TIPC node management routines * -* Copyright (c) 2000-2006, 2014-2015, Ericsson AB +* Copyright (c) 2000-2006, 2014-2016, Ericsson AB * Copyright (c) 2005, 2010-2014, Wind River Systems * All rights reserved. *
@@ -45,11 +45,14 @@/* Optional capabilities supported by this code version */ enum { -TIPC_BCAST_SYNCH = (1 <<1 ), -TIPC_BLOCK_FLOWCTL = (2 <<1 ) +TIPC_BCAST_SYNCH = (1 <<1 ), +TIPC_BCAST_STATE_NACK = (1 <<2 ), +TIPC_BLOCK_FLOWCTL = (1 <<3 ) }; -#define TIPC_NODE_CAPABILITIES (TIPC_BCAST_SYNCH | TIPC_BLOCK_FLOWCTL) +#define TIPC_NODE_CAPABILITIES (TIPC_BCAST_SYNCH | \ + TIPC_BCAST_STATE_NACK | \ + TIPC_BLOCK_FLOWCTL)#define INVALID_BEARER_ID -1void tipc_node_stop (struct net *net);
Signature · 4 lines
2.7.4 ------------------------------------------------------------------------------
PATCH 2/3 tipc: rate limit broadcast retransmissions
In reply to Jon MaloyAs cluster sizes grow, so does the amount of identical or overlapping broadcast NACKs generated by the packet receivers. This often leads to 'NACK crunches' resulting in huge numbers of redundant retransmissions of the same packet ranges.
In this commit, we introduce rate control of broadcast retransmissions, so that a retransmitted range cannot be retransmitted again until after at least 10 ms. This reduces the frequency of duplicate, redundant retransmissions by an order of magnitude, while having a significant positive impact on overall throughput and scalability.
--- net/tipc/link.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-)
net/tipc/link.c +47 -5
@@ -181,7 +181,10 @@ struct tipc_link {u16 acked;struct tipc_link *bc_rcvlink;struct tipc_link *bc_sndlink; -int nack_state; +unsigned long prev_retr; +u16 prev_from; +u16 prev_to; +u8 nack_state;bool bc_peer_is_up;/* Statistics */
@@ -202,6 +205,8 @@ enum { BC_NACK_SND_SUPPRESS, }; +#define TIPC_BC_RETR_LIMIT 10/* [ms] */ +/* * Interval between NACKs when packets arrive out of order */
@@ -1590,11 +1595,48 @@ void tipc_link_bc_init_rcv(struct tipc_link *l, struct tipc_msg *hdr) l->rcv_nxt = peers_snd_nxt; } +/* link_bc_retr eval()- check if the indicated range can be retransmitted now +* - Adjust permitted range if there is overlap with previous retransmission +*/ +static bool link_bc_retr_eval (struct tipc_link *l,u16 *from,u16 *to) +{ +unsigned long elapsed =jiffies_to_msecs (jiffies - l->prev_retr); + +if (less (*to, *from)) +return false; + +/* New retransmission request */ +if ((elapsed >TIPC_BC_RETR_LIMIT ) || +less (*to, l->prev_from) ||more (*from, l->prev_to)) { + l->prev_from = *from; + l->prev_to = *to; + l->prev_retr = jiffies; +return true; + } + +/* Inside range of previous retransmit */ +if (!less (*from, l->prev_from) && !more (*to, l->prev_to)) +return false; + +/* Fully or partially outside previous range => exclude overlap */ +if (less (*from, l->prev_from)) { + *to = l->prev_from -1 ; + l->prev_from = *from; + } +if (more (*to, l->prev_to)) { + *from = l->prev_to +1 ; + l->prev_to = *to; + } + l->prev_retr = jiffies; +return true; +} +/* tipc_link_bc_sync_rcv - update rcv link according to peer's send state */ int tipc_link_bc_sync_rcv (struct tipc_link *l,struct tipc_msg *hdr,struct sk_buff_head *xmitq) { +struct tipc_link *snd_l = l->bc_sndlink;u16 peers_snd_nxt =msg_bc_snd_nxt (hdr);u16 from =msg_bcast_ack (hdr) +1 ;u16 to = from +msg_bc_gap (hdr) -1 ;
@@ -1613,14 +1655,14 @@ int tipc_link_bc_sync_rcv(struct tipc_link *l, struct tipc_msg *hdr,if (!l->bc_peer_is_up)return rc; + l->stats.recv_nacks++; +/* Ignore if peers_snd_nxt goes beyond receive window */ if (more (peers_snd_nxt, l->rcv_nxt + l->window))return rc; -if (!less (to, from)) { - rc =tipc_link_retrans (l->bc_sndlink, from, to, xmitq); - l->stats.recv_nacks++; - } +if (link_bc_retr_eval (snd_l, &from, &to)) + rc =tipc_link_retrans (snd_l, from, to, xmitq); l->snd_nxt = peers_snd_nxt;if (link_bc_rcv_gap (l))
Signature · 4 lines
2.7.4 ------------------------------------------------------------------------------
PATCH 3/3 tipc: send broadcast nack directly upon sequence gap detection
In reply to Jon MaloyBecause of the risk of an excessive number of NACK messages and retransissions, receivers have until now abstained from sending broadcast NACKS directly upon detection of a packet sequence number gap. We have instead relied on such gaps being detected by link protocol STATE message exchange, something that by necessity delays such detection and subsequent retransmissions.
With the introduction of unicast NACK transmission and rate control of retransmissions we can now remove this limitation. We now allow receiving nodes to send NACKS immediately, while coordinating the permission to do so among the nodes in order to avoid NACK storms.
--- net/tipc/link.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
net/tipc/link.c +16 -7
@@ -242,8 +242,8 @@ static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe, u16 rcvgap, int tolerance, int priority, struct sk_buff_head *xmitq);static void link_print (struct tipc_link *l,const char *str); -static void tipc_link_build_nack_msg (struct tipc_link *l, -struct sk_buff_head *xmitq); +static int tipc_link_build_nack_msg (struct tipc_link *l, +struct sk_buff_head *xmitq);static void tipc_link_build_bc_init_msg (struct tipc_link *l,struct sk_buff_head *xmitq);static bool tipc_link_release_pkts (struct tipc_link *l,u16 to);
@@ -1184,17 +1184,26 @@ void tipc_link_build_reset_msg(struct tipc_link *l, struct sk_buff_head *xmitq) }/* tipc_link_build_nack_msg: prepare link nack message for transmission +* Note that sending of broadcast NACK is coordinated among nodes, to +* reduce the risk of NACK storms towards the sender */ -static void tipc_link_build_nack_msg (struct tipc_link *l, -struct sk_buff_head *xmitq) +static int tipc_link_build_nack_msg (struct tipc_link *l, +struct sk_buff_head *xmitq) {u32 def_cnt = ++l->stats.deferred_recv; +int match1, match2; -if (link_is_bc_rcvlink (l)) -return ; +if (link_is_bc_rcvlink (l)) { + match1 = def_cnt &0xf ; + match2 =tipc_own_addr (l->net) &0xf ; +if (match1 == match2) +return TIPC_LINK_SND_STATE ; +return 0 ; + }if ((skb_queue_len (&l->deferdq) ==1 ) || !(def_cnt %TIPC_NACK_INTV ))tipc_link_build_proto_msg (l,STATE_MSG ,0 ,0 ,0 ,0 , xmitq); +return 0 ; }/* tipc_link_rcv - process TIPC packets/messages arriving from off-node
@@ -1245,7 +1254,7 @@ int tipc_link_rcv(struct tipc_link *l, struct sk_buff *skb,/* Defer delivery if sequence gap */ if (unlikely (seqno != rcv_nxt)) {__tipc_skb_queue_sorted (defq, seqno, skb); -tipc_link_build_nack_msg (l, xmitq); + rc |=tipc_link_build_nack_msg (l, xmitq);break ; }
Signature · 4 lines
2.7.4 ------------------------------------------------------------------------------
David Miller
maintainerFrom: Jon Maloy <[email protected]>
Date: Thu, 1 Sep 2016 13:52:48 -0400
Quoted 5 lines
The broadcast protocol has turned out to not scale well beyond 70-80 nodes, while it is now possible to build TIPC clusters of at least ten times that size. This commit series improves the NACK/retransmission mechanism of the broadcast protocol to make is at scalable as the rest of TIPC.
Series applied, thanks Jon.