From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751341AbbJYF4f (ORCPT ); Sun, 25 Oct 2015 01:56:35 -0400 Received: from mail-wi0-f194.google.com ([209.85.212.194]:34513 "EHLO mail-wi0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750797AbbJYF4c convert rfc822-to-8bit (ORCPT ); Sun, 25 Oct 2015 01:56:32 -0400 From: "Bendik =?ISO-8859-1?Q?R=F8nning?= Opstad" X-Google-Original-From: Bendik =?ISO-8859-1?Q?R=F8nning?= Opstad 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@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-api@vger.kernel.org, Andreas Petlund , Carsten Griwodz , =?UTF-8?Q?P=C3=A5l_Halvorsen?= , Jonas Markussen , Kristian Evensen , Kenneth Klette Jonassen 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> User-Agent: KMail/4.14.6 (Linux/3.19.0-30-generic; KDE/4.14.6; x86_64; ; ) In-Reply-To: <1445636654.22974.193.camel@edumazet-glaptop2.roam.corp.google.com> 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-Transfer-Encoding: 8BIT Content-Type: text/plain; charset="iso-8859-1" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@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ønning Opstad wrote: > > > > > +/** > > + * 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 = 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 : > > You are using a do_div() while both operands are 32bits. A regular > divide would be ok : > > u32 dpif_lim = (tp->srtt_us >> 3) / tp->thin_dpifl_itt_lower_bound; > > But then, you can avoid the divide by using a multiply, less expensive : > > return (u64)tcp_packets_in_flight(tp) * tp->thin_dpifl_itt_lower_bound < > (tp->srtt_us >> 3); > You are of course correct. Will fix this and use multiply. Thanks.