Skip to content

Commit 5405ff6

Browse files
Jon Paul Maloydavem330
authored andcommitted
tipc: convert node lock to rwlock
According to the node FSM a node in state SELF_UP_PEER_UP cannot change state inside a lock context, except when a TUNNEL_PROTOCOL (SYNCH or FAILOVER) packet arrives. However, the node's individual links may still change state. Since each link now is protected by its own spinlock, we finally have the conditions in place to convert the node spinlock to an rwlock_t. If the node state and arriving packet type are rigth, we can let the link directly receive the packet under protection of its own spinlock and the node lock in read mode. In all other cases we use the node lock in write mode. This enables full concurrent execution between parallel links during steady-state traffic situations, i.e., 99+ % of the time. This commit implements this change. Reviewed-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2312bf6 commit 5405ff6

3 files changed

Lines changed: 136 additions & 133 deletions

File tree

‎net/tipc/link.c‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,7 @@ static struct tipc_node *tipc_link_find_owner(struct net *net,
15471547
*bearer_id = 0;
15481548
rcu_read_lock();
15491549
list_for_each_entry_rcu(n_ptr, &tn->node_list, list) {
1550-
tipc_node_lock(n_ptr);
1550+
tipc_node_read_lock(n_ptr);
15511551
for (i = 0; i < MAX_BEARERS; i++) {
15521552
l_ptr = n_ptr->links[i].link;
15531553
if (l_ptr && !strcmp(l_ptr->name, link_name)) {
@@ -1556,7 +1556,7 @@ static struct tipc_node *tipc_link_find_owner(struct net *net,
15561556
break;
15571557
}
15581558
}
1559-
tipc_node_unlock(n_ptr);
1559+
tipc_node_read_unlock(n_ptr);
15601560
if (found_node)
15611561
break;
15621562
}
@@ -1658,7 +1658,7 @@ int tipc_nl_link_set(struct sk_buff *skb, struct genl_info *info)
16581658
if (!node)
16591659
return -EINVAL;
16601660

1661-
tipc_node_lock(node);
1661+
tipc_node_read_lock(node);
16621662

16631663
link = node->links[bearer_id].link;
16641664
if (!link) {
@@ -1699,7 +1699,7 @@ int tipc_nl_link_set(struct sk_buff *skb, struct genl_info *info)
16991699
}
17001700

17011701
out:
1702-
tipc_node_unlock(node);
1702+
tipc_node_read_unlock(node);
17031703

17041704
return res;
17051705
}
@@ -1898,10 +1898,10 @@ int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb)
18981898

18991899
list_for_each_entry_continue_rcu(node, &tn->node_list,
19001900
list) {
1901-
tipc_node_lock(node);
1901+
tipc_node_read_lock(node);
19021902
err = __tipc_nl_add_node_links(net, &msg, node,
19031903
&prev_link);
1904-
tipc_node_unlock(node);
1904+
tipc_node_read_unlock(node);
19051905
if (err)
19061906
goto out;
19071907

@@ -1913,10 +1913,10 @@ int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb)
19131913
goto out;
19141914

19151915
list_for_each_entry_rcu(node, &tn->node_list, list) {
1916-
tipc_node_lock(node);
1916+
tipc_node_read_lock(node);
19171917
err = __tipc_nl_add_node_links(net, &msg, node,
19181918
&prev_link);
1919-
tipc_node_unlock(node);
1919+
tipc_node_read_unlock(node);
19201920
if (err)
19211921
goto out;
19221922

@@ -1967,16 +1967,16 @@ int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info)
19671967
if (!node)
19681968
return -EINVAL;
19691969

1970-
tipc_node_lock(node);
1970+
tipc_node_read_lock(node);
19711971
link = node->links[bearer_id].link;
19721972
if (!link) {
1973-
tipc_node_unlock(node);
1973+
tipc_node_read_unlock(node);
19741974
nlmsg_free(msg.skb);
19751975
return -EINVAL;
19761976
}
19771977

19781978
err = __tipc_nl_add_link(net, &msg, link, 0);
1979-
tipc_node_unlock(node);
1979+
tipc_node_read_unlock(node);
19801980
if (err) {
19811981
nlmsg_free(msg.skb);
19821982
return err;
@@ -2021,18 +2021,18 @@ int tipc_nl_link_reset_stats(struct sk_buff *skb, struct genl_info *info)
20212021
node = tipc_link_find_owner(net, link_name, &bearer_id);
20222022
if (!node)
20232023
return -EINVAL;
2024+
20242025
le = &node->links[bearer_id];
2025-
tipc_node_lock(node);
2026+
tipc_node_read_lock(node);
20262027
spin_lock_bh(&le->lock);
20272028
link = le->link;
20282029
if (!link) {
2029-
tipc_node_unlock(node);
2030+
spin_unlock_bh(&le->lock);
2031+
tipc_node_read_unlock(node);
20302032
return -EINVAL;
20312033
}
2032-
20332034
link_reset_statistics(link);
20342035
spin_unlock_bh(&le->lock);
2035-
tipc_node_unlock(node);
2036-
2036+
tipc_node_read_unlock(node);
20372037
return 0;
20382038
}

0 commit comments

Comments
 (0)