Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Nov 2004 03:01:49 GMT
From:      Ted Schundler <tschundler@scu.edu>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   i386/73921: sysctlbyname for machdep.tsc_freq doesn't handle speeds > 2^31 Hz properly
Message-ID:  <200411140301.iAE31n1e003404@www.freebsd.org>
Resent-Message-ID: <200411140310.iAE3ANgK060101@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         73921
>Category:       i386
>Synopsis:       sysctlbyname for machdep.tsc_freq doesn't handle speeds > 2^31 Hz properly
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-i386
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 14 03:10:23 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Ted Schundler
>Release:        5.3-STABLE
>Organization:
>Environment:
FreeBSD ****.scu.edu 5.3-STABLE FreeBSD 5.3-STABLE #4: Mon Oct 18 15:50:18 PDT 2004     ted@****.scu.edu:/usr/obj/usr/src/sys/GX280  i386

>Description:
In an app that needs the CPU speed, I'm calling sysctlbyname("machdep.tsc_freq",.... with an 64-bit long long (so when 5GHz CPUs come around, it should still work). However I'm getting very large numbers are a result. It seems that internally it is getting the value as a 32 bit integer and converting that to 64 bits by extending the sign. It shouldn't be 32 bits to begin with imho, but even if it is, it should at least be treated as unsigned.
>How-To-Repeat:
On a sufficiently fast system (in my case 3.1Ghz):

  unsigned long long sysctl_data;
  bl=8;
  sysctlbyname("machdep.tsc_freq", &sysctl_data,&bl,NULL,0);
  printf("cpuspeed: %llu\n",sysctl_data);

result:
cpuspeed: 13817017134246676192

should be:
spuspeed: 3192014560
>Fix:
      
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200411140301.iAE31n1e003404>