[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140727094849.GC5965@cpaasch-mac>
Date: Sun, 27 Jul 2014 11:48:49 +0200
From: Christoph Paasch <christoph.paasch@...ouvain.be>
To: Eric Dumazet <eric.dumazet@...il.com>
Cc: Stephen Hemminger <stephen@...workplumber.org>,
David Miller <davem@...emloft.net>, netdev@...r.kernel.org,
Neal Cardwell <ncardwell@...gle.com>,
David Laight <David.Laight@...LAB.COM>,
Doug Leith <doug.leith@...m.ie>
Subject: Re: [PATCH v2 net] tcp: Fix integer-overflows in TCP vegas
On 26/07/14 - 11:54:57, Eric Dumazet wrote:
> On Sat, 2014-07-26 at 10:59 +0200, Christoph Paasch wrote:
>
> > do you mean, using "do_div"?
> >
> > David suggested to avoid using do_div in tcp_vegas.
>
> My understanding is the following :
>
> On 64bit arches, used on most servers that really care of TCP
> performance these days, do_div() is the fastest thing : No extra
> conditional.
>
> # define do_div(n,base) ({ \
> uint32_t __base = (base); \
> uint32_t __rem; \
> __rem = ((uint64_t)(n)) % __base; \
> (n) = ((uint64_t)(n)) / __base; \
> __rem; \
> })
>
>
> Then on 32bit, do_div(target_cwnd, Y) will perform a single divide
> if target_cwnd is < 2^32, which is very likely the case :
>
>
> # define do_div(n,base) ({ \
> uint32_t __base = (base); \
> uint32_t __rem; \
> (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
> if (likely(((n) >> 32) == 0)) { \
> __rem = (uint32_t)(n) % __base; \
> (n) = (uint32_t)(n) / __base; \
> } else \
> __rem = __div64_32(&(n), __base); \
> __rem; \
> })
>
>
>
> (In both cases, compiler will remove the modulo operation, as we do not use it)
I am very fine with using do_div. Indeed, cwnd and rtt must be quite high to
fall into the case of 64-bit divides.
I will wait a bit for other feedback and then send a new version with do_div.
Thanks,
Christoph
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists