irqflags-tracing.txt 2.6 KB

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