From nobody Wed Jan 24 16:41:17 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TKqTp1XGYz58KVY; Wed, 24 Jan 2024 16:41:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TKqTn5p9qz4wZp; Wed, 24 Jan 2024 16:41:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706114477; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CYHYCAShoa6xiIe9VY9FKbPSrmp6G31to9rWy1mksmg=; b=sCbzBrYyP6pFPzXMBJlMhdRgLEJunynvPYYJsbjYe8U291/YSvn/wyx2XWIcInjQCWGkTv dAMPpdAh5mEITgGKBDB+ECoi/roBfliQ64sR0iLSYyoROwDqfOUtDDpZgzPruJTqJh4fPf VvfOW3vBitHy0hc61cVyGsCcE/us6HXeAwt+MOCFjG2t4CMCbcyI22bSv/XsqZjpL4sOQu 1fnqyIRCQU00eEgTfKRqJCU63p3GW6RYqNoxoABth3Mihi6tHu+TdebiM2ZByGreJSKUzU 7HdP2NH6dQXI/xHT8IJeC6q6fwyJAqCTZwbxDCa4bj9VcxwukFHYLFaFWMnpLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706114477; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CYHYCAShoa6xiIe9VY9FKbPSrmp6G31to9rWy1mksmg=; b=JX3SVu31cBjHF3cOImKnVpYI2zl68J4xNoTeu2WWg+gChFviPt6+FSBYT8xfTfeoduGYWl djybp5CBmeBII8wr7GG1rIRWaHr4Rzrr+nHerfac+BUBoUlqqksCCv1VLxOGTJGVHxdrCC oX0gs19Hg2kJ7Eq/SpXr9Mbjy26o0Uoa2L3hIa1Xp79fci6bIE7eJy7gIM6YjBgew58TTp 2HkC/iGoaAwmGlOlTszwkP3lgiqbNY2J68/hHaCcPo2NPMtJUTL97yEZwgTWRlsHYuMZQT rYHZbBKkavMsX5mj20ra8bzKvMeROZMlIq1BuRJkrfIvZhy11gGc2L+4UsQVdw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706114477; a=rsa-sha256; cv=none; b=PnVqIvPv9POzkk6FmQfi7lWncWBdMMNVB4yjoXGpkmgrp1YqDjpmJhqiYiUJsdSAd5W24N mo2dEjpbCCab1geJAzt4a7QRzV2qNrVxdzSH/XcPFDRIK0dJwuAEb3jS3MFjmLQHHb7bAZ UAg3/7yWa6cJiZZDiOHOirrwrIij1paXshk8xf0q8wf10ZL9Le6/qYyA+2buIM6SrMSIty rIaANMPBeb9nFKsIil+kTx8lqqrTQfMF5/1bEcz12twoWvZXb/7aujWO/uTV55u5LkjF9E gLnMjNdJO6+MUozHsTRJPSsVcCLnSihLbwctaGyFjkv0uMmn3rrrY3wjltF1mQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TKqTn3mRRzMQd; Wed, 24 Jan 2024 16:41:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40OGfH0g095846; Wed, 24 Jan 2024 16:41:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40OGfH1O095843; Wed, 24 Jan 2024 16:41:17 GMT (envelope-from git) Date: Wed, 24 Jan 2024 16:41:17 GMT Message-Id: <202401241641.40OGfH1O095843@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Richard Scheffenegger Subject: git: c7c325d01de4 - main - tcp: pass maxseg around instead of calculating locally List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c7c325d01de4a1509e0a978f28275279de692130 Auto-Submitted: auto-generated The branch main has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=c7c325d01de4a1509e0a978f28275279de692130 commit c7c325d01de4a1509e0a978f28275279de692130 Author: Richard Scheffenegger AuthorDate: 2024-01-24 15:42:29 +0000 Commit: Richard Scheffenegger CommitDate: 2024-01-24 15:43:29 +0000 tcp: pass maxseg around instead of calculating locally Improve slowpath processing (reordering, retransmissions) slightly by calculating maxseg only once. This typically saves one of two calls to tcp_maxseg(). Reviewed By: glebius, tuexen, cc, #transport Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D43536 --- sys/netinet/tcp_input.c | 37 +++++++++++++++++++++++++------------ sys/netinet/tcp_sack.c | 9 +++++++-- sys/netinet/tcp_var.h | 8 +++++--- 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index ed5f28490852..02b042fd3273 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1529,7 +1529,7 @@ tcp_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th, struct mbuf *mfree; struct tcpopt to; int tfo_syn; - u_int maxseg; + u_int maxseg = 0; thflags = tcp_get_flags(th); tp->sackhint.last_sack_ack = 0; @@ -2596,7 +2596,8 @@ tcp_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th, if (V_tcp_do_prr && IN_FASTRECOVERY(tp->t_flags) && (tp->t_flags & TF_SACK_PERMIT)) { - tcp_do_prr_ack(tp, th, &to, sack_changed); + tcp_do_prr_ack(tp, th, &to, + sack_changed, &maxseg); } else if (tcp_is_sack_recovery(tp, &to) && IN_FASTRECOVERY(tp->t_flags)) { int awnd; @@ -2801,19 +2802,24 @@ resume_partialack: */ if (IN_FASTRECOVERY(tp->t_flags)) { if (SEQ_LT(th->th_ack, tp->snd_recover)) { - if (tp->t_flags & TF_SACK_PERMIT) + if (tp->t_flags & TF_SACK_PERMIT) { if (V_tcp_do_prr && to.to_flags & TOF_SACK) { tcp_timer_activate(tp, TT_REXMT, 0); tp->t_rtttime = 0; - tcp_do_prr_ack(tp, th, &to, sack_changed); + tcp_do_prr_ack(tp, th, &to, + sack_changed, &maxseg); tp->t_flags |= TF_ACKNOW; (void) tcp_output(tp); - } else - tcp_sack_partialack(tp, th); - else + } else { + tcp_sack_partialack(tp, th, + &maxseg); + } + } else { tcp_newreno_partial_ack(tp, th); - } else + } + } else { cc_post_recovery(tp, th); + } } else if (IN_CONGRECOVERY(tp->t_flags)) { if (SEQ_LT(th->th_ack, tp->snd_recover)) { if (V_tcp_do_prr) { @@ -2823,11 +2829,13 @@ resume_partialack: * During ECN cwnd reduction * always use PRR-SSRB */ - tcp_do_prr_ack(tp, th, &to, SACK_CHANGE); + tcp_do_prr_ack(tp, th, &to, SACK_CHANGE, + &maxseg); (void) tcp_output(tp); } - } else + } else { cc_post_recovery(tp, th); + } } /* * If we reach this point, ACK is not a duplicate, @@ -3946,13 +3954,18 @@ tcp_mssopt(struct in_conninfo *inc) } void -tcp_do_prr_ack(struct tcpcb *tp, struct tcphdr *th, struct tcpopt *to, sackstatus_t sack_changed) +tcp_do_prr_ack(struct tcpcb *tp, struct tcphdr *th, struct tcpopt *to, + sackstatus_t sack_changed, u_int *maxsegp) { int snd_cnt = 0, limit = 0, del_data = 0, pipe = 0; - int maxseg = tcp_maxseg(tp); + u_int maxseg; INP_WLOCK_ASSERT(tptoinpcb(tp)); + if (*maxsegp == 0) { + *maxsegp = tcp_maxseg(tp); + } + maxseg = *maxsegp; /* * Compute the amount of data that this ACK is indicating * (del_data) and an estimate of how many bytes are in the diff --git a/sys/netinet/tcp_sack.c b/sys/netinet/tcp_sack.c index f9ca83850c09..f517bb9fcdb7 100644 --- a/sys/netinet/tcp_sack.c +++ b/sys/netinet/tcp_sack.c @@ -936,13 +936,18 @@ tcp_resend_sackholes(struct tcpcb *tp) * the midst of sack recovery. */ void -tcp_sack_partialack(struct tcpcb *tp, struct tcphdr *th) +tcp_sack_partialack(struct tcpcb *tp, struct tcphdr *th, u_int *maxsegp) { struct sackhole *temp; int num_segs = 1; - u_int maxseg = tcp_maxseg(tp); + u_int maxseg; INP_WLOCK_ASSERT(tptoinpcb(tp)); + + if (*maxsegp == 0) { + *maxsegp = tcp_maxseg(tp); + } + maxseg = *maxsegp; tcp_timer_activate(tp, TT_REXMT, 0); tp->t_rtttime = 0; /* Send one or 2 segments based on how much new data was acked. */ diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index f9b3d1a5c3ee..cbe8de7988c7 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1481,14 +1481,16 @@ sackstatus_t tcp_sack_doack(struct tcpcb *, struct tcpopt *, tcp_seq); int tcp_dsack_block_exists(struct tcpcb *); void tcp_update_dsack_list(struct tcpcb *, tcp_seq, tcp_seq); -void tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_laststart, tcp_seq rcv_lastend); +void tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_laststart, + tcp_seq rcv_lastend); void tcp_clean_dsack_blocks(struct tcpcb *tp); void tcp_clean_sackreport(struct tcpcb *tp); void tcp_sack_adjust(struct tcpcb *tp); struct sackhole *tcp_sack_output(struct tcpcb *tp, int *sack_bytes_rexmt); -void tcp_do_prr_ack(struct tcpcb *, struct tcphdr *, struct tcpopt *, sackstatus_t); +void tcp_do_prr_ack(struct tcpcb *, struct tcphdr *, struct tcpopt *, + sackstatus_t, u_int *); void tcp_lost_retransmission(struct tcpcb *, struct tcphdr *); -void tcp_sack_partialack(struct tcpcb *, struct tcphdr *); +void tcp_sack_partialack(struct tcpcb *, struct tcphdr *, u_int *); void tcp_resend_sackholes(struct tcpcb *tp); void tcp_free_sackholes(struct tcpcb *tp); void tcp_sack_lost_retransmission(struct tcpcb *, struct tcphdr *);