Re: [RFC patch 08/18] cnt32_to_63 should use smp_rmb()



* David Howells (dhowells@xxxxxxxxxx) wrote:
Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxx> wrote:

First off, using this macro with get_cycles() is simply buggy, because the
macro expects _perfect_ order of timestamps, no skew whatsoever, or
otherwise time could jump.

Erm... Why can't I pass it get_cycles()? Are you saying that sched_clock()
in MN10300 is wrong for it's use of get_cycles() with cnt32_to_63()?


Yes. Do you think the synchronization of the cycles counters is
_perfect_ across CPUs so that there is no possible way whatsoever that
two cycle counter values appear to go backward between CPUs ? (also
taking in account delays in __m_cnt_hi write-back...)

As I showed in my previous example, if you are unlucky enough to hit the
spot where the cycle counters go backward at the time warp edge, time
will jump of 2^32, so about 4.29s at 1GHz.

__x.lo = readl(cnt_lo); /* mmio read */

readl() might insert an extra barrier instruction. Not only that, io_addr
must be unsigned long.

If we expect the only correct use-case to be with readl(), I don't see
the problem with added synchronization.



Ah, right, then the parameters should be updated accordingly.

static inline u64 cnt32_to_63(unsigned long io_addr, u32 *__m_cnt_hi)
{
union cnt32_to_63 __x;
__x.hi = *__m_cnt_hi; /* memory read for high bits internal state */
rmb(); /*
* read high bits before low bits insures time
* does not go backward. Sync across
* CPUs and for interrupts.
*/
__x.lo = readl(io_addr); /* mmio read */
if (unlikely((s32)(__x.hi ^ __x.lo) < 0))
*__m_cnt_hi =
__x.hi = (__x.hi ^ 0x80000000) + (__x.hi >> 31);
return __x.val;
}

Mathieu

David

--
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: Unix Time and Leap Seconds
    ... backward" happens all the time. ... (Assume the HPET is more stable than the TSC but its frequency ... That doesn't mean the system will necessarily allow a backward jump to ... means it is exactly identical to the 'system clock', ...
    (comp.unix.programmer)
  • Re: 8.5... end of sept?
    ... I think you are probably right to be a little concerned about going to a 64bit OS - as you say there are limited 64 bit apps at present and all your devices will need 64 bit drivers - everything. ... My personal thinking is that when I go dual core I will get a big jump in speed anyway (CPUs are faster than my existing one and I get two of them for rendering), I will get 2 CPUs allowing me to do some serious ... I will most likely leave WinX64 for now but jump to Vista 64 in a year, 18 months time when it comes out. ... 64bit and a nice new OS - I have to admit I really enjoy moving to brand new generation OS's when they ...
    (comp.graphics.apps.lightwave)
  • Re: 8.5... end of sept?
    ... I can jump to the full-on 64XP when more apps comply and more drivers comply. ... Either way, I know that things are moving in the 64bit direction anyway, so I won't have a system I can't use. ... My personal thinking is that when I go dual core I will get a big jump in speed anyway (CPUs are faster than my existing one and I get two of them for rendering), I will get 2 CPUs allowing me to do some serious ...
    (comp.graphics.apps.lightwave)
  • time stamps not linear
    ... The time stamps on the text file have backward and forward jumps in them.  ... They increase linearly for about 12000 samples, then jump backwards ... samples/sec and 1024 samples are set to acquire/generate per loop. ...
    (comp.lang.labview)
  • Re: x86 setup rewrite tree ready for flamage^W review
    ... protected mode requires a jump immediately after setting PE in %cr0. ... To serialize the instruction stream and to be on an execution that ... is tested and guaranteed to work in cpus. ... What Intel documents and what Intel ...
    (Linux-Kernel)