Print this page
patch as-lock-macro-simplification

*** 194,204 **** * stop() when SWATCHOK is set, so we need to handle multiple threads * at once. See holdwatch() for the details of this dance. */ mutex_enter(&p->p_maplock); ! AS_LOCK_ENTER(as, &as->a_lock, RW_READER); tpw.wp_vaddr = (caddr_t)((uintptr_t)addr & (uintptr_t)PAGEMASK); if ((pwp = avl_find(&as->a_wpage, &tpw, &where)) == NULL) pwp = avl_nearest(&as->a_wpage, where, AVL_AFTER); --- 194,204 ---- * stop() when SWATCHOK is set, so we need to handle multiple threads * at once. See holdwatch() for the details of this dance. */ mutex_enter(&p->p_maplock); ! AS_LOCK_ENTER(as, RW_READER); tpw.wp_vaddr = (caddr_t)((uintptr_t)addr & (uintptr_t)PAGEMASK); if ((pwp = avl_find(&as->a_wpage, &tpw, &where)) == NULL) pwp = avl_nearest(&as->a_wpage, where, AVL_AFTER);
*** 233,254 **** if (p->p_mapcnt == 0) { /* * Release as lock while in holdwatch() * in case other threads need to grab it. */ ! AS_LOCK_EXIT(as, &as->a_lock); mutex_exit(&p->p_maplock); if (holdwatch() != 0) { /* * We stopped in holdwatch(). * Start all over again because the * watched page list may have changed. */ goto startover; } mutex_enter(&p->p_maplock); ! AS_LOCK_ENTER(as, &as->a_lock, RW_READER); } p->p_mapcnt++; } addr = pwp->wp_vaddr; --- 233,254 ---- if (p->p_mapcnt == 0) { /* * Release as lock while in holdwatch() * in case other threads need to grab it. */ ! AS_LOCK_EXIT(as); mutex_exit(&p->p_maplock); if (holdwatch() != 0) { /* * We stopped in holdwatch(). * Start all over again because the * watched page list may have changed. */ goto startover; } mutex_enter(&p->p_maplock); ! AS_LOCK_ENTER(as, RW_READER); } p->p_mapcnt++; } addr = pwp->wp_vaddr;
*** 304,315 **** if (pwp->wp_oprot != 0) { /* if page exists */ struct seg *seg; uint_t oprot; int err, retrycnt = 0; ! AS_LOCK_EXIT(as, &as->a_lock); ! AS_LOCK_ENTER(as, &as->a_lock, RW_WRITER); retry: seg = as_segat(as, addr); ASSERT(seg != NULL); SEGOP_GETPROT(seg, addr, 0, &oprot); if (prot != oprot) { --- 304,315 ---- if (pwp->wp_oprot != 0) { /* if page exists */ struct seg *seg; uint_t oprot; int err, retrycnt = 0; ! AS_LOCK_EXIT(as); ! AS_LOCK_ENTER(as, RW_WRITER); retry: seg = as_segat(as, addr); ASSERT(seg != NULL); SEGOP_GETPROT(seg, addr, 0, &oprot); if (prot != oprot) {
*** 318,330 **** ASSERT(retrycnt == 0); retrycnt++; goto retry; } } ! AS_LOCK_EXIT(as, &as->a_lock); } else ! AS_LOCK_EXIT(as, &as->a_lock); /* * When all pages are mapped back to their normal state, * continue the other lwps. */ --- 318,330 ---- ASSERT(retrycnt == 0); retrycnt++; goto retry; } } ! AS_LOCK_EXIT(as); } else ! AS_LOCK_EXIT(as); /* * When all pages are mapped back to their normal state, * continue the other lwps. */
*** 338,351 **** mutex_exit(&p->p_lock); mutex_enter(&p->p_maplock); } } ! AS_LOCK_ENTER(as, &as->a_lock, RW_READER); } ! AS_LOCK_EXIT(as, &as->a_lock); mutex_exit(&p->p_maplock); return (rv); } --- 338,351 ---- mutex_exit(&p->p_lock); mutex_enter(&p->p_maplock); } } ! AS_LOCK_ENTER(as, RW_READER); } ! AS_LOCK_EXIT(as); mutex_exit(&p->p_maplock); return (rv); }
*** 392,402 **** if (p->p_wprot == NULL) return; ASSERT(MUTEX_NOT_HELD(&curproc->p_lock)); ! AS_LOCK_ENTER(as, &as->a_lock, RW_WRITER); pwp = p->p_wprot; while (pwp != NULL) { vaddr = pwp->wp_vaddr; --- 392,402 ---- if (p->p_wprot == NULL) return; ASSERT(MUTEX_NOT_HELD(&curproc->p_lock)); ! AS_LOCK_ENTER(as, RW_WRITER); pwp = p->p_wprot; while (pwp != NULL) { vaddr = pwp->wp_vaddr;
*** 429,439 **** pwp = next; } p->p_wprot = NULL; ! AS_LOCK_EXIT(as, &as->a_lock); } /* Must be called with as lock held */ --- 429,439 ---- pwp = next; } p->p_wprot = NULL; ! AS_LOCK_EXIT(as); } /* Must be called with as lock held */
*** 503,515 **** if ((as == &kas) || avl_numnodes(&as->a_wpage) == 0) return (0); /* Grab the lock because of XHAT (see comment in pr_mappage()) */ ! AS_LOCK_ENTER(as, &as->a_lock, RW_READER); rv = pr_is_watchpage_as(addr, rw, as); ! AS_LOCK_EXIT(as, &as->a_lock); return (rv); } --- 503,515 ---- if ((as == &kas) || avl_numnodes(&as->a_wpage) == 0) return (0); /* Grab the lock because of XHAT (see comment in pr_mappage()) */ ! AS_LOCK_ENTER(as, RW_READER); rv = pr_is_watchpage_as(addr, rw, as); ! AS_LOCK_EXIT(as); return (rv); }