From owner-svn-src-all@FreeBSD.ORG Tue Mar 15 15:29:43 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by hub.freebsd.org (Postfix) with ESMTP id 6E449106564A; Tue, 15 Mar 2011 15:29:43 +0000 (UTC) (envelope-from jkim@FreeBSD.org) From: Jung-uk Kim To: Maxim Dounin Date: Tue, 15 Mar 2011 11:29:31 -0400 User-Agent: KMail/1.6.2 References: <201103142330.p2ENUEL8014903@svn.freebsd.org> <20110315061957.GD99496@mdounin.ru> In-Reply-To: <20110315061957.GD99496@mdounin.ru> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201103151129.34552.jkim@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r219653 - in head/sys: arm/include i386/include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Mar 2011 15:29:43 -0000 On Tuesday 15 March 2011 02:19 am, Maxim Dounin wrote: > Hello! > > On Mon, Mar 14, 2011 at 11:30:14PM +0000, Jung-uk Kim wrote: > > Author: jkim > > Date: Mon Mar 14 23:30:14 2011 > > New Revision: 219653 > > URL: http://svn.freebsd.org/changeset/base/219653 > > > > Log: > > Make get_cyclecount(9) little bit more useful where > > binuptime(9) is used. > > get_cyclecount(9) is for random harvesting, and dropping half of > it's entropy in binuptime() case may not be a good idea. I know it is used for random harvesting but we are not dropping much entropy here (if any). Because it is mostly used boot time, bt.sec is often times trivial. In other words, it only affects few lower bits (trivially) and other bits are just flipped. Basically, I am trying to preserve as much entropy as possible without losing historical get_cyclecount() semantics. > It's probably better to fix manpage instead, to clarify it's > intended usage. It had to be done long ago. :-( Jung-uk Kim > Maxim Dounin > > > Modified: > > head/sys/arm/include/cpu.h > > head/sys/i386/include/cpu.h > > > > Modified: head/sys/arm/include/cpu.h > > ================================================================= > >============= --- head/sys/arm/include/cpu.h Mon Mar 14 23:19:04 > > 2011 (r219652) +++ head/sys/arm/include/cpu.h Mon Mar 14 23:30:14 > > 2011 (r219653) @@ -16,7 +16,7 @@ get_cyclecount(void) > > struct bintime bt; > > > > binuptime(&bt); > > - return (bt.frac ^ bt.sec); > > + return ((uint64_t)bt.sec << 56 | bt.frac >> 8); > > > > } > > #endif > > > > Modified: head/sys/i386/include/cpu.h > > ================================================================= > >============= --- head/sys/i386/include/cpu.h Mon Mar 14 23:19:04 > > 2011 (r219652) +++ head/sys/i386/include/cpu.h Mon Mar 14 > > 23:30:14 2011 (r219653) @@ -67,7 +67,7 @@ void swi_vm(void *); > > * Return contents of in-cpu fast counter as a sort of > > "bogo-time" * for random-harvesting purposes. > > */ > > -static __inline u_int64_t > > +static __inline uint64_t > > get_cyclecount(void) > > { > > #if defined(I486_CPU) || defined(KLD_MODULE) > > @@ -75,7 +75,7 @@ get_cyclecount(void) > > > > if (!tsc_present) { > > binuptime(&bt); > > - return (bt.frac ^ bt.sec); > > + return ((uint64_t)bt.sec << 56 | bt.frac >> 8); > > } > > #endif > > return (rdtsc()); > > _______________________________________________ > > svn-src-all@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/svn-src-all > > To unsubscribe, send any mail to > > "svn-src-all-unsubscribe@freebsd.org"