From owner-freebsd-emulation@FreeBSD.ORG Thu Dec 20 11:14:46 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 68A6B235 for ; Thu, 20 Dec 2012 11:14:46 +0000 (UTC) (envelope-from decke@bluelife.at) Received: from mail-ob0-f176.google.com (mail-ob0-f176.google.com [209.85.214.176]) by mx1.freebsd.org (Postfix) with ESMTP id 1D1048FC16 for ; Thu, 20 Dec 2012 11:14:45 +0000 (UTC) Received: by mail-ob0-f176.google.com with SMTP id un3so3110345obb.35 for ; Thu, 20 Dec 2012 03:14:45 -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=OH6FMMHWAJvKhU5FRkQeAdamjmWZUeGjjHFucfPtN5M=; b=Z6eDs79JAx6D91q0mA3jC5QecA8tYzblabKXjJwXZRMLchZF4Z12890bXae04NFPQE 0ePMPg7/ctqO8qWoOQ4ammazOzZUBKb8dnX+g80MPmcn8Z5m/yCv3qExYSTTJhe4H5In pVVvBum3alsUhVp4gJcb/BLa9rZ9b5hB7L0Rc= 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=OH6FMMHWAJvKhU5FRkQeAdamjmWZUeGjjHFucfPtN5M=; b=n0vqrk2N0LJp6vlZENEwpv5JpuspaHk00w4NLKeBUCIM+WHyxzu89RKjCPpSVXO/5o xhk6ov2FOds/MdjbzZERa7ovKiqq7WtISl8LNCVI44GYo6Q3nRR34KGKC5i2CrhYyggV QGctzeTMKS1tC8Bp5i7t1H9a3JIklkmYuROCfMdso3arJ3MF1PgR7H/gmwFsZWuVpe5l ImlZFx+qd70fTNg5JHC4duzH5okqIz1X9que+83AGn+dfIuF2be234hVHELlCPmaLbJL ENIac3LwUEk+hl/N2YFLlZd5qqybTcpBDzt8TjaNkLRHUU9N42vffJJhgz9/Asy1OyP3 fQrQ== MIME-Version: 1.0 Received: by 10.182.114.71 with SMTP id je7mr7691580obb.20.1356002085088; Thu, 20 Dec 2012 03:14:45 -0800 (PST) Received: by 10.76.8.199 with HTTP; Thu, 20 Dec 2012 03:14:45 -0800 (PST) X-Originating-IP: [80.123.233.199] In-Reply-To: <50C9D369.6040204@FreeBSD.org> References: <50C9D369.6040204@FreeBSD.org> Date: Thu, 20 Dec 2012 12:14:45 +0100 Message-ID: Subject: Re: incorrect usage of callout_reset in vbox 4.2.4 ? 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: ALoCoQldm5+/nw05jb1rOro67xHtLf2cr98y34FTGL8oMI/XZZmKfBKYDeVXpiMpMvxoP6t2EZBn 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:14:46 -0000 On Thu, Dec 13, 2012 at 2:08 PM, Andriy Gapon wrote: > > It looks like in timer-r0drv-freebsd.c the code tries to pass absolute ti= me as a > timeout parameter to callout_reset while that function actually expects r= elative > time (period). > > I am testing the following patch, but I am sure that the code can be made= more > efficient. > > --- timer-r0drv-freebsd.c.orig 2012-12-12 20:13:27.623202784 +0200 > +++ timer-r0drv-freebsd.c 2012-12-12 20:19:43.368202795 +0200 > @@ -172,15 +172,16 @@ > /* > * Calc when it should start firing. > */ > - u64First +=3D RTTimeNanoTS(); > + const uint64_t u64Now =3D RTTimeNanoTS(); > + u64First +=3D u64Now; > > pTimer->fSuspended =3D false; > pTimer->iTick =3D 0; > pTimer->u64StartTS =3D u64First; > pTimer->u64NextTS =3D u64First; > > - tv.tv_sec =3D u64First / 1000000000; > - tv.tv_usec =3D (u64First % 1000000000) / 1000; > + tv.tv_sec =3D (u64First - u64Now) / 1000000000; > + tv.tv_usec =3D ((u64First - u64Now) % 1000000000) / 1000; > callout_reset(&pTimer->Callout, tvtohz(&tv), rtTimerFreeBSDCallback,= pTimer); > > return VINF_SUCCESS; > @@ -247,8 +248,8 @@ > if (pTimer->u64NextTS < u64NanoTS) > pTimer->u64NextTS =3D u64NanoTS + RTTimerGetSystemGranularit= y() / 2; > > - tv.tv_sec =3D pTimer->u64NextTS / 1000000000; > - tv.tv_usec =3D (pTimer->u64NextTS % 1000000000) / 1000; > + tv.tv_sec =3D (pTimer->u64NextTS - u64NanoTS) / 1000000000; > + tv.tv_usec =3D ((pTimer->u64NextTS - u64NanoTS) % 1000000000) / = 1000; > callout_reset(&pTimer->Callout, tvtohz(&tv), rtTimerFreeBSDCallb= ack, pTimer); > } What is your results from that tests? Is the patch correct so should we inc= lude it into the port? --=20 Bernhard Fr=F6hlich http://www.bluelife.at/