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

lockdep: Always inline lockdep_{off,on}()

These functions are called {early,late} in nmi_{enter,exit} and should
not be traced or probed. They are also puny, so 'inline' them.

Reported-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
Link: https://lkml.kernel.org/r/20200505134101.048523500@linutronix.de


authored by

Peter Zijlstra and committed by
Thomas Gleixner
e616cb8d 69ea03b5

+21 -21
+21 -2
include/linux/lockdep.h
··· 308 308 309 309 extern void lockdep_init_task(struct task_struct *task); 310 310 311 - extern void lockdep_off(void); 312 - extern void lockdep_on(void); 311 + /* 312 + * Split the recrursion counter in two to readily detect 'off' vs recursion. 313 + */ 314 + #define LOCKDEP_RECURSION_BITS 16 315 + #define LOCKDEP_OFF (1U << LOCKDEP_RECURSION_BITS) 316 + #define LOCKDEP_RECURSION_MASK (LOCKDEP_OFF - 1) 317 + 318 + /* 319 + * lockdep_{off,on}() are macros to avoid tracing and kprobes; not inlines due 320 + * to header dependencies. 321 + */ 322 + 323 + #define lockdep_off() \ 324 + do { \ 325 + current->lockdep_recursion += LOCKDEP_OFF; \ 326 + } while (0) 327 + 328 + #define lockdep_on() \ 329 + do { \ 330 + current->lockdep_recursion -= LOCKDEP_OFF; \ 331 + } while (0) 313 332 314 333 extern void lockdep_register_key(struct lock_class_key *key); 315 334 extern void lockdep_unregister_key(struct lock_class_key *key);
-19
kernel/locking/lockdep.c
··· 393 393 task->lockdep_recursion = 0; 394 394 } 395 395 396 - /* 397 - * Split the recrursion counter in two to readily detect 'off' vs recursion. 398 - */ 399 - #define LOCKDEP_RECURSION_BITS 16 400 - #define LOCKDEP_OFF (1U << LOCKDEP_RECURSION_BITS) 401 - #define LOCKDEP_RECURSION_MASK (LOCKDEP_OFF - 1) 402 - 403 - void lockdep_off(void) 404 - { 405 - current->lockdep_recursion += LOCKDEP_OFF; 406 - } 407 - EXPORT_SYMBOL(lockdep_off); 408 - 409 - void lockdep_on(void) 410 - { 411 - current->lockdep_recursion -= LOCKDEP_OFF; 412 - } 413 - EXPORT_SYMBOL(lockdep_on); 414 - 415 396 static inline void lockdep_recursion_finish(void) 416 397 { 417 398 if (WARN_ON_ONCE(--current->lockdep_recursion))