From: Simon Kirby <sim@hostway.ca>
To: Julian Anastasov <ja@ssi.bg>
Cc: lvs-devel@vger.kernel.org, Changli Gao <xiaosuo@gmail.com>
Subject: Re: activeconns * weight overflowing 32-bit int
Date: Thu, 23 May 2013 09:58:36 -0700 [thread overview]
Message-ID: <20130523165836.GC436@hostway.ca> (raw)
In-Reply-To: <alpine.LFD.2.00.1305220915480.1953@ja.ssi.bg>
On Wed, May 22, 2013 at 09:18:03AM +0300, Julian Anastasov wrote:
> > > With b552f7e3a9524abcbcdf86f0a99b2be58e55a9c6, which "git tag --contains"
> > > says appeared in 2.6.39-rc, the open-coded activeconns * 50 + inactconns
> > > was changed to ip_vs_dest_conn_overhead() that matches the implementation
> > > in ip_vs_wlc.c and others. The problem for us is that ip_vs_lblc.c uses
> > > "int" (and wlc uses "unsigned int") for "loh" and "doh" variables that
> > > the ip_vs_dest_conn_overhead() result is stored in, and then these are
> > > multiplied by the weight.
> > >
> > > ip_vs_dest_conn_overhead() uses (activeconns << 8) + inactconns (* 256
> > > instead of * 50), so before where 3000 * 3000 * 50 would fit in an int,
> > > 3000 * 3000 * 256 does not.
> >
> > There is no big difference between 50 and 256.
> >
> > > We really don't care about inactconns, so removing the "<< 8" and just
> > > using activeconns would work for us, but I suspect it must be there for a
> > > raeason. "unsigned long" would fix the problem only for 64-bit arches.
> > > Using __u64 would work everywhere, but perhaps be slow on 32-bit arches.
> > > Thoughts?
> >
> > May be we can avoid 64-bit multiply with a
> > 32*32=>64 optimization, for example:
> >
> > - if (loh * atomic_read(&dest->weight) >
> > - doh * atomic_read(&least->weight)) {
> > + if ((__u64) loh * atomic_read(&dest->weight) >
> > + (__u64) doh * atomic_read(&least->weight)) {
> >
> > May be __s64/__u64 does not matter here. Can you
> > create and test such patch for lblc and lblcr against
> > ipvs-next or net-next tree? Such change should be also
> > applied to other schedulers but it does not look so critical.
>
> Any progress on this problem?
Hello!
Yes, see: http://0x.ca/sim/ref/3.9-ipvs/
The case of just (__u64) on i386 looks not very good, but making the
weight also unsigned (__u32) seems to improve things. I set up a test
harness (ipvs.c) and disassembled i386 and amd64 compiler outputs for
both. The only reason I haven't submitted it yet is that I haven't yet
confirmed that it fixes our problem in production, though it did seem to
work in testing. Will follow-up shortly.
Simon-
next prev parent reply other threads:[~2013-05-23 16:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-13 6:43 activeconns * weight overflowing 32-bit int Simon Kirby
2013-04-13 15:10 ` Julian Anastasov
2013-05-22 6:18 ` Julian Anastasov
2013-05-23 16:58 ` Simon Kirby [this message]
2013-05-23 20:44 ` Julian Anastasov
2013-05-24 0:43 ` Simon Kirby
2013-05-24 8:11 ` Julian Anastasov
2013-08-05 6:10 ` Julian Anastasov
2013-08-06 2:41 ` Simon Kirby
2013-08-06 6:45 ` Julian Anastasov
2013-08-08 23:54 ` [PATCH] ipvs: Use 64-bit comparisons (connections * weight) to avoid overflow Simon Kirby
2013-08-09 9:02 ` Julian Anastasov
2013-08-10 8:26 ` [PATCH v2] ipvs: fix overflow on dest weight multiply Simon Kirby
2013-08-10 12:31 ` Julian Anastasov
2013-08-13 2:23 ` Simon Horman
2013-08-13 4:45 ` Simon Horman
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=20130523165836.GC436@hostway.ca \
--to=sim@hostway.ca \
--cc=ja@ssi.bg \
--cc=lvs-devel@vger.kernel.org \
--cc=xiaosuo@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.