[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] xl: Need help with overflow and error handling for vif rate support



On Thu, 2012-03-29 at 15:36 +0100, Ian Jackson wrote:
> Ian Campbell writes ("Re: [Xen-devel] xl: Need help with overflow and error 
> handling for vif rate support"):
> > On Tue, 2012-03-27 at 18:04 +0100, Mathieu Gagnà wrote:
> > > - How should I check for overflows when multiplying 2 uint64_t together?
> > >    - I'm currently using math.h and log. Is it the correct approach?
> > 
> > You can check if A*B > UINT64_MAX by first checking
> >     if B != 0 && A > UINT64_MAX/B
> >             WOULD OVERFLOW
> 
> Another approach is to limit both A and B to less than
> sqrt(UINT64_MAX), or to limit each of them to some smaller number.

I looked at that, you can limit the interval ok to even less than that
but the rate would ideally have the possibility to be bigger than this
would allow.

I ran some vague numbers using 1s as the max interval and the rate was
in the several 10s of gigabytes, which is a lot today but not very
future proof...

> 
> Or use floating point, and do a check at the end when you convert it
> back.
> 
> Ian.



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.