cvs commit: src/sys/alpha/alpha trap.c src/sys/i386/i386 trap.c src/sys/ia64/ia64 trap.c src/sys/kern kern_thread.c src/sys/sparc64/sparc64 trap.c

David Xu davidxu at freebsd.org
Fri Apr 18 19:31:15 PDT 2003


er, I found some code in i386/i386/trap.c:

PROC_LOCK(p);
		if ((p->p_flag & P_WEXIT) && (p->p_singlethread !=3D td)) {
			mtx_lock_spin(&sched_lock);
			thread_exit();
			/* NOTREACHED */
		}
PROC_UNLOCK(p);

The P_WEXIT and p_singlethread will never be set at same
time. see kern_exit.c. so the code never be executed.=20
replacing P_WEXIT with P_SINGLE_EXIT will work,
and because 1:1 thread borrows KSE code, so you now need code
like this:

PROC_LOCK(p);
if ((p->p_flag & P_SINGLE_EXIT) && (p->p_singlethread !=3D td)) {
mtx_lock_spin(&sched_lock);
if (p->p_flag & P_THREADED)
    thread_exit();
else
    thr_exit();
/* NOTREACHED */
}
PROC_UNLOCK(p);

I suggest remove such code from trap.c, just keep it in kernel
thread control code (e.g kern_thread.c or kern_thr.c) to reduce
maintain overhead.

David Xu

----- Original Message -----=20
From: "John Baldwin" <jhb at FreeBSD.org>
To: <src-committers at FreeBSD.org>; <cvs-src at FreeBSD.org>; =
<cvs-all at FreeBSD.org>
Sent: Saturday, April 19, 2003 4:20 AM
Subject: cvs commit: src/sys/alpha/alpha trap.c src/sys/i386/i386 trap.c =
src/sys/ia64/ia64 trap.c src/sys/kern kern_thread.c =
src/sys/sparc64/sparc64 trap.c


> jhb         2003/04/18 13:20:00 PDT
>=20
>   FreeBSD src repository
>=20
>   Modified files:
>     sys/alpha/alpha      trap.c=20
>     sys/i386/i386        trap.c=20
>     sys/ia64/ia64        trap.c=20
>     sys/kern             kern_thread.c=20
>     sys/sparc64/sparc64  trap.c=20
>   Log:
>   Use the proc lock to protect p_singlethread and a P_WEXIT test.  =
This
>   fixes a couple of potential KSE panics on non-i386 arch's that =
weren't
>   holding the proc lock when calling thread_exit().
>  =20
>   Revision  Changes    Path
>   1.111     +2 -1      src/sys/alpha/alpha/trap.c
>   1.246     +2 -2      src/sys/i386/i386/trap.c
>   1.73      +3 -1      src/sys/ia64/ia64/trap.c
>   1.117     +2 -2      src/sys/kern/kern_thread.c
>   1.59      +2 -1      src/sys/sparc64/sparc64/trap.c



More information about the cvs-src mailing list