Column: Embedded design
Figure 2: The “Selection Details” window shows that one instance of the IRQ handler took approximately 3.3ms to execute
Figure 3: When printk is removed, maximum execution time decreases to 14µs, with noticeably more variations
Figure 4: The “Periodicity – From Ready” view in the “Actor Instances” window
Linux scheduler keeps giving execution resources back to the IRQ handler; this adverse phenomenon is commonly known as “thrashing”. Since we’re not instructing the device to stop firing the interrupt, why do we see the periodicity of the IRQ handler level out ultimately (we would expect the CPU to continue to thrash)? After looking into the device
specification, it became clear that it has a fail-safe mechanism which automatically de-asserts the interrupt if it has not been acknowledged over the I2
C bus. When
including the printk in the IRQ handler, the execution time of the IRQ handler
10 March 2021
www.electronicsworld.co.uk
extends into the deassertion time, which effectively masks the fact that our own code does not properly de-assert the interrupt over the I2
C bus. Another important observation
we’ve made using Tracealyzer is that the printk actually masked this bug. Since the time between the invocation of the IRQ handlers and the printk was approximately 80ms, we would have completely missed the fact that we needed to instruct the device to stop firing interrupts until it handled the first interrupt. Instead, this bug would have manifested itself as we approached
release and removed extraneous printk calls. At that point, major modifications to the driver would incur significant time and cost. In summary, using Tracealyzer
during different stages of driver development could expose bugs as well as performance issues. We see here that it can be a tremendously valuable tool in ensuring that a critical component of any device driver – the IRQ handler – is performs properly. We also see the advantages of Tracealyzer for this purpose instead of printks, which could add substantial overhead.
Page 1 |
Page 2 |
Page 3 |
Page 4 |
Page 5 |
Page 6 |
Page 7 |
Page 8 |
Page 9 |
Page 10 |
Page 11 |
Page 12 |
Page 13 |
Page 14 |
Page 15 |
Page 16 |
Page 17 |
Page 18 |
Page 19 |
Page 20 |
Page 21 |
Page 22 |
Page 23 |
Page 24 |
Page 25 |
Page 26 |
Page 27 |
Page 28 |
Page 29 |
Page 30 |
Page 31 |
Page 32 |
Page 33 |
Page 34 |
Page 35 |
Page 36 |
Page 37 |
Page 38 |
Page 39 |
Page 40 |
Page 41 |
Page 42 |
Page 43 |
Page 44