Skip to content

Commit c092dd5

Browse files
edumazetdavem330
authored andcommitted
tcp: switch tcp_internal_pacing() to tcp_wstamp_ns
Now TCP keeps track of tcp_wstamp_ns, recording the earliest departure time of next packet, we can remove duplicate code from tcp_internal_pacing() This removes one ktime_get_tai_ns() call, and a divide. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ab408b6 commit c092dd5

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

net/ipv4/tcp_output.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -993,21 +993,12 @@ enum hrtimer_restart tcp_pace_kick(struct hrtimer *timer)
993993
return HRTIMER_NORESTART;
994994
}
995995

996-
static void tcp_internal_pacing(struct sock *sk, const struct sk_buff *skb)
996+
static void tcp_internal_pacing(struct sock *sk)
997997
{
998-
u64 len_ns;
999-
u32 rate;
1000-
1001998
if (!tcp_needs_internal_pacing(sk))
1002999
return;
1003-
rate = sk->sk_pacing_rate;
1004-
if (!rate || rate == ~0U)
1005-
return;
1006-
1007-
len_ns = (u64)skb->len * NSEC_PER_SEC;
1008-
do_div(len_ns, rate);
10091000
hrtimer_start(&tcp_sk(sk)->pacing_timer,
1010-
ktime_add_ns(ktime_get_tai_ns(), len_ns),
1001+
ns_to_ktime(tcp_sk(sk)->tcp_wstamp_ns),
10111002
HRTIMER_MODE_ABS_PINNED_SOFT);
10121003
sock_hold(sk);
10131004
}
@@ -1026,7 +1017,8 @@ static void tcp_update_skb_after_send(struct sock *sk, struct sk_buff *skb)
10261017
*/
10271018
if (rate != ~0U && rate && tp->data_segs_out >= 10) {
10281019
tp->tcp_wstamp_ns += div_u64((u64)skb->len * NSEC_PER_SEC, rate);
1029-
/* TODO: update internal pacing here */
1020+
1021+
tcp_internal_pacing(sk);
10301022
}
10311023
}
10321024
list_move_tail(&skb->tcp_tsorted_anchor, &tp->tsorted_sent_queue);
@@ -1167,7 +1159,6 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb,
11671159
tcp_event_data_sent(tp, sk);
11681160
tp->data_segs_out += tcp_skb_pcount(skb);
11691161
tp->bytes_sent += skb->len - tcp_header_size;
1170-
tcp_internal_pacing(sk, skb);
11711162
}
11721163

11731164
if (after(tcb->end_seq, tp->snd_nxt) || tcb->seq == tcb->end_seq)

0 commit comments

Comments
 (0)