diff options
| author | Attilio Rao <attilio@FreeBSD.org> | 2008-09-12 21:44:01 +0000 |
|---|---|---|
| committer | Attilio Rao <attilio@FreeBSD.org> | 2008-09-12 21:44:01 +0000 |
| commit | d56bc17bcea59253e909583b9717898433be1478 (patch) | |
| tree | 9273013a14fc38e518b572654d27d985a9bdbf62 | |
| parent | e6ee3717431df2b2e9a89a85453e5e7062a3b112 (diff) | |
Notes
| -rw-r--r-- | sys/kern/subr_witness.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 15f960ebccd5..0e00107f5f38 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -1099,6 +1099,7 @@ witness_checkorder(struct lock_object *lock, int flags, const char *file, plock = &(*lock_list)->ll_children[(*lock_list)->ll_count - 1]; if (interlock != NULL && plock->li_lock == interlock) { if ((*lock_list)->ll_count == 1) { + /* * The interlock is the only lock we hold, so * nothing to do. @@ -1523,10 +1524,20 @@ found: intr_restore(s); /* - * If this lock list entry is not the first and is now empty, free it. + * In order to reduce contention on w_mtx, we want to keep always an + * head object into lists so that frequent allocation from the + * free witness pool (and subsequent locking) is avoided. + * In order to maintain the current code simple, when the head + * object is totally unloaded it means also that we do not have + * further objects in the list, so the list ownership needs to be + * hand over to another object if the current head needs to be freed. */ - if (*lock_list != lle && (*lock_list)->ll_count == 0) { - lle = *lock_list; + if ((*lock_list)->ll_count == 0) { + if (*lock_list == lle) { + if (lle->ll_next == NULL) + return; + } else + lle = *lock_list; *lock_list = lle->ll_next; CTR3(KTR_WITNESS, "%s: pid %d removed lle %p", __func__, td->td_proc->p_pid, lle); @@ -2025,7 +2036,9 @@ static int witness_thread_has_locks(struct thread *td) { - return (td->td_sleeplocks != NULL); + if (td->td_sleeplocks == NULL) + return (0); + return (td->td_sleeplocks->ll_count != 0); } static int @@ -2252,7 +2265,7 @@ DB_SHOW_COMMAND(alllocks, db_witness_list_all) if (!witness_thread_has_locks(td)) continue; db_printf("Process %d (%s) thread %p (%d)\n", p->p_pid, - td->td_name, td, td->td_tid); + p->p_comm, td, td->td_tid); witness_ddb_list(td); } } |
