Release 4.15 kernel/locking/spinlock_debug.c
/*
* Copyright 2005, Red Hat, Inc., Ingo Molnar
* Released under the General Public License (GPL).
*
* This file contains the spinlock/rwlock implementations for
* DEBUG_SPINLOCK.
*/
#include <linux/spinlock.h>
#include <linux/nmi.h>
#include <linux/interrupt.h>
#include <linux/debug_locks.h>
#include <linux/delay.h>
#include <linux/export.h>
void __raw_spin_lock_init(raw_spinlock_t *lock, const char *name,
struct lock_class_key *key)
{
#ifdef CONFIG_DEBUG_LOCK_ALLOC
/*
* Make sure we are not reinitializing a held lock:
*/
debug_check_no_locks_freed((void *)lock, sizeof(*lock));
lockdep_init_map(&lock->dep_map, name, key, 0);
#endif
lock->raw_lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
lock->magic = SPINLOCK_MAGIC;
lock->owner = SPINLOCK_OWNER_INIT;
lock->owner_cpu = -1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 76 | 92.68% | 1 | 20.00% |
Thomas Gleixner | 4 | 4.88% | 3 | 60.00% |
Peter Zijlstra | 2 | 2.44% | 1 | 20.00% |
Total | 82 | 100.00% | 5 | 100.00% |
EXPORT_SYMBOL(__raw_spin_lock_init);
void __rwlock_init(rwlock_t *lock, const char *name,
struct lock_class_key *key)
{
#ifdef CONFIG_DEBUG_LOCK_ALLOC
/*
* Make sure we are not reinitializing a held lock:
*/
debug_check_no_locks_freed((void *)lock, sizeof(*lock));
lockdep_init_map(&lock->dep_map, name, key, 0);
#endif
lock->raw_lock = (arch_rwlock_t) __ARCH_RW_LOCK_UNLOCKED;
lock->magic = RWLOCK_MAGIC;
lock->owner = SPINLOCK_OWNER_INIT;
lock->owner_cpu = -1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 78 | 95.12% | 1 | 33.33% |
Thomas Gleixner | 2 | 2.44% | 1 | 33.33% |
Peter Zijlstra | 2 | 2.44% | 1 | 33.33% |
Total | 82 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL(__rwlock_init);
static void spin_dump(raw_spinlock_t *lock, const char *msg)
{
struct task_struct *owner = NULL;
if (lock->owner && lock->owner != SPINLOCK_OWNER_INIT)
owner = lock->owner;
printk(KERN_EMERG "BUG: spinlock %s on CPU#%d, %s/%d\n",
msg, raw_smp_processor_id(),
current->comm, task_pid_nr(current));
printk(KERN_EMERG " lock: %pS, .magic: %08x, .owner: %s/%d, "
".owner_cpu: %d\n",
lock, lock->magic,
owner ? owner->comm : "<none>",
owner ? task_pid_nr(owner) : -1,
lock->owner_cpu);
dump_stack();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 86 | 87.76% | 2 | 28.57% |
Pavel Emelyanov | 6 | 6.12% | 1 | 14.29% |
Dave Jones | 3 | 3.06% | 1 | 14.29% |
Thomas Gleixner | 1 | 1.02% | 1 | 14.29% |
Stephen Boyd | 1 | 1.02% | 1 | 14.29% |
Akinobu Mita | 1 | 1.02% | 1 | 14.29% |
Total | 98 | 100.00% | 7 | 100.00% |
static void spin_bug(raw_spinlock_t *lock, const char *msg)
{
if (!debug_locks_off())
return;
spin_dump(lock, msg);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Akinobu Mita | 29 | 100.00% | 1 | 100.00% |
Total | 29 | 100.00% | 1 | 100.00% |
#define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg)
static inline void
debug_spin_lock_before(raw_spinlock_t *lock)
{
SPIN_BUG_ON(lock->magic != SPINLOCK_MAGIC, lock, "bad magic");
SPIN_BUG_ON(lock->owner == current, lock, "recursion");
SPIN_BUG_ON(lock->owner_cpu == raw_smp_processor_id(),
lock, "cpu recursion");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 50 | 98.04% | 1 | 50.00% |
Thomas Gleixner | 1 | 1.96% | 1 | 50.00% |
Total | 51 | 100.00% | 2 | 100.00% |
static inline void debug_spin_lock_after(raw_spinlock_t *lock)
{
lock->owner_cpu = raw_smp_processor_id();
lock->owner = current;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 23 | 95.83% | 1 | 50.00% |
Thomas Gleixner | 1 | 4.17% | 1 | 50.00% |
Total | 24 | 100.00% | 2 | 100.00% |
static inline void debug_spin_unlock(raw_spinlock_t *lock)
{
SPIN_BUG_ON(lock->magic != SPINLOCK_MAGIC, lock, "bad magic");
SPIN_BUG_ON(!raw_spin_is_locked(lock), lock, "already unlocked");
SPIN_BUG_ON(lock->owner != current, lock, "wrong owner");
SPIN_BUG_ON(lock->owner_cpu != raw_smp_processor_id(),
lock, "wrong CPU");
lock->owner = SPINLOCK_OWNER_INIT;
lock->owner_cpu = -1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 75 | 97.40% | 1 | 50.00% |
Thomas Gleixner | 2 | 2.60% | 1 | 50.00% |
Total | 77 | 100.00% | 2 | 100.00% |
/*
* We are now relying on the NMI watchdog to detect lockup instead of doing
* the detection here with an unfair lock which can cause problem of its own.
*/
void do_raw_spin_lock(raw_spinlock_t *lock)
{
debug_spin_lock_before(lock);
arch_spin_lock(&lock->raw_lock);
debug_spin_lock_after(lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 24 | 88.89% | 1 | 25.00% |
Thomas Gleixner | 2 | 7.41% | 2 | 50.00% |
Waiman Long | 1 | 3.70% | 1 | 25.00% |
Total | 27 | 100.00% | 4 | 100.00% |
int do_raw_spin_trylock(raw_spinlock_t *lock)
{
int ret = arch_spin_trylock(&lock->raw_lock);
if (ret)
debug_spin_lock_after(lock);
#ifndef CONFIG_SMP
/*
* Must not happen on UP:
*/
SPIN_BUG_ON(!ret, lock, "trylock failure on UP");
#endif
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 45 | 93.75% | 1 | 25.00% |
Thomas Gleixner | 3 | 6.25% | 3 | 75.00% |
Total | 48 | 100.00% | 4 | 100.00% |
void do_raw_spin_unlock(raw_spinlock_t *lock)
{
debug_spin_unlock(lock);
arch_spin_unlock(&lock->raw_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 19 | 86.36% | 1 | 25.00% |
Thomas Gleixner | 3 | 13.64% | 3 | 75.00% |
Total | 22 | 100.00% | 4 | 100.00% |
static void rwlock_bug(rwlock_t *lock, const char *msg)
{
if (!debug_locks_off())
return;
printk(KERN_EMERG "BUG: rwlock %s on CPU#%d, %s/%d, %p\n",
msg, raw_smp_processor_id(), current->comm,
task_pid_nr(current), lock);
dump_stack();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 43 | 91.49% | 3 | 60.00% |
Pavel Emelyanov | 3 | 6.38% | 1 | 20.00% |
Dave Jones | 1 | 2.13% | 1 | 20.00% |
Total | 47 | 100.00% | 5 | 100.00% |
#define RWLOCK_BUG_ON(cond, lock, msg) if (unlikely(cond)) rwlock_bug(lock, msg)
void do_raw_read_lock(rwlock_t *lock)
{
RWLOCK_BUG_ON(lock->magic != RWLOCK_MAGIC, lock, "bad magic");
arch_read_lock(&lock->raw_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 28 | 93.33% | 1 | 33.33% |
Thomas Gleixner | 2 | 6.67% | 2 | 66.67% |
Total | 30 | 100.00% | 3 | 100.00% |
int do_raw_read_trylock(rwlock_t *lock)
{
int ret = arch_read_trylock(&lock->raw_lock);
#ifndef CONFIG_SMP
/*
* Must not happen on UP:
*/
RWLOCK_BUG_ON(!ret, lock, "trylock failure on UP");
#endif
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 37 | 94.87% | 1 | 33.33% |
Thomas Gleixner | 2 | 5.13% | 2 | 66.67% |
Total | 39 | 100.00% | 3 | 100.00% |
void do_raw_read_unlock(rwlock_t *lock)
{
RWLOCK_BUG_ON(lock->magic != RWLOCK_MAGIC, lock, "bad magic");
arch_read_unlock(&lock->raw_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 28 | 93.33% | 1 | 33.33% |
Thomas Gleixner | 2 | 6.67% | 2 | 66.67% |
Total | 30 | 100.00% | 3 | 100.00% |
static inline void debug_write_lock_before(rwlock_t *lock)
{
RWLOCK_BUG_ON(lock->magic != RWLOCK_MAGIC, lock, "bad magic");
RWLOCK_BUG_ON(lock->owner == current, lock, "recursion");
RWLOCK_BUG_ON(lock->owner_cpu == raw_smp_processor_id(),
lock, "cpu recursion");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 51 | 100.00% | 1 | 100.00% |
Total | 51 | 100.00% | 1 | 100.00% |
static inline void debug_write_lock_after(rwlock_t *lock)
{
lock->owner_cpu = raw_smp_processor_id();
lock->owner = current;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 24 | 100.00% | 1 | 100.00% |
Total | 24 | 100.00% | 1 | 100.00% |
static inline void debug_write_unlock(rwlock_t *lock)
{
RWLOCK_BUG_ON(lock->magic != RWLOCK_MAGIC, lock, "bad magic");
RWLOCK_BUG_ON(lock->owner != current, lock, "wrong owner");
RWLOCK_BUG_ON(lock->owner_cpu != raw_smp_processor_id(),
lock, "wrong CPU");
lock->owner = SPINLOCK_OWNER_INIT;
lock->owner_cpu = -1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 64 | 100.00% | 1 | 100.00% |
Total | 64 | 100.00% | 1 | 100.00% |
void do_raw_write_lock(rwlock_t *lock)
{
debug_write_lock_before(lock);
arch_write_lock(&lock->raw_lock);
debug_write_lock_after(lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 25 | 92.59% | 1 | 33.33% |
Thomas Gleixner | 2 | 7.41% | 2 | 66.67% |
Total | 27 | 100.00% | 3 | 100.00% |
int do_raw_write_trylock(rwlock_t *lock)
{
int ret = arch_write_trylock(&lock->raw_lock);
if (ret)
debug_write_lock_after(lock);
#ifndef CONFIG_SMP
/*
* Must not happen on UP:
*/
RWLOCK_BUG_ON(!ret, lock, "trylock failure on UP");
#endif
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 46 | 95.83% | 1 | 33.33% |
Thomas Gleixner | 2 | 4.17% | 2 | 66.67% |
Total | 48 | 100.00% | 3 | 100.00% |
void do_raw_write_unlock(rwlock_t *lock)
{
debug_write_unlock(lock);
arch_write_unlock(&lock->raw_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 20 | 90.91% | 1 | 33.33% |
Thomas Gleixner | 2 | 9.09% | 2 | 66.67% |
Total | 22 | 100.00% | 3 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 888 | 91.17% | 4 | 21.05% |
Thomas Gleixner | 32 | 3.29% | 7 | 36.84% |
Akinobu Mita | 30 | 3.08% | 1 | 5.26% |
Pavel Emelyanov | 9 | 0.92% | 1 | 5.26% |
Dave Jones | 4 | 0.41% | 1 | 5.26% |
Peter Zijlstra | 4 | 0.41% | 1 | 5.26% |
Andrew Morton | 3 | 0.31% | 1 | 5.26% |
Waiman Long | 2 | 0.21% | 1 | 5.26% |
Stephen Boyd | 1 | 0.10% | 1 | 5.26% |
Paul Gortmaker | 1 | 0.10% | 1 | 5.26% |
Total | 974 | 100.00% | 19 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.