Skip to content

Commit 5ca509f

Browse files
Jon Paul Maloydavem330
authored andcommitted
tipc: change node timer unit from jiffies to ms
The node keepalive interval is recalculated at each timer expiration to catch any changes in the link tolerance, and stored in a field in struct tipc_node. We use jiffies as unit for the stored value. This is suboptimal, because it makes the calculation unnecessary complex, including two unit conversions. The conversions also lead to a rounding error that causes the link "abort limit" to be 3 in the normal case, instead of 4, as intended. This again leads to unnecessary link resets when the network is pushed close to its limit, e.g., in an environment with hundreds of nodes or namesapces. In this commit, we do instead let the keepalive value be calculated and stored in milliseconds, so that there is only one conversion and the rounding error is eliminated. We also remove a redundant "keepalive" field in struct tipc_link. This is remnant from the previous implementation. Acked-by: Ying Xue <[email protected]> Signed-off-by: Jon Maloy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c4282ca commit 5ca509f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

net/tipc/link.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ struct tipc_stats {
8787
* @peer_bearer_id: bearer id used by link's peer endpoint
8888
* @bearer_id: local bearer id used by link
8989
* @tolerance: minimum link continuity loss needed to reset link [in ms]
90-
* @keepalive_intv: link keepalive timer interval
9190
* @abort_limit: # of unacknowledged continuity probes needed to reset link
9291
* @state: current state of link FSM
9392
* @peer_caps: bitmap describing capabilities of peer node
@@ -131,7 +130,6 @@ struct tipc_link {
131130
u32 peer_bearer_id;
132131
u32 bearer_id;
133132
u32 tolerance;
134-
unsigned long keepalive_intv;
135133
u32 abort_limit;
136134
u32 state;
137135
u16 peer_caps;

net/tipc/node.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -378,14 +378,13 @@ static void tipc_node_calculate_timer(struct tipc_node *n, struct tipc_link *l)
378378
{
379379
unsigned long tol = tipc_link_tolerance(l);
380380
unsigned long intv = ((tol / 4) > 500) ? 500 : tol / 4;
381-
unsigned long keepalive_intv = msecs_to_jiffies(intv);
382381

383382
/* Link with lowest tolerance determines timer interval */
384-
if (keepalive_intv < n->keepalive_intv)
385-
n->keepalive_intv = keepalive_intv;
383+
if (intv < n->keepalive_intv)
384+
n->keepalive_intv = intv;
386385

387-
/* Ensure link's abort limit corresponds to current interval */
388-
tipc_link_set_abort_limit(l, tol / jiffies_to_msecs(n->keepalive_intv));
386+
/* Ensure link's abort limit corresponds to current tolerance */
387+
tipc_link_set_abort_limit(l, tol / n->keepalive_intv);
389388
}
390389

391390
static void tipc_node_delete(struct tipc_node *node)
@@ -526,7 +525,7 @@ static void tipc_node_timeout(unsigned long data)
526525
if (rc & TIPC_LINK_DOWN_EVT)
527526
tipc_node_link_down(n, bearer_id, false);
528527
}
529-
mod_timer(&n->timer, jiffies + n->keepalive_intv);
528+
mod_timer(&n->timer, jiffies + msecs_to_jiffies(n->keepalive_intv));
530529
}
531530

532531
/**
@@ -735,6 +734,7 @@ void tipc_node_check_dest(struct net *net, u32 onode,
735734
bool accept_addr = false;
736735
bool reset = true;
737736
char *if_name;
737+
unsigned long intv;
738738

739739
*dupl_addr = false;
740740
*respond = false;
@@ -840,9 +840,11 @@ void tipc_node_check_dest(struct net *net, u32 onode,
840840
le->link = l;
841841
n->link_cnt++;
842842
tipc_node_calculate_timer(n, l);
843-
if (n->link_cnt == 1)
844-
if (!mod_timer(&n->timer, jiffies + n->keepalive_intv))
843+
if (n->link_cnt == 1) {
844+
intv = jiffies + msecs_to_jiffies(n->keepalive_intv);
845+
if (!mod_timer(&n->timer, intv))
845846
tipc_node_get(n);
847+
}
846848
}
847849
memcpy(&le->maddr, maddr, sizeof(*maddr));
848850
exit:

0 commit comments

Comments
 (0)