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