diff options
author | Mateusz Guzik <mjg@FreeBSD.org> | 2017-12-31 00:33:28 +0000 |
---|---|---|
committer | Mateusz Guzik <mjg@FreeBSD.org> | 2017-12-31 00:33:28 +0000 |
commit | 1f4d28c7ea9efb31813352b57e94520bf4bcf509 (patch) | |
tree | 1032946282b3088f3156bba93a24c43c44405b7a | |
parent | 80c39f6c374bd412b6c88e63268094030d77245c (diff) | |
download | src-test2-1f4d28c7ea9efb31813352b57e94520bf4bcf509.tar.gz src-test2-1f4d28c7ea9efb31813352b57e94520bf4bcf509.zip |
Notes
-rw-r--r-- | sys/kern/kern_mutex.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index e7985b4a4c5e..aaebf7f817f7 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -899,6 +899,10 @@ thread_lock_flags_(struct thread *td, int opts, const char *file, int line) lock_delay_arg_init(&lda, &mtx_spin_delay); +#ifdef HWPMC_HOOKS + PMC_SOFT_CALL( , , lock, failed); +#endif + #ifdef LOCK_PROFILING doing_lockprof = 1; #elif defined(KDTRACE_HOOKS) @@ -908,22 +912,20 @@ thread_lock_flags_(struct thread *td, int opts, const char *file, int line) #endif for (;;) { retry: - v = MTX_UNOWNED; spinlock_enter(); m = td->td_lock; thread_lock_validate(m, opts, file, line); + v = MTX_READ_VALUE(m); for (;;) { - if (_mtx_obtain_lock_fetch(m, &v, tid)) - break; - if (v == MTX_UNOWNED) + if (v == MTX_UNOWNED) { + if (_mtx_obtain_lock_fetch(m, &v, tid)) + break; continue; + } if (v == tid) { m->mtx_recurse++; break; } -#ifdef HWPMC_HOOKS - PMC_SOFT_CALL( , , lock, failed); -#endif lock_profile_obtain_lock_failed(&m->lock_object, &contested, &waittime); /* Give interrupts a chance while we spin. */ |