From owner-freebsd-current@FreeBSD.ORG Thu May 12 08:15:34 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 545281065672; Thu, 12 May 2011 08:15:34 +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 35CB18FC19; Thu, 12 May 2011 08:15:33 +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 LAA19432; Thu, 12 May 2011 11:15:31 +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 1QKR3T-000K6n-6b; Thu, 12 May 2011 11:15:31 +0300 Message-ID: <4DCB9722.1020409@FreeBSD.org> Date: Thu, 12 May 2011 11:15:30 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.17) Gecko/20110503 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: FreeBSD current X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: better integration of osol cyclic with clocksource 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: Thu, 12 May 2011 08:15:34 -0000 I would like to commit the following patch soon, so I would like to ask you for reviews and testing. Idea of the patch is to improve integration with relatively recently introduced clocksource framework. Practical benefits are only achieved when one-shot timers are used to drive a system. In this case there will not be unnecessary timer interrupts and, which is not the least, cyclic events should happen more close to their scheduled times. Currently cyclic subsystem is used only by DTrace, so that means that DTrace profile provider becomes much more accurate. E.g. if currently you specify profile:::profile-4001 probe and your hz is 1000, then actually most of the time this probe is invoked 4 times in succession at every hz tick. With the proposed change it should be generally called every 250µs. The patch: http://people.freebsd.org/~avg/cyclic.diff BIG NOTE: the patch needs osol gethrtime() to be implemented with the same (high) prevision as the clocksource code, which is not the case now. Without that the cyclic code will work very unstably. So one of the following actions should be taken additionally: A) The following patch changes gethrtime() to sufficiently accurate implementation. Since gethrtime() is also used in ZFS code, there is a concern that the patch may negatively impact ZFS performance. This hasn't been demonstrated/proven, but I am also unable to conclusively prove that this will not be the case. The only argument that I have is that OpenSolaris uses a precise implementation (based on TSC where possible), so the change shouldn't make things worse than in OpenSolaris. --- sys/cddl/compat/opensolaris/sys/time.h (revision 221802) +++ sys/cddl/compat/opensolaris/sys/time.h (working copy) @@ -53,7 +53,7 @@ struct timespec ts; hrtime_t nsec; - getnanouptime(&ts); + nanouptime(&ts); nsec = (hrtime_t)ts.tv_sec * NANOSEC + ts.tv_nsec; return (nsec); } B) Create a private copy of gethrtime() in sys/cddl/dev/cyclic/cyclic.c and patch only that copy. This is a safer approach suggested by pjd. The only minor drawback is very small code duplication. -- Andriy Gapon