--- old/usr/src/cmd/mdb/common/modules/genunix/findstack.c	2015-05-08 18:03:03.120465384 -0400
+++ new/usr/src/cmd/mdb/common/modules/genunix/findstack.c	2015-05-08 18:03:03.128043121 -0400
@@ -874,9 +874,6 @@
 		if (sep->se_failed != 0) {
 			char *reason;
 			switch (sep->se_failed) {
-			case FSI_FAIL_NOTINMEMORY:
-				reason = "thread not in memory";
-				break;
 			case FSI_FAIL_THREADCORRUPT:
 				reason = "thread structure stack info corrupt";
 				break;
--- old/usr/src/cmd/mdb/common/modules/genunix/findstack.h	2015-05-08 18:03:03.350521117 -0400
+++ new/usr/src/cmd/mdb/common/modules/genunix/findstack.h	2015-05-08 18:03:03.357826973 -0400
@@ -47,9 +47,8 @@
 } findstack_info_t;
 
 #define	FSI_FAIL_BADTHREAD	1
-#define	FSI_FAIL_NOTINMEMORY	2
-#define	FSI_FAIL_THREADCORRUPT	3
-#define	FSI_FAIL_STACKNOTFOUND	4
+#define	FSI_FAIL_THREADCORRUPT	2
+#define	FSI_FAIL_STACKNOTFOUND	3
 
 typedef struct stacks_module {
 	char		sm_name[MAXPATHLEN]; /* name of module */
--- old/usr/src/cmd/mdb/common/modules/genunix/findstack_subr.c	2015-05-08 18:03:03.559749591 -0400
+++ new/usr/src/cmd/mdb/common/modules/genunix/findstack_subr.c	2015-05-08 18:03:03.567192725 -0400
@@ -163,13 +163,6 @@
 	fsip->fsi_tstate = thr.t_state;
 	fsip->fsi_panic = !!(thr.t_flag & T_PANIC);
 
-	if ((thr.t_schedflag & TS_LOAD) == 0) {
-		if (print_warnings)
-			mdb_warn("thread %p isn't in memory\n", addr);
-		fsip->fsi_failed = FSI_FAIL_NOTINMEMORY;
-		return (DCMD_ERR);
-	}
-
 	if (thr.t_stk < thr.t_stkbase) {
 		if (print_warnings)
 			mdb_warn(
--- old/usr/src/cmd/mdb/common/modules/genunix/kmem.c	2015-05-08 18:03:03.776269998 -0400
+++ new/usr/src/cmd/mdb/common/modules/genunix/kmem.c	2015-05-08 18:03:03.784009205 -0400
@@ -4322,14 +4322,6 @@
 		return (WALK_NEXT);
 
 	/*
-	 * Warn about swapped out threads, but drive on anyway
-	 */
-	if (!(t->t_schedflag & TS_LOAD)) {
-		mdb_warn("thread %p's stack swapped out\n", addr);
-		return (WALK_NEXT);
-	}
-
-	/*
 	 * Search the thread's stack for the given pointer.  Note that it would
 	 * be more efficient to follow ::kgrep's lead and read in page-sized
 	 * chunks, but this routine is already fast and simple.
--- old/usr/src/cmd/mdb/common/modules/genunix/leaky_subr.c	2015-05-08 18:03:04.118089830 -0400
+++ new/usr/src/cmd/mdb/common/modules/genunix/leaky_subr.c	2015-05-08 18:03:04.125343001 -0400
@@ -24,8 +24,6 @@
  * Use is subject to license terms.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <mdb/mdb_param.h>
 #include <mdb/mdb_modapi.h>
 
@@ -278,22 +276,13 @@
 	return (WALK_NEXT);
 }
 
+/*ARGSUSED*/
 static int
 leaky_thread(uintptr_t addr, const kthread_t *t, unsigned long *pagesize)
 {
 	uintptr_t size, base = (uintptr_t)t->t_stkbase;
 	uintptr_t stk = (uintptr_t)t->t_stk;
 
-	/*
-	 * If this thread isn't in memory, we can't look at its stack.  This
-	 * may result in false positives, so we print a warning.
-	 */
-	if (!(t->t_schedflag & TS_LOAD)) {
-		mdb_printf("findleaks: thread %p's stack swapped out; "
-		    "false positives possible\n", addr);
-		return (WALK_NEXT);
-	}
-
 	if (t->t_state != TS_FREE)
 		leaky_grep(base, stk - base);
 
--- old/usr/src/uts/common/disp/disp.c	2015-05-08 18:03:04.348376949 -0400
+++ new/usr/src/uts/common/disp/disp.c	2015-05-08 18:03:04.355736337 -0400
@@ -96,9 +96,7 @@
 #define	KPQPRI	-1 		/* pri where cpu affinity is dropped for kpq */
 pri_t	kpqpri = KPQPRI; 	/* can be set in /etc/system */
 disp_t	cpu0_disp;		/* boot CPU's dispatch queue */
-disp_lock_t	swapped_lock;	/* lock swapped threads and swap queue */
 int	nswapped;		/* total number of swapped threads */
-void	disp_swapped_enq(kthread_t *tp);
 static void	disp_swapped_setrun(kthread_t *tp);
 static void	cpu_resched(cpu_t *cp, pri_t tpri);
 
@@ -776,7 +774,6 @@
 	tp = dq->dq_first;
 
 	ASSERT(tp != NULL);
-	ASSERT(tp->t_schedflag & TS_LOAD);	/* thread must be swapped in */
 
 	DTRACE_SCHED2(dequeue, kthread_t *, tp, disp_t *, dp);
 
@@ -815,12 +812,6 @@
 		tp->t_link = NULL;
 	}
 
-	/*
-	 * Set TS_DONT_SWAP flag to prevent another processor from swapping
-	 * out this thread before we have a chance to run it.
-	 * While running, it is protected against swapping by t_lock.
-	 */
-	tp->t_schedflag |= TS_DONT_SWAP;
 	cpup->cpu_dispthread = tp;		/* protected by spl only */
 	cpup->cpu_dispatch_pri = pri;
 	ASSERT(pri == DISP_PRIO(tp));
@@ -1191,15 +1182,6 @@
 	ASSERT((tp->t_schedflag & TS_ALLSTART) == 0);
 	ASSERT(!thread_on_queue(tp));	/* make sure tp isn't on a runq */
 
-	/*
-	 * If thread is "swapped" or on the swap queue don't
-	 * queue it, but wake sched.
-	 */
-	if ((tp->t_schedflag & (TS_LOAD | TS_ON_SWAPQ)) != TS_LOAD) {
-		disp_swapped_setrun(tp);
-		return;
-	}
-
 	self = (tp == curthread);
 
 	if (tp->t_bound_cpu || tp->t_weakbound_cpu)
@@ -1380,15 +1362,6 @@
 	ASSERT((tp->t_schedflag & TS_ALLSTART) == 0);
 	ASSERT(!thread_on_queue(tp));	/* make sure tp isn't on a runq */
 
-	/*
-	 * If thread is "swapped" or on the swap queue don't
-	 * queue it, but wake sched.
-	 */
-	if ((tp->t_schedflag & (TS_LOAD | TS_ON_SWAPQ)) != TS_LOAD) {
-		disp_swapped_setrun(tp);
-		return;
-	}
-
 	if (tp->t_bound_cpu || tp->t_weakbound_cpu)
 		bound = 1;
 	else
@@ -1617,13 +1590,6 @@
 	if (tp->t_state != TS_RUN)
 		return (0);
 
-	/*
-	 * The thread is "swapped" or is on the swap queue and
-	 * hence no longer on the run queue, so return true.
-	 */
-	if ((tp->t_schedflag & (TS_LOAD | TS_ON_SWAPQ)) != TS_LOAD)
-		return (1);
-
 	tpri = DISP_PRIO(tp);
 	dp = tp->t_disp_queue;
 	ASSERT(tpri < dp->disp_npri);
@@ -1677,110 +1643,6 @@
 	return (1);
 }
 
-
-/*
- * dq_sruninc and dq_srundec are public functions for
- * incrementing/decrementing the sruncnts when a thread on
- * a dispatcher queue is made schedulable/unschedulable by
- * resetting the TS_LOAD flag.
- *
- * The caller MUST have the thread lock and therefore the dispatcher
- * queue lock so that the operation which changes
- * the flag, the operation that checks the status of the thread to
- * determine if it's on a disp queue AND the call to this function
- * are one atomic operation with respect to interrupts.
- */
-
-/*
- * Called by sched AFTER TS_LOAD flag is set on a swapped, runnable thread.
- */
-void
-dq_sruninc(kthread_t *t)
-{
-	ASSERT(t->t_state == TS_RUN);
-	ASSERT(t->t_schedflag & TS_LOAD);
-
-	THREAD_TRANSITION(t);
-	setfrontdq(t);
-}
-
-/*
- * See comment on calling conventions above.
- * Called by sched BEFORE TS_LOAD flag is cleared on a runnable thread.
- */
-void
-dq_srundec(kthread_t *t)
-{
-	ASSERT(t->t_schedflag & TS_LOAD);
-
-	(void) dispdeq(t);
-	disp_swapped_enq(t);
-}
-
-/*
- * Change the dispatcher lock of thread to the "swapped_lock"
- * and return with thread lock still held.
- *
- * Called with thread_lock held, in transition state, and at high spl.
- */
-void
-disp_swapped_enq(kthread_t *tp)
-{
-	ASSERT(THREAD_LOCK_HELD(tp));
-	ASSERT(tp->t_schedflag & TS_LOAD);
-
-	switch (tp->t_state) {
-	case TS_RUN:
-		disp_lock_enter_high(&swapped_lock);
-		THREAD_SWAP(tp, &swapped_lock);	/* set TS_RUN state and lock */
-		break;
-	case TS_ONPROC:
-		disp_lock_enter_high(&swapped_lock);
-		THREAD_TRANSITION(tp);
-		wake_sched_sec = 1;		/* tell clock to wake sched */
-		THREAD_SWAP(tp, &swapped_lock);	/* set TS_RUN state and lock */
-		break;
-	default:
-		panic("disp_swapped: tp: %p bad t_state", (void *)tp);
-	}
-}
-
-/*
- * This routine is called by setbackdq/setfrontdq if the thread is
- * not loaded or loaded and on the swap queue.
- *
- * Thread state TS_SLEEP implies that a swapped thread
- * has been woken up and needs to be swapped in by the swapper.
- *
- * Thread state TS_RUN, it implies that the priority of a swapped
- * thread is being increased by scheduling class (e.g. ts_update).
- */
-static void
-disp_swapped_setrun(kthread_t *tp)
-{
-	ASSERT(THREAD_LOCK_HELD(tp));
-	ASSERT((tp->t_schedflag & (TS_LOAD | TS_ON_SWAPQ)) != TS_LOAD);
-
-	switch (tp->t_state) {
-	case TS_SLEEP:
-		disp_lock_enter_high(&swapped_lock);
-		/*
-		 * Wakeup sched immediately (i.e., next tick) if the
-		 * thread priority is above maxclsyspri.
-		 */
-		if (DISP_PRIO(tp) > maxclsyspri)
-			wake_sched = 1;
-		else
-			wake_sched_sec = 1;
-		THREAD_RUN(tp, &swapped_lock); /* set TS_RUN state and lock */
-		break;
-	case TS_RUN:				/* called from ts_update */
-		break;
-	default:
-		panic("disp_swapped_setrun: tp: %p bad t_state", (void *)tp);
-	}
-}
-
 /*
  *	Make a thread give up its processor.  Find the processor on
  *	which this thread is executing, and have that processor
@@ -2154,11 +2016,10 @@
 
 	/*
 	 * Don't do anything if the thread is not bound, or
-	 * currently not runnable or swapped out.
+	 * currently not runnable.
 	 */
 	if (tp->t_bound_cpu == NULL ||
-	    tp->t_state != TS_RUN ||
-	    tp->t_schedflag & TS_ON_SWAPQ)
+	    tp->t_state != TS_RUN)
 		return;
 
 	tpri = DISP_PRIO(tp);
@@ -2353,8 +2214,6 @@
 	 */
 	dp->disp_steal = 0;
 
-	tp->t_schedflag |= TS_DONT_SWAP;
-
 	/*
 	 * Setup thread to run on the current CPU.
 	 */
--- old/usr/src/uts/common/disp/fss.c	2015-05-08 18:03:04.649446992 -0400
+++ new/usr/src/uts/common/disp/fss.c	2015-05-08 18:03:04.656768437 -0400
@@ -349,8 +349,6 @@
 
 static id_t	fss_cid;
 
-static time_t	fss_minrun = 2;	/* t_pri becomes 59 within 2 secs */
-static time_t	fss_minslp = 2;	/* min time on sleep queue for hardswap */
 static int	fss_quantum = 11;
 
 static void	fss_newpri(fssproc_t *, boolean_t);
@@ -379,8 +377,6 @@
 static void	fss_exit(kthread_t *);
 static void	fss_active(kthread_t *);
 static void	fss_inactive(kthread_t *);
-static pri_t	fss_swapin(kthread_t *, int);
-static pri_t	fss_swapout(kthread_t *, int);
 static void	fss_trapret(kthread_t *);
 static void	fss_preempt(kthread_t *);
 static void	fss_setrun(kthread_t *);
@@ -417,8 +413,6 @@
 	fss_exit,
 	fss_active,
 	fss_inactive,
-	fss_swapin,
-	fss_swapout,
 	fss_trapret,
 	fss_preempt,
 	fss_setrun,
@@ -2140,107 +2134,6 @@
 }
 
 /*
- * fss_swapin() returns -1 if the thread is loaded or is not eligible to be
- * swapped in. Otherwise, it returns the thread's effective priority based
- * on swapout time and size of process (0 <= epri <= 0 SHRT_MAX).
- */
-/*ARGSUSED*/
-static pri_t
-fss_swapin(kthread_t *t, int flags)
-{
-	fssproc_t *fssproc = FSSPROC(t);
-	long epri = -1;
-	proc_t *pp = ttoproc(t);
-
-	ASSERT(THREAD_LOCK_HELD(t));
-
-	if (t->t_state == TS_RUN && (t->t_schedflag & TS_LOAD) == 0) {
-		time_t swapout_time;
-
-		swapout_time = (ddi_get_lbolt() - t->t_stime) / hz;
-		if (INHERITED(t) || (fssproc->fss_flags & FSSKPRI)) {
-			epri = (long)DISP_PRIO(t) + swapout_time;
-		} else {
-			/*
-			 * Threads which have been out for a long time,
-			 * have high user mode priority and are associated
-			 * with a small address space are more deserving.
-			 */
-			epri = fssproc->fss_umdpri;
-			ASSERT(epri >= 0 && epri <= fss_maxumdpri);
-			epri += swapout_time - pp->p_swrss / nz(maxpgio)/2;
-		}
-		/*
-		 * Scale epri so that SHRT_MAX / 2 represents zero priority.
-		 */
-		epri += SHRT_MAX / 2;
-		if (epri < 0)
-			epri = 0;
-		else if (epri > SHRT_MAX)
-			epri = SHRT_MAX;
-	}
-	return ((pri_t)epri);
-}
-
-/*
- * fss_swapout() returns -1 if the thread isn't loaded or is not eligible to
- * be swapped out. Otherwise, it returns the thread's effective priority
- * based on if the swapper is in softswap or hardswap mode.
- */
-static pri_t
-fss_swapout(kthread_t *t, int flags)
-{
-	fssproc_t *fssproc = FSSPROC(t);
-	long epri = -1;
-	proc_t *pp = ttoproc(t);
-	time_t swapin_time;
-
-	ASSERT(THREAD_LOCK_HELD(t));
-
-	if (INHERITED(t) ||
-	    (fssproc->fss_flags & FSSKPRI) ||
-	    (t->t_proc_flag & TP_LWPEXIT) ||
-	    (t->t_state & (TS_ZOMB|TS_FREE|TS_STOPPED|TS_ONPROC|TS_WAIT)) ||
-	    !(t->t_schedflag & TS_LOAD) ||
-	    !(SWAP_OK(t)))
-		return (-1);
-
-	ASSERT(t->t_state & (TS_SLEEP | TS_RUN));
-
-	swapin_time = (ddi_get_lbolt() - t->t_stime) / hz;
-
-	if (flags == SOFTSWAP) {
-		if (t->t_state == TS_SLEEP && swapin_time > maxslp) {
-			epri = 0;
-		} else {
-			return ((pri_t)epri);
-		}
-	} else {
-		pri_t pri;
-
-		if ((t->t_state == TS_SLEEP && swapin_time > fss_minslp) ||
-		    (t->t_state == TS_RUN && swapin_time > fss_minrun)) {
-			pri = fss_maxumdpri;
-			epri = swapin_time -
-			    (rm_asrss(pp->p_as) / nz(maxpgio)/2) - (long)pri;
-		} else {
-			return ((pri_t)epri);
-		}
-	}
-
-	/*
-	 * Scale epri so that SHRT_MAX / 2 represents zero priority.
-	 */
-	epri += SHRT_MAX / 2;
-	if (epri < 0)
-		epri = 0;
-	else if (epri > SHRT_MAX)
-		epri = SHRT_MAX;
-
-	return ((pri_t)epri);
-}
-
-/*
  * If thread is currently at a kernel mode priority (has slept) and is
  * returning to the userland we assign it the appropriate user mode priority
  * and time quantum here.  If we're lowering the thread's priority below that
@@ -2271,16 +2164,6 @@
 		if (DISP_MUST_SURRENDER(t))
 			cpu_surrender(t);
 	}
-
-	/*
-	 * Swapout lwp if the swapper is waiting for this thread to reach
-	 * a safe point.
-	 */
-	if (t->t_schedflag & TS_SWAPENQ) {
-		thread_unlock(t);
-		swapout_lwp(ttolwp(t));
-		thread_lock(t);
-	}
 }
 
 /*
@@ -2325,14 +2208,6 @@
 	}
 
 	/*
-	 * If preempted in user-land mark the thread as swappable because it
-	 * cannot be holding any kernel locks.
-	 */
-	ASSERT(t->t_schedflag & TS_DONT_SWAP);
-	if (lwp != NULL && lwp->lwp_state == LWP_USER)
-		t->t_schedflag &= ~TS_DONT_SWAP;
-
-	/*
 	 * Check to see if we're doing "preemption control" here.  If
 	 * we are, and if the user has requested that this thread not
 	 * be preempted, and if preemptions haven't been put off for
@@ -2356,7 +2231,6 @@
 					fssproc->fss_flags |= FSSRESTORE;
 				}
 				THREAD_CHANGE_PRI(t, fss_maxumdpri);
-				t->t_schedflag |= TS_DONT_SWAP;
 			}
 			schedctl_set_yield(t, 1);
 			setfrontdq(t);
@@ -2462,20 +2336,17 @@
 		if (DISP_MUST_SURRENDER(curthread))
 			cpu_surrender(t);
 	}
-	t->t_stime = ddi_get_lbolt();	/* time stamp for the swapper */
 }
 
 /*
  * A tick interrupt has ocurrend on a running thread. Check to see if our
- * time slice has expired.  We must also clear the TS_DONT_SWAP flag in
- * t_schedflag if the thread is eligible to be swapped out.
+ * time slice has expired.
  */
 static void
 fss_tick(kthread_t *t)
 {
 	fssproc_t *fssproc;
 	fssproj_t *fssproj;
-	klwp_t *lwp;
 	boolean_t call_cpu_surrender = B_FALSE;
 	boolean_t cpucaps_enforce = B_FALSE;
 
@@ -2547,10 +2418,6 @@
 			 * accomplishes this.
 			 */
 			if (thread_change_pri(t, new_pri, 0)) {
-				if ((t->t_schedflag & TS_LOAD) &&
-				    (lwp = t->t_lwp) &&
-				    lwp->lwp_state == LWP_USER)
-					t->t_schedflag &= ~TS_DONT_SWAP;
 				fssproc->fss_timeleft = fss_quantum;
 			} else {
 				call_cpu_surrender = B_TRUE;
@@ -2614,7 +2481,6 @@
 
 	fss_active(t);
 
-	t->t_stime = ddi_get_lbolt();		/* time stamp for the swapper */
 	fssproc = FSSPROC(t);
 	fssproc->fss_flags &= ~FSSBACKQ;
 
--- old/usr/src/uts/common/disp/fx.c	2015-05-08 18:03:04.958133699 -0400
+++ new/usr/src/uts/common/disp/fx.c	2015-05-08 18:03:04.965537783 -0400
@@ -181,8 +181,6 @@
 static int	fx_parmsset(kthread_t *, void *, id_t, cred_t *);
 static void	fx_stop(kthread_t *, int, int);
 static void	fx_exit(kthread_t *);
-static pri_t	fx_swapin(kthread_t *, int);
-static pri_t	fx_swapout(kthread_t *, int);
 static void	fx_trapret(kthread_t *);
 static void	fx_preempt(kthread_t *);
 static void	fx_setrun(kthread_t *);
@@ -226,8 +224,6 @@
 	fx_exit,
 	fx_nullsys,	/* active */
 	fx_nullsys,	/* inactive */
-	fx_swapin,
-	fx_swapout,
 	fx_trapret,
 	fx_preempt,
 	fx_setrun,
@@ -1224,49 +1220,6 @@
 	if (FX_HAS_CB(fxpp)) {
 		FX_CB_SLEEP(FX_CALLB(fxpp), fxpp->fx_cookie);
 	}
-	t->t_stime = ddi_get_lbolt();		/* time stamp for the swapper */
-}
-
-
-/*
- * Return Values:
- *
- *	-1 if the thread is loaded or is not eligible to be swapped in.
- *
- * FX and RT threads are designed so that they don't swapout; however,
- * it is possible that while the thread is swapped out and in another class, it
- * can be changed to FX or RT.  Since these threads should be swapped in
- * as soon as they're runnable, rt_swapin returns SHRT_MAX, and fx_swapin
- * returns SHRT_MAX - 1, so that it gives deference to any swapped out
- * RT threads.
- */
-/* ARGSUSED */
-static pri_t
-fx_swapin(kthread_t *t, int flags)
-{
-	pri_t	tpri = -1;
-
-	ASSERT(THREAD_LOCK_HELD(t));
-
-	if (t->t_state == TS_RUN && (t->t_schedflag & TS_LOAD) == 0) {
-		tpri = (pri_t)SHRT_MAX - 1;
-	}
-
-	return (tpri);
-}
-
-/*
- * Return Values
- *	-1 if the thread isn't loaded or is not eligible to be swapped out.
- */
-/* ARGSUSED */
-static pri_t
-fx_swapout(kthread_t *t, int flags)
-{
-	ASSERT(THREAD_LOCK_HELD(t));
-
-	return (-1);
-
 }
 
 /* ARGSUSED */
@@ -1396,7 +1349,6 @@
 
 	ASSERT(THREAD_LOCK_HELD(t));
 
-	t->t_stime = ddi_get_lbolt();		/* time stamp for the swapper */
 	if (FX_HAS_CB(fxpp)) {
 		clock_t new_quantum =  (clock_t)fxpp->fx_pquantum;
 		pri_t	newpri = fxpp->fx_pri;
--- old/usr/src/uts/common/disp/rt.c	2015-05-08 18:03:05.218902886 -0400
+++ new/usr/src/uts/common/disp/rt.c	2015-05-08 18:03:05.226228608 -0400
@@ -131,8 +131,6 @@
 static void	rt_setrun(kthread_t *);
 static void	rt_tick(kthread_t *);
 static void	rt_wakeup(kthread_t *);
-static pri_t	rt_swapin(kthread_t *, int);
-static pri_t	rt_swapout(kthread_t *, int);
 static pri_t	rt_globpri(kthread_t *);
 static void	rt_yield(kthread_t *);
 static int	rt_alloc(void **, int);
@@ -170,8 +168,6 @@
 	rt_nullsys,	/* exit */
 	rt_nullsys,	/* active */
 	rt_nullsys,	/* inactive */
-	rt_swapin,
-	rt_swapout,
 	rt_nullsys,	/* trapret */
 	rt_preempt,
 	rt_setrun,
@@ -902,16 +898,9 @@
 rt_preempt(kthread_t *t)
 {
 	rtproc_t *rtpp = (rtproc_t *)(t->t_cldata);
-	klwp_t *lwp;
 
 	ASSERT(THREAD_LOCK_HELD(t));
 
-	/*
-	 * If the state is user I allow swapping because I know I won't
-	 * be holding any locks.
-	 */
-	if ((lwp = curthread->t_lwp) != NULL && lwp->lwp_state == LWP_USER)
-		t->t_schedflag &= ~TS_DONT_SWAP;
 	if ((rtpp->rt_flags & RTBACKQ) != 0) {
 		rtpp->rt_timeleft = rtpp->rt_pquantum;
 		rtpp->rt_flags &= ~RTBACKQ;
@@ -944,44 +933,6 @@
 }
 
 /*
- * Returns the priority of the thread, -1 if the thread is loaded or ineligible
- * for swapin.
- *
- * FX and RT threads are designed so that they don't swapout; however, it
- * is possible that while the thread is swapped out and in another class, it
- * can be changed to FX or RT.  Since these threads should be swapped in as
- * soon as they're runnable, rt_swapin returns SHRT_MAX, and fx_swapin
- * returns SHRT_MAX - 1, so that it gives deference to any swapped out RT
- * threads.
- */
-/* ARGSUSED */
-static pri_t
-rt_swapin(kthread_t *t, int flags)
-{
-	pri_t	tpri = -1;
-
-	ASSERT(THREAD_LOCK_HELD(t));
-
-	if (t->t_state == TS_RUN && (t->t_schedflag & TS_LOAD) == 0) {
-		tpri = (pri_t)SHRT_MAX;
-	}
-
-	return (tpri);
-}
-
-/*
- * Return an effective priority for swapout.
- */
-/* ARGSUSED */
-static pri_t
-rt_swapout(kthread_t *t, int flags)
-{
-	ASSERT(THREAD_LOCK_HELD(t));
-
-	return (-1);
-}
-
-/*
  * Check for time slice expiration (unless thread has infinite time
  * slice).  If time slice has expired arrange for thread to be preempted
  * and placed on back of queue.
--- old/usr/src/uts/common/disp/sysclass.c	2015-05-08 18:03:05.453188335 -0400
+++ new/usr/src/uts/common/disp/sysclass.c	2015-05-08 18:03:05.460464124 -0400
@@ -27,8 +27,6 @@
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
 /*	  All Rights Reserved  	*/
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"	/* from SVr4.0 1.12 */
-
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/sysmacros.h>
@@ -66,7 +64,6 @@
 static int	sys_doprio(kthread_t *, cred_t *, int, int *);
 static void	sys_forkret(kthread_t *, kthread_t *);
 static void	sys_nullsys();
-static pri_t	sys_swappri(kthread_t *, int);
 static int	sys_alloc(void **, int);
 
 struct classfuncs sys_classfuncs = {
@@ -95,8 +92,6 @@
 		sys_nullsys,	/* exit */
 		sys_nullsys,	/* active */
 		sys_nullsys,	/* inactive */
-		sys_swappri,	/* swapin */
-		sys_swappri,	/* swapout */
 		sys_nullsys,	/* trapret */
 		setfrontdq,	/* preempt */
 		setbackdq,	/* setrun */
@@ -194,15 +189,6 @@
 	mutex_exit(&pp->p_lock);
 }
 
-/* ARGSUSED */
-static pri_t
-sys_swappri(t, flags)
-	kthread_t	*t;
-	int		flags;
-{
-	return (-1);
-}
-
 static int
 sys_nosys()
 {
--- old/usr/src/uts/common/disp/sysdc.c	2015-05-08 18:03:05.660750748 -0400
+++ new/usr/src/uts/common/disp/sysdc.c	2015-05-08 18:03:05.668144025 -0400
@@ -1110,14 +1110,6 @@
 	return (t->t_epri);
 }
 
-/*ARGSUSED*/
-static pri_t
-sysdc_no_swap(kthread_t *t, int flags)
-{
-	/* SDC threads cannot be swapped. */
-	return (-1);
-}
-
 /*
  * Get maximum and minimum priorities enjoyed by SDC threads.
  */
@@ -1202,8 +1194,6 @@
 		sysdc_exit,
 		sysdc_nullsys,	/* active */
 		sysdc_nullsys,	/* inactive */
-		sysdc_no_swap,	/* swapin */
-		sysdc_no_swap,	/* swapout */
 		sysdc_nullsys,	/* trapret */
 		sysdc_preempt,
 		sysdc_setrun,
--- old/usr/src/uts/common/disp/thread.c	2015-05-08 18:03:05.904526312 -0400
+++ new/usr/src/uts/common/disp/thread.c	2015-05-08 18:03:05.911732605 -0400
@@ -429,8 +429,7 @@
 	t->t_clfuncs = &sys_classfuncs.thread;
 	t->t_cid = syscid;
 	t->t_pri = pri;
-	t->t_stime = ddi_get_lbolt();
-	t->t_schedflag = TS_LOAD | TS_DONT_SWAP;
+	t->t_schedflag = 0;
 	t->t_bind_cpu = PBIND_NONE;
 	t->t_bindflag = (uchar_t)default_binding_mode;
 	t->t_bind_pset = PS_NONE;
--- old/usr/src/uts/common/disp/ts.c	2015-05-08 18:03:06.173187226 -0400
+++ new/usr/src/uts/common/disp/ts.c	2015-05-08 18:03:06.189874510 -0400
@@ -202,8 +202,6 @@
 static void	ts_preempt(kthread_t *);
 static void	ts_setrun(kthread_t *);
 static void	ts_sleep(kthread_t *);
-static pri_t	ts_swapin(kthread_t *, int);
-static pri_t	ts_swapout(kthread_t *, int);
 static void	ts_tick(kthread_t *);
 static void	ts_trapret(kthread_t *);
 static void	ts_update(void *);
@@ -261,8 +259,6 @@
 	ts_exit,
 	ts_nullsys,	/* active */
 	ts_nullsys,	/* inactive */
-	ts_swapin,
-	ts_swapout,
 	ts_trapret,
 	ts_preempt,
 	ts_setrun,
@@ -306,8 +302,6 @@
 	ts_exit,
 	ts_nullsys,	/* active */
 	ts_nullsys,	/* inactive */
-	ts_swapin,
-	ts_swapout,
 	ts_trapret,
 	ts_preempt,
 	ts_setrun,
@@ -1404,14 +1398,6 @@
 	}
 
 	/*
-	 * If thread got preempted in the user-land then we know
-	 * it isn't holding any locks.  Mark it as swappable.
-	 */
-	ASSERT(t->t_schedflag & TS_DONT_SWAP);
-	if (lwp != NULL && lwp->lwp_state == LWP_USER)
-		t->t_schedflag &= ~TS_DONT_SWAP;
-
-	/*
 	 * Check to see if we're doing "preemption control" here.  If
 	 * we are, and if the user has requested that this thread not
 	 * be preempted, and if preemptions haven't been put off for
@@ -1435,7 +1421,6 @@
 					tspp->ts_flags |= TSRESTORE;
 				}
 				THREAD_CHANGE_PRI(t, ts_maxumdpri);
-				t->t_schedflag |= TS_DONT_SWAP;
 			}
 			schedctl_set_yield(t, 1);
 			setfrontdq(t);
@@ -1562,138 +1547,10 @@
 		if (DISP_MUST_SURRENDER(curthread))
 			cpu_surrender(curthread);
 	}
-	t->t_stime = ddi_get_lbolt();		/* time stamp for the swapper */
 	TRACE_2(TR_FAC_DISP, TR_SLEEP,
 	    "sleep:tid %p old pri %d", t, old_pri);
 }
 
-
-/*
- * Return Values:
- *
- *	-1 if the thread is loaded or is not eligible to be swapped in.
- *
- *	effective priority of the specified thread based on swapout time
- *		and size of process (epri >= 0 , epri <= SHRT_MAX).
- */
-/* ARGSUSED */
-static pri_t
-ts_swapin(kthread_t *t, int flags)
-{
-	tsproc_t	*tspp = (tsproc_t *)(t->t_cldata);
-	long		epri = -1;
-	proc_t		*pp = ttoproc(t);
-
-	ASSERT(THREAD_LOCK_HELD(t));
-
-	/*
-	 * We know that pri_t is a short.
-	 * Be sure not to overrun its range.
-	 */
-	if (t->t_state == TS_RUN && (t->t_schedflag & TS_LOAD) == 0) {
-		time_t swapout_time;
-
-		swapout_time = (ddi_get_lbolt() - t->t_stime) / hz;
-		if (INHERITED(t) || (tspp->ts_flags & (TSKPRI | TSIASET)))
-			epri = (long)DISP_PRIO(t) + swapout_time;
-		else {
-			/*
-			 * Threads which have been out for a long time,
-			 * have high user mode priority and are associated
-			 * with a small address space are more deserving
-			 */
-			epri = ts_dptbl[tspp->ts_umdpri].ts_globpri;
-			ASSERT(epri >= 0 && epri <= ts_maxumdpri);
-			epri += swapout_time - pp->p_swrss / nz(maxpgio)/2;
-		}
-		/*
-		 * Scale epri so SHRT_MAX/2 represents zero priority.
-		 */
-		epri += SHRT_MAX/2;
-		if (epri < 0)
-			epri = 0;
-		else if (epri > SHRT_MAX)
-			epri = SHRT_MAX;
-	}
-	return ((pri_t)epri);
-}
-
-/*
- * Return Values
- *	-1 if the thread isn't loaded or is not eligible to be swapped out.
- *
- *	effective priority of the specified thread based on if the swapper
- *		is in softswap or hardswap mode.
- *
- *		Softswap:  Return a low effective priority for threads
- *			   sleeping for more than maxslp secs.
- *
- *		Hardswap:  Return an effective priority such that threads
- *			   which have been in memory for a while and are
- *			   associated with a small address space are swapped
- *			   in before others.
- *
- *		(epri >= 0 , epri <= SHRT_MAX).
- */
-time_t	ts_minrun = 2;		/* XXX - t_pri becomes 59 within 2 secs */
-time_t	ts_minslp = 2;		/* min time on sleep queue for hardswap */
-
-static pri_t
-ts_swapout(kthread_t *t, int flags)
-{
-	tsproc_t	*tspp = (tsproc_t *)(t->t_cldata);
-	long		epri = -1;
-	proc_t		*pp = ttoproc(t);
-	time_t		swapin_time;
-
-	ASSERT(THREAD_LOCK_HELD(t));
-
-	if (INHERITED(t) || (tspp->ts_flags & (TSKPRI | TSIASET)) ||
-	    (t->t_proc_flag & TP_LWPEXIT) ||
-	    (t->t_state & (TS_ZOMB | TS_FREE | TS_STOPPED |
-	    TS_ONPROC | TS_WAIT)) ||
-	    !(t->t_schedflag & TS_LOAD) || !SWAP_OK(t))
-		return (-1);
-
-	ASSERT(t->t_state & (TS_SLEEP | TS_RUN));
-
-	/*
-	 * We know that pri_t is a short.
-	 * Be sure not to overrun its range.
-	 */
-	swapin_time = (ddi_get_lbolt() - t->t_stime) / hz;
-	if (flags == SOFTSWAP) {
-		if (t->t_state == TS_SLEEP && swapin_time > maxslp) {
-			epri = 0;
-		} else {
-			return ((pri_t)epri);
-		}
-	} else {
-		pri_t pri;
-
-		if ((t->t_state == TS_SLEEP && swapin_time > ts_minslp) ||
-		    (t->t_state == TS_RUN && swapin_time > ts_minrun)) {
-			pri = ts_dptbl[tspp->ts_umdpri].ts_globpri;
-			ASSERT(pri >= 0 && pri <= ts_maxumdpri);
-			epri = swapin_time -
-			    (rm_asrss(pp->p_as) / nz(maxpgio)/2) - (long)pri;
-		} else {
-			return ((pri_t)epri);
-		}
-	}
-
-	/*
-	 * Scale epri so SHRT_MAX/2 represents zero priority.
-	 */
-	epri += SHRT_MAX/2;
-	if (epri < 0)
-		epri = 0;
-	else if (epri > SHRT_MAX)
-		epri = SHRT_MAX;
-
-	return ((pri_t)epri);
-}
-
 /*
  * Check for time slice expiration.  If time slice has expired
  * move thread to priority specified in tsdptbl for time slice expiration
@@ -1703,7 +1560,6 @@
 ts_tick(kthread_t *t)
 {
 	tsproc_t *tspp = (tsproc_t *)(t->t_cldata);
-	klwp_t *lwp;
 	boolean_t call_cpu_surrender = B_FALSE;
 	pri_t	oldpri = t->t_pri;
 
@@ -1758,10 +1614,6 @@
 			 * this.
 			 */
 			if (thread_change_pri(t, new_pri, 0)) {
-				if ((t->t_schedflag & TS_LOAD) &&
-				    (lwp = t->t_lwp) &&
-				    lwp->lwp_state == LWP_USER)
-					t->t_schedflag &= ~TS_DONT_SWAP;
 				tspp->ts_timeleft =
 				    ts_dptbl[tspp->ts_cpupri].ts_quantum;
 			} else {
@@ -1835,16 +1687,6 @@
 			cpu_surrender(t);
 	}
 
-	/*
-	 * Swapout lwp if the swapper is waiting for this thread to
-	 * reach a safe point.
-	 */
-	if ((t->t_schedflag & TS_SWAPENQ) && !(tspp->ts_flags & TSIASET)) {
-		thread_unlock(t);
-		swapout_lwp(ttolwp(t));
-		thread_lock(t);
-	}
-
 	TRACE_2(TR_FAC_DISP, TR_TRAPRET,
 	    "trapret:tid %p old pri %d", t, old_pri);
 }
@@ -1982,8 +1824,6 @@
 
 	ASSERT(THREAD_LOCK_HELD(t));
 
-	t->t_stime = ddi_get_lbolt();		/* time stamp for the swapper */
-
 	if (tspp->ts_flags & TSKPRI) {
 		tspp->ts_flags &= ~TSBACKQ;
 		if (tspp->ts_flags & TSIASET)
--- old/usr/src/uts/common/fs/nfs/nfs_srv.c	2015-05-08 18:03:06.472459512 -0400
+++ new/usr/src/uts/common/fs/nfs/nfs_srv.c	2015-05-08 18:03:06.479903432 -0400
@@ -1215,8 +1215,6 @@
 	nrp->ro = ro;
 	nrp->thread = curthread;
 
-	ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
-
 	/*
 	 * Look to see if there is already a cluster started
 	 * for this file.
--- old/usr/src/uts/common/os/clock.c	2015-05-08 18:03:06.769352622 -0400
+++ new/usr/src/uts/common/os/clock.c	2015-05-08 18:03:06.776726542 -0400
@@ -902,44 +902,6 @@
 			calcloadavg(genloadavg(&cpupart->cp_loadavg),
 			    cpupart->cp_hp_avenrun);
 		} while ((cpupart = cpupart->cp_next) != cp_list_head);
-
-		/*
-		 * Wake up the swapper thread if necessary.
-		 */
-		if (runin ||
-		    (runout && (avefree < desfree || wake_sched_sec))) {
-			t = &t0;
-			thread_lock(t);
-			if (t->t_state == TS_STOPPED) {
-				runin = runout = 0;
-				wake_sched_sec = 0;
-				t->t_whystop = 0;
-				t->t_whatstop = 0;
-				t->t_schedflag &= ~TS_ALLSTART;
-				THREAD_TRANSITION(t);
-				setfrontdq(t);
-			}
-			thread_unlock(t);
-		}
-	}
-
-	/*
-	 * Wake up the swapper if any high priority swapped-out threads
-	 * became runable during the last tick.
-	 */
-	if (wake_sched) {
-		t = &t0;
-		thread_lock(t);
-		if (t->t_state == TS_STOPPED) {
-			runin = runout = 0;
-			wake_sched = 0;
-			t->t_whystop = 0;
-			t->t_whatstop = 0;
-			t->t_schedflag &= ~TS_ALLSTART;
-			THREAD_TRANSITION(t);
-			setfrontdq(t);
-		}
-		thread_unlock(t);
 	}
 }
 
--- old/usr/src/uts/common/os/condvar.c	2015-05-08 18:03:07.060262992 -0400
+++ new/usr/src/uts/common/os/condvar.c	2015-05-08 18:03:07.067713824 -0400
@@ -193,7 +193,6 @@
 		return;
 	ASSERT(!quiesce_active);
 
-	ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
 	thread_lock(curthread);			/* lock the thread */
 	cv_block((condvar_impl_t *)cvp);
 	thread_unlock_nopreempt(curthread);	/* unlock the waiters field */
@@ -326,7 +325,6 @@
 	}
 	ASSERT(t->t_intr == NULL);
 
-	ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
 	cancel_pending = schedctl_cancel_pending();
 	lwp->lwp_asleep = 1;
 	lwp->lwp_sysabort = 0;
@@ -554,8 +552,6 @@
 	thread_lock(t);
 	t->t_kpri_req = 0;	/* don't need kernel priority */
 	cv_block_sig(t, (condvar_impl_t *)cvp);
-	/* I can be swapped now */
-	curthread->t_schedflag &= ~TS_DONT_SWAP;
 	thread_unlock_nopreempt(t);
 	mutex_exit(mp);
 	if (ISSIG(t, JUSTLOOKING) || MUSTRETURN(p, t) || cancel_pending)
@@ -564,8 +560,6 @@
 	swtch();
 	signalled = (t->t_schedflag & TS_SIGNALLED);
 	t->t_flag &= ~T_WAKEABLE;
-	/* TS_DONT_SWAP set by disp() */
-	ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
 	mutex_enter(mp);
 	if (ISSIG_PENDING(t, lwp, p)) {
 		mutex_exit(mp);
--- old/usr/src/uts/common/os/cpu.c	2015-05-08 18:03:07.289917347 -0400
+++ new/usr/src/uts/common/os/cpu.c	2015-05-08 18:03:07.297240388 -0400
@@ -301,10 +301,6 @@
 	kstat_named_t pgpgin;
 	kstat_named_t pgout;
 	kstat_named_t pgpgout;
-	kstat_named_t swapin;
-	kstat_named_t pgswapin;
-	kstat_named_t swapout;
-	kstat_named_t pgswapout;
 	kstat_named_t zfod;
 	kstat_named_t dfree;
 	kstat_named_t scan;
@@ -333,10 +329,6 @@
 	{ "pgpgin",		KSTAT_DATA_UINT64 },
 	{ "pgout",		KSTAT_DATA_UINT64 },
 	{ "pgpgout",		KSTAT_DATA_UINT64 },
-	{ "swapin",		KSTAT_DATA_UINT64 },
-	{ "pgswapin",		KSTAT_DATA_UINT64 },
-	{ "swapout",		KSTAT_DATA_UINT64 },
-	{ "pgswapout",		KSTAT_DATA_UINT64 },
 	{ "zfod",		KSTAT_DATA_UINT64 },
 	{ "dfree",		KSTAT_DATA_UINT64 },
 	{ "scan",		KSTAT_DATA_UINT64 },
@@ -2682,13 +2674,10 @@
 				(void) dispdeq(tp);
 				setbackdq(tp);
 				/*
-				 * Either on the bound CPU's disp queue now,
-				 * or swapped out or on the swap queue.
+				 * On the bound CPU's disp queue now.
 				 */
 				ASSERT(tp->t_disp_queue == cp->cpu_disp ||
-				    tp->t_weakbound_cpu == ocp ||
-				    (tp->t_schedflag & (TS_LOAD | TS_ON_SWAPQ))
-				    != TS_LOAD);
+				    tp->t_weakbound_cpu == ocp);
 			}
 		}
 	}
@@ -3291,10 +3280,6 @@
 	cvskd->pgpgin.value.ui64 = cvs->pgpgin;
 	cvskd->pgout.value.ui64 = cvs->pgout;
 	cvskd->pgpgout.value.ui64 = cvs->pgpgout;
-	cvskd->swapin.value.ui64 = cvs->swapin;
-	cvskd->pgswapin.value.ui64 = cvs->pgswapin;
-	cvskd->swapout.value.ui64 = cvs->swapout;
-	cvskd->pgswapout.value.ui64 = cvs->pgswapout;
 	cvskd->zfod.value.ui64 = cvs->zfod;
 	cvskd->dfree.value.ui64 = cvs->dfree;
 	cvskd->scan.value.ui64 = cvs->scan;
@@ -3421,10 +3406,6 @@
 	cso->cpu_vminfo.pgpgin		= CPU_STATS(cp, vm.pgpgin);
 	cso->cpu_vminfo.pgout		= CPU_STATS(cp, vm.pgout);
 	cso->cpu_vminfo.pgpgout		= CPU_STATS(cp, vm.pgpgout);
-	cso->cpu_vminfo.swapin		= CPU_STATS(cp, vm.swapin);
-	cso->cpu_vminfo.pgswapin	= CPU_STATS(cp, vm.pgswapin);
-	cso->cpu_vminfo.swapout		= CPU_STATS(cp, vm.swapout);
-	cso->cpu_vminfo.pgswapout	= CPU_STATS(cp, vm.pgswapout);
 	cso->cpu_vminfo.zfod		= CPU_STATS(cp, vm.zfod);
 	cso->cpu_vminfo.dfree		= CPU_STATS(cp, vm.dfree);
 	cso->cpu_vminfo.scan		= CPU_STATS(cp, vm.scan);
--- old/usr/src/uts/common/os/panic.c	2015-05-08 18:03:07.616642435 -0400
+++ new/usr/src/uts/common/os/panic.c	2015-05-08 18:03:07.624012723 -0400
@@ -223,7 +223,6 @@
 	(void) setjmp(&t->t_pcb);
 	t->t_flag |= T_PANIC;
 
-	t->t_schedflag |= TS_DONT_SWAP;
 	t->t_bound_cpu = cp;
 	t->t_preempt++;
 
--- old/usr/src/uts/common/os/sched.c	2015-05-08 18:03:07.832479229 -0400
+++ new/usr/src/uts/common/os/sched.c	2015-05-08 18:03:07.839932202 -0400
@@ -54,265 +54,37 @@
 #include <vm/seg_kmem.h>
 #include <sys/callb.h>
 
-/*
- * The swapper sleeps on runout when there is no one to swap in.
- * It sleeps on runin when it could not find space to swap someone
- * in or after swapping someone in.
- */
-char	runout;
-char	runin;
-char	wake_sched;	/* flag tells clock to wake swapper on next tick */
-char	wake_sched_sec;	/* flag tells clock to wake swapper after a second */
-
-/*
- * The swapper swaps processes to reduce memory demand and runs
- * when avefree < desfree.  The swapper resorts to SOFTSWAP when
- * avefree < desfree which results in swapping out all processes
- * sleeping for more than maxslp seconds.  HARDSWAP occurs when the
- * system is on the verge of thrashing and this results in swapping
- * out runnable threads or threads sleeping for less than maxslp secs.
- *
- * The swapper runs through all the active processes in the system
- * and invokes the scheduling class specific swapin/swapout routine
- * for every thread in the process to obtain an effective priority
- * for the process.  A priority of -1 implies that the thread isn't
- * swappable.  This effective priority is used to find the most
- * eligible process to swapout or swapin.
- *
- * NOTE:  Threads which have been swapped are not linked on any
- *	  queue and their dispatcher lock points at the "swapped_lock".
- *
- * Processes containing threads with the TS_DONT_SWAP flag set cannot be
- * swapped out immediately by the swapper.  This is due to the fact that
- * such threads may be holding locks which may be needed by the swapper
- * to push its pages out.  The TS_SWAPENQ flag is set on such threads
- * to prevent them running in user mode.  When such threads reach a
- * safe point (i.e., are not holding any locks - CL_TRAPRET), they
- * queue themseleves onto the swap queue which is processed by the
- * swapper.  This results in reducing memory demand when the system
- * is desparate for memory as the thread can't run in user mode.
- *
- * The swap queue consists of threads, linked via t_link, which are
- * haven't been swapped, are runnable but not on the run queue.  The
- * swap queue is protected by the "swapped_lock".  The dispatcher
- * lock (t_lockp) of all threads on the swap queue points at the
- * "swapped_lock".  Thus, the entire queue and/or threads on the
- * queue can be locked by acquiring "swapped_lock".
- */
-static kthread_t *tswap_queue;
-extern disp_lock_t swapped_lock; /* protects swap queue and threads on it */
-
-int	maxslp = 0;
 pgcnt_t	avefree;	/* 5 sec moving average of free memory */
 pgcnt_t	avefree30;	/* 30 sec moving average of free memory */
 
 /*
- * Minimum size used to decide if sufficient memory is available
- * before a process is swapped in.  This is necessary since in most
- * cases the actual size of a process (p_swrss) being swapped in
- * is usually 2 pages (kernel stack pages).  This is due to the fact
- * almost all user pages of a process are stolen by pageout before
- * the swapper decides to swapout it out.
- */
-int	min_procsize = 12;
-
-static int	swapin(proc_t *);
-static int	swapout(proc_t *, uint_t *, int);
-static void	process_swap_queue();
-
-#ifdef __sparc
-extern void lwp_swapin(kthread_t *);
-#endif /* __sparc */
-
-/*
- * Counters to keep track of the number of swapins or swapouts.
- */
-uint_t tot_swapped_in, tot_swapped_out;
-uint_t softswap, hardswap, swapqswap;
-
-/*
- * Macro to determine if a process is eligble to be swapped.
- */
-#define	not_swappable(p)					\
-	(((p)->p_flag & SSYS) || (p)->p_stat == SIDL ||		\
-	    (p)->p_stat == SZOMB || (p)->p_as == NULL ||	\
-	    (p)->p_as == &kas)
-
-/*
  * Memory scheduler.
  */
 void
 sched()
 {
 	kthread_id_t	t;
-	pri_t		proc_pri;
-	pri_t		thread_pri;
-	pri_t		swapin_pri;
-	int		desperate;
-	pgcnt_t		needs;
-	int		divisor;
-	proc_t		*prp;
-	proc_t		*swapout_prp;
-	proc_t		*swapin_prp;
-	spgcnt_t	avail;
-	int		chosen_pri;
-	time_t		swapout_time;
-	time_t		swapin_proc_time;
 	callb_cpr_t	cprinfo;
 	kmutex_t	swap_cpr_lock;
 
 	mutex_init(&swap_cpr_lock, NULL, MUTEX_DEFAULT, NULL);
 	CALLB_CPR_INIT(&cprinfo, &swap_cpr_lock, callb_generic_cpr, "sched");
-	if (maxslp == 0)
-		maxslp = MAXSLP;
-loop:
-	needs = 0;
-	desperate = 0;
-
-	swapin_pri = v.v_nglobpris;
-	swapin_prp = NULL;
-	chosen_pri = -1;
-
-	process_swap_queue();
-
-	/*
-	 * Set desperate if
-	 * 	1.  At least 2 runnable processes (on average).
-	 *	2.  Short (5 sec) and longer (30 sec) average is less
-	 *	    than minfree and desfree respectively.
-	 *	3.  Pagein + pageout rate is excessive.
-	 */
-	if (avenrun[0] >= 2 * FSCALE &&
-	    (MAX(avefree, avefree30) < desfree) &&
-	    (pginrate + pgoutrate > maxpgio || avefree < minfree)) {
-		TRACE_4(TR_FAC_SCHED, TR_DESPERATE,
-		    "desp:avefree: %d, avefree30: %d, freemem: %d"
-		    " pginrate: %d\n", avefree, avefree30, freemem, pginrate);
-		desperate = 1;
-		goto unload;
-	}
-
-	/*
-	 * Search list of processes to swapin and swapout deadwood.
-	 */
-	swapin_proc_time = 0;
-top:
-	mutex_enter(&pidlock);
-	for (prp = practive; prp != NULL; prp = prp->p_next) {
-		if (not_swappable(prp))
-			continue;
-
-		/*
-		 * Look at processes with at least one swapped lwp.
-		 */
-		if (prp->p_swapcnt) {
-			time_t proc_time;
 
-			/*
-			 * Higher priority processes are good candidates
-			 * to swapin.
-			 */
-			mutex_enter(&prp->p_lock);
-			proc_pri = -1;
-			t = prp->p_tlist;
-			proc_time = 0;
-			do {
-				if (t->t_schedflag & TS_LOAD)
-					continue;
-
-				thread_lock(t);
-				thread_pri = CL_SWAPIN(t, 0);
-				thread_unlock(t);
-
-				if (t->t_stime - proc_time > 0)
-					proc_time = t->t_stime;
-				if (thread_pri > proc_pri)
-					proc_pri = thread_pri;
-			} while ((t = t->t_forw) != prp->p_tlist);
-			mutex_exit(&prp->p_lock);
-
-			if (proc_pri == -1)
-				continue;
-
-			TRACE_3(TR_FAC_SCHED, TR_CHOOSE_SWAPIN,
-			    "prp %p epri %d proc_time %d",
-			    prp, proc_pri, proc_time);
-
-			/*
-			 * Swapin processes with a high effective priority.
-			 */
-			if (swapin_prp == NULL || proc_pri > chosen_pri) {
-				swapin_prp = prp;
-				chosen_pri = proc_pri;
-				swapin_pri = proc_pri;
-				swapin_proc_time = proc_time;
-			}
-		} else {
-			/*
-			 * No need to soft swap if we have sufficient
-			 * memory.
-			 */
-			if (avefree > desfree ||
-			    avefree < desfree && freemem > desfree)
-				continue;
-
-			/*
-			 * Skip processes that are exiting
-			 * or whose address spaces are locked.
-			 */
-			mutex_enter(&prp->p_lock);
-			if ((prp->p_flag & SEXITING) ||
-			    (prp->p_as != NULL && AS_ISPGLCK(prp->p_as))) {
-				mutex_exit(&prp->p_lock);
-				continue;
-			}
-
-			/*
-			 * Softswapping to kick out deadwood.
+	for (;;) {
+		if (avenrun[0] >= 2 * FSCALE &&
+		    (MAX(avefree, avefree30) < desfree) &&
+		    (pginrate + pgoutrate > maxpgio || avefree < minfree)) {
+			/*
+			 * Unload all unloadable modules, free all other memory
+			 * resources we can find, then look for a thread to
+			 * hardswap.
 			 */
-			proc_pri = -1;
-			t = prp->p_tlist;
-			do {
-				if ((t->t_schedflag & (TS_SWAPENQ |
-				    TS_ON_SWAPQ | TS_LOAD)) != TS_LOAD)
-					continue;
-
-				thread_lock(t);
-				thread_pri = CL_SWAPOUT(t, SOFTSWAP);
-				thread_unlock(t);
-				if (thread_pri > proc_pri)
-					proc_pri = thread_pri;
-			} while ((t = t->t_forw) != prp->p_tlist);
-
-			if (proc_pri != -1) {
-				uint_t swrss;
-
-				mutex_exit(&pidlock);
-
-				TRACE_1(TR_FAC_SCHED, TR_SOFTSWAP,
-				    "softswap:prp %p", prp);
-
-				(void) swapout(prp, &swrss, SOFTSWAP);
-				softswap++;
-				prp->p_swrss += swrss;
-				mutex_exit(&prp->p_lock);
-				goto top;
-			}
-			mutex_exit(&prp->p_lock);
+			modreap();
+			segkp_cache_free();
 		}
-	}
-	if (swapin_prp != NULL)
-		mutex_enter(&swapin_prp->p_lock);
-	mutex_exit(&pidlock);
-
-	if (swapin_prp == NULL) {
-		TRACE_3(TR_FAC_SCHED, TR_RUNOUT,
-		"schedrunout:runout nswapped: %d, avefree: %ld freemem: %ld",
-		    nswapped, avefree, freemem);
 
 		t = curthread;
 		thread_lock(t);
-		runout++;
 		t->t_schedflag |= (TS_ALLSTART & ~TS_CSTART);
 		t->t_whystop = PR_SUSPENDED;
 		t->t_whatstop = SUSPEND_NORMAL;
@@ -320,620 +92,10 @@
 		mutex_enter(&swap_cpr_lock);
 		CALLB_CPR_SAFE_BEGIN(&cprinfo);
 		mutex_exit(&swap_cpr_lock);
-		thread_stop(t);		/* change state and drop lock */
+		thread_stop(t);		/* change to stop state and drop lock */
 		swtch();
 		mutex_enter(&swap_cpr_lock);
 		CALLB_CPR_SAFE_END(&cprinfo, &swap_cpr_lock);
 		mutex_exit(&swap_cpr_lock);
-		goto loop;
-	}
-
-	/*
-	 * Decide how deserving this process is to be brought in.
-	 * Needs is an estimate of how much core the process will
-	 * need.  If the process has been out for a while, then we
-	 * will bring it in with 1/2 the core needed, otherwise
-	 * we are conservative.
-	 */
-	divisor = 1;
-	swapout_time = (ddi_get_lbolt() - swapin_proc_time) / hz;
-	if (swapout_time > maxslp / 2)
-		divisor = 2;
-
-	needs = MIN(swapin_prp->p_swrss, lotsfree);
-	needs = MAX(needs, min_procsize);
-	needs = needs / divisor;
-
-	/*
-	 * Use freemem, since we want processes to be swapped
-	 * in quickly.
-	 */
-	avail = freemem - deficit;
-	if (avail > (spgcnt_t)needs) {
-		deficit += needs;
-
-		TRACE_2(TR_FAC_SCHED, TR_SWAPIN_VALUES,
-		    "swapin_values: prp %p needs %lu", swapin_prp, needs);
-
-		if (swapin(swapin_prp)) {
-			mutex_exit(&swapin_prp->p_lock);
-			goto loop;
-		}
-		deficit -= MIN(needs, deficit);
-		mutex_exit(&swapin_prp->p_lock);
-	} else {
-		mutex_exit(&swapin_prp->p_lock);
-		/*
-		 * If deficit is high, too many processes have been
-		 * swapped in so wait a sec before attempting to
-		 * swapin more.
-		 */
-		if (freemem > needs) {
-			TRACE_2(TR_FAC_SCHED, TR_HIGH_DEFICIT,
-			    "deficit: prp %p needs %lu", swapin_prp, needs);
-			goto block;
-		}
-	}
-
-	TRACE_2(TR_FAC_SCHED, TR_UNLOAD,
-	    "unload: prp %p needs %lu", swapin_prp, needs);
-
-unload:
-	/*
-	 * Unload all unloadable modules, free all other memory
-	 * resources we can find, then look for a thread to hardswap.
-	 */
-	modreap();
-	segkp_cache_free();
-
-	swapout_prp = NULL;
-	mutex_enter(&pidlock);
-	for (prp = practive; prp != NULL; prp = prp->p_next) {
-
-		/*
-		 * No need to soft swap if we have sufficient
-		 * memory.
-		 */
-		if (not_swappable(prp))
-			continue;
-
-		if (avefree > minfree ||
-		    avefree < minfree && freemem > desfree) {
-			swapout_prp = NULL;
-			break;
-		}
-
-		/*
-		 * Skip processes that are exiting
-		 * or whose address spaces are locked.
-		 */
-		mutex_enter(&prp->p_lock);
-		if ((prp->p_flag & SEXITING) ||
-		    (prp->p_as != NULL && AS_ISPGLCK(prp->p_as))) {
-			mutex_exit(&prp->p_lock);
-			continue;
-		}
-
-		proc_pri = -1;
-		t = prp->p_tlist;
-		do {
-			if ((t->t_schedflag & (TS_SWAPENQ |
-			    TS_ON_SWAPQ | TS_LOAD)) != TS_LOAD)
-				continue;
-
-			thread_lock(t);
-			thread_pri = CL_SWAPOUT(t, HARDSWAP);
-			thread_unlock(t);
-			if (thread_pri > proc_pri)
-				proc_pri = thread_pri;
-		} while ((t = t->t_forw) != prp->p_tlist);
-
-		mutex_exit(&prp->p_lock);
-		if (proc_pri == -1)
-			continue;
-
-		/*
-		 * Swapout processes sleeping with a lower priority
-		 * than the one currently being swapped in, if any.
-		 */
-		if (swapin_prp == NULL || swapin_pri > proc_pri) {
-			TRACE_2(TR_FAC_SCHED, TR_CHOOSE_SWAPOUT,
-			    "hardswap: prp %p needs %lu", prp, needs);
-
-			if (swapout_prp == NULL || proc_pri < chosen_pri) {
-				swapout_prp = prp;
-				chosen_pri = proc_pri;
-			}
-		}
-	}
-
-	/*
-	 * Acquire the "p_lock" before dropping "pidlock"
-	 * to prevent the proc structure from being freed
-	 * if the process exits before swapout completes.
-	 */
-	if (swapout_prp != NULL)
-		mutex_enter(&swapout_prp->p_lock);
-	mutex_exit(&pidlock);
-
-	if ((prp = swapout_prp) != NULL) {
-		uint_t swrss = 0;
-		int swapped;
-
-		swapped = swapout(prp, &swrss, HARDSWAP);
-		if (swapped) {
-			/*
-			 * If desperate, we want to give the space obtained
-			 * by swapping this process out to processes in core,
-			 * so we give them a chance by increasing deficit.
-			 */
-			prp->p_swrss += swrss;
-			if (desperate)
-				deficit += MIN(prp->p_swrss, lotsfree);
-			hardswap++;
-		}
-		mutex_exit(&swapout_prp->p_lock);
-
-		if (swapped)
-			goto loop;
-	}
-
-	/*
-	 * Delay for 1 second and look again later.
-	 */
-	TRACE_3(TR_FAC_SCHED, TR_RUNIN,
-	    "schedrunin:runin nswapped: %d, avefree: %ld freemem: %ld",
-	    nswapped, avefree, freemem);
-
-block:
-	t = curthread;
-	thread_lock(t);
-	runin++;
-	t->t_schedflag |= (TS_ALLSTART & ~TS_CSTART);
-	t->t_whystop = PR_SUSPENDED;
-	t->t_whatstop = SUSPEND_NORMAL;
-	(void) new_mstate(t, LMS_SLEEP);
-	mutex_enter(&swap_cpr_lock);
-	CALLB_CPR_SAFE_BEGIN(&cprinfo);
-	mutex_exit(&swap_cpr_lock);
-	thread_stop(t);		/* change to stop state and drop lock */
-	swtch();
-	mutex_enter(&swap_cpr_lock);
-	CALLB_CPR_SAFE_END(&cprinfo, &swap_cpr_lock);
-	mutex_exit(&swap_cpr_lock);
-	goto loop;
-}
-
-/*
- * Remove the specified thread from the swap queue.
- */
-static void
-swapdeq(kthread_id_t tp)
-{
-	kthread_id_t *tpp;
-
-	ASSERT(THREAD_LOCK_HELD(tp));
-	ASSERT(tp->t_schedflag & TS_ON_SWAPQ);
-
-	tpp = &tswap_queue;
-	for (;;) {
-		ASSERT(*tpp != NULL);
-		if (*tpp == tp)
-			break;
-		tpp = &(*tpp)->t_link;
-	}
-	*tpp = tp->t_link;
-	tp->t_schedflag &= ~TS_ON_SWAPQ;
-}
-
-/*
- * Swap in lwps.  Returns nonzero on success (i.e., if at least one lwp is
- * swapped in) and 0 on failure.
- */
-static int
-swapin(proc_t *pp)
-{
-	kthread_id_t tp;
-	int err;
-	int num_swapped_in = 0;
-	struct cpu *cpup = CPU;
-	pri_t thread_pri;
-
-	ASSERT(MUTEX_HELD(&pp->p_lock));
-	ASSERT(pp->p_swapcnt);
-
-top:
-	tp = pp->p_tlist;
-	do {
-		/*
-		 * Only swapin eligible lwps (specified by the scheduling
-		 * class) which are unloaded and ready to run.
-		 */
-		thread_lock(tp);
-		thread_pri = CL_SWAPIN(tp, 0);
-		if (thread_pri != -1 && tp->t_state == TS_RUN &&
-		    (tp->t_schedflag & TS_LOAD) == 0) {
-			size_t stack_size;
-			pgcnt_t stack_pages;
-
-			ASSERT((tp->t_schedflag & TS_ON_SWAPQ) == 0);
-
-			thread_unlock(tp);
-			/*
-			 * Now drop the p_lock since the stack needs
-			 * to brought in.
-			 */
-			mutex_exit(&pp->p_lock);
-
-			stack_size = swapsize(tp->t_swap);
-			stack_pages = btopr(stack_size);
-			/* Kernel probe */
-			TNF_PROBE_4(swapin_lwp, "vm swap swapin", /* CSTYLED */,
-			    tnf_pid,		pid,		pp->p_pid,
-			    tnf_lwpid,		lwpid,		tp->t_tid,
-			    tnf_kthread_id,	tid,		tp,
-			    tnf_ulong,		page_count,	stack_pages);
-
-			rw_enter(&kas.a_lock, RW_READER);
-			err = segkp_fault(segkp->s_as->a_hat, segkp,
-			    tp->t_swap, stack_size, F_SOFTLOCK, S_OTHER);
-			rw_exit(&kas.a_lock);
-
-			/*
-			 * Re-acquire the p_lock.
-			 */
-			mutex_enter(&pp->p_lock);
-			if (err) {
-				num_swapped_in = 0;
-				break;
-			} else {
-#ifdef __sparc
-				lwp_swapin(tp);
-#endif /* __sparc */
-				CPU_STATS_ADDQ(cpup, vm, swapin, 1);
-				CPU_STATS_ADDQ(cpup, vm, pgswapin,
-				    stack_pages);
-
-				pp->p_swapcnt--;
-				pp->p_swrss -= stack_pages;
-
-				thread_lock(tp);
-				tp->t_schedflag |= TS_LOAD;
-				dq_sruninc(tp);
-
-				/* set swapin time */
-				tp->t_stime = ddi_get_lbolt();
-				thread_unlock(tp);
-
-				nswapped--;
-				tot_swapped_in++;
-				num_swapped_in++;
-
-				TRACE_2(TR_FAC_SCHED, TR_SWAPIN,
-				    "swapin: pp %p stack_pages %lu",
-				    pp, stack_pages);
-				goto top;
-			}
-		}
-		thread_unlock(tp);
-	} while ((tp = tp->t_forw) != pp->p_tlist);
-	return (num_swapped_in);
-}
-
-/*
- * Swap out lwps.  Returns nonzero on success (i.e., if at least one lwp is
- * swapped out) and 0 on failure.
- */
-static int
-swapout(proc_t *pp, uint_t *swrss, int swapflags)
-{
-	kthread_id_t tp;
-	pgcnt_t ws_pages = 0;
-	int err;
-	int swapped_lwps = 0;
-	struct as *as = pp->p_as;
-	struct cpu *cpup = CPU;
-	pri_t thread_pri;
-
-	ASSERT(MUTEX_HELD(&pp->p_lock));
-
-	if (pp->p_flag & SEXITING)
-		return (0);
-
-top:
-	tp = pp->p_tlist;
-	do {
-		klwp_t *lwp = ttolwp(tp);
-
-		/*
-		 * Swapout eligible lwps (specified by the scheduling
-		 * class) which don't have TS_DONT_SWAP set.  Set the
-		 * "intent to swap" flag (TS_SWAPENQ) on threads
-		 * which have TS_DONT_SWAP set so that they can be
-		 * swapped if and when they reach a safe point.
-		 */
-		thread_lock(tp);
-		thread_pri = CL_SWAPOUT(tp, swapflags);
-		if (thread_pri != -1) {
-			if (tp->t_schedflag & TS_DONT_SWAP) {
-				tp->t_schedflag |= TS_SWAPENQ;
-				tp->t_trapret = 1;
-				aston(tp);
-			} else {
-				pgcnt_t stack_pages;
-				size_t stack_size;
-
-				ASSERT((tp->t_schedflag &
-				    (TS_DONT_SWAP | TS_LOAD)) == TS_LOAD);
-
-				if (lock_try(&tp->t_lock)) {
-					/*
-					 * Remove thread from the swap_queue.
-					 */
-					if (tp->t_schedflag & TS_ON_SWAPQ) {
-						ASSERT(!(tp->t_schedflag &
-						    TS_SWAPENQ));
-						swapdeq(tp);
-					} else if (tp->t_state == TS_RUN)
-						dq_srundec(tp);
-
-					tp->t_schedflag &=
-					    ~(TS_LOAD | TS_SWAPENQ);
-					lock_clear(&tp->t_lock);
-
-					/*
-					 * Set swapout time if the thread isn't
-					 * sleeping.
-					 */
-					if (tp->t_state != TS_SLEEP)
-						tp->t_stime = ddi_get_lbolt();
-					thread_unlock(tp);
-
-					nswapped++;
-					tot_swapped_out++;
-
-					lwp->lwp_ru.nswap++;
-
-					/*
-					 * Now drop the p_lock since the
-					 * stack needs to pushed out.
-					 */
-					mutex_exit(&pp->p_lock);
-
-					stack_size = swapsize(tp->t_swap);
-					stack_pages = btopr(stack_size);
-					ws_pages += stack_pages;
-					/* Kernel probe */
-					TNF_PROBE_4(swapout_lwp,
-					    "vm swap swapout",
-					    /* CSTYLED */,
-					    tnf_pid, pid, pp->p_pid,
-					    tnf_lwpid, lwpid, tp->t_tid,
-					    tnf_kthread_id, tid, tp,
-					    tnf_ulong, page_count,
-					    stack_pages);
-
-					rw_enter(&kas.a_lock, RW_READER);
-					err = segkp_fault(segkp->s_as->a_hat,
-					    segkp, tp->t_swap, stack_size,
-					    F_SOFTUNLOCK, S_WRITE);
-					rw_exit(&kas.a_lock);
-
-					if (err) {
-						cmn_err(CE_PANIC,
-						    "swapout: segkp_fault "
-						    "failed err: %d", err);
-					}
-					CPU_STATS_ADDQ(cpup,
-					    vm, pgswapout, stack_pages);
-
-					mutex_enter(&pp->p_lock);
-					pp->p_swapcnt++;
-					swapped_lwps++;
-					goto top;
-				}
-			}
-		}
-		thread_unlock(tp);
-	} while ((tp = tp->t_forw) != pp->p_tlist);
-
-	/*
-	 * Unload address space when all lwps are swapped out.
-	 */
-	if (pp->p_swapcnt == pp->p_lwpcnt) {
-		size_t as_size = 0;
-
-		/*
-		 * Avoid invoking as_swapout() if the process has
-		 * no MMU resources since pageout will eventually
-		 * steal pages belonging to this address space.  This
-		 * saves CPU cycles as the number of pages that are
-		 * potentially freed or pushed out by the segment
-		 * swapout operation is very small.
-		 */
-		if (rm_asrss(pp->p_as) != 0)
-			as_size = as_swapout(as);
-
-		CPU_STATS_ADDQ(cpup, vm, pgswapout, btop(as_size));
-		CPU_STATS_ADDQ(cpup, vm, swapout, 1);
-		ws_pages += btop(as_size);
-
-		TRACE_2(TR_FAC_SCHED, TR_SWAPOUT,
-		    "swapout: pp %p pages_pushed %lu", pp, ws_pages);
-		/* Kernel probe */
-		TNF_PROBE_2(swapout_process, "vm swap swapout", /* CSTYLED */,
-		    tnf_pid,	pid,		pp->p_pid,
-		    tnf_ulong,	page_count,	ws_pages);
-	}
-	*swrss = ws_pages;
-	return (swapped_lwps);
-}
-
-void
-swapout_lwp(klwp_t *lwp)
-{
-	kthread_id_t tp = curthread;
-
-	ASSERT(curthread == lwptot(lwp));
-
-	/*
-	 * Don't insert the thread onto the swap queue if
-	 * sufficient memory is available.
-	 */
-	if (avefree > desfree || avefree < desfree && freemem > desfree) {
-		thread_lock(tp);
-		tp->t_schedflag &= ~TS_SWAPENQ;
-		thread_unlock(tp);
-		return;
-	}
-
-	/*
-	 * Lock the thread, then move it to the swapped queue from the
-	 * onproc queue and set its state to be TS_RUN.
-	 */
-	thread_lock(tp);
-	ASSERT(tp->t_state == TS_ONPROC);
-	if (tp->t_schedflag & TS_SWAPENQ) {
-		tp->t_schedflag &= ~TS_SWAPENQ;
-
-		/*
-		 * Set the state of this thread to be runnable
-		 * and move it from the onproc queue to the swap queue.
-		 */
-		disp_swapped_enq(tp);
-
-		/*
-		 * Insert the thread onto the swap queue.
-		 */
-		tp->t_link = tswap_queue;
-		tswap_queue = tp;
-		tp->t_schedflag |= TS_ON_SWAPQ;
-
-		thread_unlock_nopreempt(tp);
-
-		TRACE_1(TR_FAC_SCHED, TR_SWAPOUT_LWP, "swapout_lwp:%x", lwp);
-
-		swtch();
-	} else {
-		thread_unlock(tp);
-	}
-}
-
-/*
- * Swap all threads on the swap queue.
- */
-static void
-process_swap_queue(void)
-{
-	kthread_id_t tp;
-	uint_t ws_pages;
-	proc_t *pp;
-	struct cpu *cpup = CPU;
-	klwp_t *lwp;
-	int err;
-
-	if (tswap_queue == NULL)
-		return;
-
-	/*
-	 * Acquire the "swapped_lock" which locks the swap queue,
-	 * and unload the stacks of all threads on it.
-	 */
-	disp_lock_enter(&swapped_lock);
-	while ((tp = tswap_queue) != NULL) {
-		pgcnt_t stack_pages;
-		size_t stack_size;
-
-		tswap_queue = tp->t_link;
-		tp->t_link = NULL;
-
-		/*
-		 * Drop the "dispatcher lock" before acquiring "t_lock"
-		 * to avoid spinning on it since the thread at the front
-		 * of the swap queue could be pinned before giving up
-		 * its "t_lock" in resume.
-		 */
-		disp_lock_exit(&swapped_lock);
-		lock_set(&tp->t_lock);
-
-		/*
-		 * Now, re-acquire the "swapped_lock".  Acquiring this lock
-		 * results in locking the thread since its dispatcher lock
-		 * (t_lockp) is the "swapped_lock".
-		 */
-		disp_lock_enter(&swapped_lock);
-		ASSERT(tp->t_state == TS_RUN);
-		ASSERT(tp->t_schedflag & (TS_LOAD | TS_ON_SWAPQ));
-
-		tp->t_schedflag &= ~(TS_LOAD | TS_ON_SWAPQ);
-		tp->t_stime = ddi_get_lbolt();		/* swapout time */
-		disp_lock_exit(&swapped_lock);
-		lock_clear(&tp->t_lock);
-
-		lwp = ttolwp(tp);
-		lwp->lwp_ru.nswap++;
-
-		pp = ttoproc(tp);
-		stack_size = swapsize(tp->t_swap);
-		stack_pages = btopr(stack_size);
-
-		/* Kernel probe */
-		TNF_PROBE_4(swapout_lwp, "vm swap swapout", /* CSTYLED */,
-		    tnf_pid,		pid,		pp->p_pid,
-		    tnf_lwpid,		lwpid,		tp->t_tid,
-		    tnf_kthread_id,	tid,		tp,
-		    tnf_ulong,		page_count,	stack_pages);
-
-		rw_enter(&kas.a_lock, RW_READER);
-		err = segkp_fault(segkp->s_as->a_hat, segkp, tp->t_swap,
-		    stack_size, F_SOFTUNLOCK, S_WRITE);
-		rw_exit(&kas.a_lock);
-
-		if (err) {
-			cmn_err(CE_PANIC,
-			"process_swap_list: segkp_fault failed err: %d", err);
-		}
-		CPU_STATS_ADDQ(cpup, vm, pgswapout, stack_pages);
-
-		nswapped++;
-		tot_swapped_out++;
-		swapqswap++;
-
-		/*
-		 * Don't need p_lock since the swapper is the only
-		 * thread which increments/decrements p_swapcnt and p_swrss.
-		 */
-		ws_pages = stack_pages;
-		pp->p_swapcnt++;
-
-		TRACE_1(TR_FAC_SCHED, TR_SWAPQ_LWP, "swaplist: pp %p", pp);
-
-		/*
-		 * Unload address space when all lwps are swapped out.
-		 */
-		if (pp->p_swapcnt == pp->p_lwpcnt) {
-			size_t as_size = 0;
-
-			if (rm_asrss(pp->p_as) != 0)
-				as_size = as_swapout(pp->p_as);
-
-			CPU_STATS_ADDQ(cpup, vm, pgswapout,
-			    btop(as_size));
-			CPU_STATS_ADDQ(cpup, vm, swapout, 1);
-
-			ws_pages += btop(as_size);
-
-			TRACE_2(TR_FAC_SCHED, TR_SWAPQ_PROC,
-			    "swaplist_proc: pp %p pages_pushed: %lu",
-			    pp, ws_pages);
-			/* Kernel probe */
-			TNF_PROBE_2(swapout_process, "vm swap swapout",
-			    /* CSTYLED */,
-			    tnf_pid,	pid,		pp->p_pid,
-			    tnf_ulong,	page_count,	ws_pages);
-		}
-		pp->p_swrss += ws_pages;
-		disp_lock_enter(&swapped_lock);
 	}
-	disp_lock_exit(&swapped_lock);
 }
--- old/usr/src/uts/common/os/timers.c	2015-05-08 18:03:08.072258817 -0400
+++ new/usr/src/uts/common/os/timers.c	2015-05-08 18:03:08.079598112 -0400
@@ -654,13 +654,6 @@
 		thread_lock(t);
 		switch (t->t_state) {
 		case TS_SLEEP:
-			/*
-			 * Don't touch the lwp is it is swapped out.
-			 */
-			if (!(t->t_schedflag & TS_LOAD)) {
-				mstate = LMS_SLEEP;
-				break;
-			}
 			switch (mstate = ttolwp(t)->lwp_mstate.ms_prev) {
 			case LMS_TFAULT:
 			case LMS_DFAULT:
--- old/usr/src/uts/common/os/waitq.c	2015-05-08 18:03:08.325035710 -0400
+++ new/usr/src/uts/common/os/waitq.c	2015-05-08 18:03:08.332423985 -0400
@@ -223,11 +223,6 @@
 	 */
 	t->t_waitrq = gethrtime_unscaled();
 
-	/*
-	 * Mark thread as not swappable.  If necessary, it will get
-	 * swapped out when it returns to the userland.
-	 */
-	t->t_schedflag |= TS_DONT_SWAP;
 	DTRACE_SCHED1(cpucaps__sleep, kthread_t *, t);
 	waitq_link(wq, t);
 
--- old/usr/src/uts/common/sys/class.h	2015-05-08 18:03:08.535788194 -0400
+++ new/usr/src/uts/common/sys/class.h	2015-05-08 18:03:08.543130125 -0400
@@ -81,8 +81,6 @@
 	void	(*cl_exit)(kthread_t *);
 	void	(*cl_active)(kthread_t *);
 	void	(*cl_inactive)(kthread_t *);
-	pri_t	(*cl_swapin)(kthread_t *, int);
-	pri_t 	(*cl_swapout)(kthread_t *, int);
 	void 	(*cl_trapret)(kthread_t *);
 	void	(*cl_preempt)(kthread_t *);
 	void	(*cl_setrun)(kthread_t *);
@@ -196,10 +194,6 @@
 
 #define	CL_INACTIVE(t)		(*(t)->t_clfuncs->cl_inactive)(t)
 
-#define	CL_SWAPIN(t, flags)	(*(t)->t_clfuncs->cl_swapin)(t, flags)
-
-#define	CL_SWAPOUT(t, flags)	(*(t)->t_clfuncs->cl_swapout)(t, flags)
-
 #define	CL_TICK(t)		(*(t)->t_clfuncs->cl_tick)(t)
 
 #define	CL_TRAPRET(t)		(*(t)->t_clfuncs->cl_trapret)(t)
--- old/usr/src/uts/common/sys/disp.h	2015-05-08 18:03:08.742218794 -0400
+++ new/usr/src/uts/common/sys/disp.h	2015-05-08 18:03:08.749647481 -0400
@@ -30,8 +30,6 @@
 #ifndef _SYS_DISP_H
 #define	_SYS_DISP_H
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.11	*/
-
 #include <sys/priocntl.h>
 #include <sys/thread.h>
 #include <sys/class.h>
@@ -143,8 +141,6 @@
 extern void		swtch_to(kthread_t *);
 extern void		swtch_from_zombie(void)
 				__NORETURN;
-extern void		dq_sruninc(kthread_t *);
-extern void		dq_srundec(kthread_t *);
 extern void		cpu_rechoose(kthread_t *);
 extern void		cpu_surrender(kthread_t *);
 extern void		kpreempt(int);
--- old/usr/src/uts/common/sys/proc.h	2015-05-08 18:03:08.949905229 -0400
+++ new/usr/src/uts/common/sys/proc.h	2015-05-08 18:03:08.957275124 -0400
@@ -129,10 +129,8 @@
 struct corectl_content;
 
 /*
- * One structure allocated per active process.  It contains all
- * data needed about the process while the process may be swapped
- * out.  Other per-process data (user.h) is also inside the proc structure.
- * Lightweight-process data (lwp.h) and the kernel stack may be swapped out.
+ * One structure allocated per active process.  Per-process data (user.h) is
+ * also inside the proc structure.
  */
 typedef struct	proc {
 	/*
@@ -146,7 +144,6 @@
 	/*
 	 * Fields protected by pidlock
 	 */
-	int	p_swapcnt;		/* number of swapped out lwps */
 	char	p_stat;			/* status of process */
 	char	p_wcode;		/* current wait code */
 	ushort_t p_pidflag;		/* flags protected only by pidlock */
--- old/usr/src/uts/common/sys/sysinfo.h	2015-05-08 18:03:09.181049718 -0400
+++ new/usr/src/uts/common/sys/sysinfo.h	2015-05-08 18:03:09.188328228 -0400
@@ -252,10 +252,6 @@
 	uint64_t pgpgin;		/* pages paged in */
 	uint64_t pgout;			/* pageouts */
 	uint64_t pgpgout;		/* pages paged out */
-	uint64_t swapin;		/* swapins */
-	uint64_t pgswapin;		/* pages swapped in */
-	uint64_t swapout;		/* swapouts */
-	uint64_t pgswapout;		/* pages swapped out */
 	uint64_t zfod;			/* pages zero filled on demand */
 	uint64_t dfree;			/* pages freed by daemon or auto */
 	uint64_t scan;			/* pages examined by pageout daemon */
--- old/usr/src/uts/common/sys/systm.h	2015-05-08 18:03:09.393614918 -0400
+++ new/usr/src/uts/common/sys/systm.h	2015-05-08 18:03:09.400928232 -0400
@@ -63,11 +63,6 @@
 extern struct vnode *devicesdir;	/* pointer to /devices vnode */
 extern int interrupts_unleashed;	/* set after the spl0() in main() */
 
-extern char runin;		/* scheduling flag */
-extern char runout;		/* scheduling flag */
-extern char wake_sched;		/* causes clock to wake swapper on next tick */
-extern char wake_sched_sec;	/* causes clock to wake swapper after a sec */
-
 extern pgcnt_t	maxmem;		/* max available memory (pages) */
 extern pgcnt_t	physmem;	/* physical memory (pages) on this CPU */
 extern pfn_t	physmax;	/* highest numbered physical page present */
--- old/usr/src/uts/common/sys/thread.h	2015-05-08 18:03:09.609575285 -0400
+++ new/usr/src/uts/common/sys/thread.h	2015-05-08 18:03:09.616988693 -0400
@@ -155,9 +155,6 @@
 	struct _kcpc_ctx *t_cpc_ctx;	/* performance counter context */
 	struct _kcpc_set *t_cpc_set;	/* set this thread has bound */
 
-	/*
-	 * non swappable part of the lwp state.
-	 */
 	id_t		t_tid;		/* lwp's id */
 	id_t		t_waitfor;	/* target lwp id in lwp_wait() */
 	struct sigqueue	*t_sigqueue;	/* queue of siginfo structs */
@@ -268,7 +265,6 @@
 		void		  **ts_value;	/* array of value/key */
 	} *t_tsd;
 
-	clock_t		t_stime;	/* time stamp used by the swapper */
 	struct door_data *t_door;	/* door invocation data */
 	kmutex_t	*t_plockp;	/* pointer to process's p_lock */
 
@@ -399,10 +395,6 @@
  * Thread scheduler flag (t_schedflag) definitions.
  *	The thread must be locked via thread_lock() or equiv. to change these.
  */
-#define	TS_LOAD		0x0001	/* thread is in memory */
-#define	TS_DONT_SWAP	0x0002	/* thread/lwp should not be swapped */
-#define	TS_SWAPENQ	0x0004	/* swap thread when it reaches a safe point */
-#define	TS_ON_SWAPQ	0x0008	/* thread is on the swap queue */
 #define	TS_SIGNALLED	0x0010	/* thread was awakened by cv_signal() */
 #define	TS_PROJWAITQ	0x0020	/* thread is on its project's waitq */
 #define	TS_ZONEWAITQ	0x0040	/* thread is on its zone's waitq */
@@ -480,12 +472,6 @@
 #define	ASSIGNED_PRIO(t)	((t)->t_pri)
 
 /*
- * Macros to determine whether a thread can be swapped.
- * If t_lock is held, the thread is either on a processor or being swapped.
- */
-#define	SWAP_OK(t)	(!LOCK_HELD(&(t)->t_lock))
-
-/*
  * proctot(x)
  *	convert a proc pointer to a thread pointer. this only works with
  *	procs that have only one lwp.
@@ -653,12 +639,6 @@
 #define	THREAD_WAIT(tp, lp)	THREAD_SET_STATE(tp, TS_WAIT, lp)
 
 /*
- * Put thread in run state, and set the lock pointer to the dispatcher queue
- * lock pointer provided (i.e., the "swapped_lock").  This lock should be held.
- */
-#define	THREAD_SWAP(tp, lp)	THREAD_SET_STATE(tp, TS_RUN, lp)
-
-/*
  * Put the thread in zombie state and set the lock pointer to NULL.
  * The NULL will catch anything that tries to lock a zombie.
  */
--- old/usr/src/uts/common/sys/vmsystm.h	2015-05-08 18:03:09.836251880 -0400
+++ new/usr/src/uts/common/sys/vmsystm.h	2015-05-08 18:03:09.843447290 -0400
@@ -121,10 +121,8 @@
 struct page;
 struct anon;
 
-extern int maxslp;
 extern ulong_t pginrate;
 extern ulong_t pgoutrate;
-extern void swapout_lwp(klwp_t *);
 
 extern	int valid_va_range(caddr_t *basep, size_t *lenp, size_t minlen,
 		int dir);
--- old/usr/src/uts/common/vm/anon.h	2015-05-08 18:03:10.048053781 -0400
+++ new/usr/src/uts/common/vm/anon.h	2015-05-08 18:03:10.055429729 -0400
@@ -439,8 +439,6 @@
 extern pgcnt_t	anon_grow(struct anon_hdr *, ulong_t *, pgcnt_t, pgcnt_t, int);
 extern void	anon_array_enter(struct anon_map *, ulong_t,
 			anon_sync_obj_t *);
-extern int	anon_array_try_enter(struct anon_map *, ulong_t,
-			anon_sync_obj_t *);
 extern void	anon_array_exit(anon_sync_obj_t *);
 
 /*
--- old/usr/src/uts/common/vm/as.h	2015-05-08 18:03:10.266805551 -0400
+++ new/usr/src/uts/common/vm/as.h	2015-05-08 18:03:10.274151438 -0400
@@ -283,7 +283,6 @@
 	    size_t redzone, size_t off);
 
 int	as_memory(struct as *as, caddr_t *basep, size_t *lenp);
-size_t	as_swapout(struct as *as);
 int	as_incore(struct as *as, caddr_t addr, size_t size, char *vec,
 		size_t *sizep);
 int	as_ctl(struct as *as, caddr_t addr, size_t size, int func, int attr,
--- old/usr/src/uts/common/vm/hat.h	2015-05-08 18:03:10.476678815 -0400
+++ new/usr/src/uts/common/vm/hat.h	2015-05-08 18:03:10.484011940 -0400
@@ -106,12 +106,6 @@
  *	informs hat layer as is being destroyed.  hat layer cannot use as
  *	pointer after this call.
  *
- * void hat_swapin(hat)
- *	allocate any hat resources required for process being swapped in.
- *
- * void hat_swapout(hat)
- *	deallocate hat resources for process being swapped out.
- *
  * size_t hat_get_mapped_size(hat)
  *	returns number of bytes that have valid mappings in hat.
  *
@@ -133,8 +127,6 @@
 void	hat_free_start(struct hat *);
 void	hat_free_end(struct hat *);
 int	hat_dup(struct hat *, struct hat *, caddr_t, size_t, uint_t);
-void	hat_swapin(struct hat *);
-void	hat_swapout(struct hat *);
 size_t	hat_get_mapped_size(struct hat *);
 int	hat_stats_enable(struct hat *);
 void	hat_stats_disable(struct hat *);
--- old/usr/src/uts/common/vm/seg.h	2015-05-08 18:03:10.695701074 -0400
+++ new/usr/src/uts/common/vm/seg.h	2015-05-08 18:03:10.702992319 -0400
@@ -124,7 +124,6 @@
 	int	(*setprot)(struct seg *, caddr_t, size_t, uint_t);
 	int	(*checkprot)(struct seg *, caddr_t, size_t, uint_t);
 	int	(*kluster)(struct seg *, caddr_t, ssize_t);
-	size_t	(*swapout)(struct seg *);
 	int	(*sync)(struct seg *, caddr_t, size_t, int, uint_t);
 	size_t	(*incore)(struct seg *, caddr_t, size_t, char *);
 	int	(*lockop)(struct seg *, caddr_t, size_t, int, int, ulong_t *,
@@ -219,7 +218,6 @@
 #define	SEGOP_SETPROT(s, a, l, p)   (*(s)->s_ops->setprot)((s), (a), (l), (p))
 #define	SEGOP_CHECKPROT(s, a, l, p) (*(s)->s_ops->checkprot)((s), (a), (l), (p))
 #define	SEGOP_KLUSTER(s, a, d)	    (*(s)->s_ops->kluster)((s), (a), (d))
-#define	SEGOP_SWAPOUT(s)	    (*(s)->s_ops->swapout)((s))
 #define	SEGOP_SYNC(s, a, l, atr, f) \
 		(*(s)->s_ops->sync)((s), (a), (l), (atr), (f))
 #define	SEGOP_INCORE(s, a, l, v)    (*(s)->s_ops->incore)((s), (a), (l), (v))
--- old/usr/src/uts/common/vm/seg_dev.c	2015-05-08 18:03:10.905587708 -0400
+++ new/usr/src/uts/common/vm/seg_dev.c	2015-05-08 18:03:10.913180796 -0400
@@ -200,7 +200,6 @@
 	segdev_setprot,
 	segdev_checkprot,
 	(int (*)())segdev_badop,	/* kluster */
-	(size_t (*)(struct seg *))NULL,	/* swapout */
 	segdev_sync,			/* sync */
 	segdev_incore,
 	segdev_lockop,			/* lockop */
--- old/usr/src/uts/common/vm/seg_kmem.c	2015-05-08 18:03:11.259098622 -0400
+++ new/usr/src/uts/common/vm/seg_kmem.c	2015-05-08 18:03:11.266447652 -0400
@@ -782,7 +782,6 @@
 	segkmem_setprot,
 	segkmem_checkprot,
 	segkmem_kluster,
-	SEGKMEM_BADOP(size_t),		/* swapout */
 	SEGKMEM_BADOP(int),		/* sync */
 	SEGKMEM_BADOP(size_t),		/* incore */
 	SEGKMEM_BADOP(int),		/* lockop */
--- old/usr/src/uts/common/vm/seg_kp.c	2015-05-08 18:03:11.510030184 -0400
+++ new/usr/src/uts/common/vm/seg_kp.c	2015-05-08 18:03:11.517414202 -0400
@@ -154,7 +154,6 @@
 	SEGKP_BADOP(int),		/* setprot */
 	segkp_checkprot,
 	segkp_kluster,
-	SEGKP_BADOP(size_t),		/* swapout */
 	SEGKP_BADOP(int),		/* sync */
 	SEGKP_BADOP(size_t),		/* incore */
 	SEGKP_BADOP(int),		/* lockop */
@@ -760,15 +759,11 @@
  * stack base.  If the amount of stack remaining is questionable
  * (less than red_minavail), then segkp_map_red() will map in the redzone
  * and return 1.  Otherwise, it will return 0.  segkp_map_red() can
- * _only_ be called when:
- *
- *   - it is safe to sleep on page_create_va().
- *   - the caller is non-swappable.
+ * _only_ be called when it is safe to sleep on page_create_va().
  *
  * It is up to the caller to remember whether segkp_map_red() successfully
  * mapped the redzone, and, if so, to call segkp_unmap_red() at a later
- * time.  Note that the caller must _remain_ non-swappable until after
- * calling segkp_unmap_red().
+ * time.
  *
  * Currently, this routine is only called from pagefault() (which necessarily
  * satisfies the above conditions).
@@ -782,8 +777,6 @@
 	caddr_t stkbase;
 #endif
 
-	ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
-
 	/*
 	 * Optimize for the common case where we simply return.
 	 */
@@ -884,7 +877,6 @@
 	    (uintptr_t)PAGEMASK) - PAGESIZE);
 
 	ASSERT(curthread->t_red_pp != NULL);
-	ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
 
 	/*
 	 * Because we locked the mapping down, we can't simply rely
--- old/usr/src/uts/common/vm/seg_kpm.c	2015-05-08 18:03:11.762607389 -0400
+++ new/usr/src/uts/common/vm/seg_kpm.c	2015-05-08 18:03:11.769780618 -0400
@@ -119,7 +119,6 @@
 	SEGKPM_BADOP(int),	/* setprot */
 	SEGKPM_BADOP(int),	/* checkprot */
 	SEGKPM_BADOP(int),	/* kluster */
-	SEGKPM_BADOP(size_t),	/* swapout */
 	SEGKPM_BADOP(int),	/* sync */
 	SEGKPM_BADOP(size_t),	/* incore */
 	SEGKPM_BADOP(int),	/* lockop */
--- old/usr/src/uts/common/vm/seg_map.c	2015-05-08 18:03:11.974843234 -0400
+++ new/usr/src/uts/common/vm/seg_map.c	2015-05-08 18:03:11.982209927 -0400
@@ -109,7 +109,6 @@
 	SEGMAP_BADOP(int),	/* setprot */
 	segmap_checkprot,
 	segmap_kluster,
-	SEGMAP_BADOP(size_t),	/* swapout */
 	SEGMAP_BADOP(int),	/* sync */
 	SEGMAP_BADOP(size_t),	/* incore */
 	SEGMAP_BADOP(int),	/* lockop */
--- old/usr/src/uts/common/vm/seg_spt.c	2015-05-08 18:03:12.259414194 -0400
+++ new/usr/src/uts/common/vm/seg_spt.c	2015-05-08 18:03:12.266988890 -0400
@@ -94,7 +94,6 @@
 	SEGSPT_BADOP(int),		/* setprot */
 	SEGSPT_BADOP(int),		/* checkprot */
 	SEGSPT_BADOP(int),		/* kluster */
-	SEGSPT_BADOP(size_t),		/* swapout */
 	SEGSPT_BADOP(int),		/* sync */
 	SEGSPT_BADOP(size_t),		/* incore */
 	SEGSPT_BADOP(int),		/* lockop */
@@ -123,7 +122,6 @@
 static int segspt_shmcheckprot(struct seg *seg, caddr_t addr, size_t size,
 			uint_t prot);
 static int	segspt_shmkluster(struct seg *seg, caddr_t addr, ssize_t delta);
-static size_t	segspt_shmswapout(struct seg *seg);
 static size_t segspt_shmincore(struct seg *seg, caddr_t addr, size_t len,
 			register char *vec);
 static int segspt_shmsync(struct seg *seg, register caddr_t addr, size_t len,
@@ -154,7 +152,6 @@
 	segspt_shmsetprot,
 	segspt_shmcheckprot,
 	segspt_shmkluster,
-	segspt_shmswapout,
 	segspt_shmsync,
 	segspt_shmincore,
 	segspt_shmlockop,
@@ -2242,13 +2239,6 @@
 {
 	return (0);
 }
-
-/*ARGSUSED*/
-static size_t
-segspt_shmswapout(struct seg *seg)
-{
-	return (0);
-}
 
 /*
  * duplicate the shared page tables
--- old/usr/src/uts/common/vm/seg_vn.c	2015-05-08 18:03:12.577084963 -0400
+++ new/usr/src/uts/common/vm/seg_vn.c	2015-05-08 18:03:12.585126870 -0400
@@ -111,7 +111,6 @@
 static int	segvn_checkprot(struct seg *seg, caddr_t addr,
 		    size_t len, uint_t prot);
 static int	segvn_kluster(struct seg *seg, caddr_t addr, ssize_t delta);
-static size_t	segvn_swapout(struct seg *seg);
 static int	segvn_sync(struct seg *seg, caddr_t addr, size_t len,
 		    int attr, uint_t flags);
 static size_t	segvn_incore(struct seg *seg, caddr_t addr, size_t len,
@@ -146,7 +145,6 @@
 	segvn_setprot,
 	segvn_checkprot,
 	segvn_kluster,
-	segvn_swapout,
 	segvn_sync,
 	segvn_incore,
 	segvn_lockop,
@@ -7051,189 +7049,6 @@
 }
 
 /*
- * Swap the pages of seg out to secondary storage, returning the
- * number of bytes of storage freed.
- *
- * The basic idea is first to unload all translations and then to call
- * VOP_PUTPAGE() for all newly-unmapped pages, to push them out to the
- * swap device.  Pages to which other segments have mappings will remain
- * mapped and won't be swapped.  Our caller (as_swapout) has already
- * performed the unloading step.
- *
- * The value returned is intended to correlate well with the process's
- * memory requirements.  However, there are some caveats:
- * 1)	When given a shared segment as argument, this routine will
- *	only succeed in swapping out pages for the last sharer of the
- *	segment.  (Previous callers will only have decremented mapping
- *	reference counts.)
- * 2)	We assume that the hat layer maintains a large enough translation
- *	cache to capture process reference patterns.
- */
-static size_t
-segvn_swapout(struct seg *seg)
-{
-	struct segvn_data *svd = (struct segvn_data *)seg->s_data;
-	struct anon_map *amp;
-	pgcnt_t pgcnt = 0;
-	pgcnt_t npages;
-	pgcnt_t page;
-	ulong_t anon_index;
-
-	ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as, &seg->s_as->a_lock));
-
-	SEGVN_LOCK_ENTER(seg->s_as, &svd->lock, RW_READER);
-	/*
-	 * Find pages unmapped by our caller and force them
-	 * out to the virtual swap device.
-	 */
-	if ((amp = svd->amp) != NULL)
-		anon_index = svd->anon_index;
-	npages = seg->s_size >> PAGESHIFT;
-	for (page = 0; page < npages; page++) {
-		page_t *pp;
-		struct anon *ap;
-		struct vnode *vp;
-		u_offset_t off;
-		anon_sync_obj_t cookie;
-
-		/*
-		 * Obtain <vp, off> pair for the page, then look it up.
-		 *
-		 * Note that this code is willing to consider regular
-		 * pages as well as anon pages.  Is this appropriate here?
-		 */
-		ap = NULL;
-		if (amp != NULL) {
-			ANON_LOCK_ENTER(&amp->a_rwlock, RW_READER);
-			if (anon_array_try_enter(amp, anon_index + page,
-			    &cookie)) {
-				ANON_LOCK_EXIT(&amp->a_rwlock);
-				continue;
-			}
-			ap = anon_get_ptr(amp->ahp, anon_index + page);
-			if (ap != NULL) {
-				swap_xlate(ap, &vp, &off);
-			} else {
-				vp = svd->vp;
-				off = svd->offset + ptob(page);
-			}
-			anon_array_exit(&cookie);
-			ANON_LOCK_EXIT(&amp->a_rwlock);
-		} else {
-			vp = svd->vp;
-			off = svd->offset + ptob(page);
-		}
-		if (vp == NULL) {		/* untouched zfod page */
-			ASSERT(ap == NULL);
-			continue;
-		}
-
-		pp = page_lookup_nowait(vp, off, SE_SHARED);
-		if (pp == NULL)
-			continue;
-
-
-		/*
-		 * Examine the page to see whether it can be tossed out,
-		 * keeping track of how many we've found.
-		 */
-		if (!page_tryupgrade(pp)) {
-			/*
-			 * If the page has an i/o lock and no mappings,
-			 * it's very likely that the page is being
-			 * written out as a result of klustering.
-			 * Assume this is so and take credit for it here.
-			 */
-			if (!page_io_trylock(pp)) {
-				if (!hat_page_is_mapped(pp))
-					pgcnt++;
-			} else {
-				page_io_unlock(pp);
-			}
-			page_unlock(pp);
-			continue;
-		}
-		ASSERT(!page_iolock_assert(pp));
-
-
-		/*
-		 * Skip if page is locked or has mappings.
-		 * We don't need the page_struct_lock to look at lckcnt
-		 * and cowcnt because the page is exclusive locked.
-		 */
-		if (pp->p_lckcnt != 0 || pp->p_cowcnt != 0 ||
-		    hat_page_is_mapped(pp)) {
-			page_unlock(pp);
-			continue;
-		}
-
-		/*
-		 * dispose skips large pages so try to demote first.
-		 */
-		if (pp->p_szc != 0 && !page_try_demote_pages(pp)) {
-			page_unlock(pp);
-			/*
-			 * XXX should skip the remaining page_t's of this
-			 * large page.
-			 */
-			continue;
-		}
-
-		ASSERT(pp->p_szc == 0);
-
-		/*
-		 * No longer mapped -- we can toss it out.  How
-		 * we do so depends on whether or not it's dirty.
-		 */
-		if (hat_ismod(pp) && pp->p_vnode) {
-			/*
-			 * We must clean the page before it can be
-			 * freed.  Setting B_FREE will cause pvn_done
-			 * to free the page when the i/o completes.
-			 * XXX:	This also causes it to be accounted
-			 *	as a pageout instead of a swap: need
-			 *	B_SWAPOUT bit to use instead of B_FREE.
-			 *
-			 * Hold the vnode before releasing the page lock
-			 * to prevent it from being freed and re-used by
-			 * some other thread.
-			 */
-			VN_HOLD(vp);
-			page_unlock(pp);
-
-			/*
-			 * Queue all i/o requests for the pageout thread
-			 * to avoid saturating the pageout devices.
-			 */
-			if (!queue_io_request(vp, off))
-				VN_RELE(vp);
-		} else {
-			/*
-			 * The page was clean, free it.
-			 *
-			 * XXX:	Can we ever encounter modified pages
-			 *	with no associated vnode here?
-			 */
-			ASSERT(pp->p_vnode != NULL);
-			/*LINTED: constant in conditional context*/
-			VN_DISPOSE(pp, B_FREE, 0, kcred);
-		}
-
-		/*
-		 * Credit now even if i/o is in progress.
-		 */
-		pgcnt++;
-	}
-	SEGVN_LOCK_EXIT(seg->s_as, &svd->lock);
-
-	/*
-	 * Wakeup pageout to initiate i/o on all queued requests.
-	 */
-	cv_signal_pageout();
-	return (ptob(pgcnt));
-}
-
-/*
  * Synchronize primary storage cache with real object in virtual memory.
  *
  * XXX - Anonymous pages should not be sync'ed out at all.
--- old/usr/src/uts/common/vm/vm_anon.c	2015-05-08 18:03:13.164296440 -0400
+++ new/usr/src/uts/common/vm/vm_anon.c	2015-05-08 18:03:13.171820983 -0400
@@ -67,8 +67,8 @@
  * we don't require backing store all anonymous pages in the system.
  * This is important for consideration for large memory systems.
  * We can also use this technique to delay binding physical locations
- * to anonymous pages until pageout/swapout time where we can make
- * smarter allocation decisions to improve anonymous klustering.
+ * to anonymous pages until pageout time where we can make smarter
+ * allocation decisions to improve anonymous klustering.
  *
  * Many of the routines defined here take a (struct anon **) argument,
  * which allows the code at this level to manage anon pages directly,
@@ -3578,43 +3578,6 @@
 	mutex_exit(mtx);
 }
 
-int
-anon_array_try_enter(struct anon_map *amp, ulong_t an_idx,
-			anon_sync_obj_t *sobj)
-{
-	ulong_t		*ap_slot;
-	kmutex_t	*mtx;
-	int		hash;
-
-	/*
-	 * Try to lock a range of anon slots.
-	 * Use szc to determine anon slot(s) to appear atomic.
-	 * If szc = 0, then lock the anon slot and mark it busy.
-	 * If szc > 0, then lock the range of slots by getting the
-	 * anon_array_lock for the first anon slot, and mark only the
-	 * first anon slot busy to represent whole range being busy.
-	 * Fail if the mutex or the anon_array are busy.
-	 */
-
-	ASSERT(RW_READ_HELD(&amp->a_rwlock));
-	an_idx = P2ALIGN(an_idx, page_get_pagecnt(amp->a_szc));
-	hash = ANON_ARRAY_HASH(amp, an_idx);
-	sobj->sync_mutex = mtx = &anon_array_lock[hash].pad_mutex;
-	sobj->sync_cv = &anon_array_cv[hash];
-	if (!mutex_tryenter(mtx)) {
-		return (EWOULDBLOCK);
-	}
-	ap_slot = anon_get_slot(amp->ahp, an_idx);
-	if (ANON_ISBUSY(ap_slot)) {
-		mutex_exit(mtx);
-		return (EWOULDBLOCK);
-	}
-	ANON_SETBUSY(ap_slot);
-	sobj->sync_data = ap_slot;
-	mutex_exit(mtx);
-	return (0);
-}
-
 void
 anon_array_exit(anon_sync_obj_t *sobj)
 {
--- old/usr/src/uts/common/vm/vm_as.c	2015-05-08 18:03:13.499934409 -0400
+++ new/usr/src/uts/common/vm/vm_as.c	2015-05-08 18:03:13.507324455 -0400
@@ -2058,61 +2058,6 @@
 }
 
 /*
- * Swap the pages associated with the address space as out to
- * secondary storage, returning the number of bytes actually
- * swapped.
- *
- * The value returned is intended to correlate well with the process's
- * memory requirements.  Its usefulness for this purpose depends on
- * how well the segment-level routines do at returning accurate
- * information.
- */
-size_t
-as_swapout(struct as *as)
-{
-	struct seg *seg;
-	size_t swpcnt = 0;
-
-	/*
-	 * Kernel-only processes have given up their address
-	 * spaces.  Of course, we shouldn't be attempting to
-	 * swap out such processes in the first place...
-	 */
-	if (as == NULL)
-		return (0);
-
-	AS_LOCK_ENTER(as, &as->a_lock, RW_READER);
-
-	/*
-	 * Free all mapping resources associated with the address
-	 * space.  The segment-level swapout routines capitalize
-	 * on this unmapping by scavanging pages that have become
-	 * unmapped here.
-	 */
-	hat_swapout(as->a_hat);
-
-	/*
-	 * Call the swapout routines of all segments in the address
-	 * space to do the actual work, accumulating the amount of
-	 * space reclaimed.
-	 */
-	for (seg = AS_SEGFIRST(as); seg != NULL; seg = AS_SEGNEXT(as, seg)) {
-		struct seg_ops *ov = seg->s_ops;
-
-		/*
-		 * We have to check to see if the seg has
-		 * an ops vector because the seg may have
-		 * been in the middle of being set up when
-		 * the process was picked for swapout.
-		 */
-		if ((ov != NULL) && (ov->swapout != NULL))
-			swpcnt += SEGOP_SWAPOUT(seg);
-	}
-	AS_LOCK_EXIT(as, &as->a_lock);
-	return (swpcnt);
-}
-
-/*
  * Determine whether data from the mappings in interval [addr, addr + size)
  * are in the primary memory (core) cache.
  */
--- old/usr/src/uts/i86pc/os/mlsetup.c	2015-05-08 18:03:13.820392790 -0400
+++ new/usr/src/uts/i86pc/os/mlsetup.c	2015-05-08 18:03:13.827628793 -0400
@@ -277,7 +277,7 @@
 	t0.t_stk = (caddr_t)rp - MINFRAME;
 	t0.t_stkbase = t0stack;
 	t0.t_pri = maxclsyspri - 3;
-	t0.t_schedflag = TS_LOAD | TS_DONT_SWAP;
+	t0.t_schedflag = 0;
 	t0.t_procp = &p0;
 	t0.t_plockp = &p0lock.pl_lock;
 	t0.t_lwp = &lwp0;
--- old/usr/src/uts/i86pc/os/trap.c	2015-05-08 18:03:14.040615585 -0400
+++ new/usr/src/uts/i86pc/os/trap.c	2015-05-08 18:03:14.047945690 -0400
@@ -491,7 +491,6 @@
 
 	type = rp->r_trapno;
 	CPU_STATS_ADDQ(CPU, sys, trap, 1);
-	ASSERT(ct->t_schedflag & TS_DONT_SWAP);
 
 	if (type == T_PGFLT) {
 
--- old/usr/src/uts/i86pc/vm/hat_i86.c	2015-05-08 18:03:14.320224880 -0400
+++ new/usr/src/uts/i86pc/vm/hat_i86.c	2015-05-08 18:03:14.327650553 -0400
@@ -1125,88 +1125,6 @@
 }
 
 /*
- * Allocate any hat resources required for a process being swapped in.
- */
-/*ARGSUSED*/
-void
-hat_swapin(hat_t *hat)
-{
-	/* do nothing - we let everything fault back in */
-}
-
-/*
- * Unload all translations associated with an address space of a process
- * that is being swapped out.
- */
-void
-hat_swapout(hat_t *hat)
-{
-	uintptr_t	vaddr = (uintptr_t)0;
-	uintptr_t	eaddr = _userlimit;
-	htable_t	*ht = NULL;
-	level_t		l;
-
-	XPV_DISALLOW_MIGRATE();
-	/*
-	 * We can't just call hat_unload(hat, 0, _userlimit...)  here, because
-	 * seg_spt and shared pagetables can't be swapped out.
-	 * Take a look at segspt_shmswapout() - it's a big no-op.
-	 *
-	 * Instead we'll walk through all the address space and unload
-	 * any mappings which we are sure are not shared, not locked.
-	 */
-	ASSERT(IS_PAGEALIGNED(vaddr));
-	ASSERT(IS_PAGEALIGNED(eaddr));
-	ASSERT(AS_LOCK_HELD(hat->hat_as, &hat->hat_as->a_lock));
-	if ((uintptr_t)hat->hat_as->a_userlimit < eaddr)
-		eaddr = (uintptr_t)hat->hat_as->a_userlimit;
-
-	while (vaddr < eaddr) {
-		(void) htable_walk(hat, &ht, &vaddr, eaddr);
-		if (ht == NULL)
-			break;
-
-		ASSERT(!IN_VA_HOLE(vaddr));
-
-		/*
-		 * If the page table is shared skip its entire range.
-		 */
-		l = ht->ht_level;
-		if (ht->ht_flags & HTABLE_SHARED_PFN) {
-			vaddr = ht->ht_vaddr + LEVEL_SIZE(l + 1);
-			htable_release(ht);
-			ht = NULL;
-			continue;
-		}
-
-		/*
-		 * If the page table has no locked entries, unload this one.
-		 */
-		if (ht->ht_lock_cnt == 0)
-			hat_unload(hat, (caddr_t)vaddr, LEVEL_SIZE(l),
-			    HAT_UNLOAD_UNMAP);
-
-		/*
-		 * If we have a level 0 page table with locked entries,
-		 * skip the entire page table, otherwise skip just one entry.
-		 */
-		if (ht->ht_lock_cnt > 0 && l == 0)
-			vaddr = ht->ht_vaddr + LEVEL_SIZE(1);
-		else
-			vaddr += LEVEL_SIZE(l);
-	}
-	if (ht)
-		htable_release(ht);
-
-	/*
-	 * We're in swapout because the system is low on memory, so
-	 * go back and flush all the htables off the cached list.
-	 */
-	htable_purge_hat(hat);
-	XPV_ALLOW_MIGRATE();
-}
-
-/*
  * returns number of bytes that have valid mappings in hat.
  */
 size_t
--- old/usr/src/uts/i86xpv/vm/seg_mf.c	2015-05-08 18:03:14.668156628 -0400
+++ new/usr/src/uts/i86xpv/vm/seg_mf.c	2015-05-08 18:03:14.675404904 -0400
@@ -766,7 +766,6 @@
 	segmf_setprot,
 	segmf_checkprot,
 	(int (*)())segmf_kluster,
-	(size_t (*)(struct seg *))NULL,	/* swapout */
 	segmf_sync,
 	segmf_incore,
 	segmf_lockop,
--- old/usr/src/uts/intel/ia32/os/syscall.c	2015-05-08 18:03:14.894992995 -0400
+++ new/usr/src/uts/intel/ia32/os/syscall.c	2015-05-08 18:03:14.902334948 -0400
@@ -149,7 +149,7 @@
 	int error = 0;
 	uint_t nargs;
 
-	ASSERT(t == curthread && curthread->t_schedflag & TS_DONT_SWAP);
+	ASSERT(t == curthread);
 
 	lwp->lwp_ru.sysc++;
 	lwp->lwp_eosys = NORMALRETURN;	/* assume this will be normal */
@@ -243,8 +243,6 @@
 
 	t->t_pre_sys = repost = 0;	/* clear pre-syscall processing flag */
 
-	ASSERT(t->t_schedflag & TS_DONT_SWAP);
-
 #if defined(DEBUG)
 	/*
 	 * On the i386 kernel, lwp_ap points at the piece of the thread
--- old/usr/src/uts/sfmmu/vm/hat_sfmmu.c	2015-05-08 18:03:15.148563658 -0400
+++ new/usr/src/uts/sfmmu/vm/hat_sfmmu.c	2015-05-08 18:03:15.156677546 -0400
@@ -1970,149 +1970,6 @@
 }
 
 /*
- * Set up any translation structures, for the specified address space,
- * that are needed or preferred when the process is being swapped in.
- */
-/* ARGSUSED */
-void
-hat_swapin(struct hat *hat)
-{
-}
-
-/*
- * Free all of the translation resources, for the specified address space,
- * that can be freed while the process is swapped out. Called from as_swapout.
- * Also, free up the ctx that this process was using.
- */
-void
-hat_swapout(struct hat *sfmmup)
-{
-	struct hmehash_bucket *hmebp;
-	struct hme_blk *hmeblkp;
-	struct hme_blk *pr_hblk = NULL;
-	struct hme_blk *nx_hblk;
-	int i;
-	struct hme_blk *list = NULL;
-	hatlock_t *hatlockp;
-	struct tsb_info *tsbinfop;
-	struct free_tsb {
-		struct free_tsb *next;
-		struct tsb_info *tsbinfop;
-	};			/* free list of TSBs */
-	struct free_tsb *freelist, *last, *next;
-
-	SFMMU_STAT(sf_swapout);
-
-	/*
-	 * There is no way to go from an as to all its translations in sfmmu.
-	 * Here is one of the times when we take the big hit and traverse
-	 * the hash looking for hme_blks to free up.  Not only do we free up
-	 * this as hme_blks but all those that are free.  We are obviously
-	 * swapping because we need memory so let's free up as much
-	 * as we can.
-	 *
-	 * Note that we don't flush TLB/TSB here -- it's not necessary
-	 * because:
-	 *  1) we free the ctx we're using and throw away the TSB(s);
-	 *  2) processes aren't runnable while being swapped out.
-	 */
-	ASSERT(sfmmup != KHATID);
-	for (i = 0; i <= UHMEHASH_SZ; i++) {
-		hmebp = &uhme_hash[i];
-		SFMMU_HASH_LOCK(hmebp);
-		hmeblkp = hmebp->hmeblkp;
-		pr_hblk = NULL;
-		while (hmeblkp) {
-
-			if ((hmeblkp->hblk_tag.htag_id == sfmmup) &&
-			    !hmeblkp->hblk_shw_bit && !hmeblkp->hblk_lckcnt) {
-				ASSERT(!hmeblkp->hblk_shared);
-				(void) sfmmu_hblk_unload(sfmmup, hmeblkp,
-				    (caddr_t)get_hblk_base(hmeblkp),
-				    get_hblk_endaddr(hmeblkp),
-				    NULL, HAT_UNLOAD);
-			}
-			nx_hblk = hmeblkp->hblk_next;
-			if (!hmeblkp->hblk_vcnt && !hmeblkp->hblk_hmecnt) {
-				ASSERT(!hmeblkp->hblk_lckcnt);
-				sfmmu_hblk_hash_rm(hmebp, hmeblkp, pr_hblk,
-				    &list, 0);
-			} else {
-				pr_hblk = hmeblkp;
-			}
-			hmeblkp = nx_hblk;
-		}
-		SFMMU_HASH_UNLOCK(hmebp);
-	}
-
-	sfmmu_hblks_list_purge(&list, 0);
-
-	/*
-	 * Now free up the ctx so that others can reuse it.
-	 */
-	hatlockp = sfmmu_hat_enter(sfmmup);
-
-	sfmmu_invalidate_ctx(sfmmup);
-
-	/*
-	 * Free TSBs, but not tsbinfos, and set SWAPPED flag.
-	 * If TSBs were never swapped in, just return.
-	 * This implies that we don't support partial swapping
-	 * of TSBs -- either all are swapped out, or none are.
-	 *
-	 * We must hold the HAT lock here to prevent racing with another
-	 * thread trying to unmap TTEs from the TSB or running the post-
-	 * relocator after relocating the TSB's memory.  Unfortunately, we
-	 * can't free memory while holding the HAT lock or we could
-	 * deadlock, so we build a list of TSBs to be freed after marking
-	 * the tsbinfos as swapped out and free them after dropping the
-	 * lock.
-	 */
-	if (SFMMU_FLAGS_ISSET(sfmmup, HAT_SWAPPED)) {
-		sfmmu_hat_exit(hatlockp);
-		return;
-	}
-
-	SFMMU_FLAGS_SET(sfmmup, HAT_SWAPPED);
-	last = freelist = NULL;
-	for (tsbinfop = sfmmup->sfmmu_tsb; tsbinfop != NULL;
-	    tsbinfop = tsbinfop->tsb_next) {
-		ASSERT((tsbinfop->tsb_flags & TSB_SWAPPED) == 0);
-
-		/*
-		 * Cast the TSB into a struct free_tsb and put it on the free
-		 * list.
-		 */
-		if (freelist == NULL) {
-			last = freelist = (struct free_tsb *)tsbinfop->tsb_va;
-		} else {
-			last->next = (struct free_tsb *)tsbinfop->tsb_va;
-			last = last->next;
-		}
-		last->next = NULL;
-		last->tsbinfop = tsbinfop;
-		tsbinfop->tsb_flags |= TSB_SWAPPED;
-		/*
-		 * Zero out the TTE to clear the valid bit.
-		 * Note we can't use a value like 0xbad because we want to
-		 * ensure diagnostic bits are NEVER set on TTEs that might
-		 * be loaded.  The intent is to catch any invalid access
-		 * to the swapped TSB, such as a thread running with a valid
-		 * context without first calling sfmmu_tsb_swapin() to
-		 * allocate TSB memory.
-		 */
-		tsbinfop->tsb_tte.ll = 0;
-	}
-
-	/* Now we can drop the lock and free the TSB memory. */
-	sfmmu_hat_exit(hatlockp);
-	for (; freelist != NULL; freelist = next) {
-		next = freelist->next;
-		sfmmu_tsb_free(freelist->tsbinfop);
-	}
-}
-
-/*
  * Duplicate the translations of an as into another newas
  */
 /* ARGSUSED */
@@ -9816,7 +9673,7 @@
 
 /*
  * Replace the specified TSB with a new TSB.  This function gets called when
- * we grow, shrink or swapin a TSB.  When swapping in a TSB (TSB_SWAPIN), the
+ * we grow, or shrink a TSB.  When swapping in a TSB (TSB_SWAPIN), the
  * TSB_FORCEALLOC flag may be used to force allocation of a minimum-sized TSB
  * (8K).
  *
--- old/usr/src/uts/sparc/os/syscall.c	2015-05-08 18:03:15.904693102 -0400
+++ new/usr/src/uts/sparc/os/syscall.c	2015-05-08 18:03:15.912070460 -0400
@@ -359,8 +359,6 @@
 
 	t->t_pre_sys = repost = 0;	/* clear pre-syscall processing flag */
 
-	ASSERT(t->t_schedflag & TS_DONT_SWAP);
-
 	syscall_mstate(LMS_USER, LMS_SYSTEM);
 
 	/*
--- old/usr/src/uts/sparc/v9/os/v9dep.c	2015-05-08 18:03:16.143986015 -0400
+++ new/usr/src/uts/sparc/v9/os/v9dep.c	2015-05-08 18:03:16.151451345 -0400
@@ -860,15 +860,6 @@
 	fpp->fpu_fprs = 0;
 }
 
-void
-lwp_swapin(kthread_t *tp)
-{
-	struct machpcb *mpcb = lwptompcb(ttolwp(tp));
-
-	mpcb->mpcb_pa = va_to_pa(mpcb);
-	mpcb->mpcb_wbuf_pa = va_to_pa(mpcb->mpcb_wbuf);
-}
-
 /*
  * Construct the execution environment for the user's signal
  * handler and arrange for control to be given to it on return
--- old/usr/src/uts/sparc/v9/vm/seg_nf.c	2015-05-08 18:03:16.424701283 -0400
+++ new/usr/src/uts/sparc/v9/vm/seg_nf.c	2015-05-08 18:03:16.432182596 -0400
@@ -31,8 +31,6 @@
  * under license from the Regents of the University of California.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 /*
  * VM - segment for non-faulting loads.
  */
@@ -97,7 +95,6 @@
 	segnf_setprot,
 	segnf_checkprot,
 	(int (*)())segnf_badop,		/* kluster */
-	(size_t (*)(struct seg *))NULL,	/* swapout */
 	(int (*)(struct seg *, caddr_t, size_t, int, uint_t))
 		segnf_nop,		/* sync */
 	(size_t (*)(struct seg *, caddr_t, size_t, char *))
--- old/usr/src/uts/sun4/os/mlsetup.c	2015-05-08 18:03:16.641016550 -0400
+++ new/usr/src/uts/sun4/os/mlsetup.c	2015-05-08 18:03:16.648264486 -0400
@@ -148,7 +148,7 @@
 	/* Can't use va_to_pa here - wait until prom_ initialized */
 	t0.t_stkbase = t0stack;
 	t0.t_pri = maxclsyspri - 3;
-	t0.t_schedflag = TS_LOAD | TS_DONT_SWAP;
+	t0.t_schedflag = 0;
 	t0.t_procp = &p0;
 	t0.t_plockp = &p0lock.pl_lock;
 	t0.t_lwp = &lwp0;
--- old/usr/src/uts/sun4/os/trap.c	2015-05-08 18:03:16.858108246 -0400
+++ new/usr/src/uts/sun4/os/trap.c	2015-05-08 18:03:16.865476109 -0400
@@ -168,13 +168,6 @@
 
 	CPU_STATS_ADDQ(CPU, sys, trap, 1);
 
-#ifdef SF_ERRATA_23 /* call causes illegal-insn */
-	ASSERT((curthread->t_schedflag & TS_DONT_SWAP) ||
-	    (type == T_UNIMP_INSTR));
-#else
-	ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
-#endif /* SF_ERRATA_23 */
-
 	if (USERMODE(rp->r_tstate) || (type & T_USER)) {
 		/*
 		 * Set lwp_state before trying to acquire any
@@ -1372,8 +1365,6 @@
 
 	CPU_STATS_ADDQ(CPU, sys, trap, 1);
 
-	ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
-
 	if (USERMODE(rp->r_tstate)) {
 		/*
 		 * Set lwp_state before trying to acquire any
