From owner-svn-src-all@FreeBSD.ORG Mon Nov 22 10:42:36 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C91AE106564A; Mon, 22 Nov 2010 10:42:36 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 5A73F8FC17; Mon, 22 Nov 2010 10:42:35 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id oAMAgWWb071468 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 22 Nov 2010 12:42:32 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id oAMAgWqn090688; Mon, 22 Nov 2010 12:42:32 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id oAMAgWhq090687; Mon, 22 Nov 2010 12:42:32 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 22 Nov 2010 12:42:32 +0200 From: Kostik Belousov To: Alexander Leidinger Message-ID: <20101122104232.GY2392@deviant.kiev.zoral.com.ua> References: <201011220907.oAM970To084256@svn.freebsd.org> <20101122093134.GU2392@deviant.kiev.zoral.com.ua> <20101122111306.16504je0tt7xe5us@webmail.leidinger.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="YYyN6dyDU9bDiN2J" Content-Disposition: inline In-Reply-To: <20101122111306.16504je0tt7xe5us@webmail.leidinger.net> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_05, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r215664 - in head/sys: compat/linux kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Nov 2010 10:42:36 -0000 --YYyN6dyDU9bDiN2J Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Nov 22, 2010 at 11:13:06AM +0100, Alexander Leidinger wrote: > Quoting Kostik Belousov (from Mon, 22 Nov 2010 =20 > 11:31:34 +0200): >=20 > >On Mon, Nov 22, 2010 at 09:07:00AM +0000, Alexander Leidinger wrote: > >>Author: netchild > >>Date: Mon Nov 22 09:06:59 2010 > >>New Revision: 215664 > >>URL: http://svn.freebsd.org/changeset/base/215664 > >> > >>Log: > >> By using the 32-bit Linux version of Sun's Java Development Kit 1.6 > >> on FreeBSD (amd64), invocations of "javac" (or "java") eventually > >> end with the output of "Killed" and exit code 137. >=20 >=20 > >>@@ -196,6 +198,12 @@ linux_proc_exit(void *arg __unused, stru > >> } else > >> EMUL_SHARED_WUNLOCK(&emul_shared_lock); > >> > >>+ if ((shared_flags & EMUL_SHARED_HASXSTAT) !=3D 0) { > >>+ PROC_LOCK(p); > >>+ p->p_xstat =3D shared_xstat; > >>+ PROC_UNLOCK(p); > >>+ } > >Why is process lock taken there ? The assignment to u_short inside the > >properly aligned structure is atomic on all supported architectures, and > >the thread that should see side-effect of assignment is the same thread > >that does assignment. >=20 > Change below. >=20 > >>+ > >> if (child_clear_tid !=3D NULL) { > >> struct linux_sys_futex_args cup; > >> int null =3D 0; > >>@@ -257,6 +265,9 @@ linux_proc_exec(void *arg __unused, stru > >> if (__predict_false(imgp->sysent =3D=3D &elf_linux_sysvec > >> && p->p_sysent !=3D &elf_linux_sysvec)) > >> linux_proc_init(FIRST_THREAD_IN_PROC(p), p->p_pid, 0); > >>+ if (__predict_false(p->p_sysent =3D=3D &elf_linux_sysvec)) > >>+ /* Kill threads regardless of imgp->sysent value */ > >>+ linux_kill_threads(FIRST_THREAD_IN_PROC(p), SIGKILL); > >This is better expressed by > > if ((p->p_sysent->sv_flags & SV_ABI_MASK) =3D=3D SV_ABI_LINUX) >=20 > Is this OK for you? > ---snip--- > Index: compat/linux/linux_emul.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 > --- compat/linux/linux_emul.c (Revision 215664) > +++ compat/linux/linux_emul.c (Arbeitskopie) > @@ -198,11 +198,8 @@ > } else > EMUL_SHARED_WUNLOCK(&emul_shared_lock); >=20 > - if ((shared_flags & EMUL_SHARED_HASXSTAT) !=3D 0) { > - PROC_LOCK(p); > + if ((shared_flags & EMUL_SHARED_HASXSTAT) !=3D 0) > p->p_xstat =3D shared_xstat; > - PROC_UNLOCK(p); > - } >=20 > if (child_clear_tid !=3D NULL) { > struct linux_sys_futex_args cup; > @@ -265,7 +262,8 @@ > if (__predict_false(imgp->sysent =3D=3D &elf_linux_sysvec > && p->p_sysent !=3D &elf_linux_sysvec)) > linux_proc_init(FIRST_THREAD_IN_PROC(p), p->p_pid, 0); > - if (__predict_false(p->p_sysent =3D=3D &elf_linux_sysvec)) > + if (__predict_false((p->p_sysent->sv_flags & SV_ABI_MASK) =3D=3D > + SV_ABI_LINUX)) > /* Kill threads regardless of imgp->sysent value */ > linux_kill_threads(FIRST_THREAD_IN_PROC(p), SIGKILL); > if (__predict_false(imgp->sysent !=3D &elf_linux_sysvec > ---snip--- Yes. >=20 > >Regardless of this mostly cosmetic issue, this is racy. Other > >linux thread in the same process might do an execve(3). > >More, if execve(3) call fails, then you return into the process > >that lacks all threads except the one that called execve(3). >=20 > How critical is this in your opinion (relative to the issue this patch = =20 > is fixing)? Do you prefer a backout or do you think the probability =20 > that the someone wins the race is low enough? >=20 > Do you see a solution for the race? I did not asked for backout, nor I am asking now. Most likely, the semantic of linux thread groups cannot be implemented by only using event handlers that linux.ko hooks now. How linux handles single-threading when doing execve(2) from multithreaded process ? --YYyN6dyDU9bDiN2J Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAkzqSRcACgkQC3+MBN1Mb4isEACePbwrVD5CTKib0MUfuA+mq5bb OP4AoPQVUNCtn7peWPyed7S0wXADtaiV =Xxmt -----END PGP SIGNATURE----- --YYyN6dyDU9bDiN2J--