world leader in high performance signal processing
Trace: » interrupt_latency

How to test interrupt latency in uClinux on Blackfin

Now we use a watchdog timer driver to test the interrupt in uClinux on Blackfin. It is in drivers/char/bfin_timer_latency.c. The process of testing is:

  • create a proc file /proc/timer_latency. Hook an ISR to watch dog timer (IVT13).
  • When got a writing of watchdog timer period (in us) to this file, do following:
    • a). set the period and start watch dog timer. (which decreases by 1 every SCLK)
    • b). Reset and start the CYCLES counter of Blackfin. (which increases by 1 every CCLK).
    • c). After the period, watch dog generates an interrupt. In the ISR, read the CYCLES counter. The value should be a litter more than the period. So the interrupt latency is (CYCLES value - watchdog period)) cycles.
    • d). The watchdog ISR reset the timer and CYCLES counter to start another test automatically.
  • When got a reading from this file, return the latency records (in cycles).

Please be noted that this latency includes 3 parts:

  1. Hardware latency.
  2. Context saving time before entering ISR.
  3. IRQ multimplexing time. (this part occupied more than half of the latency. It can be saved by not sharing the IRQ.)


So the simplest way to test the interrupt latency is:

  • In menuconfig:
  1. Disable watchdog timer driver in “Kernel configuration” → “Drivers” → “Watchdog Timer Support”.
  2. Disable the “Watchdog simple daemon” in “user configuration” → “Blackfin app programs
  3. Enable timer latency driver in “Kernel configuration” → “Drivers” → “Char devices” → “Blackfin 5xx interrupt latency test”.
  • Boot Blackfin uClinux and start the test.

Run command <echo “timer period in us” > /proc/timer_latency> to start the test. The driver keeps re-start the watchdog timer interrupt and records latencies. Note that the “timer period us” can start from 100 (us) to several seconds like 5000000 (5 seconds). Don’t set this value too small otherwise too many interrupts may halt the system.

  • Run command <cat /proc/timer_latency> to see current latency records.

Of course you can also give the CPU any kind of load and/or use a script to test the result any times you want.