After trying the new code with "isync" and unsigned long long convertion, this problem doesn't happen(I tested for several minutes). But the previous block of codes(lacking of isync) is borrowed from kernel. And if this is a bug of kernel?<br>
<br>Thanks<br>Gino<br><br><div class="gmail_quote">2010/3/26 Benjamin Herrenschmidt <span dir="ltr"><<a href="mailto:benh@kernel.crashing.org">benh@kernel.crashing.org</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Thu, 2010-03-25 at 23:00 +0800, Csdncannon wrote:<br>
> I am really sorry that the previously attached code is wrong, this one<br>
> "timebase.c" is the right one, and the "log_timebase" file is the<br>
> right log.<br>
><br>
> We are using FreeScale PowerPc 8378, kernel 2.6.28 and compiled as<br>
> 32-bit.<br>
<br>
</div>And despite all those sync/isync you can still observe the timebase<br>
going backward ? That sounds scary. However, at this stage all I can<br>
suggest is getting freescale folks to have a look, as this should really<br>
not happen. Maybe there's some setting with that specific SoC that is<br>
missing or similar...<br>
<br>
Cheers,<br>
Ben.<br>
<div><div></div><div class="h5"><br>
><br>
> Thanks<br>
> Gino<br>
><br>
> 2010/3/25 Arnd Bergmann <<a href="mailto:arnd@arndb.de">arnd@arndb.de</a>><br>
> On Thursday 25 March 2010, Benjamin Herrenschmidt wrote:<br>
> > On Thu, 2010-03-25 at 10:41 +0800, Csdncannon wrote:<br>
> > > In my program, the value of the 64-bit time base<br>
> register is<br>
> > > read out, and you will find the later value is even<br>
> smaller than the<br>
> > > earlier value from the log “log_timebase”. While the<br>
> kernel depends on<br>
> > > the accuracy of the timebase for the compensation of the<br>
> lost PIT<br>
> > > interrupt, the negative value between two continual<br>
> timebase reading<br>
> > > will bring to the jump of the jiffies. And this timebase<br>
> problem will<br>
> > > bring to the instability of the gettimeofday system call.<br>
> > ><br>
> > > Do you have any idea about this problem, thanks<br>
> for your any<br>
> > > advice. Attached is the code and log.<br>
> ><br>
> > This is a concern, it should definitely not happen. What<br>
> machine is<br>
> > that ? is the code compiled 32-bit or 64-bit ? What kernel<br>
> version ?<br>
> ><br>
> > Arnd, any chance that could relate to the bug you've been<br>
> chasing on<br>
> > Cell ?<br>
><br>
><br>
> We're still busy with the problem analysis on Cell, waiting<br>
> for a time<br>
> slot to run the next test kernel. So far it seems like the<br>
> timebase<br>
> is actually synchronized at a significant accuracy on QS22 to<br>
> never<br>
> cause this problem with correct code, however it is possible<br>
> to<br>
> observe incorrect timebase values on Cell whenever the mftb<br>
> instruction<br>
> is not serialized with memory accesses, e.g. by using an isync<br>
> in front<br>
> of the mftb. On Power6 and other CPUs, that problem will not<br>
> happen.<br>
><br>
> Arnd<br>
><br>
<br>
<br>
</div></div></blockquote></div><br>