From owner-freebsd-emulation@FreeBSD.ORG Thu Dec 20 11:13:44 2012 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 00ED11D7 for ; Thu, 20 Dec 2012 11:13:43 +0000 (UTC) (envelope-from decke@bluelife.at) Received: from mail-oa0-f46.google.com (mail-oa0-f46.google.com [209.85.219.46]) by mx1.freebsd.org (Postfix) with ESMTP id A83C78FC18 for ; Thu, 20 Dec 2012 11:13:43 +0000 (UTC) Received: by mail-oa0-f46.google.com with SMTP id h16so3191388oag.19 for ; Thu, 20 Dec 2012 03:13:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bluelife.at; s=google; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=OMV3m/3Y7tnnSjH7mn8UqAVOUzA/KQeSafRslFA++LA=; b=CWIxprXRK2JbjrZUyfb80sKK2tTSAAbAz7lO/9hZhtBBsSkZLGhh5zdCSkCbuqqcA0 4DJ0b0T+lY23GXcyp9DNL0tPlC/xwLK1q9chgtB+TrusdzZzzk3tx3ijAReLVaIO5/8T adK4A9PFrDS/r1W84fZ7VL6hTZeKCN8MN5D8o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding:x-gm-message-state; bh=OMV3m/3Y7tnnSjH7mn8UqAVOUzA/KQeSafRslFA++LA=; b=PsRrj7jx5yq0Jqm/E39lPgc0xfLIHmOeBwuIMLv/GHt1svgxwmosIf0FMwQUFqP2S6 tus9WWC/Yxm05DWrs0GWJ22N6NsmdXkD3vg2bZ2rPRaa+jCipZwHFntI5s3JHxdt0Q9A mcGL0+2jCDQx8i9iAhlYMZmvh1hOowh2AX/trmcHnXiFFNumN1/xFnigqZPY7vsjI5Jm oE241ZQq4e2tnpandgvFM1+/rNLeQ/LO5hb0V8hoYgIJ/qC4OwNr/Trz4NWpTl2mFZsY o9RFsL1jBwVbtfpNqeOutArukhOYl1nzAF1RmOoQD8t6UtQuFdhheqr8c25uPz8arjcO vqgQ== MIME-Version: 1.0 Received: by 10.182.95.133 with SMTP id dk5mr7854272obb.14.1356002022724; Thu, 20 Dec 2012 03:13:42 -0800 (PST) Received: by 10.76.8.199 with HTTP; Thu, 20 Dec 2012 03:13:42 -0800 (PST) X-Originating-IP: [80.123.233.199] In-Reply-To: <50C9D27C.1090707@FreeBSD.org> References: <50C9D27C.1090707@FreeBSD.org> Date: Thu, 20 Dec 2012 12:13:42 +0100 Message-ID: Subject: Re: issue with under-tick waits From: =?ISO-8859-1?Q?Bernhard_Fr=F6hlich?= To: Andriy Gapon Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQkfgj8IoJrv52nsvj0kCE+/cmMQTkpCF+IW6bLjGJwymkXNelUOEjQWRM5k86NwgV+lYY8f Cc: freebsd-emulation@freebsd.org, vbox@freebsd.org X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Dec 2012 11:13:44 -0000 On Thu, Dec 13, 2012 at 2:05 PM, Andriy Gapon wrote: > > I think that the following patch is needed in VirtualBox 4.2.4 kernel mod= ule: > > --- sleepqueue-r0drv-freebsd.h.orig 2012-12-12 20:09:29.675203802 +02= 00 > +++ sleepqueue-r0drv-freebsd.h 2012-12-12 20:11:53.604203131 +0200 > @@ -82,6 +82,8 @@ > uint64_t cTicks =3D ASMMultU64ByU32DivByU32(uTimeout, hz, UINT32_C(1= 000000000)); > if (cTicks >=3D INT_MAX) > return RTSEMWAIT_FLAGS_INDEFINITE; > + else if (cTicks =3D=3D 0 && uTimeout > 0) > + pWait->iTimeout =3D 1; > else > pWait->iTimeout =3D (int)cTicks; > #endif > > Without this patch any waits for periods shorter than a single tick retur= n > immediately leading to a lot of unnecessary spinning. For example, I obs= erve that > my guest's idle loop does a lot of sleeps with periods slightly shorter t= han 1 ms > (1/hz), e.g. 900us. All that waiting turns into pure spinning and Virtua= lBox eats > 100% of a core. > The above patch improves the situation significantly. Also, it (approxim= ately) > follows what tvtohz does. Thanks a lot! I've added the patch to the port. https://github.com/decke/freebsd-vbox/commit/102a18dbfd8a0a668f7042e6d086b9= d0df25e20f --=20 Bernhard Fr=F6hlich http://www.bluelife.at/