irqflags-tracing.txt 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. =======================
  2. IRQ-flags state tracing
  3. =======================
  4. :Author: started by Ingo Molnar <mingo@redhat.com>
  5. The "irq-flags tracing" feature "traces" hardirq and softirq state, in
  6. that it gives interested subsystems an opportunity to be notified of
  7. every hardirqs-off/hardirqs-on, softirqs-off/softirqs-on event that
  8. happens in the kernel.
  9. CONFIG_TRACE_IRQFLAGS_SUPPORT is needed for CONFIG_PROVE_SPIN_LOCKING
  10. and CONFIG_PROVE_RW_LOCKING to be offered by the generic lock debugging
  11. code. Otherwise only CONFIG_PROVE_MUTEX_LOCKING and
  12. CONFIG_PROVE_RWSEM_LOCKING will be offered on an architecture - these
  13. are locking APIs that are not used in IRQ context. (the one exception
  14. for rwsems is worked around)
  15. Architecture support for this is certainly not in the "trivial"
  16. category, because lots of lowlevel assembly code deal with irq-flags
  17. state changes. But an architecture can be irq-flags-tracing enabled in a
  18. rather straightforward and risk-free manner.
  19. Architectures that want to support this need to do a couple of
  20. code-organizational changes first:
  21. - add and enable TRACE_IRQFLAGS_SUPPORT in their arch level Kconfig file
  22. and then a couple of functional changes are needed as well to implement
  23. irq-flags-tracing support:
  24. - in lowlevel entry code add (build-conditional) calls to the
  25. trace_hardirqs_off()/trace_hardirqs_on() functions. The lock validator
  26. closely guards whether the 'real' irq-flags matches the 'virtual'
  27. irq-flags state, and complains loudly (and turns itself off) if the
  28. two do not match. Usually most of the time for arch support for
  29. irq-flags-tracing is spent in this state: look at the lockdep
  30. complaint, try to figure out the assembly code we did not cover yet,
  31. fix and repeat. Once the system has booted up and works without a
  32. lockdep complaint in the irq-flags-tracing functions arch support is
  33. complete.
  34. - if the architecture has non-maskable interrupts then those need to be
  35. excluded from the irq-tracing [and lock validation] mechanism via
  36. lockdep_off()/lockdep_on().
  37. In general there is no risk from having an incomplete irq-flags-tracing
  38. implementation in an architecture: lockdep will detect that and will
  39. turn itself off. I.e. the lock validator will still be reliable. There
  40. should be no crashes due to irq-tracing bugs. (except if the assembly
  41. changes break other code by modifying conditions or registers that
  42. shouldn't be)