4
votes

I want to track down jitter in a piece of code and I know there are many potential sources ( task switch, system calls, cache misses, moving task to another CPU, cpu throttling, etc ) and I know how to track all of those but the only one I don't know how to track is time the kernel spent servicing interrupts. The data is in /proc/stat but that measures time in soft-irq and irq at a low resolution and I'm looking for something at a much finer resolution.

Is there a way to get the time, down to the nanosecond or at least microsecond, spent by the kernel servicing interrupts?

1
You can compile a custom kernel that flips a gpio on interrupt enter/exit, then trace the timing on a logic analyzer.TJD
Any attempt to measure something will affect the something (in varying degree). So external measurement is preferred, such as @TJD 's comment.sawdust

1 Answers

1
votes

Yes put a printk before and after the calling to handle_IRQ the timer on the screen is usually the high resolution one:

 86 /*
 87  * asm_do_IRQ is the interface to be used from assembly code.
 88  */
 89 asmlinkage void __exception_irq_entry
 90 asm_do_IRQ(unsigned int irq, struct pt_regs *regs)
 91 {
 92         handle_IRQ(irq, regs);
 93 }
 94 

If you ask about the irq_latency see these nice answers:

What is the irq latency due to the operating system?