Acked-by: Jon Maloy <[email protected]> -----Original Message----- From: Tung Nguyen [mailto:[email protected]] Sent: Wednesday, May 02, 2018 11:09 PM To: [email protected]; Jon Maloy <[email protected]>; [email protected]; [email protected] Subject: [PATCH v1 1/1] tipc: improve function tipc_node_timeout()
In single-link usage, function tipc_node_timeout() still reiterates over link array to handle each link. Given that the maximum number of bearers are 3, there are 2 redundant reiterations with lock grab/release. This commit adds conditional checking to stop the next iteration after handling the used link in the case only one link is configured to be used. Signed-off-by: Tung Nguyen <[email protected]> --- net/tipc/node.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/tipc/node.c b/net/tipc/node.c index 6f98b56..1f14df2 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -530,21 +530,23 @@ static void tipc_node_timeout(struct timer_list *t) struct tipc_node *n = from_timer(n, t, timer); struct tipc_link_entry *le; struct sk_buff_head xmitq; + int remains = n->link_cnt; int bearer_id; int rc = 0; __skb_queue_head_init(&xmitq); - for (bearer_id = 0; bearer_id < MAX_BEARERS; bearer_id++) { + for (bearer_id = 0; remains && (bearer_id < MAX_BEARERS); bearer_id++) +{ tipc_node_read_lock(n); le = &n->links[bearer_id]; - spin_lock_bh(&le->lock); if (le->link) { + spin_lock_bh(&le->lock); /* Link tolerance may change asynchronously: */ tipc_node_calculate_timer(n, le->link); rc = tipc_link_timeout(le->link, &xmitq); + spin_unlock_bh(&le->lock); + remains--; } - spin_unlock_bh(&le->lock); tipc_node_read_unlock(n); tipc_bearer_xmit(n->net, bearer_id, &xmitq, &le->maddr); if (rc & TIPC_LINK_DOWN_EVT) -- 2.8.3 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ tipc-discussion mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tipc-discussion
