Skip to content

Commit 49faa77

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
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: 6eebad1 ("lockdep: __always_inline more for noinstr") Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1f008d4 commit 49faa77

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

include/linux/debug_locks.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ extern int debug_locks_off(void);
2727
int __ret = 0; \
2828
\
2929
if (!oops_in_progress && unlikely(c)) { \
30+
instrumentation_begin(); \
3031
if (debug_locks_off() && !debug_locks_silent) \
3132
WARN(1, "DEBUG_LOCKS_WARN_ON(%s)", #c); \
33+
instrumentation_end(); \
3234
__ret = 1; \
3335
} \
3436
__ret; \

kernel/locking/lockdep.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,20 +843,22 @@ static int count_matching_names(struct lock_class *new_class)
843843
}
844844

845845
/* used from NMI context -- must be lockless */
846-
static __always_inline struct lock_class *
846+
static noinstr struct lock_class *
847847
look_up_lock_class(const struct lockdep_map *lock, unsigned int subclass)
848848
{
849849
struct lockdep_subclass_key *key;
850850
struct hlist_head *hash_head;
851851
struct lock_class *class;
852852

853853
if (unlikely(subclass >= MAX_LOCKDEP_SUBCLASSES)) {
854+
instrumentation_begin();
854855
debug_locks_off();
855856
printk(KERN_ERR
856857
"BUG: looking up invalid subclass: %u\n", subclass);
857858
printk(KERN_ERR
858859
"turning off the locking correctness validator.\n");
859860
dump_stack();
861+
instrumentation_end();
860862
return NULL;
861863
}
862864

lib/debug_locks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ EXPORT_SYMBOL_GPL(debug_locks_silent);
3636
/*
3737
* Generic 'turn off all lock debugging' function:
3838
*/
39-
noinstr int debug_locks_off(void)
39+
int debug_locks_off(void)
4040
{
4141
if (debug_locks && __debug_locks_off()) {
4242
if (!debug_locks_silent) {

0 commit comments

Comments
 (0)