MCPcopy Create free account
hub / github.com/F-Stack/f-stack / __mtx_lock_sleep

Function __mtx_lock_sleep

freebsd/kern/kern_mutex.c:492–689  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

490 int line)
491#else
492void
493__mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v)
494#endif
495{
496 struct thread *td;
497 struct mtx *m;
498 struct turnstile *ts;
499 uintptr_t tid;
500 struct thread *owner;
501#ifdef LOCK_PROFILING
502 int contested = 0;
503 uint64_t waittime = 0;
504#endif
505#if defined(ADAPTIVE_MUTEXES) || defined(KDTRACE_HOOKS)
506 struct lock_delay_arg lda;
507#endif
508#ifdef KDTRACE_HOOKS
509 u_int sleep_cnt = 0;
510 int64_t sleep_time = 0;
511 int64_t all_time = 0;
512#endif
513#if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING)
514 int doing_lockprof = 0;
515#endif
516
517 td = curthread;
518 tid = (uintptr_t)td;
519 m = mtxlock2mtx(c);
520
521#ifdef KDTRACE_HOOKS
522 if (LOCKSTAT_PROFILE_ENABLED(adaptive__acquire)) {
523 while (v == MTX_UNOWNED) {
524 if (_mtx_obtain_lock_fetch(m, &v, tid))
525 goto out_lockstat;
526 }
527 doing_lockprof = 1;
528 all_time -= lockstat_nsecs(&m->lock_object);
529 }
530#endif
531#ifdef LOCK_PROFILING
532 doing_lockprof = 1;
533#endif
534
535 if (SCHEDULER_STOPPED_TD(td))
536 return;
537
538 if (__predict_false(v == MTX_UNOWNED))
539 v = MTX_READ_VALUE(m);
540
541 if (__predict_false(lv_mtx_owner(v) == td)) {
542 KASSERT((m->lock_object.lo_flags & LO_RECURSABLE) != 0 ||
543 (opts & MTX_RECURSE) != 0,
544 ("_mtx_lock_sleep: recursed on non-recursive mutex %s @ %s:%d\n",
545 m->lock_object.lo_name, file, line));
546#if LOCK_DEBUG > 0
547 opts &= ~MTX_RECURSE;
548#endif
549 m->mtx_recurse++;

Callers

nothing calls this directly

Calls 10

lockstat_nsecsFunction · 0.85
lock_delay_arg_initFunction · 0.85
lock_delayFunction · 0.85
turnstile_trywaitFunction · 0.85
turnstile_cancelFunction · 0.85
mtx_assertFunction · 0.85
turnstile_waitFunction · 0.85
sched_tdnameFunction · 0.70

Tested by

no test coverage detected