From owner-freebsd-current@FreeBSD.ORG Fri Dec 3 18:06:02 2010 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by hub.freebsd.org (Postfix) with ESMTP id 3A0B6106566C; Fri, 3 Dec 2010 18:06:01 +0000 (UTC) (envelope-from jkim@FreeBSD.org) From: Jung-uk Kim To: freebsd-current@FreeBSD.org Date: Fri, 3 Dec 2010 13:05:50 -0500 User-Agent: KMail/1.6.2 References: <4CF92852.20705@freebsd.org> In-Reply-To: <4CF92852.20705@freebsd.org> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201012031305.53750.jkim@FreeBSD.org> Cc: Andriy Gapon Subject: Re: non-invariant tsc and cputicker X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Dec 2010 18:06:02 -0000 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? > 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. Thanks, Jung-uk Kim