From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Bendik =?ISO-8859-1?Q?R=F8nning?= Opstad" Subject: Re: [PATCH RFC net-next 1/2] tcp: Add DPIFL thin stream detection mechanism Date: Sun, 25 Oct 2015 06:56:29 +0100 Message-ID: <1799007.TiMX4hfQRk@desktop> References: <1445633413-3532-1-git-send-email-bro.devel+kernel@gmail.com> <1445633413-3532-2-git-send-email-bro.devel+kernel@gmail.com> <1445636654.22974.193.camel@edumazet-glaptop2.roam.corp.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: <1445636654.22974.193.camel-XN9IlZ5yJG9HTL0Zs8A6p/gx64E7kk8eUsxypvmhUTTZJqsBc5GL+g@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Eric Dumazet Cc: "David S. Miller" , Alexey Kuznetsov , James Morris , Hideaki YOSHIFUJI , Patrick McHardy , Jonathan Corbet , Eric Dumazet , Neal Cardwell , Tom Herbert , Yuchung Cheng , Paolo Abeni , Erik Kline , Hannes Frederic Sowa , Al Viro , Jiri Pirko , Alexander Duyck , Florian Westphal , Daniel Lee , Marcelo Ricardo Leitner , Daniel Borkmann , Willem de Bruijn , =?UTF-8?Q?Linus_L=C3=BCssing?= , linux-doc-u79uwXL29TasMV2rI37PzA@public.gmane.org List-Id: linux-api@vger.kernel.org On Friday, October 23, 2015 02:44:14 PM Eric Dumazet wrote: > On Fri, 2015-10-23 at 22:50 +0200, Bendik R=F8nning Opstad wrote: >=20 > > =20 > > +/** > > + * tcp_stream_is_thin_dpifl() - Tests if the stream is thin based = on dynamic PIF > > + * limit > > + * @tp: the tcp_sock struct > > + * > > + * Return: true if current packets in flight (PIF) count is lower = than > > + * the dynamic PIF limit, else false > > + */ > > +static inline bool tcp_stream_is_thin_dpifl(const struct tcp_sock = *tp) > > +{ > > + u64 dpif_lim =3D tp->srtt_us >> 3; > > + /* Div by is_thin_min_itt_lim, the minimum allowed ITT > > + * (Inter-transmission time) in usecs. > > + */ > > + do_div(dpif_lim, tp->thin_dpifl_itt_lower_bound); > > + return tcp_packets_in_flight(tp) < dpif_lim; > > +} > > + > This is very strange : >=20 > You are using a do_div() while both operands are 32bits. A regular > divide would be ok : >=20 > u32 dpif_lim =3D (tp->srtt_us >> 3) / tp->thin_dpifl_itt_lower_bound; >=20 > But then, you can avoid the divide by using a multiply, less expensiv= e : >=20 > return (u64)tcp_packets_in_flight(tp) * tp->thin_dpifl_itt_lower_boun= d < > (tp->srtt_us >> 3); >=20 You are of course correct. Will fix this and use multiply. Thanks.