kernel/locking/lockdep.c:2877-2887: dead code

From: sunying
Date: Mon May 22 2023 - 05:37:45 EST


Analyzing the preprocessed statement #ifdef in the kernel/locking/lockdep.c shows that
the functions “check_irq_usage” and “usage_skip” at lines 2877-2887 are defined valid only
under the “CONFIG_PROVE_LOCKING && !(CONFIG_TRACE_IRQFLAGS)” is true.

However, according to the configuration item "CONFIG_PROVE_LOCKING" defined in lib/Kconfig.debug, we can see:
config PROVE_LOCKING
bool "Lock debugging: prove locking correctness"
depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
select LOCKDEP
select DEBUG_SPINLOCK
select DEBUG_MUTEXES if !PREEMPT_RT
select DEBUG_RT_MUTEXES if RT_MUTEXES
select DEBUG_RWSEMS
select DEBUG_WW_MUTEX_SLOWPATH
select DEBUG_LOCK_ALLOC
select PREEMPT_COUNT if !ARCH_NO_PREEMPT
select TRACE_IRQFLAGS
default n

If "CONFIG_PROVE_LOCKING: is enabled, "CONFIG_TRACE_IRQFLAGS" is automatically enabled.
The above condition "CONFIG_PROVE_LOCKING && !(CONFIG_TRACE_IRQFLAGS)" will never be true,
so lines 2877-2887 will never be executed.

Should the dead code of line 2877-2887 be deleted?


Best Regards
Yanjie Ren
Ying Sun