Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 03 Dec 2010 20:14:45 +0200
From:      Andriy Gapon <avg@freebsd.org>
To:        Jung-uk Kim <jkim@freebsd.org>
Cc:        freebsd-current@freebsd.org
Subject:   Re: non-invariant tsc and cputicker
Message-ID:  <4CF93395.3060601@freebsd.org>
In-Reply-To: <201012031305.53750.jkim@FreeBSD.org>
References:  <4CF92852.20705@freebsd.org> <201012031305.53750.jkim@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
on 03/12/2010 20:05 Jung-uk Kim said the following:
> On Friday 03 December 2010 12:26 pm, Andriy Gapon wrote:
>> FreeBSD uses cpu_ticks [function pointer] in a few places for a few
>> things like process CPU time accounting.  On x86 cpu_ticks always
>> points to rdtsc. If TSC is not invariant that leads to incorrect
>> accounting of "CPU ticks". The code pretends to try to handle
>> changing cpufreq levels, but does that incorrectly.
> 
> Arg...  Probably it is my fault. :-(
> 
>> I think that we could use a selected timecounter instead of "raw"
>> TSC if the latter is not invariant.  In this case cpu_ticks calls
>> would be slightly costlier, but always correct.
>>
>> The change is quite trivial:
>> http://people.freebsd.org/~avg/tsc-cputicker.diff
>>
>> What do you think?
> 
> Why don't we just fix it properly?

Patch? :-)
It seems that it is not too trivial to do and is prone to error accumulation given
how the ticks are added up.
Besides, why using a timecounter would not be a proper fix?

>> P.S. it's probably a good idea to merge i386 and amd64 tsc.c files
>> into a common x86 version, which would be the same as i386 version,
>> which seems to be generic enough.
> 
> Agreed.

Cool!

-- 
Andriy Gapon



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