4

I have a simple interrupt that is triggered by a GPIO-input. The IRQ only increments a variable and returns. When I turn the frequency of the interrupts up to somewhere around 10-20 kHz, the system becomes unresponsive. I measure the CPU-load using top while turning the frequency up, but there is no significant change in any of the metrics from the top command.

So the processor CPU gets loaded, but I can't measure it with top!

How is top making its measurement? How come the very frequent interrupt isn't visible?

How can I measure the impact the interrupt has on the overall performance of the system?

EDIT

By setting the CPU-frequency governor to "performance", and setting the frequency to static 1GHz, I was able to get the interrupt frequency up to 150kHz, before the processor crashed..

Wiingaard
  • 141
  • I think there are some options in the kernel config for time accounting. The old way was something like it measures using the system timer interrupt, and so other interrupts that come and go between system timer interrupts are missed. The new way uses the high precision processor timestamp registers to accurately account for even short bursts of time spent in interrupt handlers, and then this will be reflected in the system time reported by top. – psusi Nov 14 '15 at 03:12
  • I'm sure sure i quite understand it.. Top used to be measured with wih he system imer interrupt, but is now measured with high precision timestamps. Is there a way i can test which method my system uses?

    By setting the CPU-frequency governor to "performance", and setting the frequency to static 1GHz, I was able to get the interrupt frequency up to 150kHz, before the processor crashed.. The "intr/s" value of mpstat does infact scale with the interrupt frequency. It shows 860.90 at an interrupt frequency on 1 Hz, and 1959.68 at an interrupt frequency on 150kHz.

    – Wiingaard Nov 23 '15 at 15:36
  • top only show part of the picture. Others already mentioned mptstat, add to it vmstat – Rui F Ribeiro Nov 23 '15 at 19:15
  • vmstat doesn't give me anything either, only interrupts / sec, which I suspect draws it's data from the same place as mpstat... – Wiingaard Nov 24 '15 at 11:54

1 Answers1

2

Is “top” accounting for kernel interrupts?

It depends on your kernel. If IRQ_TIME_ACCOUNTING is not enabled, then time spent handling interrupts will probably not be counted.

config IRQ_TIME_ACCOUNTING
    bool "Fine granularity task level IRQ time accounting"
    depends on HAVE_IRQ_TIME_ACCOUNTING && !VIRT_CPU_ACCOUNTING_NATIVE
    help
      Select this option to enable fine granularity task irq time
      accounting. This is done by reading a timestamp on each
      transitions between softirq and hardirq state, so there can be a
      small performance impact.

You could try searching inside your kernel config file. On many systems, the kernel config can be read from /boot/config-*.

There is some more explanation about this in the original patch series: Proper kernel irq time accounting -v4.

The details depend on your CPU architecture. For example this feature is never enabled on ancient x86 CPUs which lack a TSC. And some Linux architectures simply do not implement HAVE_IRQ_TIME_ACCOUNTING.

A few Linux architectures provide this feature as part of VIRTUAL_CPU_ACCOUNTING_NATIVE instead. Currently those architectures are S390, IA64, and PowerPC. My guess is you are not using any of these (partly based on your use of "GPIO" :-P).

sourcejedi
  • 50,249