I was going to hack LB a bit, and add a timestamp, just like you see in the newer Linux kernels, to look for potential bottlenecks specific to my MLB. The kernel printk uses sched_clock() to get the current time. Is there an equivalent call in LB? I've looked through the code base for files / code that has *clock* or *time* or something similar, but without much luck.
On Wed, 2006-04-26 at 11:39 -0700, Eric Poulsen wrote:
I was going to hack LB a bit, and add a timestamp, just like you see in the newer Linux kernels, to look for potential bottlenecks specific to my MLB. The kernel printk uses sched_clock() to get the current time. Is there an equivalent call in LB? I've looked through the code base for files / code that has *clock* or *time* or something similar, but without much luck.
There used to be something like POST_TSC which prints the CPU TSC register value in every printk. I don't know if it is still there.
Eric Poulsen schrieb:
I was going to hack LB a bit, and add a timestamp, just like you see in the newer Linux kernels, to look for potential bottlenecks specific to my MLB. The kernel printk uses sched_clock() to get the current time. Is there an equivalent call in LB? I've looked through the code base for files / code that has *clock* or *time* or something similar, but without much luck.
I suppose MLB means VIA EPIA ML Board?
On Intel compatible Pentium (or higher) boards like VIA EPIA, you could read the Time Stamp Counter (TSC) CPU register which tells you the number of cycles from the last machine reset. Use the "cpuid" assembler command as a barrier (to prevent out-of-order command execution) in combination with the "rdtsc" assembler command to read the time time stamp counter. The linux kernel sourcecode contains examples for this.
If you manage to get some inline assembler code into linuxbios, you could take two time stamp counter (TSC) values and store them somewhere. You can convert the number of ticks into real time units afterwards, you could either use the processor speed from /proc/cpuinfo or determine the number of processor cycles per second on your processor yourself. Disable automatic CPU clock adjust to have the CPU run at constant speed.
bye, Daniel.
Daniel Parthey wrote:
Eric Poulsen schrieb:
I was going to hack LB a bit, and add a timestamp, just like you see in the newer Linux kernels, to look for potential bottlenecks specific to my MLB. The kernel printk uses sched_clock() to get the current time. Is there an equivalent call in LB? I've looked through the code base for files / code that has *clock* or *time* or something similar, but without much luck.
I suppose MLB means VIA EPIA ML Board?
I had meant Main Logic Board, but I guess it works both ways.
On Intel compatible Pentium (or higher) boards like VIA EPIA, you could read the Time Stamp Counter (TSC) CPU register which tells you the number of cycles from the last machine reset. Use the "cpuid" assembler command as a barrier (to prevent out-of-order command execution) in combination with the "rdtsc" assembler command to read the time time stamp counter. The linux kernel sourcecode contains examples for this.
My Intel assembly is 15 years rusty -- I'd have better luck doing this on a PIC. My co-worker hacks Intel assembly -- I'll get him to help me.
If you manage to get some inline assembler code into linuxbios, you could take two time stamp counter (TSC) values and store them somewhere. You can convert the number of ticks into real time units afterwards, you could either use the processor speed from /proc/cpuinfo or determine the number of processor cycles per second on your processor yourself. Disable automatic CPU clock adjust to have the CPU run at constant speed.
bye, Daniel.
On 4/27/06, Eric Poulsen eric@zyxod.com wrote:
Daniel Parthey wrote:
Eric Poulsen schrieb:
I was going to hack LB a bit, and add a timestamp, just like you see in the newer Linux kernels, to look for potential bottlenecks specific to my MLB. The kernel printk uses sched_clock() to get the current time. Is there an equivalent call in LB? I've looked through the code base for files / code that has *clock* or *time* or something similar, but without much luck.
I suppose MLB means VIA EPIA ML Board?
I had meant Main Logic Board, but I guess it works both ways.
On Intel compatible Pentium (or higher) boards like VIA EPIA, you could read the Time Stamp Counter (TSC) CPU register which tells you the number of cycles from the last machine reset. Use the "cpuid" assembler command as a barrier (to prevent out-of-order command execution) in combination with the "rdtsc" assembler command to read the time time stamp counter. The linux kernel sourcecode contains examples for this.
My Intel assembly is 15 years rusty -- I'd have better luck doing this on a PIC. My co-worker hacks Intel assembly -- I'll get him to help me.
I'm not yet started at LB development, but this sample code can probably do the job for you, given that you're using GCC:
#define do_rdtsc(ticks) \ __asm__ volatile (".byte 0x0f, 0x31" : "=A" (ticks));
uint64_t current_ticks; do_rdtsc(current_ticks);
This instruction returns a 64-bit value in EDX:EAX. If you don't need to use 64 bits, getting the lower 32 bits will require a change on "=A" by "=a" and on uint64_t by uint32_t.
Hope that helps,
-- Lucas powered by /dev/dsp
Eric Poulsen wrote:
I was going to hack LB a bit, and add a timestamp, just like you see in the newer Linux kernels, to look for potential bottlenecks specific to my MLB. The kernel printk uses sched_clock() to get the current time. Is there an equivalent call in LB? I've looked through the code base for files / code that has *clock* or *time* or something similar, but without much luck.
Look at ollie's serial_post. He added a tsc counter some time ago.
thanks
ron