mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-05 12:56:08 +00:00
Teach WITNESS_SAVE() and WITNESS_RESTORE() to work with spin locks instead
of only sleep locks.
This commit is contained in:
parent
0a46ed7d56
commit
b0e9883e2f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=153854
@ -1807,15 +1807,20 @@ witness_display_spinlock(struct lock_object *lock, struct thread *owner)
|
|||||||
void
|
void
|
||||||
witness_save(struct lock_object *lock, const char **filep, int *linep)
|
witness_save(struct lock_object *lock, const char **filep, int *linep)
|
||||||
{
|
{
|
||||||
|
struct lock_list_entry *lock_list;
|
||||||
struct lock_instance *instance;
|
struct lock_instance *instance;
|
||||||
|
|
||||||
KASSERT(!witness_cold, ("%s: witness_cold", __func__));
|
KASSERT(!witness_cold, ("%s: witness_cold", __func__));
|
||||||
if (lock->lo_witness == NULL || witness_watch == 0 || panicstr != NULL)
|
if (lock->lo_witness == NULL || witness_watch == 0 || panicstr != NULL)
|
||||||
return;
|
return;
|
||||||
if ((lock->lo_class->lc_flags & LC_SLEEPLOCK) == 0)
|
if (lock->lo_class->lc_flags & LC_SLEEPLOCK)
|
||||||
panic("%s: lock (%s) %s is not a sleep lock", __func__,
|
lock_list = curthread->td_sleeplocks;
|
||||||
lock->lo_class->lc_name, lock->lo_name);
|
else {
|
||||||
instance = find_instance(curthread->td_sleeplocks, lock);
|
if (witness_skipspin)
|
||||||
|
return;
|
||||||
|
lock_list = PCPU_GET(spinlocks);
|
||||||
|
}
|
||||||
|
instance = find_instance(lock_list, lock);
|
||||||
if (instance == NULL)
|
if (instance == NULL)
|
||||||
panic("%s: lock (%s) %s not locked", __func__,
|
panic("%s: lock (%s) %s not locked", __func__,
|
||||||
lock->lo_class->lc_name, lock->lo_name);
|
lock->lo_class->lc_name, lock->lo_name);
|
||||||
@ -1826,15 +1831,20 @@ witness_save(struct lock_object *lock, const char **filep, int *linep)
|
|||||||
void
|
void
|
||||||
witness_restore(struct lock_object *lock, const char *file, int line)
|
witness_restore(struct lock_object *lock, const char *file, int line)
|
||||||
{
|
{
|
||||||
|
struct lock_list_entry *lock_list;
|
||||||
struct lock_instance *instance;
|
struct lock_instance *instance;
|
||||||
|
|
||||||
KASSERT(!witness_cold, ("%s: witness_cold", __func__));
|
KASSERT(!witness_cold, ("%s: witness_cold", __func__));
|
||||||
if (lock->lo_witness == NULL || witness_watch == 0 || panicstr != NULL)
|
if (lock->lo_witness == NULL || witness_watch == 0 || panicstr != NULL)
|
||||||
return;
|
return;
|
||||||
if ((lock->lo_class->lc_flags & LC_SLEEPLOCK) == 0)
|
if (lock->lo_class->lc_flags & LC_SLEEPLOCK)
|
||||||
panic("%s: lock (%s) %s is not a sleep lock", __func__,
|
lock_list = curthread->td_sleeplocks;
|
||||||
lock->lo_class->lc_name, lock->lo_name);
|
else {
|
||||||
instance = find_instance(curthread->td_sleeplocks, lock);
|
if (witness_skipspin)
|
||||||
|
return;
|
||||||
|
lock_list = PCPU_GET(spinlocks);
|
||||||
|
}
|
||||||
|
instance = find_instance(lock_list, lock);
|
||||||
if (instance == NULL)
|
if (instance == NULL)
|
||||||
panic("%s: lock (%s) %s not locked", __func__,
|
panic("%s: lock (%s) %s not locked", __func__,
|
||||||
lock->lo_class->lc_name, lock->lo_name);
|
lock->lo_class->lc_name, lock->lo_name);
|
||||||
|
Loading…
Reference in New Issue
Block a user