From owner-svn-src-head@FreeBSD.ORG Wed Sep 3 15:06:11 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7EF76E37 for ; Wed, 3 Sep 2014 15:06:11 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 60919176B for ; Wed, 3 Sep 2014 15:06:11 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.9/8.14.9) with ESMTP id s83F6BZe062790 for ; Wed, 3 Sep 2014 15:06:11 GMT (envelope-from bdrewery@freefall.freebsd.org) Received: (from bdrewery@localhost) by freefall.freebsd.org (8.14.9/8.14.9/Submit) id s83F6BcS062783 for svn-src-head@freebsd.org; Wed, 3 Sep 2014 15:06:11 GMT (envelope-from bdrewery) Received: (qmail 36553 invoked from network); 3 Sep 2014 10:06:09 -0500 Received: from unknown (HELO ?10.10.0.24?) (freebsd@shatow.net@10.10.0.24) by sweb.xzibition.com with ESMTPA; 3 Sep 2014 10:06:09 -0500 Message-ID: <54072E34.3080403@FreeBSD.org> Date: Wed, 03 Sep 2014 10:05:24 -0500 From: Bryan Drewery Organization: FreeBSD User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: Konstantin Belousov , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r271000 - head/sys/kern References: <201409030818.s838I8uY084843@svn.freebsd.org> In-Reply-To: <201409030818.s838I8uY084843@svn.freebsd.org> OpenPGP: id=6E4697CF; url=http://www.shatow.net/bryan/bryan2.asc Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="mv7p62cdxbHga8v6jLn38kEFvItCLoG9o" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Sep 2014 15:06:11 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --mv7p62cdxbHga8v6jLn38kEFvItCLoG9o Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 9/3/2014 3:18 AM, Konstantin Belousov wrote: > Author: kib > Date: Wed Sep 3 08:18:07 2014 > New Revision: 271000 > URL: http://svnweb.freebsd.org/changeset/base/271000 >=20 > Log: > Right now, thread_single(SINGLE_EXIT) returns after the p_numthreads > reaches 1. The p_numthreads counter is decremented in thread_exit() b= y > a call to thread_unlink(). This means that the exiting threads may > still execute on other CPUs when thread_single(SINGLE_EXIT) returns. > As result, vmspace could be destroyed while paging structures are > still used on other CPUs by exiting threads. > =20 > Delay the return from thread_single(SINGLE_EXIT) until all threads ar= e > really destroyed by thread_stash() after the last switch out. The > p_exitthreads counter already provides the required mechanism, move > the wait from the thread_wait() (which is called from wait(2) code) > into thread_single(). > =20 > Reported by: many (as "panic: pmap active ") > Reviewed by: alc, jhb > Tested by: pho > Sponsored by: The FreeBSD Foundation > MFC after: 1 week >=20 > Modified: > head/sys/kern/kern_thread.c >=20 > Modified: head/sys/kern/kern_thread.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/kern/kern_thread.c Wed Sep 3 08:14:07 2014 (r270999) > +++ head/sys/kern/kern_thread.c Wed Sep 3 08:18:07 2014 (r271000) > @@ -432,6 +432,7 @@ thread_exit(void) > */ > if (p->p_flag & P_HADTHREADS) { > if (p->p_numthreads > 1) { > + atomic_add_int(&td->td_proc->p_exitthreads, 1); > thread_unlink(td); > td2 =3D FIRST_THREAD_IN_PROC(p); > sched_exit_thread(td2, td); > @@ -452,7 +453,6 @@ thread_exit(void) > } > } > =20 > - atomic_add_int(&td->td_proc->p_exitthreads, 1); > PCPU_SET(deadthread, td); > } else { > /* > @@ -507,14 +507,12 @@ thread_wait(struct proc *p) > struct thread *td; > =20 > mtx_assert(&Giant, MA_NOTOWNED); > - KASSERT((p->p_numthreads =3D=3D 1), ("Multiple threads in wait1()"));= > + KASSERT((p->p_numthreads =3D=3D 1), ("multiple threads in thread_wait= ()")); > + KASSERT((p->p_exitthreads =3D=3D 0), ("p_exitthreads leaking")); > td =3D FIRST_THREAD_IN_PROC(p); > /* Lock the last thread so we spin until it exits cpu_throw(). */ > thread_lock(td); > thread_unlock(td); > - /* Wait for any remaining threads to exit cpu_throw(). */ > - while (p->p_exitthreads) > - sched_relinquish(curthread); > lock_profile_thread_exit(td); > cpuset_rel(td->td_cpuset); > td->td_cpuset =3D NULL; > @@ -722,6 +720,17 @@ stopme: > p->p_singlethread =3D NULL; > p->p_flag &=3D ~(P_STOPPED_SINGLE | P_SINGLE_EXIT); > thread_unthread(td); > + > + /* > + * Wait for any remaining threads to exit cpu_throw(). > + */ > + while (p->p_exitthreads !=3D 0) { > + PROC_SUNLOCK(p); > + PROC_UNLOCK(p); > + sched_relinquish(td); > + PROC_LOCK(p); > + PROC_SLOCK(p); > + } > } > PROC_SUNLOCK(p); > return (0); >=20 Thanks! --=20 Regards, Bryan Drewery --mv7p62cdxbHga8v6jLn38kEFvItCLoG9o Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) iQEcBAEBAgAGBQJUBy40AAoJEDXXcbtuRpfPgNIIAMcrjKmUsAr+qHsxaYGODJT+ wKHwdGwcNM3XuVXe8g8zG3/gyzYIvrWNuQyUKc0ZOewIhEgxUvHJz3WPB/IMV7zH cxH7R+W2sM/L+QUIbSEcpqe6YdogX8mzgzzmOxwKmN22HkE4RcaG5Dc7V3xmXs6v fnw1Ilbez0YCDXL1CpLSyc06cu11zTW5F/Fce798HdCyI0YQn1rxFbamfR5wdLLD gOeHFUgltZ7eMb6t7HEI101jrsh1qrsYpokPStA5pIdKhYK/rXKT+5LfTdrFl+Fz Ao5TX8NcmvgPwqrwBsLvV5ZMRPNOcgwkC3WurfhG3/uzm8F1Q655liXlU/Y6js0= =Eg8Q -----END PGP SIGNATURE----- --mv7p62cdxbHga8v6jLn38kEFvItCLoG9o--