svn commit: r220584 - in head/sys: amd64/amd64 i386/i386

Dimitry Andric dim at FreeBSD.org
Wed Apr 13 21:41:32 UTC 2011


On 2011-04-13 01:49, Jung-uk Kim wrote:
> Author: jkim
> Date: Tue Apr 12 23:49:07 2011
> New Revision: 220584
> URL: http://svn.freebsd.org/changeset/base/220584
>
> Log:
>    Reduce errors in effective frequency calculation.
>
> Modified:
>    head/sys/amd64/amd64/machdep.c
>    head/sys/i386/i386/machdep.c
>
> Modified: head/sys/amd64/amd64/machdep.c
> ==============================================================================
> --- head/sys/amd64/amd64/machdep.c	Tue Apr 12 23:04:01 2011	(r220583)
> +++ head/sys/amd64/amd64/machdep.c	Tue Apr 12 23:49:07 2011	(r220584)
> @@ -546,7 +546,7 @@ int
>   cpu_est_clockrate(int cpu_id, uint64_t *rate)
>   {
>   	uint64_t tsc1, tsc2;
> -	uint64_t acnt, mcnt;
> +	uint64_t acnt, mcnt, perf;
>   	register_t reg;
>
>   	if (pcpu_find(cpu_id) == NULL || rate == NULL)
> @@ -579,7 +579,8 @@ cpu_est_clockrate(int cpu_id, uint64_t *
>   		acnt = rdmsr(MSR_APERF);
>   		tsc2 = rdtsc();
>   		intr_restore(reg);
> -		*rate = (tsc2 - tsc1) / 1000 * acnt / mcnt * 1000000;
> +		perf = 1000 * acnt / mcnt;
> +		*rate = (tsc2 - tsc1) * perf;
>   	} else {
>   		tsc1 = rdtsc();
>   		DELAY(1000);

Hmm...  on my VMs this now leads to:

Fatal trap 18: integer divide fault while in kernel mode
cpuid = 0; apic id = 00
instruction pointer     = 0x20:0xffffffff809c908d
stack pointer           = 0x28:0xffffff80f6a14850
frame pointer           = 0x28:0xffffff80f6a14880
code segment            = base 0x0, limit 0xfffff, type 0x1b
                         = DPL 0, pres 1, long 1, def32 0, gran 1
processor eflags        = interrupt enabled, resume, IOPL = 0
current process         = 54 (sysctl)
[ thread pid 54 tid 100060 ]
Stopped at      cpu_est_clockrate+0x11d:        divq    %rdi,%eax
db> bt
Tracing pid 54 tid 100060 td 0xfffffe0002dbe8c0
cpu_est_clockrate() at cpu_est_clockrate+0x11d
cf_get_method() at cf_get_method+0x2d4
cpufreq_curr_sysctl() at cpufreq_curr_sysctl+0x6c
sysctl_root() at sysctl_root+0x19d
userland_sysctl() at userland_sysctl+0x1a4
__sysctl() at __sysctl+0x75
syscallenter() at syscallenter+0x201
syscall() at syscall+0x38
Xfast_syscall() at Xfast_syscall+0xe1
--- syscall (202, FreeBSD ELF64, __sysctl), rip = 0x8009472ac, rsp = 0x7fffffffca38, rbp = 0x7fffffffd310 ---

But I don't really see why, yet. :)  With r220532, it worked fine.


More information about the svn-src-head mailing list