Print this page
11909 THREAD_KPRI_RELEASE does nothing of the sort
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>

*** 22,32 **** * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* ! * Copyright (c) 2013, Joyent, Inc. All rights reserved. */ #include <sys/param.h> #include <sys/thread.h> #include <sys/cmn_err.h> --- 22,32 ---- * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* ! * Copyright 2019 Joyent, Inc. */ #include <sys/param.h> #include <sys/thread.h> #include <sys/cmn_err.h>
*** 267,279 **** void (*rw_lock_delay)(uint_t) = NULL; /* * Full-service implementation of rw_enter() to handle all the hard cases. * Called from the assembly version if anything complicated is going on. - * The only semantic difference between calling rw_enter() and calling - * rw_enter_sleep() directly is that we assume the caller has already done - * a THREAD_KPRI_REQUEST() in the RW_READER cases. */ void rw_enter_sleep(rwlock_impl_t *lp, krw_t rw) { uintptr_t old, new, lock_value, lock_busy, lock_wait; --- 267,276 ----
*** 340,358 **** turnstile_exit(lp); continue; } /* ! * We really are going to block. Bump the stats, and drop ! * kpri if we're a reader. */ ASSERT(lp->rw_wwwh & lock_wait); ASSERT(lp->rw_wwwh & RW_LOCKED); sleep_time = -gethrtime(); if (rw != RW_WRITER) { - THREAD_KPRI_RELEASE(); CPU_STATS_ADDQ(CPU, sys, rw_rdfails, 1); (void) turnstile_block(ts, TS_READER_Q, lp, &rw_sobj_ops, NULL, NULL); } else { CPU_STATS_ADDQ(CPU, sys, rw_wrfails, 1); --- 337,353 ---- turnstile_exit(lp); continue; } /* ! * We really are going to block, so bump the stats. */ ASSERT(lp->rw_wwwh & lock_wait); ASSERT(lp->rw_wwwh & RW_LOCKED); sleep_time = -gethrtime(); if (rw != RW_WRITER) { CPU_STATS_ADDQ(CPU, sys, rw_rdfails, 1); (void) turnstile_block(ts, TS_READER_Q, lp, &rw_sobj_ops, NULL, NULL); } else { CPU_STATS_ADDQ(CPU, sys, rw_wrfails, 1);
*** 364,375 **** LOCKSTAT_RECORD4(LS_RW_ENTER_BLOCK, lp, sleep_time, rw, (old & RW_WRITE_LOCKED) ? 1 : 0, old >> RW_HOLD_COUNT_SHIFT); /* ! * We wake up holding the lock (and having kpri if we're ! * a reader) via direct handoff from the previous owner. */ break; } ASSERT(rw_locked(lp, rw)); --- 359,370 ---- LOCKSTAT_RECORD4(LS_RW_ENTER_BLOCK, lp, sleep_time, rw, (old & RW_WRITE_LOCKED) ? 1 : 0, old >> RW_HOLD_COUNT_SHIFT); /* ! * We wake up holding the lock via direct handoff from the ! * previous owner. */ break; } ASSERT(rw_locked(lp, rw));
*** 392,402 **** int count = 0; while (next_reader != NULL) { if (DISP_PRIO(next_reader) < wpri) break; - next_reader->t_kpri_req++; next_reader = next_reader->t_link; count++; } return (count); } --- 387,396 ----
*** 521,531 **** } break; } if (lock_value == RW_READ_LOCK) { - THREAD_KPRI_RELEASE(); LOCKSTAT_RECORD(LS_RW_EXIT_RELEASE, lp, RW_READER); } else { LOCKSTAT_RECORD(LS_RW_EXIT_RELEASE, lp, RW_WRITER); } } --- 515,524 ----
*** 537,551 **** uintptr_t old; if (rw != RW_WRITER) { uint_t backoff = 0; int loop_count = 0; - THREAD_KPRI_REQUEST(); for (;;) { if ((old = lp->rw_wwwh) & (rw == RW_READER ? RW_WRITE_CLAIMED : RW_WRITE_LOCKED)) { - THREAD_KPRI_RELEASE(); return (0); } if (casip(&lp->rw_wwwh, old, old + RW_READ_LOCK) == old) break; if (rw_lock_delay != NULL) { --- 530,542 ----
*** 571,581 **** void rw_downgrade(krwlock_t *rwlp) { rwlock_impl_t *lp = (rwlock_impl_t *)rwlp; - THREAD_KPRI_REQUEST(); membar_exit(); if ((lp->rw_wwwh & RW_OWNER) != (uintptr_t)curthread) { rw_panic("rw_downgrade: not owner", lp); return; --- 562,571 ----
*** 610,620 **** return (0); new = old + RW_WRITE_LOCK(curthread) - RW_READ_LOCK; } while (casip(&lp->rw_wwwh, old, new) != old); membar_enter(); - THREAD_KPRI_RELEASE(); LOCKSTAT_RECORD0(LS_RW_TRYUPGRADE_UPGRADE, lp); ASSERT(rw_locked(lp, RW_WRITER)); return (1); } --- 600,609 ----