From owner-freebsd-current@FreeBSD.ORG Fri Dec 28 10:00:58 2007 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F2BE716A419 for ; Fri, 28 Dec 2007 10:00:58 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.freebsd.org (Postfix) with ESMTP id C57E613C458 for ; Fri, 28 Dec 2007 10:00:58 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [209.31.154.41]) by cyrus.watson.org (Postfix) with ESMTP id 797D446B4C; Fri, 28 Dec 2007 05:00:58 -0500 (EST) Date: Fri, 28 Dec 2007 10:00:58 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Mike Silbersack In-Reply-To: <20071228015651.X1565@odysseus.silby.com> Message-ID: <20071228095539.F45653@fledge.watson.org> References: <20071228015651.X1565@odysseus.silby.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: current@freebsd.org Subject: Re: [patch] Auto-setting hz to 100 inside QEMU/VMWare 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: Fri, 28 Dec 2007 10:00:59 -0000 On Fri, 28 Dec 2007, Mike Silbersack wrote: > When running FreeBSD inside QEMU / VMWare, one of my pet peeves is that time > is completely inaccurate. This seems to be cured by setting kern.hz=100 > (down from the default of 1000) in /boot/loader.conf, but I'm getting sick > of doing that every time I set up a virtual box. > > So, here's a patch to have the kernel auto-detect that it's running inside > one of those two environments and automatically make that adjustment. > > If you're running FreeBSD inside any other virtual environments (Parallels? > Microsoft Virtual PC?) and can detect them via data in kenv, I'll be happy > to add them to the patch as well. > > I have only tested this patch in QEMU so far, I will test inside VMWare > tomorrow. > > If anyone could review and/or test this, it would be appreciated. I like the general idea, but one thing that does worry me is that this prevents me from using config to set HZ at all, I have to set it at runtime using the tunable. Could we add an: options VIRTUAL_HZ=100 # alternative default HZ to use with virtualization Or something along these lines? kern.hz as a tunable could still override it, but this would put the default in the config rather than in the code. So the new logic would be something along the lines of { if (detect_virtualmachine()) hz = VIRTUAL_HZ; /* A big HZ hurts. */ else hz = HZ; } I also wonder if detect_virtualmachine(), or whatever the most appropriate name is, should be an MD routine shared by amd64, but also available on sun4v in the form of int detect_virtualmachine(void) { return (1); }. FYI, the vendor for Parallels is: smbios.bios.vendor="Parallels Software International Inc." In any case, having something along these lines in the tree would make my life with Parallels and VMWare a lot easier "out of the box". Robert N M Watson Computer Laboratory University of Cambridge