From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B4D82DEA6E for ; Thu, 6 Nov 2025 20:24:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762460685; cv=none; b=O9GgYWmL/RolnFs5VrMr/2upTmk9xRuzGKcy7hKnqhoobg5aJMsw/i2uMQ9g+BT/dwptyit2UjwbAmIsk0zIUvQZ1LozTZS5MZUN66kRmv1UMRTx2OhYqY8mqJOKIMqyG6zg6zfb+ykbTYTUw2gF4WKgwl+WcusR2Tg9kFSpJJs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762460685; c=relaxed/simple; bh=Im9QWWxJXdZqz7HeLFWXZzmI9TfaqMlaB4gqcycUoss=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=HyTIYKjDufB2FSMWlNdBU0YDY3AmOUTvQK+zDYKrdnnMoPOCn0g/C4/I2oW6x6/KFYoPrtR/FnD6mYqHARcN2jNw9P4hEaq+fvjCoZQSzF7XIMmDw0aYyFhbs6tJrXKth+F16Ry3fPOMUvJJeC4VFJnSfbq6wI/pI1kKdUh5EdI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Aeywhely; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Aeywhely" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-294fd2ca6acso259315ad.0 for ; Thu, 06 Nov 2025 12:24:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762460683; x=1763065483; darn=lists.linux.dev; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=z3gyUgZQhfQPtS7SLCIDf6NbyslQ68pOuETZ2b4hfpg=; b=AeywhelyyRhVcvSTW5y3qzPZq1yeX+dXisADbZ3JKd4uVPjv/pFaamY0X+1I2chheS u/DthJrAlDw/PqyJhmeWfau1mfTin+7Un5mp9O1YktcCkwJDFIOHb3dW99UdNAiiD1UT ydxC+PTjegyyTA50+APXn36NKGA8i/grDZA9rhICefo3X6pqG0ASknGxDTBwoRfyJmHt i/v2xqYgPJX37cITm13tl4b/jAiRUMUoS31HITVotmkuPWbOIhsZjQOwK2zdoAgLnYit jKEe50nShTsZJ5O3qzJpwszrs91GOkVjA8mJUi22qZ/j50f5ckGI0MhM6yJP42hroqp7 CnhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762460683; x=1763065483; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=z3gyUgZQhfQPtS7SLCIDf6NbyslQ68pOuETZ2b4hfpg=; b=q5NiWKhS/YESVpOHmuTOK+UbaD/CZbrSDsDdEvY5N/n8ZNHZ9HkH5fktGeVdTRoFXo 0lkcWPPqSBiHPUJGewA5RJJpZrdWMdnYTIvVPRQW3VZyr5dXqBVIlQPOtu8LDeqEmSbT zIdTJsEcLaCJiKDfD00/OzQG15gJ/ndL/95E0EsHsqJSFNHis4gcJOSFxAo/uAik1Rfz DFxHh+EcArp57U8JiLqVwegUoxtgi+612dumxicQmoU1iWaTQFZ098fRLQm8uUMg01C0 SIZa+BHfFgEm4VFJtcSY3Q+JK38y0rFjYYxYailSPnoVkuf3SSzU/0Ryrceo9AnVKazY 8Gvw== X-Forwarded-Encrypted: i=1; AJvYcCXUHMaJNSi6z9PsEuOOmuL2qqGrLVkHqiDcAZodkknbyIWtUOBqh2NXAAzaq88BZZl8hcyK@lists.linux.dev X-Gm-Message-State: AOJu0Yz/JGr8E0kUjl9Q3N0l+CB3O6rzo55+tZI1LpBA2zxbRFyQfUY3 2JM4JBlZL8u09j048wYzO/SQrwf3lSa7wB5N+Q6m7Cih5otQu6OZZXLmFav2TCzne/rpstDWX4P mpIt5crPaXmd64z4kephKI7x5uwqcIA4= X-Gm-Gg: ASbGnctC+vjyHd6oAABqbu/E3KLOwTMsPWvf6whG+MCGJ6SyRXqY2H66YT5TznGrF03 zUqriJbKej76Y6UAy1+gW241Yd+yiIb6W4d/c0/RNv9c/cf0vvgypNtsMHH6ALlbvkK2tPYTwYp DXU2osLWx3KY5SZ3QmlnFwE9pq9s4mwcNIGnSkCCPSzlJhueYWeIBlAXmve625egH/JzQ60H8It MD+x/0VURHMCvgqE++UPSrsbHLT7ys7SOQU9rVcm2HHKNT4m7DXYuSdkUFogMPhy6y3VYTd+NYQ W10jk4QFba1wzMdW6CJX4Aj6mgDEWg== X-Google-Smtp-Source: AGHT+IGTWzJU0xlvlovHbYWoDH5XM24Ae1wEThKwWG8ycDKpQ4Pza4FucwMrn4xnT46tQsURsHTnLGHE4XvA3l/bTbM= X-Received: by 2002:a17:902:da86:b0:267:912b:2b36 with SMTP id d9443c01a7336-297c00de2ecmr9261995ad.23.1762460682652; Thu, 06 Nov 2025 12:24:42 -0800 (PST) Precedence: bulk X-Mailing-List: quic@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <32c7730d3b0f6e5323d289d5bdfd01fc22d551b5.1761748557.git.lucien.xin@gmail.com> <43ea4062-75a8-4152-bf19-2eca561036bd@redhat.com> In-Reply-To: <43ea4062-75a8-4152-bf19-2eca561036bd@redhat.com> From: Xin Long Date: Thu, 6 Nov 2025 15:24:30 -0500 X-Gm-Features: AWmQ_blGjOQ50fcZQT5EtzHNncMYn6qzWEjBf9UHnF498_0zXTgvgxEng025WXQ Message-ID: Subject: Re: [PATCH net-next v4 09/15] quic: add congestion control To: Paolo Abeni Cc: network dev , quic@lists.linux.dev, davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Simon Horman , Stefan Metzmacher , Moritz Buhl , Tyler Fanelli , Pengtao He , Thomas Dreibholz , linux-cifs@vger.kernel.org, Steve French , Namjae Jeon , Paulo Alcantara , Tom Talpey , kernel-tls-handshake@lists.linux.dev, Chuck Lever , Jeff Layton , Steve Dickson , Hannes Reinecke , Alexander Aring , David Howells , Matthieu Baerts , John Ericson , Cong Wang , "D . Wythe" , Jason Baron , illiliti , Sabrina Dubroca , Marcelo Ricardo Leitner , Daniel Stenberg , Andy Gospodarek Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Nov 4, 2025 at 7:02=E2=80=AFAM Paolo Abeni wrot= e: > > On 10/29/25 3:35 PM, Xin Long wrote: > > +/* Compute and update the pacing rate based on congestion window and s= moothed RTT. */ > > +static void quic_cong_pace_update(struct quic_cong *cong, u32 bytes, u= 32 max_rate) > > +{ > > + u64 rate; > > + > > + /* rate =3D N * congestion_window / smoothed_rtt */ > > + rate =3D (u64)cong->window * USEC_PER_SEC * 2; > > + if (likely(cong->smoothed_rtt)) > > + rate =3D div64_ul(rate, cong->smoothed_rtt); > > + > > + WRITE_ONCE(cong->pacing_rate, min_t(u64, rate, max_rate)); > > + pr_debug("%s: update pacing rate: %u, max rate: %u, srtt: %u\n", > > + __func__, cong->pacing_rate, max_rate, cong->smoothed_rt= t); > > I think you should skip entirely the pacing_rate update when > `smoothed_rtt =3D=3D 0` > will update it. > [...]> +/* rfc9002#section-5: Estimating the Round-Trip Time */ > > +void quic_cong_rtt_update(struct quic_cong *cong, u32 time, u32 ack_de= lay) > > +{ > > + u32 adjusted_rtt, rttvar_sample; > > + > > + /* Ignore RTT sample if ACK delay is suspiciously large. */ > > + if (ack_delay > cong->max_ack_delay * 2) > > + return; > > + > > + /* rfc9002#section-5.1: latest_rtt =3D ack_time - send_time_of_la= rgest_acked */ > > + cong->latest_rtt =3D cong->time - time; > > + > > + /* rfc9002#section-5.2: Estimating min_rtt */ > > + if (!cong->min_rtt_valid) { > > + cong->min_rtt =3D cong->latest_rtt; > > + cong->min_rtt_valid =3D 1; > > + } > > + if (cong->min_rtt > cong->latest_rtt) > > + cong->min_rtt =3D cong->latest_rtt; > > + > > + if (!cong->is_rtt_set) { > > + /* rfc9002#section-5.3: > > + * smoothed_rtt =3D latest_rtt > > + * rttvar =3D latest_rtt / 2 > > + */ > > + cong->smoothed_rtt =3D cong->latest_rtt; > > + cong->rttvar =3D cong->smoothed_rtt / 2; > > + quic_cong_pto_update(cong); > > + cong->is_rtt_set =3D 1; > > + return; > > + } > > + > > + /* rfc9002#section-5.3: > > + * adjusted_rtt =3D latest_rtt > > + * if (latest_rtt >=3D min_rtt + ack_delay): > > + * adjusted_rtt =3D latest_rtt - ack_delay > > + * smoothed_rtt =3D 7/8 * smoothed_rtt + 1/8 * adjusted_rtt > > + * rttvar_sample =3D abs(smoothed_rtt - adjusted_rtt) > > + * rttvar =3D 3/4 * rttvar + 1/4 * rttvar_sample > > + */ > > + adjusted_rtt =3D cong->latest_rtt; > > + if (cong->latest_rtt >=3D cong->min_rtt + ack_delay) > > + adjusted_rtt =3D cong->latest_rtt - ack_delay; > > + > > + cong->smoothed_rtt =3D (cong->smoothed_rtt * 7 + adjusted_rtt) / = 8; > > Out of sheer curiosity, is the compiler smart enough to use a 'srl 3' > for the above? > Yes. 266 cong->smoothed_rtt =3D (cong->smoothed_rtt * 7 + adjusted_rtt) / 8; 0x593d <+77>: mov (%rbx),%ecx ; ecx =3D cong->smoothed_rtt 0x593f <+79>: lea (%rax,%rcx,8),%edx ; edx =3D adjusted_rtt + (ecx * = 8) 0x5942 <+82>: sub %ecx,%edx ; edx =3D adjusted_rtt + (8*ecx) - ecx =3D ecx*7 + adjusted_rtt 0x5946 <+86>: shr $0x3,%edx ; edx >>=3D 3 =E2=86=92 divide by= 8 0x594d <+93>: mov %edx,(%rbx) ; store result back to cong->smoothed_rtt Thanks.