xref: /illumos-gate/usr/src/uts/common/cpr/cpr_uthread.c (revision 2d6eb4a5e0a47d30189497241345dc5466bb68ab)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5ae115bc7Smrj  * Common Development and Distribution License (the "License").
6ae115bc7Smrj  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*903a11ebSrh87107  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #include <sys/types.h>
277c478bd9Sstevel@tonic-gate #include <sys/thread.h>
287c478bd9Sstevel@tonic-gate #include <sys/conf.h>
297c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h>
307c478bd9Sstevel@tonic-gate #include <sys/cpr.h>
317c478bd9Sstevel@tonic-gate #include <sys/user.h>
327c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
337c478bd9Sstevel@tonic-gate #include <sys/callb.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate extern void utstop_init(void);
367c478bd9Sstevel@tonic-gate extern void add_one_utstop(void);
377c478bd9Sstevel@tonic-gate extern void utstop_timedwait(long ticks);
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate static void cpr_stop_user(int);
407c478bd9Sstevel@tonic-gate static int cpr_check_user_threads(void);
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * CPR user thread related support routines
447c478bd9Sstevel@tonic-gate  */
457c478bd9Sstevel@tonic-gate void
cpr_signal_user(int sig)467c478bd9Sstevel@tonic-gate cpr_signal_user(int sig)
477c478bd9Sstevel@tonic-gate {
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate  * The signal SIGTHAW and SIGFREEZE cannot be sent to every thread yet
507c478bd9Sstevel@tonic-gate  * since openwin is catching every signal and default action is to exit.
517c478bd9Sstevel@tonic-gate  * We also need to implement the true SIGFREEZE and SIGTHAW to stop threads.
527c478bd9Sstevel@tonic-gate  */
537c478bd9Sstevel@tonic-gate 	struct proc *p;
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate 	mutex_enter(&pidlock);
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate 	for (p = practive; p; p = p->p_next) {
587c478bd9Sstevel@tonic-gate 		/* only user threads */
597c478bd9Sstevel@tonic-gate 		if (p->p_exec == NULL || p->p_stat == SZOMB ||
607c478bd9Sstevel@tonic-gate 		    p == proc_init || p == ttoproc(curthread))
617c478bd9Sstevel@tonic-gate 			continue;
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate 		mutex_enter(&p->p_lock);
647c478bd9Sstevel@tonic-gate 		sigtoproc(p, NULL, sig);
657c478bd9Sstevel@tonic-gate 		mutex_exit(&p->p_lock);
667c478bd9Sstevel@tonic-gate 	}
677c478bd9Sstevel@tonic-gate 	mutex_exit(&pidlock);
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate 	DELAY(MICROSEC);
707c478bd9Sstevel@tonic-gate }
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate /* max wait time for user thread stop */
737c478bd9Sstevel@tonic-gate #define	CPR_UTSTOP_WAIT		hz
747c478bd9Sstevel@tonic-gate #define	CPR_UTSTOP_RETRY	4
757c478bd9Sstevel@tonic-gate static int count;
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate int
cpr_stop_user_threads()787c478bd9Sstevel@tonic-gate cpr_stop_user_threads()
797c478bd9Sstevel@tonic-gate {
807c478bd9Sstevel@tonic-gate 	utstop_init();
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate 	count = 0;
837c478bd9Sstevel@tonic-gate 	do {
847c478bd9Sstevel@tonic-gate 		if (++count > CPR_UTSTOP_RETRY)
857c478bd9Sstevel@tonic-gate 			return (ESRCH);
867c478bd9Sstevel@tonic-gate 		cpr_stop_user(count * count * CPR_UTSTOP_WAIT);
877c478bd9Sstevel@tonic-gate 	} while (cpr_check_user_threads() &&
887c478bd9Sstevel@tonic-gate 	    (count < CPR_UTSTOP_RETRY || CPR->c_fcn != AD_CPR_FORCE));
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate 	return (0);
917c478bd9Sstevel@tonic-gate }
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate /*
947c478bd9Sstevel@tonic-gate  * This routine tries to stop all user threads before we get rid of all
957c478bd9Sstevel@tonic-gate  * its pages.It goes through allthreads list and set the TP_CHKPT flag
967c478bd9Sstevel@tonic-gate  * for all user threads and make them runnable. If all of the threads
977c478bd9Sstevel@tonic-gate  * can be stopped within the max wait time, CPR will proceed. Otherwise
987c478bd9Sstevel@tonic-gate  * CPR is aborted after a few of similiar retries.
997c478bd9Sstevel@tonic-gate  */
1007c478bd9Sstevel@tonic-gate static void
cpr_stop_user(int wait)1017c478bd9Sstevel@tonic-gate cpr_stop_user(int wait)
1027c478bd9Sstevel@tonic-gate {
1037c478bd9Sstevel@tonic-gate 	kthread_id_t tp;
1047c478bd9Sstevel@tonic-gate 	proc_t *p;
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate 	/* The whole loop below needs to be atomic */
1077c478bd9Sstevel@tonic-gate 	mutex_enter(&pidlock);
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate 	/* faster this way */
1107c478bd9Sstevel@tonic-gate 	tp = curthread->t_next;
1117c478bd9Sstevel@tonic-gate 	do {
1127c478bd9Sstevel@tonic-gate 		/* kernel threads will be handled later */
1137c478bd9Sstevel@tonic-gate 		p = ttoproc(tp);
1147c478bd9Sstevel@tonic-gate 		if (p->p_as == &kas || p->p_stat == SZOMB)
1157c478bd9Sstevel@tonic-gate 			continue;
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate 		/*
1187c478bd9Sstevel@tonic-gate 		 * If the thread is stopped (by CPR) already, do nothing;
1197c478bd9Sstevel@tonic-gate 		 * if running, mark TP_CHKPT;
1207c478bd9Sstevel@tonic-gate 		 * if sleeping normally, mark TP_CHKPT and setrun;
1217c478bd9Sstevel@tonic-gate 		 * if sleeping non-interruptable, mark TP_CHKPT only for now;
1227c478bd9Sstevel@tonic-gate 		 * if sleeping with t_wchan0 != 0 etc, virtually stopped,
1237c478bd9Sstevel@tonic-gate 		 * do nothing.
1247c478bd9Sstevel@tonic-gate 		 */
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate 		/* p_lock is needed for modifying t_proc_flag */
1277c478bd9Sstevel@tonic-gate 		mutex_enter(&p->p_lock);
1287c478bd9Sstevel@tonic-gate 		thread_lock(tp); /* needed to check CPR_ISTOPPED */
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate 		if (tp->t_state == TS_STOPPED) {
1317c478bd9Sstevel@tonic-gate 			/*
1327c478bd9Sstevel@tonic-gate 			 * if already stopped by other reasons, add this new
1337c478bd9Sstevel@tonic-gate 			 * reason to it.
1347c478bd9Sstevel@tonic-gate 			 */
1357c478bd9Sstevel@tonic-gate 			if (tp->t_schedflag & TS_RESUME)
1367c478bd9Sstevel@tonic-gate 				tp->t_schedflag &= ~TS_RESUME;
1377c478bd9Sstevel@tonic-gate 		} else {
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate 			tp->t_proc_flag |= TP_CHKPT;
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate 			thread_unlock(tp);
1427c478bd9Sstevel@tonic-gate 			mutex_exit(&p->p_lock);
1437c478bd9Sstevel@tonic-gate 			add_one_utstop();
1447c478bd9Sstevel@tonic-gate 			mutex_enter(&p->p_lock);
1457c478bd9Sstevel@tonic-gate 			thread_lock(tp);
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate 			aston(tp);
1487c478bd9Sstevel@tonic-gate 
149c97ad5cdSakolb 			if (ISWAKEABLE(tp) || ISWAITING(tp)) {
1507c478bd9Sstevel@tonic-gate 				setrun_locked(tp);
1517c478bd9Sstevel@tonic-gate 			}
1527c478bd9Sstevel@tonic-gate 		}
1537c478bd9Sstevel@tonic-gate 		/*
1547c478bd9Sstevel@tonic-gate 		 * force the thread into the kernel if it is not already there.
1557c478bd9Sstevel@tonic-gate 		 */
1567c478bd9Sstevel@tonic-gate 		if (tp->t_state == TS_ONPROC && tp->t_cpu != CPU)
1577c478bd9Sstevel@tonic-gate 			poke_cpu(tp->t_cpu->cpu_id);
1587c478bd9Sstevel@tonic-gate 		thread_unlock(tp);
1597c478bd9Sstevel@tonic-gate 		mutex_exit(&p->p_lock);
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate 	} while ((tp = tp->t_next) != curthread);
1627c478bd9Sstevel@tonic-gate 	mutex_exit(&pidlock);
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate 	utstop_timedwait(wait);
1657c478bd9Sstevel@tonic-gate }
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate /*
1687c478bd9Sstevel@tonic-gate  * Checks and makes sure all user threads are stopped
1697c478bd9Sstevel@tonic-gate  */
1707c478bd9Sstevel@tonic-gate static int
cpr_check_user_threads()1717c478bd9Sstevel@tonic-gate cpr_check_user_threads()
1727c478bd9Sstevel@tonic-gate {
1737c478bd9Sstevel@tonic-gate 	kthread_id_t tp;
1747c478bd9Sstevel@tonic-gate 	int rc = 0;
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate 	mutex_enter(&pidlock);
1777c478bd9Sstevel@tonic-gate 	tp = curthread->t_next;
1787c478bd9Sstevel@tonic-gate 	do {
1797c478bd9Sstevel@tonic-gate 		if (ttoproc(tp)->p_as == &kas || ttoproc(tp)->p_stat == SZOMB)
1807c478bd9Sstevel@tonic-gate 			continue;
1817c478bd9Sstevel@tonic-gate 
1827c478bd9Sstevel@tonic-gate 		thread_lock(tp);
1837c478bd9Sstevel@tonic-gate 		/*
1847c478bd9Sstevel@tonic-gate 		 * make sure that we are off all the queues and in a stopped
1857c478bd9Sstevel@tonic-gate 		 * state.
1867c478bd9Sstevel@tonic-gate 		 */
1877c478bd9Sstevel@tonic-gate 		if (!CPR_ISTOPPED(tp)) {
1887c478bd9Sstevel@tonic-gate 			thread_unlock(tp);
1897c478bd9Sstevel@tonic-gate 			mutex_exit(&pidlock);
1907c478bd9Sstevel@tonic-gate 
1917c478bd9Sstevel@tonic-gate 			if (count == CPR_UTSTOP_RETRY) {
192ae115bc7Smrj 			CPR_DEBUG(CPR_DEBUG1, "Suspend failed: "
193ae115bc7Smrj 			    "cannot stop uthread\n");
1947c478bd9Sstevel@tonic-gate 			cpr_err(CE_WARN, "Suspend cannot stop "
195bf30efa4Smathue 			    "process %s (%p:%x).",
196bf30efa4Smathue 			    ttoproc(tp)->p_user.u_psargs, (void *)tp,
1977c478bd9Sstevel@tonic-gate 			    tp->t_state);
1987c478bd9Sstevel@tonic-gate 			cpr_err(CE_WARN, "Process may be waiting for"
1997c478bd9Sstevel@tonic-gate 			    " network request, please try again.");
2007c478bd9Sstevel@tonic-gate 			}
2017c478bd9Sstevel@tonic-gate 
202ae115bc7Smrj 			CPR_DEBUG(CPR_DEBUG2, "cant stop t=%p state=%x pfg=%x "
203*903a11ebSrh87107 			    "sched=%x\n", (void *)tp, tp->t_state,
204*903a11ebSrh87107 			    tp->t_proc_flag, tp->t_schedflag);
205ae115bc7Smrj 			CPR_DEBUG(CPR_DEBUG2, "proc %p state=%x pid=%d\n",
206*903a11ebSrh87107 			    (void *)ttoproc(tp), ttoproc(tp)->p_stat,
207ae115bc7Smrj 			    ttoproc(tp)->p_pidp->pid_id);
2087c478bd9Sstevel@tonic-gate 			return (1);
2097c478bd9Sstevel@tonic-gate 		}
2107c478bd9Sstevel@tonic-gate 		thread_unlock(tp);
2117c478bd9Sstevel@tonic-gate 
2127c478bd9Sstevel@tonic-gate 	} while ((tp = tp->t_next) != curthread && rc == 0);
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate 	mutex_exit(&pidlock);
2157c478bd9Sstevel@tonic-gate 	return (0);
2167c478bd9Sstevel@tonic-gate }
2177c478bd9Sstevel@tonic-gate 
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate /*
2207c478bd9Sstevel@tonic-gate  * start all threads that were stopped for checkpoint.
2217c478bd9Sstevel@tonic-gate  */
2227c478bd9Sstevel@tonic-gate void
cpr_start_user_threads()2237c478bd9Sstevel@tonic-gate cpr_start_user_threads()
2247c478bd9Sstevel@tonic-gate {
2257c478bd9Sstevel@tonic-gate 	kthread_id_t tp;
2267c478bd9Sstevel@tonic-gate 	proc_t *p;
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate 	mutex_enter(&pidlock);
2297c478bd9Sstevel@tonic-gate 	tp = curthread->t_next;
2307c478bd9Sstevel@tonic-gate 	do {
2317c478bd9Sstevel@tonic-gate 		p = ttoproc(tp);
2327c478bd9Sstevel@tonic-gate 		/*
2337c478bd9Sstevel@tonic-gate 		 * kernel threads are callback'ed rather than setrun.
2347c478bd9Sstevel@tonic-gate 		 */
2357c478bd9Sstevel@tonic-gate 		if (ttoproc(tp)->p_as == &kas) continue;
2367c478bd9Sstevel@tonic-gate 		/*
2377c478bd9Sstevel@tonic-gate 		 * t_proc_flag should have been cleared. Just to make sure here
2387c478bd9Sstevel@tonic-gate 		 */
2397c478bd9Sstevel@tonic-gate 		mutex_enter(&p->p_lock);
2407c478bd9Sstevel@tonic-gate 		tp->t_proc_flag &= ~TP_CHKPT;
2417c478bd9Sstevel@tonic-gate 		mutex_exit(&p->p_lock);
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate 		thread_lock(tp);
2447c478bd9Sstevel@tonic-gate 		if (CPR_ISTOPPED(tp)) {
2457c478bd9Sstevel@tonic-gate 
2467c478bd9Sstevel@tonic-gate 			/*
2477c478bd9Sstevel@tonic-gate 			 * put it back on the runq
2487c478bd9Sstevel@tonic-gate 			 */
2497c478bd9Sstevel@tonic-gate 			tp->t_schedflag |= TS_RESUME;
2507c478bd9Sstevel@tonic-gate 			setrun_locked(tp);
2517c478bd9Sstevel@tonic-gate 		}
2527c478bd9Sstevel@tonic-gate 		thread_unlock(tp);
2537c478bd9Sstevel@tonic-gate 		/*
2547c478bd9Sstevel@tonic-gate 		 * DEBUG - Keep track of current and next thread pointer.
2557c478bd9Sstevel@tonic-gate 		 */
2567c478bd9Sstevel@tonic-gate 	} while ((tp = tp->t_next) != curthread);
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate 	mutex_exit(&pidlock);
2597c478bd9Sstevel@tonic-gate }
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate /*
2637c478bd9Sstevel@tonic-gate  * re/start kernel threads
2647c478bd9Sstevel@tonic-gate  */
2657c478bd9Sstevel@tonic-gate void
cpr_start_kernel_threads(void)2667c478bd9Sstevel@tonic-gate cpr_start_kernel_threads(void)
2677c478bd9Sstevel@tonic-gate {
268ae115bc7Smrj 	CPR_DEBUG(CPR_DEBUG1, "starting kernel daemons...");
2697c478bd9Sstevel@tonic-gate 	(void) callb_execute_class(CB_CL_CPR_DAEMON, CB_CODE_CPR_RESUME);
270ae115bc7Smrj 	CPR_DEBUG(CPR_DEBUG1, "done\n");
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate 	/* see table lock below */
2737c478bd9Sstevel@tonic-gate 	callb_unlock_table();
2747c478bd9Sstevel@tonic-gate }
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate /*
2787c478bd9Sstevel@tonic-gate  * Stop kernel threads by using the callback mechanism.  If any thread
2797c478bd9Sstevel@tonic-gate  * cannot be stopped, return failure.
2807c478bd9Sstevel@tonic-gate  */
2817c478bd9Sstevel@tonic-gate int
cpr_stop_kernel_threads(void)2827c478bd9Sstevel@tonic-gate cpr_stop_kernel_threads(void)
2837c478bd9Sstevel@tonic-gate {
2847c478bd9Sstevel@tonic-gate 	caddr_t	name;
2857c478bd9Sstevel@tonic-gate 
2867c478bd9Sstevel@tonic-gate 	callb_lock_table();	/* Note: we unlock the table in resume. */
2877c478bd9Sstevel@tonic-gate 
288ae115bc7Smrj 	CPR_DEBUG(CPR_DEBUG1, "stopping kernel daemons...");
2897c478bd9Sstevel@tonic-gate 	if ((name = callb_execute_class(CB_CL_CPR_DAEMON,
2907c478bd9Sstevel@tonic-gate 	    CB_CODE_CPR_CHKPT)) != (caddr_t)NULL) {
2917c478bd9Sstevel@tonic-gate 		cpr_err(CE_WARN,
2927c478bd9Sstevel@tonic-gate 		    "Could not stop \"%s\" kernel thread.  "
2937c478bd9Sstevel@tonic-gate 		    "Please try again later.", name);
2947c478bd9Sstevel@tonic-gate 		return (EBUSY);
2957c478bd9Sstevel@tonic-gate 	}
2967c478bd9Sstevel@tonic-gate 
2972df1fe9cSrandyf 	CPR_DEBUG(CPR_DEBUG1, ("done\n"));
2982df1fe9cSrandyf 	return (0);
2992df1fe9cSrandyf }
3002df1fe9cSrandyf 
3012df1fe9cSrandyf /*
3022df1fe9cSrandyf  * Check to see that kernel threads are stopped.
3032df1fe9cSrandyf  * This should be called while CPU's are paused, and the caller is
3042df1fe9cSrandyf  * effectively running single user, or else we are virtually guaranteed
3052df1fe9cSrandyf  * to fail.  The routine should not ASSERT on the paused state or spl
3062df1fe9cSrandyf  * level, as there may be a use for this to verify that things are running
3072df1fe9cSrandyf  * again.
3082df1fe9cSrandyf  */
3092df1fe9cSrandyf int
cpr_threads_are_stopped(void)3102df1fe9cSrandyf cpr_threads_are_stopped(void)
3112df1fe9cSrandyf {
3122df1fe9cSrandyf 	caddr_t	name;
3132df1fe9cSrandyf 	kthread_id_t tp;
3142df1fe9cSrandyf 	proc_t *p;
3152df1fe9cSrandyf 
3167c478bd9Sstevel@tonic-gate 	/*
3177c478bd9Sstevel@tonic-gate 	 * We think we stopped all the kernel threads.  Just in case
3187c478bd9Sstevel@tonic-gate 	 * someone is not playing by the rules, take a spin through
3197c478bd9Sstevel@tonic-gate 	 * the threadlist and see if we can account for everybody.
3207c478bd9Sstevel@tonic-gate 	 */
3217c478bd9Sstevel@tonic-gate 	mutex_enter(&pidlock);
3227c478bd9Sstevel@tonic-gate 	tp = curthread->t_next;
3237c478bd9Sstevel@tonic-gate 	do {
3247c478bd9Sstevel@tonic-gate 		p = ttoproc(tp);
3257c478bd9Sstevel@tonic-gate 		if (p->p_as != &kas)
3267c478bd9Sstevel@tonic-gate 			continue;
3277c478bd9Sstevel@tonic-gate 
3287c478bd9Sstevel@tonic-gate 		if (tp->t_flag & T_INTR_THREAD)
3297c478bd9Sstevel@tonic-gate 			continue;
3307c478bd9Sstevel@tonic-gate 
3317c478bd9Sstevel@tonic-gate 		if (! callb_is_stopped(tp, &name)) {
3327c478bd9Sstevel@tonic-gate 			mutex_exit(&pidlock);
3337c478bd9Sstevel@tonic-gate 			cpr_err(CE_WARN,
3347c478bd9Sstevel@tonic-gate 			    "\"%s\" kernel thread not stopped.", name);
3357c478bd9Sstevel@tonic-gate 			return (EBUSY);
3367c478bd9Sstevel@tonic-gate 		}
3377c478bd9Sstevel@tonic-gate 	} while ((tp = tp->t_next) != curthread);
3387c478bd9Sstevel@tonic-gate 
3392df1fe9cSrandyf 	mutex_exit(&pidlock);
3407c478bd9Sstevel@tonic-gate 	return (0);
3417c478bd9Sstevel@tonic-gate }
342