Subject: Getting Time Difference

From: "Gilad Benjamini" <[email-masked]>
Date: Thu, 16 Jan 2003 18:48:09 +0200

Hi,
I am porting code from a x86 platform.
That code uses rdtsc and cpu_khz to compute
the time difference between two events. Jiffies aren't good enough in this 
case.

Looking through header files I can find a few MIPS replacements.
What is the "right" one to use ?

What is the best way to change the code so it can compile
and run on both platforms ?

---

From: Ralf Baechle <[email-masked]>
Date: Fri, 17 Jan 2003 13:56:19 +0100

> and run on both platforms ?

Try do_gettimeofday().

  Ralf

---

From: Jun Sun <[email-masked]>
Date: Mon, 20 Jan 2003 11:50:59 -0800

> and run on both platforms ?

I assume you are doing this inside kernel for some performance
measurement.

In mvsita kernel we introduced an abstraction layer which consists
of the following:

readclock_init()
readclock()
clock_to_usecs()

For MIPS in general, we use the following implementation:

#define readclock_init()
#define readclock(low)   do {                           \
        db_assert(mips_cpu.options & MIPS_CPU_COUNTER); \
        low = read_32bit_cp0_register(CP0_COUNT);       \
        } while (0)     
#define clock_to_usecs(clocks) ((clocks) / ((mips_counter_frequency / 1000000)))

In mvl kernel we always calibrate mips_counter_frequency even if it
is not specified by board code.  This is different from the current
linux-mips.org tree.

Jun

---

From: Christoph Hellwig <[email-masked]>
Date: Mon, 20 Jan 2003 20:15:31 +0000

> In mvsita kernel we introduced an abstraction layer which consists

Do you have a pointer to the mvista tree (cvs/tarball/rpm/patch)?

---

From: Jun Sun <[email-masked]>
Date: Mon, 20 Jan 2003 12:19:51 -0800

> Do you have a pointer to the mvista tree (cvs/tarball/rpm/patch)?

I don't think you can freely access it.  Check with our marketing people.
Most of the work though is submitted back to the community, which of course
could take quite a while to show up, or sometimes get rejected and never
show up.

Jun

---

From: Christoph Hellwig <[email-masked]>
Date: Mon, 20 Jan 2003 20:29:38 +0000

> could take quite a while to show up, or sometimes get rejected and never

That's not exactly a nice attitude :P

Maybe there's some mvista customer here who wants to use his/her right to
freely distribute it so I can add it to the other vendor trees at
kernelnewbies.org?

---

From: Pete Popov <[email-masked]>
Date: 20 Jan 2003 12:48:34 -0800

> That's not exactly a nice attitude :P

All of that work is submitted to the community. Jun was talking about
the internal source tree not being freely accessible.

> freely distribute it so I can add it to the other vendor trees at

I think the fact that it's not in the community tree means that it was
submitted but not accepted. Not everything we do for customers is of
interest to the community at large, which is to be expected, but that's
the main reason why sometimes bits get lost and never make it there.

Pete