Re: [PATCH -v4 2/9] MIPS: add mips_timecounter_read() to get highprecision timestamp

From: pajko
Date: Thu Oct 22 2009 - 09:03:22 EST





Wu Zhangjin wrote:
>
> This patch implement a mips_timecounter_read(), which can be used to get
> high precision timestamp without extra lock.
>
> It is based on the clock counter register and the
> timecounter/cyclecounter abstraction layer of kernel.
>
>

I don't like this. I think MIPS should have a custom sched_clock()
- which ftrace would use without any extra magic -, instead of the
default jiffies-based one. It's true that the 32-bit C0 counter is too
small, but I've successfully extended it in software by having a word
in memory for the upper part of a 64-bit counter and
incrementing it every time C0 rolls over. My code is ugly and maybe
is racy, but works on our system.
Yesterday during getting that in shape I've found about that the
kernel even has a mechanism for that what I wanted to implement.

See here:
http://lxr.linux.no/#linux+v2.6.31/include/linux/cnt32_to_63.h#L34

And for a correct application of it:
http://lxr.linux.no/#linux+v2.6.31/arch/arm/plat-orion/time.c#L45

Next week I'll knock up something based on that and submit it for
review.

In my custom code (full 64-bit counter, not a 63-bit one like above)
I've set the scale factor to 15 for our system (Au1250 clocked at 756 MHz),
so
sched_clock() wraps around about every 6.2 days, and the upper word has
to be warmed up about every 5 sec. Numbers will be different for the code
using cnt32_to_63.h.

Regards,
Patrik

--
View this message in context: http://www.nabble.com/-PATCH--v4-1-9--tracing%3A-convert-trace_clock_local%28%29-as-weak-function-tp25993719p26009516.html
Sent from the linux-kernel mailing list archive at Nabble.com.

--
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/