Skip to content

Commit f3cc935

Browse files
edumazetkardebayan
authored andcommitted
tcp_bbr: better deal with suboptimal GSO (II)
This is second part of dealing with suboptimal device gso parameters. In first patch (350c9f484bde "tcp_bbr: better deal with suboptimal GSO") we dealt with devices having low gso_max_segs Some devices lower gso_max_size from 64KB to 16 KB (r8152 is an example) In order to probe an optimal cwnd, we want BBR being not sensitive to whatever GSO constraint a device can have. This patch removes tso_segs_goal() CC callback in favor of min_tso_segs() for CC wanting to override sysctl_tcp_min_tso_segs Next patch will remove bbr->tso_segs_goal since it does not have to be persistent. Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Danny Lin <danny@kdrag0n.dev> Signed-off-by: celtare21 <celtare21@gmail.com> Signed-off-by: Panchajanya1999 <panchajanya@azure-dev.live> Signed-off-by: Panchajanya Sarkar <panchajanya@azure-dev.live> Signed-off-by: Forenche <prahul2003@gmail.com> Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
1 parent 877bba9 commit f3cc935

3 files changed

Lines changed: 23 additions & 21 deletions

File tree

include/net/tcp.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,6 @@ __u32 cookie_v6_init_sequence(const struct sk_buff *skb, __u16 *mss);
577577
#endif
578578
/* tcp_output.c */
579579

580-
u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now,
581-
int min_tso_segs);
582580
void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss,
583581
int nonagle);
584582
int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs);
@@ -1062,8 +1060,8 @@ struct tcp_congestion_ops {
10621060
u32 (*undo_cwnd)(struct sock *sk);
10631061
/* hook for packet ack accounting (optional) */
10641062
void (*pkts_acked)(struct sock *sk, const struct ack_sample *sample);
1065-
/* suggest number of segments for each skb to transmit (optional) */
1066-
u32 (*tso_segs_goal)(struct sock *sk);
1063+
/* override sysctl_tcp_min_tso_segs */
1064+
u32 (*min_tso_segs)(struct sock *sk);
10671065
/* returns the multiplier used in tcp_sndbuf_expand (optional) */
10681066
u32 (*sndbuf_expand)(struct sock *sk);
10691067
/* call when packets are delivered to update cwnd and pacing rate,

net/ipv4/tcp_bbr.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,23 +261,26 @@ static void bbr_set_pacing_rate(struct sock *sk, u32 bw, int gain)
261261
sk->sk_pacing_rate = rate;
262262
}
263263

264-
/* Return count of segments we want in the skbs we send, or 0 for default. */
265-
static u32 bbr_tso_segs_goal(struct sock *sk)
264+
/* override sysctl_tcp_min_tso_segs */
265+
static u32 bbr_min_tso_segs(struct sock *sk)
266266
{
267-
struct bbr *bbr = inet_csk_ca(sk);
268-
269-
return bbr->tso_segs_goal;
267+
return sk->sk_pacing_rate < (bbr_min_tso_rate >> 3) ? 1 : 2;
270268
}
271269

272270
static void bbr_set_tso_segs_goal(struct sock *sk)
273271
{
274272
struct tcp_sock *tp = tcp_sk(sk);
275273
struct bbr *bbr = inet_csk_ca(sk);
276-
u32 min_segs;
274+
u32 segs, bytes;
275+
276+
/* Sort of tcp_tso_autosize() but ignoring
277+
* driver provided sk_gso_max_size.
278+
*/
279+
bytes = min_t(u32, sk->sk_pacing_rate >> sk->sk_pacing_shift,
280+
GSO_MAX_SIZE - 1 - MAX_TCP_HEADER);
281+
segs = max_t(u32, bytes / tp->mss_cache, bbr_min_tso_segs(sk));
277282

278-
min_segs = sk->sk_pacing_rate < (bbr_min_tso_rate >> 3) ? 1 : 2;
279-
bbr->tso_segs_goal = min(tcp_tso_autosize(sk, tp->mss_cache, min_segs),
280-
0x7FU);
283+
bbr->tso_segs_goal = min(segs, 0x7FU);
281284
}
282285

283286
/* Save "last known good" cwnd so we can restore it after losses or PROBE_RTT */
@@ -940,7 +943,7 @@ static struct tcp_congestion_ops tcp_bbr_cong_ops __read_mostly = {
940943
.undo_cwnd = bbr_undo_cwnd,
941944
.cwnd_event = bbr_cwnd_event,
942945
.ssthresh = bbr_ssthresh,
943-
.tso_segs_goal = bbr_tso_segs_goal,
946+
.min_tso_segs = bbr_min_tso_segs,
944947
.get_info = bbr_get_info,
945948
.set_state = bbr_set_state,
946949
};

net/ipv4/tcp_output.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,8 +1961,8 @@ static bool tcp_nagle_check(bool partial, const struct tcp_sock *tp,
19611961
/* Return how many segs we'd like on a TSO packet,
19621962
* to send one TSO packet per ms
19631963
*/
1964-
u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now,
1965-
int min_tso_segs)
1964+
static u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now,
1965+
int min_tso_segs)
19661966
{
19671967
u32 bytes, segs;
19681968

@@ -1978,19 +1978,20 @@ u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now,
19781978

19791979
return segs;
19801980
}
1981-
EXPORT_SYMBOL(tcp_tso_autosize);
19821981

19831982
/* Return the number of segments we want in the skb we are transmitting.
19841983
* See if congestion control module wants to decide; otherwise, autosize.
19851984
*/
19861985
static u32 tcp_tso_segs(struct sock *sk, unsigned int mss_now)
19871986
{
19881987
const struct tcp_congestion_ops *ca_ops = inet_csk(sk)->icsk_ca_ops;
1989-
u32 tso_segs = ca_ops->tso_segs_goal ? ca_ops->tso_segs_goal(sk) : 0;
1988+
u32 min_tso, tso_segs;
19901989

1991-
if (!tso_segs)
1992-
tso_segs = tcp_tso_autosize(sk, mss_now,
1993-
sysctl_tcp_min_tso_segs);
1990+
min_tso = ca_ops->min_tso_segs ?
1991+
ca_ops->min_tso_segs(sk) :
1992+
sysctl_tcp_min_tso_segs;
1993+
1994+
tso_segs = tcp_tso_autosize(sk, mss_now, min_tso);
19941995
return min_t(u32, tso_segs, sk->sk_gso_max_segs);
19951996
}
19961997

0 commit comments

Comments
 (0)