subr_turnstile.c (8a36da99deb0e19363ec04e4d3facd869c1028f5) subr_turnstile.c (06bf2a6aefbf98f0717954368a8791cd70bfba30)
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1998 Berkeley Software Design, Inc. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 552 unchanged lines hidden (view full) ---

561 MPASS(ts != NULL);
562 mtx_lock_spin(&ts->ts_lock);
563 KASSERT(ts->ts_lockobj == NULL, ("stale ts_lockobj pointer"));
564 ts->ts_lockobj = lock;
565
566 return (ts);
567}
568
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1998 Berkeley Software Design, Inc. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 552 unchanged lines hidden (view full) ---

561 MPASS(ts != NULL);
562 mtx_lock_spin(&ts->ts_lock);
563 KASSERT(ts->ts_lockobj == NULL, ("stale ts_lockobj pointer"));
564 ts->ts_lockobj = lock;
565
566 return (ts);
567}
568
569struct thread *
570turnstile_lock(struct turnstile *ts, struct lock_object **lockp)
571{
572 struct turnstile_chain *tc;
573 struct lock_object *lock;
574
575 if ((lock = ts->ts_lockobj) == NULL)
576 return (NULL);
577 tc = TC_LOOKUP(lock);
578 mtx_lock_spin(&tc->tc_lock);
579 mtx_lock_spin(&ts->ts_lock);
580 if (__predict_false(lock != ts->ts_lockobj)) {
581 mtx_unlock_spin(&tc->tc_lock);
582 mtx_unlock_spin(&ts->ts_lock);
583 return (NULL);
584 }
585 *lockp = lock;
586 return (ts->ts_owner);
587}
588
569void
589void
590turnstile_unlock(struct turnstile *ts, struct lock_object *lock)
591{
592 struct turnstile_chain *tc;
593
594 mtx_assert(&ts->ts_lock, MA_OWNED);
595 mtx_unlock_spin(&ts->ts_lock);
596 if (ts == curthread->td_turnstile)
597 ts->ts_lockobj = NULL;
598 tc = TC_LOOKUP(lock);
599 mtx_unlock_spin(&tc->tc_lock);
600}
601
602void
603turnstile_assert(struct turnstile *ts)
604{
605 MPASS(ts->ts_lockobj == NULL);
606}
607
608void
570turnstile_cancel(struct turnstile *ts)
571{
572 struct turnstile_chain *tc;
573 struct lock_object *lock;
574
575 mtx_assert(&ts->ts_lock, MA_OWNED);
576
577 mtx_unlock_spin(&ts->ts_lock);

--- 679 unchanged lines hidden ---
609turnstile_cancel(struct turnstile *ts)
610{
611 struct turnstile_chain *tc;
612 struct lock_object *lock;
613
614 mtx_assert(&ts->ts_lock, MA_OWNED);
615
616 mtx_unlock_spin(&ts->ts_lock);

--- 679 unchanged lines hidden ---