Commit 9bcc66e1 authored by Jon Maxwell's avatar Jon Maxwell Committed by David S. Miller

tcp: convert icsk_user_timeout from jiffies to msecs

This is a preparatory commit. Part of this series that improves the
socket TCP_USER_TIMEOUT option accuracy. Implement Eric Dumazets idea
to convert icsk->icsk_user_timeout from jiffies to msecs. To eliminate
the msecs_to_jiffies() and jiffies_to_msecs() dance in future.
Signed-off-by: default avatarJon Maxwell <jmaxwell37@gmail.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 975cd350
...@@ -2989,7 +2989,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, ...@@ -2989,7 +2989,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
if (val < 0) if (val < 0)
err = -EINVAL; err = -EINVAL;
else else
icsk->icsk_user_timeout = msecs_to_jiffies(val); icsk->icsk_user_timeout = val;
break; break;
case TCP_FASTOPEN: case TCP_FASTOPEN:
...@@ -3445,7 +3445,7 @@ static int do_tcp_getsockopt(struct sock *sk, int level, ...@@ -3445,7 +3445,7 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
break; break;
case TCP_USER_TIMEOUT: case TCP_USER_TIMEOUT:
val = jiffies_to_msecs(icsk->icsk_user_timeout); val = icsk->icsk_user_timeout;
break; break;
case TCP_FASTOPEN: case TCP_FASTOPEN:
......
...@@ -183,8 +183,9 @@ static bool retransmits_timed_out(struct sock *sk, ...@@ -183,8 +183,9 @@ static bool retransmits_timed_out(struct sock *sk,
else else
timeout = ((2 << linear_backoff_thresh) - 1) * rto_base + timeout = ((2 << linear_backoff_thresh) - 1) * rto_base +
(boundary - linear_backoff_thresh) * TCP_RTO_MAX; (boundary - linear_backoff_thresh) * TCP_RTO_MAX;
timeout = jiffies_to_msecs(timeout);
} }
return (tcp_time_stamp(tcp_sk(sk)) - start_ts) >= jiffies_to_msecs(timeout); return (tcp_time_stamp(tcp_sk(sk)) - start_ts) >= timeout;
} }
/* A write timeout has occurred. Process the after effects. */ /* A write timeout has occurred. Process the after effects. */
...@@ -337,8 +338,7 @@ static void tcp_probe_timer(struct sock *sk) ...@@ -337,8 +338,7 @@ static void tcp_probe_timer(struct sock *sk)
if (!start_ts) if (!start_ts)
skb->skb_mstamp = tp->tcp_mstamp; skb->skb_mstamp = tp->tcp_mstamp;
else if (icsk->icsk_user_timeout && else if (icsk->icsk_user_timeout &&
(s32)(tcp_time_stamp(tp) - start_ts) > (s32)(tcp_time_stamp(tp) - start_ts) > icsk->icsk_user_timeout)
jiffies_to_msecs(icsk->icsk_user_timeout))
goto abort; goto abort;
max_probes = sock_net(sk)->ipv4.sysctl_tcp_retries2; max_probes = sock_net(sk)->ipv4.sysctl_tcp_retries2;
...@@ -672,7 +672,7 @@ static void tcp_keepalive_timer (struct timer_list *t) ...@@ -672,7 +672,7 @@ static void tcp_keepalive_timer (struct timer_list *t)
* to determine when to timeout instead. * to determine when to timeout instead.
*/ */
if ((icsk->icsk_user_timeout != 0 && if ((icsk->icsk_user_timeout != 0 &&
elapsed >= icsk->icsk_user_timeout && elapsed >= msecs_to_jiffies(icsk->icsk_user_timeout) &&
icsk->icsk_probes_out > 0) || icsk->icsk_probes_out > 0) ||
(icsk->icsk_user_timeout == 0 && (icsk->icsk_user_timeout == 0 &&
icsk->icsk_probes_out >= keepalive_probes(tp))) { icsk->icsk_probes_out >= keepalive_probes(tp))) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment