Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Apr 2003 10:35:44 +0800
From:      "David Xu" <davidxu@freebsd.org>
To:        "John Baldwin" <jhb@freebsd.org>, <src-committers@freebsd.org>, <cvs-src@freebsd.org>, <cvs-all@freebsd.org>
Subject:   Re: 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
Message-ID:  <006c01c3061c$61a7e570$0701a8c0@tiger>
References:  <200304182020.h3IKK02F035021@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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@FreeBSD.org>
To: <src-committers@FreeBSD.org>; <cvs-src@FreeBSD.org>; =
<cvs-all@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?006c01c3061c$61a7e570$0701a8c0>