From owner-svn-src-head@FreeBSD.ORG Thu Mar 17 12:55:35 2011 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 897C0106566B; Thu, 17 Mar 2011 12:55:35 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail02.syd.optusnet.com.au (mail02.syd.optusnet.com.au [211.29.132.183]) by mx1.freebsd.org (Postfix) with ESMTP id 2522D8FC0A; Thu, 17 Mar 2011 12:55:34 +0000 (UTC) Received: from c122-107-125-80.carlnfd1.nsw.optusnet.com.au (c122-107-125-80.carlnfd1.nsw.optusnet.com.au [122.107.125.80]) by mail02.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p2HCtVGe003922 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 17 Mar 2011 23:55:32 +1100 Date: Thu, 17 Mar 2011 23:55:31 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Jung-uk Kim In-Reply-To: <201103161609.p2GG98q6097329@svn.freebsd.org> Message-ID: <20110317234320.E1128@besplex.bde.org> References: <201103161609.p2GG98q6097329@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r219698 - head/sys/i386/include X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Mar 2011 12:55:35 -0000 On Wed, 16 Mar 2011, Jung-uk Kim wrote: > Log: > Rework r219679. Always check CPU class at run-time to make it predictable. > Unfortunately, it pulls in but it is small enough and > namespace pollution is minimal, I hope. > > Pointed out by: bde Well, I don't like the namespace pollution, and the old code carefully avoided it by using the tsc_present global. > Modified: head/sys/i386/include/cpu.h > ============================================================================== > --- head/sys/i386/include/cpu.h Wed Mar 16 12:40:58 2011 (r219697) > +++ head/sys/i386/include/cpu.h Wed Mar 16 16:09:08 2011 (r219698) > @@ -39,6 +39,7 @@ > /* > * Definitions unique to i386 cpu support. > */ > +#include > #include > #include > #include > @@ -69,14 +70,13 @@ void swi_vm(void *); > static __inline uint64_t > get_cyclecount(void) > { > -#if defined(I486_CPU) || defined(KLD_MODULE) > struct bintime bt; > > - binuptime(&bt); > - return ((uint64_t)bt.sec << 56 | bt.frac >> 8); > -#else > + if (cpu_class == CPUCLASS_486) { > + binuptime(&bt); > + return ((uint64_t)bt.sec << 56 | bt.frac >> 8); > + } > return (rdtsc()); > -#endif > } > > #endif cpu_class shouldn't be used for anything, and might not be able to correctly classify whether the CPU has a TSC. The cpu feature for this should be used. Using it directly with the correct includes would give considerably more namespace pollution (md_var.h for cpu_feature and specialreg.h for CPUID_TSC). Although I said that tsc_present should go, it seems to be the best thing to use here. Rename it __cpu_feature_TSC to reflect that it is exactly (cpu_feature & CPUID_TSC) and put underscores in its name so as to start being even more careful about namespace pollution in cpu.h. Or redeclare cpu_feature and CPUID_TSC. Bruce