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