--- old/usr/src/uts/common/disp/disp.c	2014-03-28 23:33:13.026094692 -0400
+++ new/usr/src/uts/common/disp/disp.c	2014-03-28 23:33:13.036661385 -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	2014-03-28 23:33:15.949710850 -0400
+++ new/usr/src/uts/common/disp/fss.c	2014-03-28 23:33:15.960131564 -0400
@@ -213,8 +213,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 *);
@@ -251,8 +249,6 @@
 	fss_exit,
 	fss_active,
 	fss_inactive,
-	fss_swapin,
-	fss_swapout,
 	fss_trapret,
 	fss_preempt,
 	fss_setrun,
@@ -1829,107 +1825,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
@@ -1960,16 +1855,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);
-	}
 }
 
 /*
@@ -2014,14 +1899,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
@@ -2045,7 +1922,6 @@
 					fssproc->fss_flags |= FSSRESTORE;
 				}
 				THREAD_CHANGE_PRI(t, fss_maxumdpri);
-				t->t_schedflag |= TS_DONT_SWAP;
 			}
 			schedctl_set_yield(t, 1);
 			setfrontdq(t);
@@ -2151,13 +2027,11 @@
 		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)
@@ -2235,10 +2109,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;
@@ -2302,7 +2172,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	2014-03-28 23:33:18.327538536 -0400
+++ new/usr/src/uts/common/disp/fx.c	2014-03-28 23:33:18.338064235 -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	2014-03-28 23:33:20.165304394 -0400
+++ new/usr/src/uts/common/disp/rt.c	2014-03-28 23:33:20.184907592 -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	2014-03-28 23:33:21.745815552 -0400
+++ new/usr/src/uts/common/disp/sysclass.c	2014-03-28 23:33:21.813534257 -0400
@@ -66,7 +66,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 +94,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 +191,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	2014-03-28 23:33:22.892459697 -0400
+++ new/usr/src/uts/common/disp/sysdc.c	2014-03-28 23:33:22.902268880 -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	2014-03-28 23:33:24.267921642 -0400
+++ new/usr/src/uts/common/disp/thread.c	2014-03-28 23:33:24.277885287 -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	2014-03-28 23:33:25.061454172 -0400
+++ new/usr/src/uts/common/disp/ts.c	2014-03-28 23:33:25.071155389 -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
@@ -1758,10 +1615,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 +1688,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 +1825,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	2014-03-28 23:33:25.542516505 -0400
+++ new/usr/src/uts/common/fs/nfs/nfs_srv.c	2014-03-28 23:33:25.553134417 -0400
@@ -1211,8 +1211,6 @@
 	nrp->cr = cr;
 	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	2014-03-28 23:33:26.330647246 -0400
+++ new/usr/src/uts/common/os/clock.c	2014-03-28 23:33:26.340853898 -0400
@@ -901,44 +901,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	2014-03-28 23:33:28.501685781 -0400
+++ new/usr/src/uts/common/os/condvar.c	2014-03-28 23:33:28.625277811 -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	2014-03-28 23:33:30.294291279 -0400
+++ new/usr/src/uts/common/os/cpu.c	2014-03-28 23:33:30.305126998 -0400
@@ -2681,13 +2681,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);
 			}
 		}
 	}
--- old/usr/src/uts/common/os/panic.c	2014-03-28 23:33:31.354431976 -0400
+++ new/usr/src/uts/common/os/panic.c	2014-03-28 23:33:31.363878982 -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	2014-03-28 23:33:32.887365261 -0400
+++ new/usr/src/uts/common/os/sched.c	2014-03-28 23:33:32.897355800 -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	2014-03-28 23:33:34.151338387 -0400
+++ new/usr/src/uts/common/os/timers.c	2014-03-28 23:33:34.248997964 -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	2014-03-28 23:33:35.336869586 -0400
+++ new/usr/src/uts/common/os/waitq.c	2014-03-28 23:33:35.346768180 -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	2014-03-28 23:33:36.889572096 -0400
+++ new/usr/src/uts/common/sys/class.h	2014-03-28 23:33:36.899388594 -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	2014-03-28 23:33:38.069466437 -0400
+++ new/usr/src/uts/common/sys/disp.h	2014-03-28 23:33:38.079512827 -0400
@@ -143,8 +143,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	2014-03-28 23:33:39.427916452 -0400
+++ new/usr/src/uts/common/sys/proc.h	2014-03-28 23:33:39.437999559 -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/systm.h	2014-03-28 23:33:41.200931197 -0400
+++ new/usr/src/uts/common/sys/systm.h	2014-03-28 23:33:41.212089304 -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	2014-03-28 23:33:42.985110755 -0400
+++ new/usr/src/uts/common/sys/thread.h	2014-03-28 23:33:42.994951392 -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	2014-03-28 23:33:43.726194862 -0400
+++ new/usr/src/uts/common/sys/vmsystm.h	2014-03-28 23:33:43.736195401 -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/as.h	2014-03-28 23:33:45.224215812 -0400
+++ new/usr/src/uts/common/vm/as.h	2014-03-28 23:33:45.234491324 -0400
@@ -288,7 +288,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/seg_kp.c	2014-03-28 23:33:46.713503814 -0400
+++ new/usr/src/uts/common/vm/seg_kp.c	2014-03-28 23:33:46.760996219 -0400
@@ -760,15 +760,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 +778,6 @@
 	caddr_t stkbase;
 #endif
 
-	ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
-
 	/*
 	 * Optimize for the common case where we simply return.
 	 */
@@ -884,7 +878,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/vm_as.c	2014-03-28 23:33:47.944403973 -0400
+++ new/usr/src/uts/common/vm/vm_as.c	2014-03-28 23:33:47.953762208 -0400
@@ -2140,73 +2140,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);
-
-	/* Prevent XHATs from attaching */
-	mutex_enter(&as->a_contents);
-	AS_SETBUSY(as);
-	mutex_exit(&as->a_contents);
-
-
-	/*
-	 * 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);
-	if (as->a_xhat != NULL)
-		xhat_swapout_all(as);
-
-	mutex_enter(&as->a_contents);
-	AS_CLRBUSY(as);
-	mutex_exit(&as->a_contents);
-
-	/*
-	 * 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	2014-03-28 23:33:49.646739631 -0400
+++ new/usr/src/uts/i86pc/os/mlsetup.c	2014-03-28 23:33:49.657376317 -0400
@@ -292,7 +292,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	2014-03-28 23:33:50.904915690 -0400
+++ new/usr/src/uts/i86pc/os/trap.c	2014-03-28 23:33:50.914056703 -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/intel/ia32/os/syscall.c	2014-03-28 23:33:52.199649321 -0400
+++ new/usr/src/uts/intel/ia32/os/syscall.c	2014-03-28 23:33:52.209110482 -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/sparc/os/syscall.c	2014-03-28 23:33:54.129766902 -0400
+++ new/usr/src/uts/sparc/os/syscall.c	2014-03-28 23:33:54.139448156 -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	2014-03-28 23:33:55.516298065 -0400
+++ new/usr/src/uts/sparc/v9/os/v9dep.c	2014-03-28 23:33:55.594012327 -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/sun4/os/mlsetup.c	2014-03-28 23:33:57.676749960 -0400
+++ new/usr/src/uts/sun4/os/mlsetup.c	2014-03-28 23:33:57.910428631 -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	2014-03-28 23:34:00.326610666 -0400
+++ new/usr/src/uts/sun4/os/trap.c	2014-03-28 23:34:00.336648757 -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
