Lines Matching refs:lp
241 mutex_panic(char *msg, mutex_impl_t *lp)
246 if (casptr(&panic_mutex_addr, NULL, lp) == NULL)
247 panic_mutex = *lp;
249 panic("%s, lp=%p owner=%p thread=%p",
250 msg, (void *)lp, (void *)MUTEX_OWNER(&panic_mutex),
342 mutex_vector_enter(mutex_impl_t *lp)
350 volatile mutex_impl_t *vlp = (volatile mutex_impl_t *)lp;
356 if (MUTEX_TYPE_SPIN(lp)) {
357 lock_set_spl(&lp->m_spin.m_spinlock, lp->m_spin.m_minspl,
358 &lp->m_spin.m_oldspl);
362 if (!MUTEX_TYPE_ADAPTIVE(lp)) {
363 mutex_panic("mutex_enter: bad mutex", lp);
376 mutex_panic("mutex_enter: adaptive at high PIL", lp);
392 if (mutex_adaptive_tryenter(lp)) {
411 mutex_panic("recursive mutex_enter", lp);
420 if (mutex_owner_running(lp) != NULL) {
428 ts = turnstile_lookup(lp);
429 MUTEX_SET_WAITERS(lp);
436 if (mutex_owner_running(lp) != NULL) {
437 turnstile_exit(lp);
447 (void) turnstile_block(ts, TS_WRITER_Q, lp,
453 turnstile_exit(lp);
457 ASSERT(MUTEX_OWNER(lp) == curthread);
464 LOCKSTAT_RECORD(LS_MUTEX_ENTER_BLOCK, lp, sleep_time);
469 LOCKSTAT_RECORD_TIME(LS_MUTEX_ENTER_SPIN, lp,
473 LOCKSTAT_RECORD0(LS_MUTEX_ENTER_ACQUIRE, lp);
481 mutex_vector_tryenter(mutex_impl_t *lp)
485 if (MUTEX_TYPE_ADAPTIVE(lp))
488 if (!MUTEX_TYPE_SPIN(lp)) {
489 mutex_panic("mutex_tryenter: bad mutex", lp);
493 s = splr(lp->m_spin.m_minspl);
494 if (lock_try(&lp->m_spin.m_spinlock)) {
495 lp->m_spin.m_oldspl = (ushort_t)s;
507 mutex_vector_exit(mutex_impl_t *lp)
511 if (MUTEX_TYPE_SPIN(lp)) {
512 lock_clear_splx(&lp->m_spin.m_spinlock, lp->m_spin.m_oldspl);
516 if (MUTEX_OWNER(lp) != curthread) {
517 mutex_panic("mutex_exit: not owner", lp);
521 ts = turnstile_lookup(lp);
522 MUTEX_CLEAR_LOCK_AND_WAITERS(lp);
524 turnstile_exit(lp);
527 LOCKSTAT_RECORD0(LS_MUTEX_EXIT_RELEASE, lp);
533 const mutex_impl_t *lp = (const mutex_impl_t *)mp;
538 if (MUTEX_TYPE_ADAPTIVE(lp))
539 return (MUTEX_OWNER(lp) == curthread);
540 return (LOCK_HELD(&lp->m_spin.m_spinlock));
546 const mutex_impl_t *lp = (const mutex_impl_t *)mp;
549 if (MUTEX_TYPE_ADAPTIVE(lp) && (t = MUTEX_OWNER(lp)) != MUTEX_NO_OWNER)
568 mutex_impl_t *lp = (mutex_impl_t *)mp;
574 MUTEX_SET_TYPE(lp, MUTEX_SPIN);
575 LOCK_INIT_CLEAR(&lp->m_spin.m_spinlock);
576 LOCK_INIT_HELD(&lp->m_spin.m_dummylock);
577 lp->m_spin.m_minspl = (int)(intptr_t)ibc;
582 if (((uintptr_t)lp & (uintptr_t)(MUTEX_ALIGN - 1)) &&
600 (void *)lp, MUTEX_ALIGN,
612 MUTEX_SET_TYPE(lp, MUTEX_ADAPTIVE);
613 MUTEX_CLEAR_LOCK_AND_WAITERS(lp);
620 mutex_impl_t *lp = (mutex_impl_t *)mp;
622 if (lp->m_owner == 0 && !MUTEX_HAS_WAITERS(lp)) {
623 MUTEX_DESTROY(lp);
624 } else if (MUTEX_TYPE_SPIN(lp)) {
625 LOCKSTAT_RECORD0(LS_MUTEX_DESTROY_RELEASE, lp);
626 MUTEX_DESTROY(lp);
627 } else if (MUTEX_TYPE_ADAPTIVE(lp)) {
628 LOCKSTAT_RECORD0(LS_MUTEX_DESTROY_RELEASE, lp);
629 if (MUTEX_OWNER(lp) != curthread)
630 mutex_panic("mutex_destroy: not owner", lp);
631 if (MUTEX_HAS_WAITERS(lp)) {
632 turnstile_t *ts = turnstile_lookup(lp);
633 turnstile_exit(lp);
635 mutex_panic("mutex_destroy: has waiters", lp);
637 MUTEX_DESTROY(lp);
639 mutex_panic("mutex_destroy: bad mutex", lp);
647 lock_set_spin(lock_t *lp)
657 panic("lock_set: %p lock held and only one CPU", (void *)lp);
661 while (LOCK_HELD(lp) || !lock_spin_try(lp)) {
675 LOCKSTAT_RECORD_TIME(LS_LOCK_SET_SPIN, lp, spin_time);
677 LOCKSTAT_RECORD0(LS_LOCK_SET_ACQUIRE, lp);
681 lock_set_spl_spin(lock_t *lp, int new_pil, ushort_t *old_pil_addr, int old_pil)
692 (void *)lp);
700 while (LOCK_HELD(lp)) {
716 } while (!lock_spin_try(lp));
720 LOCKSTAT_RECORD_TIME(LS_LOCK_SET_SPL_SPIN, lp, spin_time);
722 LOCKSTAT_RECORD0(LS_LOCK_SET_SPL_ACQUIRE, lp);