Skip to content

Commit ca2acbd

Browse files
Peter ZijlstraSasha Levin
authored andcommitted
locking/lockdep: Improve noinstr vs errors
[ Upstream commit 49faa77 ] 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) <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20210621120120.784404944@infradead.org Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 59aa5c9 commit ca2acbd

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎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
@@ -842,20 +842,22 @@ static int count_matching_names(struct lock_class *new_class)
842842
}
843843

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

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

‎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)