From owner-freebsd-current@FreeBSD.ORG Wed Apr 27 07:07:45 2011 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 950CA106566B; Wed, 27 Apr 2011 07:07:45 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id AB5B38FC08; Wed, 27 Apr 2011 07:07:44 +0000 (UTC) Received: from porto.topspin.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id KAA07021; Wed, 27 Apr 2011 10:07:43 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost.topspin.kiev.ua ([127.0.0.1]) by porto.topspin.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1QEyqd-0008j8-1C; Wed, 27 Apr 2011 10:07:43 +0300 Message-ID: <4DB7C0BE.2040709@FreeBSD.org> Date: Wed, 27 Apr 2011 10:07:42 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.15) Gecko/20110308 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: Jung-uk Kim References: <4D9DF086.9020906@FreeBSD.org> <201104071600.13586.jkim@FreeBSD.org> <4D9EA07F.4020201@FreeBSD.org> <201104261349.49277.jkim@FreeBSD.org> In-Reply-To: <201104261349.49277.jkim@FreeBSD.org> X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: freebsd-current@FreeBSD.org Subject: Re: prefer tsc timecounter when it's good 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: Wed, 27 Apr 2011 07:07:45 -0000 on 26/04/2011 20:49 Jung-uk Kim said the following: > Can you please test attached patch? You can get it from here, too: > > http://people.freebsd.org/~jkim/tsc_smp_test.diff I am planning on testing the patch, but I am a little bit busy with other things at the moment. The idea looks good to me. The code is a little bit hard to follow :-) I would use three separate array instead of a single array with triple size (for clarity). The arrays would have to be placed inside a structure for passing to smp_rendezvous. Also, perhaps a single rendezvous per iteration would be sufficient, so that you get four values to compare per a pair of CPUs, instead of current six. Again to make the code simpler / more readable. That would allow to expand TSC_READ macro as well (two copies of the function would take less lines than the macro). BTW, not sure if you actually need 'volatile' inside tsc_read_X. > Currently this patch samples 3,000 times to determine if any CPU has > out-of-order TSC but it may be too much, especially for large SMP > machines. If it takes too long, I'll lower the number. Please > report if that's the case. > > Please note this patch also changes HPET, ACPI-fast and TSC qualities. > However, TSC on SMP does not change the default quality, i.e., HPET > or ACPI timer will be chosen by default, because we cannot be sure if > they'll drift later. If the user is sure that they don't drift AND > it is absolutely constant, kern.timecounter.smp_tsc tunable can be > used to set better quality. - You changing the relative priorities of HPET and ACPI-fast. I support this change (some others may not), but please make it as a separate commit. - Not sure if the quality test code is of much use if a user has to set some tunable to actually use it over HPET or ACPI-fast. I thought that the whole point was in automatically choosing the best timecounter. I would go the opposite way - if automatic selection of TSC causes any trouble then provide a way to disable it. -- Andriy Gapon