From owner-freebsd-arch@FreeBSD.ORG Mon May 24 15:58:00 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 70A7E1065672 for ; Mon, 24 May 2010 15:58:00 +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 014598FC18 for ; Mon, 24 May 2010 15:57:59 +0000 (UTC) Received: by fxm4 with SMTP id 4so3397023fxm.13 for ; Mon, 24 May 2010 08:57:59 -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:subject:x-enigmail-version:content-type :content-transfer-encoding; bh=aMAARUQZ6b+7DLZTORS3QFNQSrYIzVHw8SlseEXeLUc=; b=TUcEGkMbTiO9IWhnNrwmqxqmRtomEhacXxmJpKDMXHWPuyO5XFlWflwgJ2IC7uYABA O+lMYyL0MKqJIhAXgl+eYCDRaq+GYz6ExRW9KjINwZzSKafvG7hiXueIjrGhH65arGCG IJ/Zoy+YYOXO02nPzQPYcosCWwYaCY7RiwcKI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type:content-transfer-encoding; b=LouEsGUOlpb+LoztyiRsOtjbo6kViduElmy1YmbJPhzhOPYnogwvvCqntNUYlh7xuG 92vQQZTi4a2V9JnxCSjJR6gsw+NWjJdnXaW3647+fSabQaDjIS13SNFCv27TppFA5qGq ba5l39bHlF65DGuUlPqhvB/xjbR+G/TtvREK8= Received: by 10.223.16.84 with SMTP id n20mr4802055faa.94.1274716678912; Mon, 24 May 2010 08:57:58 -0700 (PDT) Received: from mavbook.mavhome.dp.ua (pc.mavhome.dp.ua [212.86.226.226]) by mx.google.com with ESMTPS id z12sm20119617fah.21.2010.05.24.08.57.57 (version=SSLv3 cipher=RC4-MD5); Mon, 24 May 2010 08:57:57 -0700 (PDT) Sender: Alexander Motin Message-ID: <4BFAA1F3.1070206@FreeBSD.org> Date: Mon, 24 May 2010 18:57:39 +0300 From: Alexander Motin User-Agent: Thunderbird 2.0.0.24 (X11/20100402) MIME-Version: 1.0 To: freebsd-arch@freebsd.org X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit Subject: Event timers X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 May 2010 15:58:00 -0000 Hi. You should agree that event timers code we have now (hardclock, statclock and profclock source) is real mess. The code is completely machine-dependent, many times duplicated (I have found 4 or 5 equal implementations and many more trivial ones), very tangled and inflexible. While it is acceptable for some platforms with single interrupt source running on hz, x86 with it's many different timers definitely doesn't look good. So I've decided to clean it. I have defined several points on that way: 1*. clean low-level timer drivers from unrelated stuff, 2*. make some common code machine-independent, 3. write common driver API for event timers (alike to one we have now for time counters) to make adding more drivers possible, 4. add support for HPET as event timer in addition to time counter, 5. add support for timers in one-shot mode (LAPIC and HPET). I have already committed first patch (r208494) for points 1 and 2. I have added two new MI functions timer1clock() and timer2clock(), which implement division of incoming interrupts from one or two sources per CPU between calls to hardclock(), statclock() and profclock(). Now MI code should just provide interrupt sources calling respective functions on every tick and set timer1hz and timer2hz variables, reporting their frequency. If only one interrupt source present, timer2hz should be set to zero. Provided functions will divide these interrupt rates according to already existing hz, stathz and profhz variables. I have updated all x86 timers to use new KPI. Now these drivers look better, getting closer to wrapping into abstract API. Other architectures should not be harmed as all legacy methods are still completely functional. Though update would give benefits in either better functionality or at least more clean code. -- Alexander Motin