From owner-freebsd-sparc64@FreeBSD.ORG Sat Jul 17 16:27:12 2010 Return-Path: Delivered-To: freebsd-sparc64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 73AF0106564A for ; Sat, 17 Jul 2010 16:27:12 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id EF9B68FC16 for ; Sat, 17 Jul 2010 16:27:11 +0000 (UTC) Received: by fxm13 with SMTP id 13so1742561fxm.13 for ; Sat, 17 Jul 2010 09:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :x-enigmail-version:content-type:content-transfer-encoding; bh=Gf1WMKi5PZcgF/XDjp32jINCicIARkST7d9q1/h79mA=; b=XxubpfHz5o16E02iGXCHWNyCspkoQZM/jPOPw/CixiR3JoltgxyDWNdAiO8EL1GUoG aKIa68foVPQSiuxJmofDAmNvD/dD7rX6N6j8fVaBtWIahowoP1yt/YkhzMo/nGBDalul fFUPggew73nJRmNPr1UBkFzfSUeE2l+z2tPjc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=U6sXV5Ekt5rKeSXXFKJzIVYKn4HmBRMM86D8zbfJFhvG4ioa603aY3LLxBk+oGZYz7 5be4GUqq/GYSHwCFCN147RaHN2yE005qzz5dzxBuJmcQ828dchYCEF0LQLx0WsvvThbI PcKY7oqwOks01UwJUTtR4N1Qgae3I0ev55SBg= Received: by 10.223.104.146 with SMTP id p18mr1802070fao.10.1279384030804; Sat, 17 Jul 2010 09:27:10 -0700 (PDT) Received: from mavbook2.mavhome.dp.ua (pc.mavhome.dp.ua [212.86.226.226]) by mx.google.com with ESMTPS id r8sm1232208faq.34.2010.07.17.09.27.09 (version=SSLv3 cipher=RC4-MD5); Sat, 17 Jul 2010 09:27:10 -0700 (PDT) Sender: Alexander Motin Message-ID: <4C41D99B.10202@FreeBSD.org> Date: Sat, 17 Jul 2010 19:26:03 +0300 From: Alexander Motin User-Agent: Thunderbird 2.0.0.23 (X11/20091212) MIME-Version: 1.0 To: Marius Strobl References: <4C404018.6040405@FreeBSD.org> <20100716213503.GT4706@alchemy.franken.de> <4C40D6F5.6070208@FreeBSD.org> <20100717152459.GU4706@alchemy.franken.de> In-Reply-To: <20100717152459.GU4706@alchemy.franken.de> X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-sparc64@FreeBSD.org Subject: Re: [RFC] Event timers on sparc64/sun4v X-BeenThere: freebsd-sparc64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the Sparc List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Jul 2010 16:27:12 -0000 Marius Strobl wrote: > On Sat, Jul 17, 2010 at 01:02:29AM +0300, Alexander Motin wrote: >> Marius Strobl wrote: >>> - using the stick instead of the tick counter for machines with CPUs >>> and thus tick counters running at different speeds has turned out >>> to be suboptimal, probably due to the fact that the 12.5MHz the >>> stick counters typically are driven by don't provide sufficient >>> granularity. >> On x86 ACPI HPET timers often run about 15MHz, i8254 - about 1.2MHz. >> What's wrong with 12.5MHz here? > > When using the stick counter instead of the tick one on machines > consisting of CPUs running at the same speed everything seems fine > except that top(1) TIME output is implausible. Given that with > this setup the only difference between using the stick and the tick > counter is the frequency at which the counter is driven my best > bet is that the stick counter just doesn't provide sufficient > granularity. If it is granularity, then it is caused not by the base frequency. Here is typical x86 timer frequencies: kern.timecounter.tc.i8254.frequency: 1193182 kern.timecounter.tc.ACPI-fast.frequency: 3579545 kern.timecounter.tc.HPET.frequency: 14318180 kern.timecounter.tc.TSC.frequency: 2000085680 , but TSC is not used on SMP. Others have frequencies not higher then stick and still working fine. IMHO while counter is monotonic and it's frequency is higher then frequency of context switches - it should not be important. I would looked for some different reason. > Using the stick counter on machines consisting of CPUs running at > different speeds (well, actually all the combinations of using > stick/tick for hardclock, timecounter, CPU ticker and cycle > counter I tried as they didn't appear totally wrong) additionally > has the problem of processes getting killed as they are diagnosed > to have exceeded their maximum CPU limit, although with the in-tree > code only the timecounter provided by the host-PCI-bridge should > be used for this calculation as far as the MD initialization is > concerned when the stick counter is used to drive hardclock. On my SB100 I've seen only tick timecounter registered. If there is some other timecounter hardware in a system, why it is not registered? It would be much easier to experiment, having more trusted spare parts. >>> Thus the more desireable variant for these machines >>> probably is to provide the tick counter of the BSP as the only >>> non-per-CPU timer and forward it to the APs via IPIs. >> It would be possible if timer was programmable from any CPU. But as I >> understand - it require thread to be binded, which handled by >> infrastructure only for per-CPU timer. > > Wouldn't it be sufficient to bind curthread to the BSP in > tick_et_start() in that case? For one-shot mode this probably > is to much overhead (assuming a tickless kernel) but for > periodic mode IMO this approach should be sound. tick_et_start() is called under spin lock and sometimes critical section. You can't call CPU binding there. For per-CPU timers reconfiguration there is special logic implemented in MI code using IPIs. By the way I have some doubts about tick_get_timecount_mp() correctness. It tries to bind thread to BSP, but what if it is called inside interrupt handler, or under lock, or some else. I have doubt binding will work in that case. >>> This also >>> leaves the stick counter of all >= US-III machines generally >>> available for driving statclock, which likely is also desirable. >> It would be nice, but I don't know how separate their interrupts. > > I think this should be possible in the soft interrupt dispatch. > However, meanwhile it came to my mind that there was a problem > with using the stick counter on US-IIIi machines (which also > only can consist of CPUs running at the same frequency though). Is this hardware working at all? May be there is something wrong by definition or it is misused? >>> - I don't like wasting CPU cycles for determining whether the >>> workaround for BlackBird CPUs is needed (assuming #1 above is >>> implemented so distinguishing stick/tick is no longer needed) >>> with every (s)tick interrupt which are a lot as this just won't >>> ever change during runtime, i.e. I'd like to keep the different >>> interrupt handlers which are set up as needed. >> Does it worth code duplication? Won't it be always cached/ predicted/ >> prefetched? I have doubt that difference can ever be measured, as this >> function is minor part of things done on interrupt. > > I wouldn't be surprised these branches to actually make a measurable > difference; f.e. moving updating the PIL counter from before calling > the tick interrupt handler to incrementing it afterwards reduced the > delay until it's called by 30% on average on a US-II SMP machine, in > turn resulting in a more steady clock and lesser drift which needs > compensation (see r157825). Besides the code already is there, just > don't nuke it :) As you wish. -- Alexander Motin