0001 =======================
0002 IRQ-flags state tracing
0003 =======================
0004
0005 :Author: started by Ingo Molnar <mingo@redhat.com>
0006
0007 The "irq-flags tracing" feature "traces" hardirq and softirq state, in
0008 that it gives interested subsystems an opportunity to be notified of
0009 every hardirqs-off/hardirqs-on, softirqs-off/softirqs-on event that
0010 happens in the kernel.
0011
0012 CONFIG_TRACE_IRQFLAGS_SUPPORT is needed for CONFIG_PROVE_SPIN_LOCKING
0013 and CONFIG_PROVE_RW_LOCKING to be offered by the generic lock debugging
0014 code. Otherwise only CONFIG_PROVE_MUTEX_LOCKING and
0015 CONFIG_PROVE_RWSEM_LOCKING will be offered on an architecture - these
0016 are locking APIs that are not used in IRQ context. (the one exception
0017 for rwsems is worked around)
0018
0019 Architecture support for this is certainly not in the "trivial"
0020 category, because lots of lowlevel assembly code deal with irq-flags
0021 state changes. But an architecture can be irq-flags-tracing enabled in a
0022 rather straightforward and risk-free manner.
0023
0024 Architectures that want to support this need to do a couple of
0025 code-organizational changes first:
0026
0027 - add and enable TRACE_IRQFLAGS_SUPPORT in their arch level Kconfig file
0028
0029 and then a couple of functional changes are needed as well to implement
0030 irq-flags-tracing support:
0031
0032 - in lowlevel entry code add (build-conditional) calls to the
0033 trace_hardirqs_off()/trace_hardirqs_on() functions. The lock validator
0034 closely guards whether the 'real' irq-flags matches the 'virtual'
0035 irq-flags state, and complains loudly (and turns itself off) if the
0036 two do not match. Usually most of the time for arch support for
0037 irq-flags-tracing is spent in this state: look at the lockdep
0038 complaint, try to figure out the assembly code we did not cover yet,
0039 fix and repeat. Once the system has booted up and works without a
0040 lockdep complaint in the irq-flags-tracing functions arch support is
0041 complete.
0042 - if the architecture has non-maskable interrupts then those need to be
0043 excluded from the irq-tracing [and lock validation] mechanism via
0044 lockdep_off()/lockdep_on().
0045
0046 In general there is no risk from having an incomplete irq-flags-tracing
0047 implementation in an architecture: lockdep will detect that and will
0048 turn itself off. I.e. the lock validator will still be reliable. There
0049 should be no crashes due to irq-tracing bugs. (except if the assembly
0050 changes break other code by modifying conditions or registers that
0051 shouldn't be)
0052