Date: Thu, 20 Dec 2012 12:14:45 +0100 From: =?ISO-8859-1?Q?Bernhard_Fr=F6hlich?= <decke@bluelife.at> To: Andriy Gapon <avg@freebsd.org> Cc: freebsd-emulation@freebsd.org, vbox@freebsd.org Subject: Re: incorrect usage of callout_reset in vbox 4.2.4 ? Message-ID: <CAE-m3X2QzsGvw6ekGdssL1MMBQucRy9ve99M4P1BhJ4=tQBh0w@mail.gmail.com> In-Reply-To: <50C9D369.6040204@FreeBSD.org> References: <50C9D369.6040204@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Dec 13, 2012 at 2:08 PM, Andriy Gapon <avg@freebsd.org> 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/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAE-m3X2QzsGvw6ekGdssL1MMBQucRy9ve99M4P1BhJ4=tQBh0w>