i386/73921: sysctlbyname for machdep.tsc_freq doesn't handle speeds
> 2^31 Hz properly
Ted Schundler
tschundler at scu.edu
Sat Nov 13 19:10:23 PST 2004
>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:
More information about the freebsd-i386
mailing list