PERFORCE change 138130 for review

John Baldwin jhb at FreeBSD.org
Wed Mar 19 21:23:43 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=138130

Change 138130 by jhb at jhb_mutex on 2008/03/19 21:22:58

	IFC @138129

Affected files ...

.. //depot/projects/smpng/sys/dev/cxgb/cxgb_main.c#8 integrate
.. //depot/projects/smpng/sys/kern/kern_cpuset.c#2 integrate
.. //depot/projects/smpng/sys/kern/kern_descrip.c#112 integrate
.. //depot/projects/smpng/sys/kern/kern_exit.c#128 integrate
.. //depot/projects/smpng/sys/kern/kern_kthread.c#20 integrate
.. //depot/projects/smpng/sys/kern/kern_lockf.c#22 integrate
.. //depot/projects/smpng/sys/kern/kern_proc.c#93 integrate
.. //depot/projects/smpng/sys/kern/kern_resource.c#77 integrate
.. //depot/projects/smpng/sys/kern/kern_sig.c#137 integrate
.. //depot/projects/smpng/sys/kern/kern_thr.c#43 integrate
.. //depot/projects/smpng/sys/kern/kern_thread.c#105 integrate
.. //depot/projects/smpng/sys/kern/sched_4bsd.c#72 integrate
.. //depot/projects/smpng/sys/kern/sched_ule.c#84 integrate
.. //depot/projects/smpng/sys/kern/subr_sleepqueue.c#37 integrate
.. //depot/projects/smpng/sys/kern/sys_generic.c#53 integrate
.. //depot/projects/smpng/sys/kern/sys_process.c#60 integrate
.. //depot/projects/smpng/sys/kern/tty.c#72 integrate
.. //depot/projects/smpng/sys/kern/uipc_socket.c#110 integrate
.. //depot/projects/smpng/sys/netinet/libalias/alias_irc.c#7 integrate
.. //depot/projects/smpng/sys/nfsserver/nfs_srvsock.c#33 integrate
.. //depot/projects/smpng/sys/sparc64/include/atomic.h#17 integrate
.. //depot/projects/smpng/sys/sun4v/include/atomic.h#3 integrate
.. //depot/projects/smpng/sys/sun4v/sun4v/intr_machdep.c#8 integrate
.. //depot/projects/smpng/sys/sys/eventhandler.h#28 integrate
.. //depot/projects/smpng/sys/sys/proc.h#184 integrate
.. //depot/projects/smpng/sys/ufs/ffs/ffs_snapshot.c#66 integrate
.. //depot/projects/smpng/sys/vm/vm_glue.c#65 integrate
.. //depot/projects/smpng/sys/vm/vm_meter.c#35 integrate
.. //depot/projects/smpng/sys/vm/vm_page.c#97 integrate
.. //depot/projects/smpng/sys/vm/vm_page.h#42 integrate
.. //depot/projects/smpng/sys/vm/vm_pageout.c#65 integrate

Differences ...

==== //depot/projects/smpng/sys/dev/cxgb/cxgb_main.c#8 (text+ko) ====

@@ -28,7 +28,7 @@
 ***************************************************************************/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/cxgb/cxgb_main.c,v 1.51 2008/03/18 03:55:11 kmacy Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/cxgb/cxgb_main.c,v 1.52 2008/03/19 20:56:51 kmacy Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1029,8 +1029,10 @@
 	/* Get the latest mac address, User can use a LAA */
 	bcopy(IF_LLADDR(p->ifp), p->hw_addr, ETHER_ADDR_LEN);
 	t3_sge_init_port(p);
+#if defined(LINK_ATTACH)	
 	cxgb_link_start(p);
 	t3_link_changed(sc, p->port_id);
+#endif
 	return (0);
 }
 
@@ -1817,6 +1819,10 @@
 			log(LOG_WARNING,
 			    "Could not initialize offload capabilities\n");
 	}
+#if !defined(LINK_ATTACH)
+	cxgb_link_start(p);
+	t3_link_changed(sc, p->port_id);
+#endif
 	ifp->if_baudrate = p->link_config.speed * 1000000;
 
 	device_printf(sc->dev, "enabling interrupts on port=%d\n", p->port_id);
@@ -1869,9 +1875,9 @@
 	} else 
 		ADAPTER_UNLOCK(pi->adapter);
 
+#if !defined(LINK_ATTACH)
 	DELAY(100);
 
-
 	/* Wait for TXFIFO empty */
 	t3_wait_op_done(pi->adapter, A_XGM_TXFIFO_CFG + pi->mac.offset,
 			F_TXFIFO_EMPTY, 1, 20, 5);
@@ -1880,7 +1886,7 @@
 	t3_mac_disable(&pi->mac, MAC_DIRECTION_TX | MAC_DIRECTION_RX);
 
 	pi->phy.ops->power_down(&pi->phy, 1);
-		
+#endif		
 
 }
 

==== //depot/projects/smpng/sys/kern/kern_cpuset.c#2 (text+ko) ====

@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_cpuset.c,v 1.4 2008/03/06 20:11:24 jeff Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_cpuset.c,v 1.5 2008/03/19 06:19:00 jeff Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -382,11 +382,9 @@
 		sx_slock(&allproc_lock);
 		FOREACH_PROC_IN_SYSTEM(p) {
 			PROC_LOCK(p);
-			PROC_SLOCK(p);
 			FOREACH_THREAD_IN_PROC(p, td)
 				if (td->td_tid == id)
 					break;
-			PROC_SUNLOCK(p);
 			if (td != NULL)
 				break;
 			PROC_UNLOCK(p);
@@ -480,11 +478,9 @@
 		error = cpuset_which(CPU_WHICH_PID, pid, &p, &td, &nset);
 		if (error)
 			goto out;
-		PROC_SLOCK(p);
 		if (nfree >= p->p_numthreads)
 			break;
 		threads = p->p_numthreads;
-		PROC_SUNLOCK(p);
 		PROC_UNLOCK(p);
 		for (; nfree < threads; nfree++) {
 			nset = uma_zalloc(cpuset_zone, M_WAITOK);
@@ -492,7 +488,6 @@
 		}
 	}
 	PROC_LOCK_ASSERT(p, MA_OWNED);
-	PROC_SLOCK_ASSERT(p, MA_OWNED);
 	/*
 	 * Now that the appropriate locks are held and we have enough cpusets,
 	 * make sure the operation will succeed before applying changes.  The
@@ -526,8 +521,8 @@
 	}
 	/*
 	 * Replace each thread's cpuset while using deferred release.  We
-	 * must do this because the PROC_SLOCK has to be held while traversing
-	 * the thread list and this limits the type of operations allowed.
+	 * must do this because the thread lock must be held while operating
+	 * on the thread and this limits the type of operations allowed.
 	 */
 	FOREACH_THREAD_IN_PROC(p, td) {
 		thread_lock(td);
@@ -561,7 +556,6 @@
 		thread_unlock(td);
 	}
 unlock_out:
-	PROC_SUNLOCK(p);
 	PROC_UNLOCK(p);
 out:
 	while ((nset = LIST_FIRST(&droplist)) != NULL)
@@ -833,13 +827,11 @@
 			thread_unlock(ttd);
 			break;
 		case CPU_WHICH_PID:
-			PROC_SLOCK(p);
 			FOREACH_THREAD_IN_PROC(p, ttd) {
 				thread_lock(ttd);
 				CPU_OR(mask, &ttd->td_cpuset->cs_mask);
 				thread_unlock(ttd);
 			}
-			PROC_SUNLOCK(p);
 			break;
 		case CPU_WHICH_CPUSET:
 			CPU_COPY(&set->cs_mask, mask);

==== //depot/projects/smpng/sys/kern/kern_descrip.c#112 (text+ko) ====

@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_descrip.c,v 1.327 2008/03/16 10:58:05 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_descrip.c,v 1.328 2008/03/19 09:58:25 sobomax Exp $");
 
 #include "opt_compat.h"
 #include "opt_ddb.h"
@@ -2801,39 +2801,9 @@
 SYSCTL_INT(_kern, KERN_MAXFILESPERPROC, maxfilesperproc, CTLFLAG_RW,
     &maxfilesperproc, 0, "Maximum files allowed open per process");
 
-/*
- * User has changed the maximum number of files.
- * This may require us to change size of the zone.
- */
-static int
-sysctl_kern_maxfiles(SYSCTL_HANDLER_ARGS)
-{
-	int error;
-	int new_maxfiles;
+SYSCTL_INT(_kern, KERN_MAXFILES, maxfiles, CTLFLAG_RW,
+    &maxfiles, 0, "Maximum number of files");
 
-	new_maxfiles = maxfiles;
-	error = sysctl_handle_int(oidp, &new_maxfiles, sizeof(int), req);
-	if (error != 0 || req->newptr == NULL)
-		return (error);
-	if (new_maxfiles <= 0) {
-		return (EINVAL);
-	}
-	maxfiles = new_maxfiles;
-	EVENTHANDLER_INVOKE(maxfiles_change);
-	return (0);
-}
-
-static void
-file_zone_change(void *tag)
-{
-
-	uma_zone_set_max(file_zone, maxfiles);
-}
-
-SYSCTL_PROC(_kern, OID_AUTO, maxfiles, CTLTYPE_INT|CTLFLAG_RW,
-    __DEVOLATILE(int *, &maxfiles), 0, sysctl_kern_maxfiles, "IU",
-    "Maximum number of files");
-
 SYSCTL_INT(_kern, OID_AUTO, openfiles, CTLFLAG_RD,
     __DEVOLATILE(int *, &openfiles), 0, "System-wide number of open files");
 
@@ -2844,13 +2814,10 @@
 
 	file_zone = uma_zcreate("Files", sizeof(struct file), NULL, NULL,
 	    NULL, NULL, UMA_ALIGN_PTR, 0);
-	uma_zone_set_max(file_zone, maxfiles);
-	EVENTHANDLER_REGISTER(maxfiles_change, file_zone_change, NULL,
-	    EVENTHANDLER_PRI_FIRST);
 	mtx_init(&sigio_lock, "sigio lock", NULL, MTX_DEF);
 	mtx_init(&fdesc_mtx, "fdesc", NULL, MTX_DEF);
 }
-SYSINIT(select, SI_SUB_EVENTHANDLER+1, SI_ORDER_MIDDLE, filelistinit, NULL);
+SYSINIT(select, SI_SUB_LOCK, SI_ORDER_FIRST, filelistinit, NULL);
 
 /*-------------------------------------------------------------------*/
 

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

@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_exit.c,v 1.308 2008/02/17 15:28:28 kris Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_exit.c,v 1.309 2008/03/19 06:19:00 jeff Exp $");
 
 #include "opt_compat.h"
 #include "opt_ktrace.h"
@@ -510,9 +510,7 @@
 	 * proc lock.
 	 */
 	wakeup(p->p_pptr);
-	PROC_SLOCK(p->p_pptr);
 	sched_exit(p->p_pptr, td);
-	PROC_SUNLOCK(p->p_pptr);
 	PROC_SLOCK(p);
 	p->p_state = PRS_ZOMBIE;
 	PROC_UNLOCK(p->p_pptr);

==== //depot/projects/smpng/sys/kern/kern_kthread.c#20 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_kthread.c,v 1.44 2007/11/15 21:45:17 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_kthread.c,v 1.45 2008/03/19 06:19:00 jeff Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -292,14 +292,12 @@
 	PROC_LOCK(p);
 	p->p_flag |= P_HADTHREADS;
 	newtd->td_sigmask = oldtd->td_sigmask; /* XXX dubious */
-	PROC_SLOCK(p);
 	thread_link(newtd, p);
 	thread_lock(oldtd);
 	/* let the scheduler know about these things. */
 	sched_fork_thread(oldtd, newtd);
 	TD_SET_CAN_RUN(newtd);
 	thread_unlock(oldtd);
-	PROC_SUNLOCK(p);
 	PROC_UNLOCK(p);
 
 

==== //depot/projects/smpng/sys/kern/kern_lockf.c#22 (text+ko) ====

@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_lockf.c,v 1.57 2007/08/07 09:04:50 kib Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_lockf.c,v 1.59 2008/03/19 07:13:24 jeff Exp $");
 
 #include "opt_debug_lockf.h"
 
@@ -283,31 +283,37 @@
 			wproc = (struct proc *)block->lf_id;
 restart:
 			nproc = NULL;
-			PROC_SLOCK(wproc);
+			PROC_LOCK(wproc);
 			FOREACH_THREAD_IN_PROC(wproc, td) {
 				thread_lock(td);
-				while (td->td_wchan &&
-				    (td->td_wmesg == lockstr) &&
-				    (i++ < maxlockdepth)) {
+				for (;;) {
+					if (!TD_ON_SLEEPQ(td) ||
+					    td->td_wmesg != lockstr)
+						break;
 					waitblock = (struct lockf *)td->td_wchan;
 					/* Get the owner of the blocking lock */
+					if (waitblock->lf_next == NULL)
+						break;
 					waitblock = waitblock->lf_next;
 					if ((waitblock->lf_flags & F_POSIX) == 0)
 						break;
-					nproc = (struct proc *)waitblock->lf_id;
-					if (nproc == (struct proc *)lock->lf_id) {
-						PROC_SUNLOCK(wproc);
+					if (waitblock->lf_id == lock->lf_id) {
 						thread_unlock(td);
+						PROC_UNLOCK(wproc);
 						lock->lf_next = *clean;
 						*clean = lock;
 						return (EDEADLK);
 					}
+					nproc = (struct proc *)waitblock->lf_id;
+					break;
 				}
 				thread_unlock(td);
+				if (nproc)
+					break;
 			}
-			PROC_SUNLOCK(wproc);
+			PROC_UNLOCK(wproc);
 			wproc = nproc;
-			if (wproc)
+			if (++i < maxlockdepth && wproc)
 				goto restart;
 		}
 		/*

==== //depot/projects/smpng/sys/kern/kern_proc.c#93 (text+ko) ====

@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_proc.c,v 1.262 2008/03/12 10:11:59 jeff Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_proc.c,v 1.263 2008/03/19 06:19:00 jeff Exp $");
 
 #include "opt_ddb.h"
 #include "opt_ktrace.h"
@@ -640,11 +640,11 @@
 	struct ucred *cred;
 	struct sigacts *ps;
 
+	PROC_LOCK_ASSERT(p, MA_OWNED);
 	bzero(kp, sizeof(*kp));
 
 	kp->ki_structsize = sizeof(*kp);
 	kp->ki_paddr = p;
-	PROC_LOCK_ASSERT(p, MA_OWNED);
 	kp->ki_addr =/* p->p_addr; */0; /* XXX */
 	kp->ki_args = p->p_args;
 	kp->ki_textvp = p->p_textvp;
@@ -776,7 +776,7 @@
 	struct proc *p;
 
 	p = td->td_proc;
-	PROC_SLOCK_ASSERT(p, MA_OWNED);
+	PROC_LOCK_ASSERT(p, MA_OWNED);
 
 	thread_lock(td);
 	if (td->td_wmesg != NULL)
@@ -851,10 +851,8 @@
 {
 
 	fill_kinfo_proc_only(p, kp);
-	PROC_SLOCK(p);
 	if (FIRST_THREAD_IN_PROC(p) != NULL)
 		fill_kinfo_thread(FIRST_THREAD_IN_PROC(p), kp, 0);
-	PROC_SUNLOCK(p);
 }
 
 struct pstats *
@@ -921,15 +919,12 @@
 
 	fill_kinfo_proc_only(p, &kinfo_proc);
 	if (flags & KERN_PROC_NOTHREADS) {
-		PROC_SLOCK(p);
 		if (FIRST_THREAD_IN_PROC(p) != NULL)
 			fill_kinfo_thread(FIRST_THREAD_IN_PROC(p),
 			    &kinfo_proc, 0);
-		PROC_SUNLOCK(p);
 		error = SYSCTL_OUT(req, (caddr_t)&kinfo_proc,
 				   sizeof(kinfo_proc));
 	} else {
-		PROC_SLOCK(p);
 		if (FIRST_THREAD_IN_PROC(p) != NULL)
 			FOREACH_THREAD_IN_PROC(p, td) {
 				fill_kinfo_thread(td, &kinfo_proc, 1);
@@ -941,7 +936,6 @@
 		else
 			error = SYSCTL_OUT(req, (caddr_t)&kinfo_proc,
 					   sizeof(kinfo_proc));
-		PROC_SUNLOCK(p);
 	}
 	PROC_UNLOCK(p);
 	if (error)
@@ -1483,7 +1477,7 @@
 
 	lwpidarray = NULL;
 	numthreads = 0;
-	PROC_SLOCK(p);
+	PROC_LOCK(p);
 repeat:
 	if (numthreads < p->p_numthreads) {
 		if (lwpidarray != NULL) {
@@ -1491,13 +1485,12 @@
 			lwpidarray = NULL;
 		}
 		numthreads = p->p_numthreads;
-		PROC_SUNLOCK(p);
+		PROC_UNLOCK(p);
 		lwpidarray = malloc(sizeof(*lwpidarray) * numthreads, M_TEMP,
 		    M_WAITOK | M_ZERO);
-		PROC_SLOCK(p);
+		PROC_LOCK(p);
 		goto repeat;
 	}
-	PROC_SUNLOCK(p);
 	i = 0;
 
 	/*
@@ -1509,7 +1502,6 @@
 	 * have changed, in which case the right to extract debug info might
 	 * no longer be assured.
 	 */
-	PROC_LOCK(p);
 	FOREACH_THREAD_IN_PROC(p, td) {
 		KASSERT(i < numthreads,
 		    ("sysctl_kern_proc_kstack: numthreads"));

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

@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_resource.c,v 1.187 2008/03/16 21:32:20 pjd Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_resource.c,v 1.189 2008/03/19 07:52:07 pjd Exp $");
 
 #include "opt_compat.h"
 
@@ -266,9 +266,7 @@
 		n = PRIO_MIN;
 	if (n < p->p_nice && priv_check(td, PRIV_SCHED_SETPRIORITY) != 0)
 		return (EACCES);
-	PROC_SLOCK(p);
 	sched_nice(p, n);
-	PROC_SUNLOCK(p);
 	return (0);
 }
 
@@ -307,7 +305,6 @@
 	case RTP_LOOKUP:
 		if ((error = p_cansee(td, p)))
 			break;
-		PROC_SLOCK(p);
 		if (uap->lwpid == 0 || uap->lwpid == td->td_tid)
 			td1 = td;
 		else
@@ -316,7 +313,6 @@
 			pri_to_rtp(td1, &rtp);
 		else
 			error = ESRCH;
-		PROC_SUNLOCK(p);
 		PROC_UNLOCK(p);
 		return (copyout(&rtp, uap->rtp, sizeof(struct rtprio)));
 	case RTP_SET:
@@ -341,7 +337,6 @@
 				break;
 		}
 
-		PROC_SLOCK(p);
 		if (uap->lwpid == 0 || uap->lwpid == td->td_tid)
 			td1 = td;
 		else
@@ -350,7 +345,6 @@
 			error = rtp_to_pri(&rtp, td1);
 		else
 			error = ESRCH;
-		PROC_SUNLOCK(p);
 		break;
 	default:
 		error = EINVAL;
@@ -399,7 +393,6 @@
 	case RTP_LOOKUP:
 		if ((error = p_cansee(td, p)))
 			break;
-		PROC_SLOCK(p);
 		/*
 		 * Return OUR priority if no pid specified,
 		 * or if one is, report the highest priority
@@ -425,7 +418,6 @@
 				}
 			}
 		}
-		PROC_SUNLOCK(p);
 		PROC_UNLOCK(p);
 		return (copyout(&rtp, uap->rtp, sizeof(struct rtprio)));
 	case RTP_SET:
@@ -456,7 +448,6 @@
 		 * do all the threads on that process. If we
 		 * specify our own pid we do the latter.
 		 */
-		PROC_SLOCK(p);
 		if (uap->pid == 0) {
 			error = rtp_to_pri(&rtp, td);
 		} else {
@@ -465,7 +456,6 @@
 					break;
 			}
 		}
-		PROC_SUNLOCK(p);
 		break;
 	default:
 		error = EINVAL;
@@ -698,9 +688,7 @@
 		if (limp->rlim_cur != RLIM_INFINITY &&
 		    p->p_cpulimit == RLIM_INFINITY)
 			callout_reset(&p->p_limco, hz, lim_cb, p);
-		PROC_SLOCK(p);
 		p->p_cpulimit = limp->rlim_cur;
-		PROC_SUNLOCK(p);
 		break;
 	case RLIMIT_DATA:
 		if (limp->rlim_cur > maxdsiz)
@@ -956,11 +944,12 @@
 	struct rusage *rup;
 {
 	struct proc *p;
+	int error;
 
+	error = 0;
 	p = td->td_proc;
 	PROC_LOCK(p);
 	switch (who) {
-
 	case RUSAGE_SELF:
 		rufetchcalc(p, rup, &rup->ru_utime,
 		    &rup->ru_stime);
@@ -972,11 +961,10 @@
 		break;
 
 	default:
-		PROC_UNLOCK(p);
-		return (EINVAL);
+		error = EINVAL;
 	}
 	PROC_UNLOCK(p);
-	return (0);
+	return (error);
 }
 
 void
@@ -1226,7 +1214,6 @@
 			uip->ui_uid = uid;
 			LIST_INSERT_HEAD(UIHASH(uid), uip, ui_hash);
 		}
-		uihold(uip);
 	}
 	uihold(uip);
 	rw_unlock(&uihashtbl_lock);

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

@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_sig.c,v 1.358 2008/03/12 10:11:59 jeff Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_sig.c,v 1.359 2008/03/19 06:19:00 jeff Exp $");
 
 #include "opt_compat.h"
 #include "opt_ktrace.h"
@@ -508,10 +508,8 @@
 	sigqueue_init(&worklist, NULL);
 	sigqueue_move_set(&p->p_sigqueue, &worklist, set);
 
-	PROC_SLOCK(p);
 	FOREACH_THREAD_IN_PROC(p, td0)
 		sigqueue_move_set(&td0->td_sigqueue, &worklist, set);
-	PROC_SUNLOCK(p);
 
 	sigqueue_flush(&worklist);
 }
@@ -734,9 +732,7 @@
 		    (sigprop(sig) & SA_IGNORE &&
 		     ps->ps_sigact[_SIG_IDX(sig)] == SIG_DFL)) {
 			/* never to be seen again */
-			PROC_SLOCK(p);
 			sigqueue_delete_proc(p, sig);
-			PROC_SUNLOCK(p);
 			if (sig != SIGCONT)
 				/* easier in psignal */
 				SIGADDSET(ps->ps_sigignore, sig);
@@ -932,9 +928,7 @@
 		if (sigprop(sig) & SA_IGNORE) {
 			if (sig != SIGCONT)
 				SIGADDSET(ps->ps_sigignore, sig);
-			PROC_SLOCK(p);
 			sigqueue_delete_proc(p, sig);
-			PROC_SUNLOCK(p);
 		}
 		ps->ps_sigact[_SIG_IDX(sig)] = SIG_DFL;
 	}
@@ -1882,7 +1876,6 @@
 	if (curproc == p && !SIGISMEMBER(curthread->td_sigmask, sig))
 		return (curthread);
 	signal_td = NULL;
-	PROC_SLOCK(p);
 	FOREACH_THREAD_IN_PROC(p, td) {
 		if (!SIGISMEMBER(td->td_sigmask, sig)) {
 			signal_td = td;
@@ -1891,7 +1884,6 @@
 	}
 	if (signal_td == NULL)
 		signal_td = FIRST_THREAD_IN_PROC(p);
-	PROC_SUNLOCK(p);
 	return (signal_td);
 }
 
@@ -2029,9 +2021,7 @@
 				ksiginfo_tryfree(ksi);
 			return (ret);
 		}
-		PROC_SLOCK(p);
 		sigqueue_delete_proc(p, SIGCONT);
-		PROC_SUNLOCK(p);
 		if (p->p_flag & P_CONTINUED) {
 			p->p_flag &= ~P_CONTINUED;
 			PROC_LOCK(p->p_pptr);
@@ -2069,7 +2059,6 @@
 	 * waking up threads so that they can cross the user boundary.
 	 * We try do the per-process part here.
 	 */
-	PROC_SLOCK(p);
 	if (P_SHOULDSTOP(p)) {
 		/*
 		 * The process is in stopped mode. All the threads should be
@@ -2081,7 +2070,6 @@
 			 * so no further action is necessary.
 			 * No signal can restart us.
 			 */
-			PROC_SUNLOCK(p);
 			goto out;
 		}
 
@@ -2107,6 +2095,7 @@
 			 * Otherwise, process goes back to sleep state.
 			 */
 			p->p_flag &= ~P_STOPPED_SIG;
+			PROC_SLOCK(p);
 			if (p->p_numthreads == p->p_suspcount) {
 				PROC_SUNLOCK(p);
 				p->p_flag |= P_CONTINUED;
@@ -2127,6 +2116,7 @@
 				 * The process wants to catch it so it needs
 				 * to run at least one thread, but which one?
 				 */
+				PROC_SUNLOCK(p);
 				goto runfast;
 			}
 			/*
@@ -2143,7 +2133,6 @@
 			 * (If we did the shell could get confused).
 			 * Just make sure the signal STOP bit set.
 			 */
-			PROC_SUNLOCK(p);
 			p->p_flag |= P_STOPPED_SIG;
 			sigqueue_delete(sigqueue, sig);
 			goto out;
@@ -2157,6 +2146,7 @@
 		 * the PROCESS runnable, leave it stopped.
 		 * It may run a bit until it hits a thread_suspend_check().
 		 */
+		PROC_SLOCK(p);
 		thread_lock(td);
 		if (TD_ON_SLEEPQ(td) && (td->td_flags & TDF_SINTR))
 			sleepq_abort(td, intrval);
@@ -2169,22 +2159,18 @@
 		 */
 	} else if (p->p_state == PRS_NORMAL) {
 		if (p->p_flag & P_TRACED || action == SIG_CATCH) {
-			thread_lock(td);
 			tdsigwakeup(td, sig, action, intrval);
-			thread_unlock(td);
-			PROC_SUNLOCK(p);
 			goto out;
 		}
 
 		MPASS(action == SIG_DFL);
 
 		if (prop & SA_STOP) {
-			if (p->p_flag & P_PPWAIT) {
-				PROC_SUNLOCK(p);
+			if (p->p_flag & P_PPWAIT)
 				goto out;
-			}
 			p->p_flag |= P_STOPPED_SIG;
 			p->p_xstat = sig;
+			PROC_SLOCK(p);
 			sig_suspend_threads(td, p, 1);
 			if (p->p_numthreads == p->p_suspcount) {
 				/*
@@ -2200,13 +2186,9 @@
 			} else
 				PROC_SUNLOCK(p);
 			goto out;
-		} 
-		else
-			goto runfast;
-		/* NOTREACHED */
+		}
 	} else {
 		/* Not in "NORMAL" state. discard the signal. */
-		PROC_SUNLOCK(p);
 		sigqueue_delete(sigqueue, sig);
 		goto out;
 	}
@@ -2215,11 +2197,9 @@
 	 * The process is not stopped so we need to apply the signal to all the
 	 * running threads.
 	 */
-
 runfast:
-	thread_lock(td);
 	tdsigwakeup(td, sig, action, intrval);
-	thread_unlock(td);
+	PROC_SLOCK(p);
 	thread_unsuspend(p);
 	PROC_SUNLOCK(p);
 out:
@@ -2240,17 +2220,16 @@
 	register int prop;
 
 	PROC_LOCK_ASSERT(p, MA_OWNED);
-	PROC_SLOCK_ASSERT(p, MA_OWNED);
-	THREAD_LOCK_ASSERT(td, MA_OWNED);
 	prop = sigprop(sig);
 
+	PROC_SLOCK(p);
+	thread_lock(td);
 	/*
 	 * Bring the priority of a thread up if we want it to get
 	 * killed in this lifetime.
 	 */
 	if (action == SIG_DFL && (prop & SA_KILL) && td->td_priority > PUSER)
 		sched_prio(td, PUSER);
-
 	if (TD_ON_SLEEPQ(td)) {
 		/*
 		 * If thread is sleeping uninterruptibly
@@ -2259,7 +2238,7 @@
 		 * trap() or syscall().
 		 */
 		if ((td->td_flags & TDF_SINTR) == 0)
-			return;
+			goto out;
 		/*
 		 * If SIGCONT is default (or ignored) and process is
 		 * asleep, we are finished; the process should not
@@ -2274,8 +2253,6 @@
 			 * Remove from both for now.
 			 */
 			sigqueue_delete(&td->td_sigqueue, sig);
-			PROC_SLOCK(p);
-			thread_lock(td);
 			return;
 		}
 
@@ -2297,6 +2274,9 @@
 			forward_signal(td);
 #endif
 	}
+out:
+	PROC_SUNLOCK(p);
+	thread_unlock(td);
 }
 
 static void

==== //depot/projects/smpng/sys/kern/kern_thr.c#43 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_thr.c,v 1.64 2007/11/15 06:35:26 julian Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_thr.c,v 1.65 2008/03/19 06:19:00 jeff Exp $");
 
 #include "opt_compat.h"
 #include "opt_posix.h"
@@ -229,14 +229,12 @@
 	PROC_LOCK(td->td_proc);
 	td->td_proc->p_flag |= P_HADTHREADS;
 	newtd->td_sigmask = td->td_sigmask;
-	PROC_SLOCK(p);
 	thread_link(newtd, p); 
 	bcopy(p->p_comm, newtd->td_name, sizeof(newtd->td_name));
 	thread_lock(td);
 	/* let the scheduler know about these things. */
 	sched_fork_thread(td, newtd);
 	thread_unlock(td);
-	PROC_SUNLOCK(p);
 	PROC_UNLOCK(p);
 	thread_lock(newtd);
 	if (rtp != NULL) {

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

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_thread.c,v 1.269 2008/03/12 10:11:59 jeff Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_thread.c,v 1.271 2008/03/19 06:20:21 jeff Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -303,7 +303,8 @@
 void
 thread_free(struct thread *td)
 {
-	cpuset_rel(td->td_cpuset);
+	if (td->td_cpuset)
+		cpuset_rel(td->td_cpuset);
 	td->td_cpuset = NULL;
 	cpu_thread_free(td);
 	if (td->td_altkstack != 0)
@@ -345,9 +346,7 @@
 #ifdef AUDIT
 	AUDIT_SYSCALL_EXIT(0, td);
 #endif
-
 	umtx_thread_exit(td);
-
 	/*
 	 * drop FPU & debug register state storage, or any other
 	 * architecture specific resources that
@@ -374,9 +373,7 @@
 	 */
 	if (p->p_flag & P_HADTHREADS) {
 		if (p->p_numthreads > 1) {
-			thread_lock(td);
 			thread_unlink(td);
-			thread_unlock(td);
 			td2 = FIRST_THREAD_IN_PROC(p);
 			sched_exit_thread(td2, td);
 
@@ -450,8 +447,8 @@
 
 	/*
 	 * XXX This can't be enabled because it's called for proc0 before
-	 * it's spinlock has been created.
-	 * PROC_SLOCK_ASSERT(p, MA_OWNED);
+	 * its lock has been created.
+	 * PROC_LOCK_ASSERT(p, MA_OWNED);
 	 */
 	td->td_state    = TDS_INACTIVE;
 	td->td_proc     = p;
@@ -487,7 +484,7 @@
 {
 	struct proc *p = td->td_proc;
 
-	PROC_SLOCK_ASSERT(p, MA_OWNED);
+	PROC_LOCK_ASSERT(p, MA_OWNED);
 	TAILQ_REMOVE(&p->p_threads, td, td_plist);
 	p->p_numthreads--;
 	/* could clear a few other things here */
@@ -863,11 +860,9 @@
 	struct thread *td;
 
 	PROC_LOCK_ASSERT(p, MA_OWNED);
-	PROC_SLOCK(p);
 	FOREACH_THREAD_IN_PROC(p, td) {
 		if (td->td_tid == tid)
 			break;
 	}
-	PROC_SUNLOCK(p);
 	return (td);
 }

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

@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/sched_4bsd.c,v 1.118 2008/03/16 10:58:05 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/sched_4bsd.c,v 1.119 2008/03/19 06:19:00 jeff Exp $");
 
 #include "opt_hwpmc_hooks.h"
 
@@ -357,7 +357,7 @@
 	realstathz = stathz ? stathz : hz;
 	sx_slock(&allproc_lock);
 	FOREACH_PROC_IN_SYSTEM(p) {
-		PROC_SLOCK(p);
+		PROC_LOCK(p);
 		FOREACH_THREAD_IN_PROC(p, td) { 
 			awake = 0;
 			thread_lock(td);
@@ -436,7 +436,7 @@
 			resetpriority_thread(td);
 			thread_unlock(td);
 		} /* end of thread loop */
-		PROC_SUNLOCK(p);
+		PROC_UNLOCK(p);
 	} /* end of process loop */
 	sx_sunlock(&allproc_lock);
 }
@@ -616,7 +616,7 @@
 
 	CTR3(KTR_SCHED, "sched_exit: %p(%s) prio %d",
 	    td, td->td_name, td->td_priority);
-	PROC_SLOCK_ASSERT(p, MA_OWNED);
+	PROC_LOCK_ASSERT(p, MA_OWNED);
 	sched_exit_thread(FIRST_THREAD_IN_PROC(p), td);
 }
 
@@ -656,7 +656,6 @@
 	struct thread *td;
 
 	PROC_LOCK_ASSERT(p, MA_OWNED);
-	PROC_SLOCK_ASSERT(p, MA_OWNED);
 	p->p_nice = nice;
 	FOREACH_THREAD_IN_PROC(p, td) {
 		thread_lock(td);

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

@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/sched_ule.c,v 1.234 2008/03/16 10:58:05 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/sched_ule.c,v 1.236 2008/03/19 07:36:37 jeff Exp $");
 
 #include "opt_hwpmc_hooks.h"
 #include "opt_sched.h"
@@ -1519,28 +1519,33 @@
 	THREAD_LOCK_ASSERT(td, MA_OWNED);
 	if (td->td_priority == prio)
 		return;
-
+	/*
+	 * If the priority has been elevated due to priority
+	 * propagation, we may have to move ourselves to a new
+	 * queue.  This could be optimized to not re-add in some
+	 * cases.
+	 */
 	if (TD_ON_RUNQ(td) && prio < td->td_priority) {
-		/*
-		 * If the priority has been elevated due to priority
-		 * propagation, we may have to move ourselves to a new
-		 * queue.  This could be optimized to not re-add in some
-		 * cases.
-		 */
 		sched_rem(td);
 		td->td_priority = prio;
 		sched_add(td, SRQ_BORROWING);
 		return;
 	}
-	tdq = TDQ_CPU(ts->ts_cpu);
-	oldpri = td->td_priority;
-	td->td_priority = prio;
+	/*
+	 * If the thread is currently running we may have to adjust the lowpri
+	 * information so other cpus are aware of our current priority.
+	 */
 	if (TD_IS_RUNNING(td)) {
+		tdq = TDQ_CPU(ts->ts_cpu);
+		oldpri = td->td_priority;
+		td->td_priority = prio;
 		if (prio < tdq->tdq_lowpri)
 			tdq->tdq_lowpri = prio;
 		else if (tdq->tdq_lowpri == oldpri)
 			tdq_setlowpri(tdq, td);
+		return;
 	}
+	td->td_priority = prio;

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list