Skip to content

Commit e616cb8

Browse files
Peter ZijlstraKAGA-KOKO
authored andcommitted
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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Alexandre Chartre <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 69ea03b commit e616cb8

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

include/linux/lockdep.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,27 @@ extern void lockdep_set_selftest_task(struct task_struct *task);
308308

309309
extern void lockdep_init_task(struct task_struct *task);
310310

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

314333
extern void lockdep_register_key(struct lock_class_key *key);
315334
extern void lockdep_unregister_key(struct lock_class_key *key);

kernel/locking/lockdep.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -393,25 +393,6 @@ void lockdep_init_task(struct task_struct *task)
393393
task->lockdep_recursion = 0;
394394
}
395395

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-
415396
static inline void lockdep_recursion_finish(void)
416397
{
417398
if (WARN_ON_ONCE(--current->lockdep_recursion))

0 commit comments

Comments
 (0)