Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Don't PHOLD() in sa_putcachelwp() because the sched...



details:   https://anonhg.NetBSD.org/src/rev/12b9a5e92115
branches:  trunk
changeset: 554690:12b9a5e92115
user:      cl <cl%NetBSD.org@localhost>
date:      Fri Oct 31 22:03:18 2003 +0000

description:
Don't PHOLD() in sa_putcachelwp() because the scheduler lock is held.
PHOLD() before grabbing the scheduler lock unless the lwp is curlwp.

diffstat:

 sys/kern/kern_sa.c |  19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diffs (96 lines):

diff -r ddcd64e03213 -r 12b9a5e92115 sys/kern/kern_sa.c
--- a/sys/kern/kern_sa.c        Fri Oct 31 21:52:11 2003 +0000
+++ b/sys/kern/kern_sa.c        Fri Oct 31 22:03:18 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sa.c,v 1.30 2003/10/30 01:58:18 simonb Exp $      */
+/*     $NetBSD: kern_sa.c,v 1.31 2003/10/31 22:03:18 cl Exp $  */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sa.c,v 1.30 2003/10/30 01:58:18 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sa.c,v 1.31 2003/10/31 22:03:18 cl Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -398,7 +398,8 @@
 #if 0
        } else {
                DPRINTFN(1,("sa_yield(%d.%d) stepping aside\n", p->p_pid, l->l_lid));
-       
+
+               PHOLD(l);
                SCHED_LOCK(s);
                l2 = sa->sa_woken;
                sa->sa_woken = NULL;
@@ -572,6 +573,7 @@
                }
 
                p->p_nrlwps--;
+               PHOLD(l);
                sa_putcachelwp(p, l);
                mi_switch(l, NULL);
                /* mostly NOTREACHED */
@@ -838,8 +840,7 @@
                        &sau->sau_state.captured.e_ctx) != 0) {
                        sadata_upcall_free(sau);
                        sa->sa_stacks[sa->sa_nstacks++] = st;
-                       sa_putcachelwp(p, l2);
-                       PRELE(l2); /* Remove the artificial hold-count */
+                       sa_putcachelwp(p, l2); /* PHOLD from sa_getcachelwp */
                        mi_switch(l, NULL);
                        return;
                }
@@ -909,8 +910,7 @@
 #else
                
                /* sa_putcachelwp does not block because we have a hold count on l2 */
-               sa_putcachelwp(p, l2);
-               PRELE(l2); /* Remove the artificial hold-count */
+               sa_putcachelwp(p, l2); /* PHOLD from sa_getcachelwp */
 
                mi_switch(l, NULL);
                return;
@@ -1017,6 +1017,7 @@
                 * newlwp helpfully puts it there. Unclear if newlwp should
                 * be tweaked.
                 */
+               PHOLD(l2);
                SCHED_LOCK(s);
                sa_putcachelwp(p, l2);
                SCHED_UNLOCK(s);
@@ -1042,7 +1043,6 @@
        p->p_nlwps--;
        l->l_stat = LSSUSPENDED;
        l->l_flag |= (L_DETACHED | L_SA);
-       PHOLD(l);
        /* XXX lock sadata */
        DPRINTFN(5,("sa_putcachelwp(%d.%d) Adding LWP %d to cache\n",
            p->p_pid, curlwp->l_lid, l->l_lid));
@@ -1110,6 +1110,7 @@
                        l->l_flag &= ~(L_SA_UPCALL|L_SA_BLOCKING);
                        l->l_upcallstack = NULL;
                        p->p_nrlwps--;
+                       PHOLD(l);
                        sa_putcachelwp(p, l);
                        SA_LWP_STATE_UNLOCK(l, f);
                        KERNEL_PROC_UNLOCK(l);
@@ -1367,6 +1368,7 @@
 
        KDASSERT(l2 != l);
        if (l2) {
+               PHOLD(l2);
                SCHED_LOCK(s);
                switch (l2->l_stat) {
                case LSRUN:
@@ -1462,6 +1464,7 @@
 
        LIST_FOREACH(l2, &p->p_lwps, l_sibling) {
                if(l2->l_flag &  L_SA_WANTS_VP) {
+                       PHOLD(l);
                        SCHED_LOCK(s);
                        
                        p->p_nrlwps--;



Home | Main Index | Thread Index | Old Index