mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@kernel.org>
To: chia-yu.chang@nokia-bell-labs.com
Cc: linux-kernel@vger.kernel.org, kuba@kernel.org,
	netdev@vger.kernel.org,  pabeni@redhat.com, davem@davemloft.net,
	kuniyu@google.com, ij@kernel.org,  ncardwell@google.com,
	koen0607@gmail.com, g.white@cablelabs.com,
	 ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com,
	 cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com,
	 vidhi_goel@apple.com, Mike_Rudolph@comcast.com,
	Jeff_Howe@comcast.com,  srichard@netapp.com,
	Olivier Tilmans <olivier.tilmans@nokia.com>
Subject: Re: [PATCH net-next v4 1/4] tcp: export CE count in rate_sample
Date: Thu, 19 Nov 2026 19:46:37 +0100	[thread overview]
Message-ID: <CAL4WiirdYsiR9a2BtHO4MtPtJX3st48mtfAwTvzft5JuQXT59g@mail.gmail.com> (raw)
In-Reply-To: <20261119180143.2912138-2-chia-yu.chang@nokia-bell-labs.com>

Le jeu. 19 nov. 2026 à 19:01, <chia-yu.chang@nokia-bell-labs.com> a écrit :
>
> From: Ilpo Järvinen <ij@kernel.org>
>
> Store the number of newly ACKed/SACKed CE-marked packets in rate_sample.
> This will be used by upcoming congestion control algorithms, e.g.,
> TCP Prague, that need access to AccECN-derived congestion info.
>
> For RFC3168 ECN mode, acked_sacked_ce equals delivered when FLAG_ECE
> is present. For AccECN mode, it carries the derived CE-marked packets
> from AccECN options or ACE field based on RFC9768.
>
> Signed-off-by: Ilpo Järvinen <ij@kernel.org>
> Co-developed-by: Olivier Tilmans <olivier.tilmans@nokia.com>
> Signed-off-by: Olivier Tilmans <olivier.tilmans@nokia.com>
> Co-developed-by: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
> Signed-off-by: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
>
> --
> v3:
> - Improve commit message
> - Rename ece_delta to acked_sacked_ce
> - Remove redundant rate_sample initializer
> ---
>  include/net/tcp.h    |  1 +
>  net/ipv4/tcp_input.c | 40 +++++++++++++++++++---------------------
>  2 files changed, 20 insertions(+), 21 deletions(-)
>
> diff --git a/include/net/tcp.h b/include/net/tcp.h
> index 25d11fab1b03..4b1159e6c125 100644
> --- a/include/net/tcp.h
> +++ b/include/net/tcp.h
> @@ -1353,6 +1353,7 @@ struct rate_sample {
>         long rtt_us;            /* RTT of last (S)ACKed packet (or -1) */
>         int  losses;            /* number of packets marked lost upon ACK */
>         u32  acked_sacked;      /* number of packets newly (S)ACKed upon ACK */
> +       u32  acked_sacked_ce;   /* number of packets ECE-marked upon ACK */

I presume you meant "CE-marked" instead of "ECE-marked"

>         u32  prior_in_flight;   /* in flight before this ACK */
>         u32  last_end_seq;      /* end_seq of most recently ACKed packet */
>         bool is_app_limited;    /* is sample from packet with bubble in pipe? */
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index 67e4aa73bd6a..72826cafa246 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -616,9 +616,10 @@ static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb,
>         return safe_delta;
>  }
>
> -static u32 tcp_accecn_process(struct sock *sk, const struct sk_buff *skb,
> -                             u32 delivered_pkts, u32 delivered_bytes,
> -                             u64 prior_bytes_acked, int *flag)
> +static void tcp_accecn_process(struct sock *sk, struct rate_sample *rs,
> +                              const struct sk_buff *skb, u32 delivered_pkts,
> +                              u32 delivered_bytes, u64 prior_bytes_acked,
> +                              int *flag)
>  {
>         struct tcp_sock *tp = tcp_sk(sk);
>         u32 delta;
> @@ -628,11 +629,11 @@ static u32 tcp_accecn_process(struct sock *sk, const struct sk_buff *skb,
>         if (delta > 0) {
>                 tcp_count_delivered_ce(tp, delta);
>                 *flag |= FLAG_ECE;
> +               rs->acked_sacked_ce = delta;
>                 /* Recalculate header predictor */
>                 if (tp->pred_flags)
>                         tcp_fast_path_on(tp);
>         }
> -       return delta;
>  }
>
>  /* Buffer size and advertised window tuning.
> @@ -4248,8 +4249,8 @@ static void tcp_xmit_recovery(struct sock *sk, int rexmit)
>  }
>
>  /* Returns the number of packets newly acked or sacked by the current ACK */
> -static u32 tcp_newly_delivered(struct sock *sk, u32 prior_delivered,
> -                              u32 ecn_count, int flag)
> +static u32 tcp_newly_delivered(struct sock *sk, struct rate_sample *rs,
> +                              u32 prior_delivered, int flag)
>  {
>         const struct net *net = sock_net(sk);
>         struct tcp_sock *tp = tcp_sk(sk);
> @@ -4260,8 +4261,9 @@ static u32 tcp_newly_delivered(struct sock *sk, u32 prior_delivered,
>
>         if (flag & FLAG_ECE) {
>                 if (tcp_ecn_mode_rfc3168(tp))
> -                       ecn_count = delivered;
> -               NET_ADD_STATS(net, LINUX_MIB_TCPDELIVEREDCE, ecn_count);
> +                       rs->acked_sacked_ce = delivered;
> +               NET_ADD_STATS(net, LINUX_MIB_TCPDELIVEREDCE,
> +                             rs->acked_sacked_ce);

In RFC 3168 mode this is every packet delivered by an ACK carrying
ECE, not the number of CE-marked packets. This was fine for a MIB
counter, but once exposed to congestion control modules it should be
documented in the field comment, especially since rate_sample already
has delivered_ce with a different meaning.

>         }
>
>         return delivered;
> @@ -4327,7 +4329,6 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
>         u32 delivered = tp->delivered;
>         u32 lost = tp->lost;
>         int rexmit = REXMIT_NONE; /* Flag to (re)transmit to recover losses */
> -       u32 ecn_count = 0;        /* Did we receive ECE/an AccECN ACE update? */
>         u32 prior_fack;
>
>         sack_state.first_sackt = 0;
> @@ -4441,10 +4442,9 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
>         tcp_rack_update_reo_wnd(sk, &rs);
>
>         if (tcp_ecn_mode_accecn(tp))
> -               ecn_count = tcp_accecn_process(sk, skb,
> -                                              tp->delivered - delivered,
> -                                              sack_state.delivered_bytes,
> -                                              prior_bytes_acked, &flag);
> +               tcp_accecn_process(sk, &rs, skb, tp->delivered - delivered,
> +                                  sack_state.delivered_bytes,
> +                                  prior_bytes_acked, &flag);
>
>         tcp_in_ack_event(sk, flag);
>
> @@ -4470,7 +4470,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
>         if ((flag & FLAG_FORWARD_PROGRESS) || !(flag & FLAG_NOT_DUP))
>                 sk_dst_confirm(sk);
>
> -       delivered = tcp_newly_delivered(sk, delivered, ecn_count, flag);
> +       delivered = tcp_newly_delivered(sk, &rs, delivered, flag);
>
>         lost = tp->lost - lost;                 /* freshly marked lost */
>         rs.is_ack_delayed = !!(flag & FLAG_ACK_MAYBE_DELAYED);
> @@ -4481,17 +4481,15 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
>
>  no_queue:
>         if (tcp_ecn_mode_accecn(tp))
> -               ecn_count = tcp_accecn_process(sk, skb,
> -                                              tp->delivered - delivered,
> -                                              sack_state.delivered_bytes,
> -                                              prior_bytes_acked, &flag);
> -
> +               tcp_accecn_process(sk, &rs, skb, tp->delivered - delivered,
> +                                  sack_state.delivered_bytes,
> +                                  prior_bytes_acked, &flag);
>         tcp_in_ack_event(sk, flag);
>         /* If data was DSACKed, see if we can undo a cwnd reduction. */
>         if (flag & FLAG_DSACKING_ACK) {
>                 tcp_fastretrans_alert(sk, prior_snd_una, num_dupack, &flag,
>                                       &rexmit);
> -               tcp_newly_delivered(sk, delivered, ecn_count, flag);
> +               tcp_newly_delivered(sk, &rs, delivered, flag);
>         }
>         /* If this ack opens up a zero window, clear backoff.  It was
>          * being used to time the probes, and is probably far higher than
> @@ -4518,7 +4516,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
>                                                 &sack_state);
>                 tcp_fastretrans_alert(sk, prior_snd_una, num_dupack, &flag,
>                                       &rexmit);
> -               tcp_newly_delivered(sk, delivered, ecn_count, flag);
> +               tcp_newly_delivered(sk, &rs, delivered, flag);
>                 tcp_xmit_recovery(sk, rexmit);
>         }
>
> --
> 2.34.1
>

  reply	other threads:[~2026-11-19 18:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 18:01 [PATCH net-next v4 0/4] TCP Prague preparation series chia-yu.chang
2026-11-19 18:01 ` [PATCH net-next v4 1/4] tcp: export CE count in rate_sample chia-yu.chang
2026-11-19 18:46   ` Eric Dumazet [this message]
2026-11-19 18:01 ` [PATCH net-next v4 2/4] tcp: rename ECN transmit helper function chia-yu.chang
2026-11-19 18:59   ` Eric Dumazet
2026-11-19 18:01 ` [PATCH net-next v4 3/4] tcp: add TCP_ECN_SEND_ECT_1 flag for congestion control chia-yu.chang
2026-11-19 18:48   ` Eric Dumazet
2026-11-19 18:01 ` [PATCH net-next v4 4/4] tcp: add MSS ceiling callback " chia-yu.chang
2026-11-19 18:54   ` Eric Dumazet
2026-11-19 18:41 ` [PATCH net-next v4 0/4] TCP Prague preparation series Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAL4WiirdYsiR9a2BtHO4MtPtJX3st48mtfAwTvzft5JuQXT59g@mail.gmail.com \
    --to=edumazet@kernel.org \
    --cc=Jason_Livingood@comcast.com \
    --cc=Jeff_Howe@comcast.com \
    --cc=Mike_Rudolph@comcast.com \
    --cc=cheshire@apple.com \
    --cc=chia-yu.chang@nokia-bell-labs.com \
    --cc=davem@davemloft.net \
    --cc=g.white@cablelabs.com \
    --cc=ij@kernel.org \
    --cc=ingemar.s.johansson@ericsson.com \
    --cc=koen0607@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mirja.kuehlewind@ericsson.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=olivier.tilmans@nokia.com \
    --cc=pabeni@redhat.com \
    --cc=rs.ietf@gmx.at \
    --cc=srichard@netapp.com \
    --cc=vidhi_goel@apple.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®