Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

locking/lockdep: Improve noinstr vs errors

Better handle the failure paths.

vmlinux.o: warning: objtool: debug_locks_off()+0x23: call to console_verbose() leaves .noinstr.text section
vmlinux.o: warning: objtool: debug_locks_off()+0x19: call to __kasan_check_write() leaves .noinstr.text section

debug_locks_off+0x19/0x40:
instrument_atomic_write at include/linux/instrumented.h:86
(inlined by) __debug_locks_off at include/linux/debug_locks.h:17
(inlined by) debug_locks_off at lib/debug_locks.c:41

Fixes: 6eebad1ad303 ("lockdep: __always_inline more for noinstr")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210621120120.784404944@infradead.org

authored by

Peter Zijlstra and committed by
Ingo Molnar
49faa777 1f008d46

+6 -2
+2
include/linux/debug_locks.h
··· 27 27 int __ret = 0; \ 28 28 \ 29 29 if (!oops_in_progress && unlikely(c)) { \ 30 + instrumentation_begin(); \ 30 31 if (debug_locks_off() && !debug_locks_silent) \ 31 32 WARN(1, "DEBUG_LOCKS_WARN_ON(%s)", #c); \ 33 + instrumentation_end(); \ 32 34 __ret = 1; \ 33 35 } \ 34 36 __ret; \
+3 -1
kernel/locking/lockdep.c
··· 843 843 } 844 844 845 845 /* used from NMI context -- must be lockless */ 846 - static __always_inline struct lock_class * 846 + static noinstr struct lock_class * 847 847 look_up_lock_class(const struct lockdep_map *lock, unsigned int subclass) 848 848 { 849 849 struct lockdep_subclass_key *key; ··· 851 851 struct lock_class *class; 852 852 853 853 if (unlikely(subclass >= MAX_LOCKDEP_SUBCLASSES)) { 854 + instrumentation_begin(); 854 855 debug_locks_off(); 855 856 printk(KERN_ERR 856 857 "BUG: looking up invalid subclass: %u\n", subclass); 857 858 printk(KERN_ERR 858 859 "turning off the locking correctness validator.\n"); 859 860 dump_stack(); 861 + instrumentation_end(); 860 862 return NULL; 861 863 } 862 864
+1 -1
lib/debug_locks.c
··· 36 36 /* 37 37 * Generic 'turn off all lock debugging' function: 38 38 */ 39 - noinstr int debug_locks_off(void) 39 + int debug_locks_off(void) 40 40 { 41 41 if (debug_locks && __debug_locks_off()) { 42 42 if (!debug_locks_silent) {