Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Apr 2003 12:16:38 -0700 (PDT)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 29521 for review
Message-ID:  <200304231916.h3NJGcN8082804@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=29521

Change 29521 by jhb@jhb_laptop on 2003/04/23 12:16:24

	IFC @29520 (proc locking).

Affected files ...

.. //depot/projects/smpng/sys/compat/linux/linux_file.c#18 integrate
.. //depot/projects/smpng/sys/kern/kern_exit.c#63 integrate
.. //depot/projects/smpng/sys/kern/kern_resource.c#36 integrate
.. //depot/projects/smpng/sys/kern/kern_sig.c#61 integrate
.. //depot/projects/smpng/sys/kern/kern_synch.c#46 integrate
.. //depot/projects/smpng/sys/kern/kern_thread.c#29 integrate
.. //depot/projects/smpng/sys/kern/sched_4bsd.c#9 integrate
.. //depot/projects/smpng/sys/kern/sched_ule.c#9 integrate
.. //depot/projects/smpng/sys/kern/subr_trap.c#52 integrate
.. //depot/projects/smpng/sys/net/if_ethersubr.c#30 integrate
.. //depot/projects/smpng/sys/sys/proc.h#83 integrate
.. //depot/projects/smpng/sys/vm/vm_glue.c#24 integrate

Differences ...

==== //depot/projects/smpng/sys/compat/linux/linux_file.c#18 (text+ko) ====

@@ -25,7 +25,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/compat/linux/linux_file.c,v 1.79 2003/03/20 21:17:38 jhb Exp $
+ * $FreeBSD: src/sys/compat/linux/linux_file.c,v 1.80 2003/04/23 18:13:26 jhb Exp $
  */
 
 #include "opt_compat.h"
@@ -126,8 +126,8 @@
 	SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
 	struct file *fp;
 
+	PROC_UNLOCK(p);
 	error = fget(td, td->td_retval[0], &fp);
-	PROC_UNLOCK(p);
 	if (!error) {
 		if (fp->f_type == DTYPE_VNODE)
 			fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, td->td_ucred,

==== //depot/projects/smpng/sys/kern/kern_exit.c#63 (text+ko) ====

@@ -36,7 +36,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)kern_exit.c	8.7 (Berkeley) 2/12/94
- * $FreeBSD: src/sys/kern/kern_exit.c,v 1.211 2003/04/21 14:42:04 davidxu Exp $
+ * $FreeBSD: src/sys/kern/kern_exit.c,v 1.212 2003/04/23 18:46:51 jhb Exp $
  */
 
 #include "opt_compat.h"
@@ -698,9 +698,11 @@
 			mtx_unlock(&Giant);
 			return (0);
 		}
+		mtx_lock_spin(&sched_lock);
 		if (P_SHOULDSTOP(p) && (p->p_suspcount == p->p_numthreads) &&
 		    ((p->p_flag & P_WAITED) == 0) &&
 		    (p->p_flag & P_TRACED || uap->options & WUNTRACED)) {
+			mtx_unlock_spin(&sched_lock);
 			p->p_flag |= P_WAITED;
 			sx_xunlock(&proctree_lock);
 			td->td_retval[0] = p->p_pid;
@@ -723,6 +725,7 @@
 			mtx_unlock(&Giant);
 			return (error);
 		}
+		mtx_unlock_spin(&sched_lock);
 		if (uap->options & WCONTINUED && (p->p_flag & P_CONTINUED)) {
 			sx_xunlock(&proctree_lock);
 			td->td_retval[0] = p->p_pid;

==== //depot/projects/smpng/sys/kern/kern_resource.c#36 (text+ko) ====

@@ -36,7 +36,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)kern_resource.c	8.5 (Berkeley) 1/21/94
- * $FreeBSD: src/sys/kern/kern_resource.c,v 1.124 2003/04/22 20:45:38 jhb Exp $
+ * $FreeBSD: src/sys/kern/kern_resource.c,v 1.125 2003/04/23 18:48:55 jhb Exp $
  */
 
 #include "opt_compat.h"
@@ -94,8 +94,6 @@
 	int error = 0;
 	struct ksegrp *kg;
 
-	mtx_lock(&Giant);
-
 	switch (uap->which) {
 	case PRIO_PROCESS:
 		if (uap->who == 0)
@@ -168,7 +166,6 @@
 	if (low == PRIO_MAX + 1 && error == 0)
 		error = ESRCH;
 	td->td_retval[0] = low;
-	mtx_unlock(&Giant);
 	return (error);
 }
 
@@ -192,8 +189,6 @@
 	register struct proc *p;
 	int found = 0, error = 0;
 
-	mtx_lock(&Giant);
-
 	switch (uap->which) {
 	case PRIO_PROCESS:
 		if (uap->who == 0) {
@@ -260,7 +255,6 @@
 	}
 	if (found == 0 && error == 0)
 		error = ESRCH;
-	mtx_unlock(&Giant);
 	return (error);
 }
 

==== //depot/projects/smpng/sys/kern/kern_sig.c#61 (text+ko) ====

@@ -36,7 +36,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)kern_sig.c	8.7 (Berkeley) 4/18/94
- * $FreeBSD: src/sys/kern/kern_sig.c,v 1.229 2003/04/19 05:04:06 davidxu Exp $
+ * $FreeBSD: src/sys/kern/kern_sig.c,v 1.230 2003/04/23 18:50:25 jhb Exp $
  */
 
 #include "opt_compat.h"
@@ -1157,33 +1157,27 @@
 	register struct osigstack_args *uap;
 {
 	struct proc *p = td->td_proc;
-	struct sigstack ss;
+	struct sigstack nss, oss;
 	int error = 0;
 
-	mtx_lock(&Giant);
-
-	if (uap->oss != NULL) {
-		PROC_LOCK(p);
-		ss.ss_sp = p->p_sigstk.ss_sp;
-		ss.ss_onstack = sigonstack(cpu_getstack(td));
-		PROC_UNLOCK(p);
-		error = copyout(&ss, uap->oss, sizeof(struct sigstack));
+	if (uap->nss != NULL) {
+		error = copyin(uap->nss, &nss, sizeof(nss));
 		if (error)
-			goto done2;
+			return (error);
 	}
-
+	PROC_LOCK(p);
+	oss.ss_sp = p->p_sigstk.ss_sp;
+	oss.ss_onstack = sigonstack(cpu_getstack(td));
 	if (uap->nss != NULL) {
-		if ((error = copyin(uap->nss, &ss, sizeof(ss))) != 0)
-			goto done2;
-		PROC_LOCK(p);
-		p->p_sigstk.ss_sp = ss.ss_sp;
+		p->p_sigstk.ss_sp = nss.ss_sp;
 		p->p_sigstk.ss_size = 0;
-		p->p_sigstk.ss_flags |= ss.ss_onstack & SS_ONSTACK;
+		p->p_sigstk.ss_flags |= nss.ss_onstack & SS_ONSTACK;
 		p->p_flag |= P_ALTSTACK;
-		PROC_UNLOCK(p);
 	}
-done2:
-	mtx_unlock(&Giant);
+	PROC_UNLOCK(p);
+	if (uap->oss != NULL)
+		error = copyout(&oss, uap->oss, sizeof(oss));
+
 	return (error);
 }
 #endif /* COMPAT_43 || COMPAT_SUNOS */

==== //depot/projects/smpng/sys/kern/kern_synch.c#46 (text+ko) ====

@@ -36,7 +36,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)kern_synch.c	8.9 (Berkeley) 5/19/95
- * $FreeBSD: src/sys/kern/kern_synch.c,v 1.217 2003/04/02 23:53:29 peter Exp $
+ * $FreeBSD: src/sys/kern/kern_synch.c,v 1.218 2003/04/23 18:46:51 jhb Exp $
  */
 
 #include "opt_ddb.h"
@@ -167,6 +167,7 @@
 	 * the thread (recursion here might be bad).
 	 * Hence the TDF_INMSLEEP flag.
 	 */
+	mtx_lock_spin(&sched_lock);
 	if (p->p_flag & P_THREADED || p->p_numthreads > 1) {
 		/*
 		 * Just don't bother if we are exiting
@@ -177,10 +178,10 @@
 		    (((p->p_flag & P_WEXIT) && (p->p_singlethread != td)) ||
 		     (td->td_flags & TDF_INTERRUPT))) {
 			td->td_flags &= ~TDF_INTERRUPT;
+			mtx_unlock_spin(&sched_lock);
 			return (EINTR);
 		}
 	}
-	mtx_lock_spin(&sched_lock);
 	if (cold ) {
 		/*
 		 * During autoconfiguration, just give interrupts

==== //depot/projects/smpng/sys/kern/kern_thread.c#29 (text+ko) ====

@@ -25,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  * DAMAGE.
  *
- * $FreeBSD: src/sys/kern/kern_thread.c,v 1.122 2003/04/22 19:47:55 jhb Exp $
+ * $FreeBSD: src/sys/kern/kern_thread.c,v 1.123 2003/04/23 18:46:51 jhb Exp $
  */
 
 #include <sys/param.h>
@@ -1299,7 +1299,8 @@
 {      
 	struct proc *p = td->td_proc;
 	struct ksegrp *kg = td->td_ksegrp;
-   
+
+	mtx_assert(&sched_lock, MA_OWNED);
 	TAILQ_REMOVE(&p->p_threads, td, td_plist);
 	p->p_numthreads--;
 	TAILQ_REMOVE(&kg->kg_threads, td, td_kglist);
@@ -1683,11 +1684,11 @@
 	if (p->p_numthreads > max_threads_per_proc) {
 		max_threads_hits++;
 		PROC_LOCK(p);
+		mtx_lock_spin(&sched_lock);
 		while (p->p_numthreads > max_threads_per_proc) {
 			if (P_SHOULDSTOP(p))
 				break;
 			upcalls = 0;
-			mtx_lock_spin(&sched_lock);
 			FOREACH_KSEGRP_IN_PROC(p, kg2) {
 				if (kg2->kg_numupcalls == 0)
 					upcalls++;
@@ -1701,7 +1702,9 @@
 			msleep(&p->p_numthreads, &p->p_mtx, PPAUSE|PCATCH,
 			    "maxthreads", NULL);
 			p->p_maxthrwaits--;
+			mtx_lock_spin(&sched_lock);
 		}
+		mtx_unlock_spin(&sched_lock);
 		PROC_UNLOCK(p);
 	}
 
@@ -1818,10 +1821,9 @@
 	} else
 		p->p_flag &= ~P_SINGLE_EXIT;
 	p->p_flag |= P_STOPPED_SINGLE;
+	mtx_lock_spin(&sched_lock);
 	p->p_singlethread = td;
-	/* XXXKSE Which lock protects the below values? */
 	while ((p->p_numthreads - p->p_suspcount) != 1) {
-		mtx_lock_spin(&sched_lock);
 		FOREACH_THREAD_IN_PROC(p, td2) {
 			if (td2 == td)
 				continue;
@@ -1855,10 +1857,8 @@
 		/* 
 		 * Maybe we suspended some threads.. was it enough? 
 		 */
-		if ((p->p_numthreads - p->p_suspcount) == 1) {
-			mtx_unlock_spin(&sched_lock);
+		if ((p->p_numthreads - p->p_suspcount) == 1)
 			break;
-		}
 
 		/*
 		 * Wake us up when everyone else has suspended.
@@ -1872,15 +1872,14 @@
 		mtx_unlock_spin(&sched_lock);
 		PICKUP_GIANT();
 		PROC_LOCK(p);
+		mtx_lock_spin(&sched_lock);
 	}
 	if (force_exit == SINGLE_EXIT) { 
-		if (td->td_upcall) {
-			mtx_lock_spin(&sched_lock);
+		if (td->td_upcall)
 			upcall_remove(td);
-			mtx_unlock_spin(&sched_lock);
-		}
 		kse_purge(p, td);
 	}
+	mtx_unlock_spin(&sched_lock);
 	return (0);
 }
 
@@ -1987,6 +1986,7 @@
 	struct proc *p = td->td_proc;
 
 	mtx_assert(&sched_lock, MA_OWNED);
+	PROC_LOCK_ASSERT(p, MA_OWNED);
 	KASSERT(!TD_IS_SUSPENDED(td), ("already suspended"));
 	p->p_suspcount++;
 	TD_SET_SUSPENDED(td);
@@ -2007,6 +2007,7 @@
 	struct proc *p = td->td_proc;
 
 	mtx_assert(&sched_lock, MA_OWNED);
+	PROC_LOCK_ASSERT(p, MA_OWNED);
 	TAILQ_REMOVE(&p->p_suspended, td, td_runq);
 	TD_CLR_SUSPENDED(td);
 	p->p_suspcount--;
@@ -2048,6 +2049,7 @@
 	p = td->td_proc;
 	PROC_LOCK_ASSERT(p, MA_OWNED);
 	p->p_flag &= ~P_STOPPED_SINGLE;
+	mtx_lock_spin(&sched_lock);
 	p->p_singlethread = NULL;
 	/*
 	 * If there are other threads they mey now run,
@@ -2056,12 +2058,11 @@
 	 * to continue however as this is a bad place to stop.
 	 */
 	if ((p->p_numthreads != 1) && (!P_SHOULDSTOP(p))) {
-		mtx_lock_spin(&sched_lock);
 		while (( td = TAILQ_FIRST(&p->p_suspended))) {
 			thread_unsuspend_one(td);
 		}
-		mtx_unlock_spin(&sched_lock);
 	}
+	mtx_unlock_spin(&sched_lock);
 }
 
 

==== //depot/projects/smpng/sys/kern/sched_4bsd.c#9 (text+ko) ====

@@ -35,7 +35,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/kern/sched_4bsd.c,v 1.16 2003/04/22 20:50:38 jhb Exp $
+ * $FreeBSD: src/sys/kern/sched_4bsd.c,v 1.17 2003/04/23 18:51:05 jhb Exp $
  */
 
 #include <sys/param.h>
@@ -441,6 +441,7 @@
 	struct ksegrp *kg;
 	struct thread *td;
 
+	mtx_assert(&sched_lock, MA_OWNED);
 	kg = ke->ke_ksegrp;
 	td = ke->ke_thread;
 
@@ -476,6 +477,8 @@
 void
 sched_exit_ksegrp(struct ksegrp *kg, struct ksegrp *child)
 {
+
+	mtx_assert(&sched_lock, MA_OWNED);
 	kg->kg_estcpu = ESTCPULIM(kg->kg_estcpu + child->kg_estcpu);
 }
 
@@ -501,6 +504,7 @@
 void
 sched_fork_ksegrp(struct ksegrp *kg, struct ksegrp *child)
 {
+	mtx_assert(&sched_lock, MA_OWNED);
 	child->kg_estcpu = kg->kg_estcpu;
 }
 
@@ -522,6 +526,7 @@
 void
 sched_class(struct ksegrp *kg, int class)
 {
+	mtx_assert(&sched_lock, MA_OWNED);
 	kg->kg_pri_class = class;
 }
 
@@ -535,6 +540,7 @@
 sched_prio(struct thread *td, u_char prio)
 {
 
+	mtx_assert(&sched_lock, MA_OWNED);
 	if (TD_ON_RUNQ(td)) {
 		adjustrunqueue(td, prio);
 	} else {
@@ -545,6 +551,8 @@
 void
 sched_sleep(struct thread *td, u_char prio)
 {
+
+	mtx_assert(&sched_lock, MA_OWNED);
 	td->td_ksegrp->kg_slptime = 0;
 	td->td_priority = prio;
 }
@@ -552,6 +560,8 @@
 void
 sched_switchin(struct thread *td)
 {
+
+	mtx_assert(&sched_lock, MA_OWNED);
 	td->td_oncpu = PCPU_GET(cpuid);
 }
 
@@ -564,6 +574,7 @@
 	ke = td->td_kse;
 	p = td->td_proc;
 
+	mtx_assert(&sched_lock, MA_OWNED);
 	KASSERT((ke->ke_state == KES_THREAD), ("mi_switch: kse state?"));
 
 	td->td_lastcpu = td->td_oncpu;
@@ -593,6 +604,7 @@
 {
 	struct ksegrp *kg;
 
+	mtx_assert(&sched_lock, MA_OWNED);
 	kg = td->td_ksegrp;
 	if (kg->kg_slptime > 1)
 		updatepri(kg);

==== //depot/projects/smpng/sys/kern/sched_ule.c#9 (text+ko) ====

@@ -23,7 +23,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/kern/sched_ule.c,v 1.31 2003/04/22 20:50:38 jhb Exp $
+ * $FreeBSD: src/sys/kern/sched_ule.c,v 1.32 2003/04/23 18:51:05 jhb Exp $
  */
 
 #include <sys/param.h>
@@ -769,6 +769,7 @@
 void
 sched_fork_kse(struct kse *ke, struct kse *child)
 {
+
 	child->ke_slice = ke->ke_slice;
 	child->ke_cpu = ke->ke_cpu; /* sched_pickcpu(); */
 	child->ke_runq = NULL;
@@ -785,6 +786,8 @@
 void
 sched_fork_ksegrp(struct ksegrp *kg, struct ksegrp *child)
 {
+
+	PROC_LOCK_ASSERT(child->kg_proc, MA_OWNED);
 	/* XXX Need something better here */
 	if (kg->kg_slptime > kg->kg_runtime) {
 		child->kg_slptime = SCHED_DYN_RANGE;
@@ -809,6 +812,7 @@
 	struct kseq *kseq;
 	struct kse *ke;
 
+	mtx_assert(&sched_lock, MA_OWNED);
 	if (kg->kg_pri_class == class)
 		return;
 

==== //depot/projects/smpng/sys/kern/subr_trap.c#52 (text+ko) ====

@@ -35,7 +35,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)trap.c	7.4 (Berkeley) 5/13/91
- * $FreeBSD: src/sys/kern/subr_trap.c,v 1.252 2003/04/22 20:54:04 jhb Exp $
+ * $FreeBSD: src/sys/kern/subr_trap.c,v 1.253 2003/04/23 18:51:55 jhb Exp $
  */
 
 #include "opt_mac.h"
@@ -78,7 +78,6 @@
             p->p_comm);
 #ifdef INVARIANTS
 	/* Check that we called signotify() enough. */
-	mtx_lock(&Giant);
 	PROC_LOCK(p);
 	mtx_lock_spin(&sched_lock);
 	if (SIGPENDING(td) && ((td->td_flags & TDF_NEEDSIGCHK) == 0 ||
@@ -86,7 +85,6 @@
 		printf("failed to set signal flags properly for ast()\n");
 	mtx_unlock_spin(&sched_lock);
 	PROC_UNLOCK(p);
-	mtx_unlock(&Giant);
 #endif
 
 	/*

==== //depot/projects/smpng/sys/net/if_ethersubr.c#30 (text+ko) ====

@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)if_ethersubr.c	8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/net/if_ethersubr.c,v 1.143 2003/03/21 17:53:15 mdodd Exp $
+ * $FreeBSD: src/sys/net/if_ethersubr.c,v 1.144 2003/04/23 18:35:40 archie Exp $
  */
 
 #include "opt_atalk.h"
@@ -281,13 +281,13 @@
 
 		if ((m->m_flags & M_BCAST) || (loop_copy > 0)) {
 			struct mbuf *n;
-			n = m_copy(m, 0, (int)M_COPYALL);
 
-			n->m_pkthdr.csum_flags |= csum_flags;
-			if (csum_flags & CSUM_DATA_VALID)
-				n->m_pkthdr.csum_data = 0xffff;
-
-			(void) if_simloop(ifp, n, dst->sa_family, hlen);
+			if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
+				n->m_pkthdr.csum_flags |= csum_flags;
+				if (csum_flags & CSUM_DATA_VALID)
+					n->m_pkthdr.csum_data = 0xffff;
+				(void)if_simloop(ifp, n, dst->sa_family, hlen);
+			}
 		} else if (bcmp(eh->ether_dhost, eh->ether_shost,
 				ETHER_ADDR_LEN) == 0) {
 			m->m_pkthdr.csum_flags |= csum_flags;

==== //depot/projects/smpng/sys/sys/proc.h#83 (text+ko) ====

@@ -36,7 +36,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)proc.h	8.15 (Berkeley) 5/19/95
- * $FreeBSD: src/sys/sys/proc.h,v 1.321 2003/04/22 20:54:04 jhb Exp $
+ * $FreeBSD: src/sys/sys/proc.h,v 1.322 2003/04/23 18:54:30 jhb Exp $
  */
 
 #ifndef _SYS_PROC_H_
@@ -157,6 +157,7 @@
  *      o - ktrace lock
  *      p - select lock (sellock)
  *      r - p_peers lock
+ *      z - zombie threads/kse/ksegroup lock
  *
  * If the locking key specifies two identifiers (for example, p_pptr) then
  * either lock is sufficient for read access, but both locks must be held
@@ -263,15 +264,15 @@
  * are linked to them. Other threads are not yet assigned.
  */
 struct thread {
-	struct proc	*td_proc;	/* Associated process. */
-	struct ksegrp	*td_ksegrp;	/* Associated KSEG. */
-	TAILQ_ENTRY(thread) td_plist;	/* All threads in this proc */
-	TAILQ_ENTRY(thread) td_kglist;	/* All threads in this ksegrp */
+	struct proc	*td_proc;	/* (*) Associated process. */
+	struct ksegrp	*td_ksegrp;	/* (*) Associated KSEG. */
+	TAILQ_ENTRY(thread) td_plist;	/* (*) All threads in this proc */
+	TAILQ_ENTRY(thread) td_kglist;	/* (*) All threads in this ksegrp */
 
 	/* The two queues below should someday be merged */
 	TAILQ_ENTRY(thread) td_slpq;	/* (j) Sleep queue. XXXKSE */
 	TAILQ_ENTRY(thread) td_lockq;	/* (j) Lock queue. XXXKSE */
-	TAILQ_ENTRY(thread) td_runq;	/* (j) Run queue(s). XXXKSE */
+	TAILQ_ENTRY(thread) td_runq;	/* (j/z) Run queue(s). XXXKSE */
 
 	TAILQ_HEAD(, selinfo) td_selq;	/* (p) List of selinfos. */
 
@@ -295,21 +296,21 @@
 	LIST_HEAD(, mtx) td_contested;	/* (j) Contested locks. */
 	struct lock_list_entry *td_sleeplocks; /* (k) Held sleep locks. */
 	int		td_intr_nesting_level; /* (k) Interrupt recursion. */
-	struct kse_thr_mailbox *td_mailbox; /* The userland mailbox address */
+	struct kse_thr_mailbox *td_mailbox; /* (*) Userland mailbox address */
 	struct ucred	*td_ucred;	/* (k) Reference to credentials. */
 	void		(*td_switchin)(void); /* (k) Switchin special func. */
-	struct thread	*td_standin;	/* (?) Use this for an upcall */
-	u_int		td_prticks;	/* (?) Profclock hits in sys for user */
-	struct kse_upcall *td_upcall;	/* our upcall structure. */
+	struct thread	*td_standin;	/* (*) Use this for an upcall */
+	u_int		td_prticks;	/* (*) Profclock hits in sys for user */
+	struct kse_upcall *td_upcall;	/* (*) Upcall structure. */
 	u_int64_t	td_sticks;	/* (j) Statclock hits in system mode. */
-	u_int		td_uuticks;	/* Statclock hits in user, for UTS */
-	u_int		td_usticks;	/* Statclock hits in kernel, for UTS */
+	u_int		td_uuticks;	/* (*) Statclock hits in user, for UTS */
+	u_int		td_usticks;	/* (*) Statclock hits in kernel, for UTS */
 	u_int		td_critnest;	/* (k) Critical section nest level. */
-	sigset_t	td_oldsigmask;	/* (c) Saved mask from pre sigpause. */
+	sigset_t	td_oldsigmask;	/* (k) Saved mask from pre sigpause. */
 	sigset_t	td_sigmask;	/* (c) Current signal mask. */
 	sigset_t	td_siglist;	/* (c) Sigs arrived, not delivered. */
-	STAILQ_HEAD(, thread) td_umtxq;	/* (p) List of threads blocked by us. */
-	STAILQ_ENTRY(thread) td_umtx;	/* (p) Link for when we're blocked. */
+	STAILQ_HEAD(, thread) td_umtxq;	/* (c?) List of threads blocked by us. */
+	STAILQ_ENTRY(thread) td_umtx;	/* (c?) Link for when we're blocked. */
 
 #define	td_endzero td_base_pri
 
@@ -335,13 +336,13 @@
 	struct callout	td_slpcallout;	/* (h) Callout for sleep. */
 	struct trapframe *td_frame;	/* (k) */
 	struct vm_object *td_kstack_obj;/* (a) Kstack object. */
-	vm_offset_t	td_kstack;	/* Kernel VA of kstack. */
-	int		td_kstack_pages; /* Size of the kstack */
+	vm_offset_t	td_kstack;	/* (a) Kernel VA of kstack. */
+	int		td_kstack_pages; /* (a) Size of the kstack */
 	struct vm_object *td_altkstack_obj;/* (a) Alternate kstack object. */
-	vm_offset_t	td_altkstack;	/* Kernel VA of alternate kstack. */
-	int		td_altkstack_pages; /* Size of the alternate kstack */
+	vm_offset_t	td_altkstack;	/* (a) Kernel VA of alternate kstack. */
+	int		td_altkstack_pages; /* (a) Size of the alternate kstack */
 	struct mdthread td_md;		/* (k) Any machine-dependent fields. */
-	struct td_sched	*td_sched;	/* Scheduler specific data */
+	struct td_sched	*td_sched;	/* (*) Scheduler specific data */
 };
 /* flags kept in td_flags */ 
 #define	TDF_OLDMASK	0x000001 /* Need to restore mask after suspend. */
@@ -425,16 +426,16 @@
  * for the group.
  */
 struct kse {
-	struct proc	*ke_proc;	/* Associated process. */
-	struct ksegrp	*ke_ksegrp;	/* Associated KSEG. */
-	TAILQ_ENTRY(kse) ke_kglist;	/* Queue of all KSEs in ke_ksegrp. */
-	TAILQ_ENTRY(kse) ke_kgrlist;	/* Queue of all KSEs in this state. */
-	TAILQ_ENTRY(kse) ke_procq;	/* (j) Run queue. */
+	struct proc	*ke_proc;	/* (*) Associated process. */
+	struct ksegrp	*ke_ksegrp;	/* (*) Associated KSEG. */
+	TAILQ_ENTRY(kse) ke_kglist;	/* (*) Queue of KSEs in ke_ksegrp. */
+	TAILQ_ENTRY(kse) ke_kgrlist;	/* (*) Queue of KSEs in this state. */
+	TAILQ_ENTRY(kse) ke_procq;	/* (j/z) Run queue. */
 
 #define	ke_startzero ke_flags
 	int		ke_flags;	/* (j) KEF_* flags. */
-	struct thread	*ke_thread;	/* Active associated thread. */
-	fixpt_t		ke_pctcpu;     /* (j) %cpu during p_swtime. */
+	struct thread	*ke_thread;	/* (*) Active associated thread. */
+	fixpt_t		ke_pctcpu;	/* (j) %cpu during p_swtime. */
 	u_char		ke_oncpu;	/* (j) Which cpu we are on. */
 	char		ke_rqindex;	/* (j) Run queue index. */
 	enum {
@@ -443,10 +444,10 @@
 		KES_ONRUNQ,
 		KES_UNQUEUED,		/* in transit */
 		KES_THREAD		/* slaved to thread state */
-	} ke_state;			/* (j) S* process status. */
+	} ke_state;			/* (j) KSE status. */
 #define	ke_endzero ke_dummy
 	u_char		ke_dummy;
-	struct ke_sched	*ke_sched;	/* Scheduler specific data */
+	struct ke_sched	*ke_sched;	/* (*) Scheduler specific data */
 };
 
 /* flags kept in ke_flags */
@@ -478,8 +479,8 @@
  * contain multiple KSEs.
  */
 struct ksegrp {
-	struct proc	*kg_proc;	/* Process that contains this KSEG. */
-	TAILQ_ENTRY(ksegrp) kg_ksegrp;	/* Queue of KSEGs in kg_proc. */
+	struct proc	*kg_proc;	/* (*) Process that contains this KSEG. */
+	TAILQ_ENTRY(ksegrp) kg_ksegrp;	/* (*) Queue of KSEGs in kg_proc. */
 	TAILQ_HEAD(, kse) kg_kseq;	/* (ke_kglist) All KSEs. */
 	TAILQ_HEAD(, kse) kg_iq;	/* (ke_kgrlist) All idle KSEs. */
 	TAILQ_HEAD(, thread) kg_threads;/* (td_kglist) All threads. */
@@ -487,27 +488,27 @@
 	TAILQ_HEAD(, thread) kg_slpq;	/* (td_runq) NONRUNNABLE threads. */
 	TAILQ_HEAD(, kse_upcall) kg_upcalls;	/* All upcalls in the group */
 #define	kg_startzero kg_estcpu
-	u_int		kg_estcpu;	/* Sum of the same field in KSEs. */
+	u_int		kg_estcpu;	/* (j) Sum of the same field in KSEs. */
 	u_int		kg_slptime;	/* (j) How long completely blocked. */
-	struct thread	*kg_last_assigned; /* (j) Last thread assigned to a KSE */
+	struct thread	*kg_last_assigned; /* (j) Last thread assigned to a KSE. */
 	int		kg_runnable;	/* (j) Num runnable threads on queue. */
 	int		kg_runq_kses;	/* (j) Num KSEs on runq. */
 	int		kg_idle_kses;	/* (j) Num KSEs on iq */
 	int		kg_numupcalls;	/* (j) Num upcalls */
 	int		kg_upsleeps;	/* (c) Num threads in kse_release() */
-	struct kse_thr_mailbox *kg_completed; /* (c) completed thread mboxes */
-	int		kg_nextupcall;	/* next upcall time */
-	int		kg_upquantum;	/* quantum to schedule an upcall */
+	struct kse_thr_mailbox *kg_completed; /* (c) Completed thread mboxes. */
+	int		kg_nextupcall;	/* (*) Next upcall time */
+	int		kg_upquantum;	/* (*) Quantum to schedule an upcall */
 #define	kg_endzero kg_pri_class
 
 #define	kg_startcopy	kg_endzero
 	u_char		kg_pri_class;	/* (j) Scheduling class. */
 	u_char		kg_user_pri;	/* (j) User pri from estcpu and nice. */
-	char		kg_nice;	/* (j?/k?) Process "nice" value. */
+	char		kg_nice;	/* (c + j) Process "nice" value. */
 #define	kg_endcopy kg_numthreads
 	int		kg_numthreads;	/* (j) Num threads in total */
 	int		kg_kses;	/* (j) Num KSEs in group. */
-	struct kg_sched	*kg_sched;	/* Scheduler specific data */
+	struct kg_sched	*kg_sched;	/* (*) Scheduler specific data */
 };
 
 /*
@@ -518,12 +519,12 @@
 	LIST_ENTRY(proc) p_list;	/* (d) List of all processes. */
 	TAILQ_HEAD(, ksegrp) p_ksegrps;	/* (kg_ksegrp) All KSEGs. */
 	TAILQ_HEAD(, thread) p_threads;	/* (td_plist) Threads. (shortcut) */
-	TAILQ_HEAD(, thread) p_suspended; /* (td_runq) suspended threads */
+	TAILQ_HEAD(, thread) p_suspended; /* (td_runq) Suspended threads. */
 	struct ucred	*p_ucred;	/* (c) Process owner's identity. */
 	struct filedesc	*p_fd;		/* (b) Ptr to open files structure. */
 					/* Accumulated stats for all KSEs? */
 	struct pstats	*p_stats;	/* (b) Accounting/statistics (CPU). */
-	struct plimit	*p_limit;	/* (m) Process limits. */
+	struct plimit	*p_limit;	/* (c*) Process limits. */
 	struct vm_object *p_upages_obj; /* (a) Upages object. */
 	struct procsig	*p_procsig;	/* (c) Signal actions, state (CPU). */
 
@@ -540,14 +541,14 @@
 		PRS_NEW = 0,		/* In creation */
 		PRS_NORMAL,		/* KSEs can be run */
 		PRS_ZOMBIE
-	} p_state;			/* (j) S* process status. */
+	} p_state;			/* (j/c) S* process status. */
 	pid_t		p_pid;		/* (b) Process identifier. */
 	LIST_ENTRY(proc) p_hash;	/* (d) Hash chain. */
 	LIST_ENTRY(proc) p_pglist;	/* (g + e) List of processes in pgrp. */
 	struct proc	*p_pptr;	/* (c + e) Pointer to parent process. */
 	LIST_ENTRY(proc) p_sibling;	/* (e) List of sibling processes. */
 	LIST_HEAD(, proc) p_children;	/* (e) Pointer to list of children. */
-	struct mtx	p_mtx;		/* (k) Lock for this struct. */
+	struct mtx	p_mtx;		/* (n) Lock for this struct. */
 
 /* The following fields are all zeroed upon creation in fork. */
 #define	p_startzero	p_oppid
@@ -580,9 +581,9 @@
 	char		p_step;		/* (c) Process is stopped. */
 	u_char		p_pfsflags;	/* (c) Procfs flags. */
 	struct nlminfo	*p_nlminfo;	/* (?) Only used by/for lockd. */
-	void		*p_aioinfo;	/* (c) ASYNC I/O info. */
-	struct thread	*p_singlethread;/* (j) If single threading this is it */
-	int		p_suspcount;	/* (j) # threads in suspended mode */
+	void		*p_aioinfo;	/* (?) ASYNC I/O info. */
+	struct thread	*p_singlethread;/* (c + j) If single threading this is it */
+	int		p_suspcount;	/* (c) # threads in suspended mode */
 /* End area that is zeroed on creation. */
 #define	p_endzero	p_sigstk
 
@@ -599,18 +600,18 @@
 #define	p_endcopy	p_xstat
 
 	u_short		p_xstat;	/* (c) Exit status; also stop sig. */
-	int		p_numthreads;	/* (?) number of threads */
+	int		p_numthreads;	/* (j) Number of threads. */
 	int		p_numksegrps;	/* (?) number of ksegrps */
-	struct mdproc	p_md;		/* (c) Any machine-dependent fields. */
-	struct callout	p_itcallout;	/* (h) Interval timer callout. */
+	struct mdproc	p_md;		/* Any machine-dependent fields. */
+	struct callout	p_itcallout;	/* (h + c) Interval timer callout. */
 	struct user	*p_uarea;	/* (k) Kernel VA of u-area (CPU) */
 	u_short		p_acflag;	/* (c) Accounting flags. */
 	struct rusage	*p_ru;		/* (a) Exit information. XXX */
 	struct proc	*p_peers;	/* (r) */
 	struct proc	*p_leader;	/* (b) */
 	void		*p_emuldata;	/* (c) Emulator state data. */
-	struct label	p_label;	/* process (not subject) MAC label */
-	struct p_sched	*p_sched;	/* Scheduler specific data */
+	struct label	p_label;	/* (*) Process (not subject) MAC label */
+	struct p_sched	*p_sched;	/* (*) Scheduler specific data */
 };
 
 #define	p_rlimit	p_limit->pl_rlimit

==== //depot/projects/smpng/sys/vm/vm_glue.c#24 (text+ko) ====

@@ -59,7 +59,7 @@
  * any improvements or extensions that they make and grant Carnegie the
  * rights to redistribute these changes.
  *
- * $FreeBSD: src/sys/vm/vm_glue.c,v 1.166 2003/04/22 20:00:26 jhb Exp $
+ * $FreeBSD: src/sys/vm/vm_glue.c,v 1.167 2003/04/23 18:21:41 jhb Exp $
  */
 
 #include "opt_vm.h"
@@ -513,14 +513,16 @@
 faultin(p)
 	struct proc *p;
 {
+#ifdef NO_SWAPPING
+
+	PROC_LOCK_ASSERT(p, MA_OWNED);
+	if ((p->p_sflag & PS_INMEM) == 0)
+		panic("faultin: proc swapped out with NO_SWAPPING!");
+#else /* !NO_SWAPPING */
 	struct thread *td;
 
 	GIANT_REQUIRED;
 	PROC_LOCK_ASSERT(p, MA_OWNED);
-#ifdef NO_SWAPPING
-	if ((p->p_sflag & PS_INMEM) == 0)
-		panic("faultin: proc swapped out with NO_SWAPPING!");
-#else
 	/*
 	 * If another process is swapping in this process,
 	 * just wait until it finishes.
@@ -558,7 +560,7 @@
 		/* Allow other threads to swap p out now. */
 		--p->p_lock;
 	}
-#endif
+#endif /* NO_SWAPPING */
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304231916.h3NJGcN8082804>