From owner-freebsd-hackers@FreeBSD.ORG Tue Apr 27 15:02:34 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D159C1065672 for ; Tue, 27 Apr 2010 15:02:34 +0000 (UTC) (envelope-from ozawa@t-oza.net) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 75BC48FC29 for ; Tue, 27 Apr 2010 15:02:33 +0000 (UTC) Received: by wyb34 with SMTP id 34so314433wyb.13 for ; Tue, 27 Apr 2010 08:02:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.87.74 with SMTP id x52mr494086wee.4.1272380546309; Tue, 27 Apr 2010 08:02:26 -0700 (PDT) Sender: ozawa@t-oza.net Received: by 10.216.135.135 with HTTP; Tue, 27 Apr 2010 08:02:25 -0700 (PDT) X-Originating-IP: [61.26.205.33] Date: Tue, 27 Apr 2010 07:02:25 -0800 X-Google-Sender-Auth: b1d092595cf64a7a Message-ID: From: Tsuyoshi Ozawa To: freebsd-hackers Content-Type: text/plain; charset=ISO-8859-1 Subject: [PATCH v2] Dynamic tick support X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Apr 2010 15:02:34 -0000 Hello, I'd like you to review dynticks v2 patch for FreeBSD 8.0. http://gist.github.com/380820 This v2 patch to add dynamic tick support can switch its tick mode automatically. Switch from pertick mode to dyntick mode before cpu_idle() is called in sched_idled. Doing this reduces needless tick. After being called cpu_idle(), switch its mode vice versa. By taking on this algorithm, I think I can eliminate the need for modifiying callout queue operation - callout_reset() and callout_delete(). When CPU is idle, callout queue ops may not be called, because no process is on the CPU. As the result, no ciritical section is born. Is this OK? If I'm wrong, please point out:) I did the benchmark that I posted my blog against this new kernel. ( http://tsuyoshiozawa.blogspot.com/2010/03/started-to-implement-dynticks-in.html ) If CPU is active(=in pertick mode), VMM process consumes about 35%. Meanwhile if CPU is idle(in dyntick mode), VMM process consumes only 10% on my environment. Of course, its mode switching is done automatically. It seems work well :D As a next step, I'll implement HPET timer to work correctly in the case that CPU is sleeping deeply (e.g. CPU is sleeping deeply to the point of local apic timer's stopping). However, it cause a lot of code duplication to add dynamic tick support for each timer device driver layer. I think it's time to divorse timer device driver from callout queue. To accomplish this, I propose vtimer - timer operation abstraction layer. Its name is from vfs. By defining some callback APIs such as vtimer->oneshot(), vtimer->periodic() or something, it's possible to avoid code dupulication and tight coupling around some switching code (e.g switch_to_dyntick() and switch_to_periodic()). But I know that it must be very big change to modify all timer device driver's code. I think hybrid architecture - we can select existing drivers and modified drivers to support dynticks - is down to earth. This is only my opinion, so let's discuss :D Thank you! Very truly yours OZAWA Tsuyoshi