From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <4A9553C7.6060307@domain.hid> Date: Wed, 26 Aug 2009 17:24:55 +0200 From: Gilles Chanteperdrix MIME-Version: 1.0 References: <4A7BC4DC.70209@domain.hid> <4A8BBA87.5010305@domain.hid> <4A8BC7BE.5020201@domain.hid> <4A8D295C.2080402@domain.hid> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] Xenomai 2.5-rc2 clock_gettime bad tv_nsec value List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Steve Cc: xenomai@xenomai.org Steve wrote: > 2009/8/20 Gilles Chanteperdrix > > > Steve wrote: > > On 19/08/2009, Gilles Chanteperdrix > > wrote: > >> Steve wrote: > >>> Were you going to delay handling this until later, or were you > hoping > >>> it wouldn't be a problem? If it's the former then this is not my > >>> number one priority at the moment, so from my perspective I can wait > >>> until the next release candidate / release. > >> To be completely frank, I was not really worried about this > issue, since > >> you had not answered, I thought that maybe the issue was in your test > >> program. > >> > >>> Linux kernel: 2.6.29.4 > >>> Xenomai: 2.5-rc2 > >>> Adeos: adeos-ipipe-2.6.29.4-x86-2.4-01 > >>> > >>> OS: Ubuntu (8.04 with updates) > >>> Hardware: > >>> Intel Core 2 CPU, kernel compiled using processor family > 'Pentium-4/etc' > >> compiled for 32 or 64 bits? > >> > >> -- > >> Gilles > >> > >> > > > > 32 bit, > > Ok. It turns out that the error is portable, and there is no other way > than to fix the result after the multiplication (trying to round > differently leads to the converse error). So, could you try the > following patch: > > diff --git a/include/asm-generic/bits/timeconv.h > b/include/asm-generic/bits/time > index 79060b3..aa595fe 100644 > --- a/include/asm-generic/bits/timeconv.h > +++ b/include/asm-generic/bits/timeconv.h > @@ -60,10 +60,17 @@ long long xnarch_ns_to_tsc(long long ns) > unsigned long long xnarch_divrem_billion(unsigned long long value, > unsigned long *rem) > { > - unsigned long long r; > - r = xnarch_nodiv_ullimd(value, bln_frac.frac, bln_frac.integ); > - *rem = value - r * 1000000000; > - return r; > + unsigned long long q; > + unsigned r; > + > + q = xnarch_nodiv_ullimd(value, bln_frac.frac, bln_frac.integ); > + r = value - q * 1000000000; > + if (r >= 1000000000) { > + ++q; > + r -= 1000000000; > + } > + *rem = r; > + return q; > } > #else /* !XNARCH_HAVE_NODIV_LLIMD */ > long long xnarch_ns_to_tsc(long long ns) > > > -- > Gilles. > > Hi, > > I have applied the patch and it works - the kernel messages from the > previous patch are no longer produced, and my test program works without > clock_gettime tv_nsec checks. Thank you. > > Just for completeness, are we sure that the value given by r is never > more than 2 billion? I only ask because the patch only deals with one > second worth of overrun. Yes. The multiplication used to compute q may only be off by one. -- Gilles