lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 1 Feb 2007 14:54:45 +0100
From:	Jiri Bohac <jbohac@...e.cz>
To:	Andi Kleen <ak@...e.de>
Cc:	jbohac@...e.cz, linux-kernel@...r.kernel.org,
	Vojtech Pavlik <vojtech@...e.cz>, ssouhlal@...ebsd.org,
	arjan@...radead.org, tglx@...utronix.de, johnstul@...ibm.com,
	zippel@...ux-m68k.org, andrea@...e.de
Subject: Re: [patch 8/9] Add time_update_mt_guess()

On Thu, Feb 01, 2007 at 12:28:50PM +0100, Andi Kleen wrote:
> On Thursday 01 February 2007 11:00, jbohac@...e.cz wrote:
> > +inline u64 mt_to_nsec(u64 mt)
> > +{
> > +	u64 ret;
> > +	ret  = ((mt & 0xffffff) * vxtime.mt_q) >> 32;
> > +	mt >>= 24;
> > +	ret += ((mt & 0xffffff) * vxtime.mt_q) >> 8;
> > +	mt >>= 24;
> > +	ret += ( mt             * vxtime.mt_q) << 16;
> > +	return ret;
> 
> Why so complicated? Isn't a single multiply good enough?

This does a multiplication and a downshift at once. The problem
is, that if we first do the multipclication, the result won't fit
in 64 bits.

If we first do the downshift, we lose precision.

This does both operations at once, avoiding both the overflow and
underflow.

-- 
Jiri Bohac <jbohac@...e.cz>
SUSE Labs, SUSE CZ

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ