diff options
author | adrian <adrian@FreeBSD.org> | 2011-10-12 09:21:02 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2011-10-12 09:21:02 +0000 |
commit | 7c88ef5a97d294739f577ab35c932712e9c6ca3b (patch) | |
tree | 08bc738a884754ac13907e065cd6afc1a712c031 /sys/kern/subr_witness.c | |
parent | 73794a4f91ea091483eab802a9aea9e396e3b089 (diff) | |
download | FreeBSD-src-7c88ef5a97d294739f577ab35c932712e9c6ca3b.zip FreeBSD-src-7c88ef5a97d294739f577ab35c932712e9c6ca3b.tar.gz |
Don't call fixup_filename() on each witness lock call.
This has been irking me for a while. This causes significant
CPU use on bottlenecked CPUs (eg my older EEEPC w/ an earlier
Celeron CPU and my MIPS24k boards) when they're passing
a lot of traffic.
Since the file/line values are only used for printing, this
should only affect display. It should have no operational
change on the code, besides reducing CPU use.
Diffstat (limited to 'sys/kern/subr_witness.c')
-rw-r--r-- | sys/kern/subr_witness.c | 104 |
1 files changed, 63 insertions, 41 deletions
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 01de5ed..3407e21 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -1053,7 +1053,6 @@ witness_checkorder(struct lock_object *lock, int flags, const char *file, w = lock->lo_witness; class = LOCK_CLASS(lock); td = curthread; - file = fixup_filename(file); if (class->lc_flags & LC_SLEEPLOCK) { @@ -1064,7 +1063,8 @@ witness_checkorder(struct lock_object *lock, int flags, const char *file, */ if (td->td_critnest != 0 && !kdb_active) panic("blockable sleep lock (%s) %s @ %s:%d", - class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, + fixup_filename(file), line); /* * If this is the first lock acquired then just return as @@ -1102,17 +1102,19 @@ witness_checkorder(struct lock_object *lock, int flags, const char *file, if ((lock1->li_flags & LI_EXCLUSIVE) != 0 && (flags & LOP_EXCLUSIVE) == 0) { printf("shared lock of (%s) %s @ %s:%d\n", - class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, + fixup_filename(file), line); printf("while exclusively locked from %s:%d\n", - lock1->li_file, lock1->li_line); + fixup_filename(lock1->li_file), lock1->li_line); panic("share->excl"); } if ((lock1->li_flags & LI_EXCLUSIVE) == 0 && (flags & LOP_EXCLUSIVE) != 0) { printf("exclusive lock of (%s) %s @ %s:%d\n", - class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, + fixup_filename(file), line); printf("while share locked from %s:%d\n", - lock1->li_file, lock1->li_line); + fixup_filename(lock1->li_file), lock1->li_line); panic("excl->share"); } return; @@ -1165,8 +1167,9 @@ witness_checkorder(struct lock_object *lock, int flags, const char *file, "acquiring duplicate lock of same type: \"%s\"\n", w->w_name); printf(" 1st %s @ %s:%d\n", plock->li_lock->lo_name, - plock->li_file, plock->li_line); - printf(" 2nd %s @ %s:%d\n", lock->lo_name, file, line); + fixup_filename(plock->li_file), plock->li_line); + printf(" 2nd %s @ %s:%d\n", lock->lo_name, + fixup_filename(file), line); witness_debugger(1); } else mtx_unlock_spin(&w_mtx); @@ -1307,19 +1310,24 @@ witness_checkorder(struct lock_object *lock, int flags, const char *file, if (i < 0) { printf(" 1st %p %s (%s) @ %s:%d\n", lock1->li_lock, lock1->li_lock->lo_name, - w1->w_name, lock1->li_file, lock1->li_line); + w1->w_name, fixup_filename(lock1->li_file), + lock1->li_line); printf(" 2nd %p %s (%s) @ %s:%d\n", lock, - lock->lo_name, w->w_name, file, line); + lock->lo_name, w->w_name, + fixup_filename(file), line); } else { printf(" 1st %p %s (%s) @ %s:%d\n", lock2->li_lock, lock2->li_lock->lo_name, lock2->li_lock->lo_witness->w_name, - lock2->li_file, lock2->li_line); + fixup_filename(lock2->li_file), + lock2->li_line); printf(" 2nd %p %s (%s) @ %s:%d\n", lock1->li_lock, lock1->li_lock->lo_name, - w1->w_name, lock1->li_file, lock1->li_line); + w1->w_name, fixup_filename(lock1->li_file), + lock1->li_line); printf(" 3rd %p %s (%s) @ %s:%d\n", lock, - lock->lo_name, w->w_name, file, line); + lock->lo_name, w->w_name, + fixup_filename(file), line); } witness_debugger(1); return; @@ -1356,7 +1364,6 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line) return; w = lock->lo_witness; td = curthread; - file = fixup_filename(file); /* Determine lock list for this lock. */ if (LOCK_CLASS(lock)->lc_flags & LC_SLEEPLOCK) @@ -1413,27 +1420,31 @@ witness_upgrade(struct lock_object *lock, int flags, const char *file, int line) if (lock->lo_witness == NULL || witness_watch == -1 || panicstr != NULL) return; class = LOCK_CLASS(lock); - file = fixup_filename(file); if (witness_watch) { if ((lock->lo_flags & LO_UPGRADABLE) == 0) panic("upgrade of non-upgradable lock (%s) %s @ %s:%d", - class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, + fixup_filename(file), line); if ((class->lc_flags & LC_SLEEPLOCK) == 0) panic("upgrade of non-sleep lock (%s) %s @ %s:%d", - class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, + fixup_filename(file), line); } instance = find_instance(curthread->td_sleeplocks, lock); if (instance == NULL) panic("upgrade of unlocked lock (%s) %s @ %s:%d", - class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, + fixup_filename(file), line); if (witness_watch) { if ((instance->li_flags & LI_EXCLUSIVE) != 0) panic("upgrade of exclusive lock (%s) %s @ %s:%d", - class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, + fixup_filename(file), line); if ((instance->li_flags & LI_RECURSEMASK) != 0) panic("upgrade of recursed lock (%s) %s r=%d @ %s:%d", class->lc_name, lock->lo_name, - instance->li_flags & LI_RECURSEMASK, file, line); + instance->li_flags & LI_RECURSEMASK, + fixup_filename(file), line); } instance->li_flags |= LI_EXCLUSIVE; } @@ -1449,23 +1460,26 @@ witness_downgrade(struct lock_object *lock, int flags, const char *file, if (lock->lo_witness == NULL || witness_watch == -1 || panicstr != NULL) return; class = LOCK_CLASS(lock); - file = fixup_filename(file); if (witness_watch) { if ((lock->lo_flags & LO_UPGRADABLE) == 0) panic("downgrade of non-upgradable lock (%s) %s @ %s:%d", - class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, + fixup_filename(file), line); if ((class->lc_flags & LC_SLEEPLOCK) == 0) panic("downgrade of non-sleep lock (%s) %s @ %s:%d", - class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, + fixup_filename(file), line); } instance = find_instance(curthread->td_sleeplocks, lock); if (instance == NULL) panic("downgrade of unlocked lock (%s) %s @ %s:%d", - class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, + fixup_filename(file), line); if (witness_watch) { if ((instance->li_flags & LI_EXCLUSIVE) == 0) panic("downgrade of shared lock (%s) %s @ %s:%d", - class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, + fixup_filename(file), line); if ((instance->li_flags & LI_RECURSEMASK) != 0) panic("downgrade of recursed lock (%s) %s r=%d @ %s:%d", class->lc_name, lock->lo_name, @@ -1488,7 +1502,6 @@ witness_unlock(struct lock_object *lock, int flags, const char *file, int line) return; td = curthread; class = LOCK_CLASS(lock); - file = fixup_filename(file); /* Find lock instance associated with this lock. */ if (class->lc_flags & LC_SLEEPLOCK) @@ -1511,7 +1524,7 @@ witness_unlock(struct lock_object *lock, int flags, const char *file, int line) */ if (witness_watch > 0) panic("lock (%s) %s not locked @ %s:%d", class->lc_name, - lock->lo_name, file, line); + lock->lo_name, fixup_filename(file), line); else return; found: @@ -1520,16 +1533,18 @@ found: if ((instance->li_flags & LI_EXCLUSIVE) != 0 && witness_watch > 0 && (flags & LOP_EXCLUSIVE) == 0) { printf("shared unlock of (%s) %s @ %s:%d\n", class->lc_name, - lock->lo_name, file, line); + lock->lo_name, + fixup_filename(file), line); printf("while exclusively locked from %s:%d\n", - instance->li_file, instance->li_line); + fixup_filename(instance->li_file), instance->li_line); panic("excl->ushare"); } if ((instance->li_flags & LI_EXCLUSIVE) == 0 && witness_watch > 0 && (flags & LOP_EXCLUSIVE) != 0) { printf("exclusive unlock of (%s) %s @ %s:%d\n", class->lc_name, - lock->lo_name, file, line); - printf("while share locked from %s:%d\n", instance->li_file, + lock->lo_name, fixup_filename(file), line); + printf("while share locked from %s:%d\n", + fixup_filename(instance->li_file), instance->li_line); panic("share->uexcl"); } @@ -1544,7 +1559,7 @@ found: /* The lock is now being dropped, check for NORELEASE flag */ if ((instance->li_flags & LI_NORELEASE) != 0 && witness_watch > 0) { printf("forbidden unlock of (%s) %s @ %s:%d\n", class->lc_name, - lock->lo_name, file, line); + lock->lo_name, fixup_filename(file), line); panic("lock marked norelease"); } @@ -2074,7 +2089,8 @@ witness_list_lock(struct lock_instance *instance, if (lock->lo_witness->w_name != lock->lo_name) prnt(" (%s)", lock->lo_witness->w_name); prnt(" r = %d (%p) locked @ %s:%d\n", - instance->li_flags & LI_RECURSEMASK, lock, instance->li_file, + instance->li_flags & LI_RECURSEMASK, lock, + fixup_filename(instance->li_file), instance->li_line); } @@ -2211,12 +2227,12 @@ witness_assert(struct lock_object *lock, int flags, const char *file, int line) panic("Lock (%s) %s is not sleep or spin!", class->lc_name, lock->lo_name); } - file = fixup_filename(file); switch (flags) { case LA_UNLOCKED: if (instance != NULL) panic("Lock (%s) %s locked @ %s:%d.", - class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, + fixup_filename(file), line); break; case LA_LOCKED: case LA_LOCKED | LA_RECURSED: @@ -2229,28 +2245,34 @@ witness_assert(struct lock_object *lock, int flags, const char *file, int line) case LA_XLOCKED | LA_NOTRECURSED: if (instance == NULL) { panic("Lock (%s) %s not locked @ %s:%d.", - class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, + fixup_filename(file), line); break; } if ((flags & LA_XLOCKED) != 0 && (instance->li_flags & LI_EXCLUSIVE) == 0) panic("Lock (%s) %s not exclusively locked @ %s:%d.", - class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, + fixup_filename(file), line); if ((flags & LA_SLOCKED) != 0 && (instance->li_flags & LI_EXCLUSIVE) != 0) panic("Lock (%s) %s exclusively locked @ %s:%d.", - class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, + fixup_filename(file), line); if ((flags & LA_RECURSED) != 0 && (instance->li_flags & LI_RECURSEMASK) == 0) panic("Lock (%s) %s not recursed @ %s:%d.", - class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, + fixup_filename(file), line); if ((flags & LA_NOTRECURSED) != 0 && (instance->li_flags & LI_RECURSEMASK) != 0) panic("Lock (%s) %s recursed @ %s:%d.", - class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, + fixup_filename(file), line); break; default: - panic("Invalid lock assertion at %s:%d.", file, line); + panic("Invalid lock assertion at %s:%d.", + fixup_filename(file), line); } #endif /* INVARIANT_SUPPORT */ |