Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Jul 2011 16:33:42 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Petr Salinger <Petr.Salinger@seznam.cz>
Cc:        freebsd-hackers@freebsd.org, Robert Millan <rmh@debian.org>, current@freebsd.org
Subject:   Re: [PATCH] Improve LinuxThreads compatibility in rfork()
Message-ID:  <20110711133342.GT43872@deviant.kiev.zoral.com.ua>
In-Reply-To: <alpine.LRH.2.02.1107111455230.7134@sci.felk.cvut.cz>
References:  <CAOfDtXMe_pkBdAFpUdvzmfs38Re=nw_YBz4w0Va0naEcuak7iw@mail.gmail.com> <20110711123332.GS43872@deviant.kiev.zoral.com.ua> <alpine.LRH.2.02.1107111455230.7134@sci.felk.cvut.cz>

next in thread | previous in thread | raw e-mail | index | archive | help

--skzcsJvRJWOW8YcK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Jul 11, 2011 at 03:27:56PM +0200, Petr Salinger wrote:
> >>This patch made by Petr Salinger improves compatibility with
> >>LinuxThreads in rfork() syscall.  The Linux clone() implementation
> >>allows specifying the signal sent to parent when child terminates
> >>(instead of SIGCHLD).
> >>
> >>As the threading implementation in Debian GNU/kFreeBSD is
> >>LinuxThreads-based, we had to diverge from upstream kFreeBSD ABI and
> >>implement this extension.
> >>
> >>I hope it is acceptable for you to use the same encoding, this way we
> >>would archieve ABI compatibility to run Debian GNU/kFreeBSD inside a
> >>chroot/jail on top of a FreeBSD system.
> >>
> >>Thanks for considering
> >>
> >>--
> >>Robert Millan
> >
> >>--- a/sys/kern/kern_fork.c
> >>+++ b/sys/kern/kern_fork.c
> >>@@ -477,7 +477,13 @@
> >> 		p2->p_sigacts =3D newsigacts;
> >> 	}
> >> 	if (flags & RFLINUXTHPN)
> >>-	        p2->p_sigparent =3D SIGUSR1;
> >>+	{
> >>+		int sig;
> >>+		sig =3D RFTHPNSIGNUM(flags);
> >>+	        if (sig =3D=3D 0) sig =3D SIGUSR1;
> >>+	        if (sig =3D=3D SIGCHLD) sig =3D 0;
> >>+	        p2->p_sigparent =3D sig;
> >>+	}
> >> 	else
> >> 	        p2->p_sigparent =3D SIGCHLD;
> >>
> >>--- a/sys/sys/unistd.h
> >>+++ b/sys/sys/unistd.h
> >>@@ -182,6 +182,10 @@
> >> #define	RFHIGHPID	(1<<18)	/* use a pid higher than 10=20
> >> (idleproc) */
> >> #define	RFPPWAIT	(1<<31)	/* parent sleeps until child exits=20
> >> (vfork) */
> >> #define	RFKERNELONLY	(RFSTOPPED | RFHIGHPID | RFPPWAIT)
> >>+#define RFTHPNSHIFT	24	/* reserve bits 24-30 */
> >>+#define RFTHPNMASK	0x7F    /* for compatibility with=20
> >>linuxthreads/clone()   */
> >>+				/* allow to specify  "clone exit parent=20
> >>notification" signal */
> >>+#define RFTHPNSIGNUM(flags)	(((flags) >> RFTHPNSHIFT) & RFTHPNMASK)
> >>
> >> #endif /* __BSD_VISIBLE */
> >>
> >I looked at this patch some time ago already.
> >
> >Can you, please, describe the reasoning behind the
> >>+	        if (sig =3D=3D SIGCHLD) sig =3D 0;
> >line ?
>=20
> The main reason is backward compatibility.
> The original FreeBSD code allows only to select between
> SIGUSR1 or SIGCHLD signals.
>=20
> The our extension changes meaning of RFLINUXTHPN to select signal based o=
n=20
> bits 24-30 of passed flags instead of using SIGUSR1 every time.
>=20
> When the passed "signal" number is zero, it should behave identically
> on plain FreeBSD and in our environment, therefore SIGUSR1 is selected.
> The assumption is (have been) that (yet) undefined bits are zero.
> That way we are backward compatible with original FreeBSD.
>=20
> We still need an alternative way to select "none signal is sent"
> after child exit (under linux #0 is used).
>=20
> The SIGCHLD can be "selected" (also on original FreeBSD) by not specifyin=
g=20
> RFLINUXTHPN, therefore combination of RFLINUXTHPN and passed "signal"=20
> number SIGCHLD is (have been) used for "none signal".
>=20
> BTW, the opposite side is in
>=20
> http://anonscm.debian.org/viewvc/glibc-bsd/trunk/glibc-ports/kfreebsd/clo=
ne.c?view=3Dmarkup

I shall state that the sig =3D=3D SIGCHLD case is ugly. Having the separate
flag "do not send signal to the parent" would be much less clumsy.
What are the requirements for the ABI stability for Debian/kFreeBSD ?
Can this be fixed now, or is it too late ?

Would you care to update the rfork(2) man page ?
Also, it would be ideal to reformat the kern_fork.c change according
to our style(9).

--skzcsJvRJWOW8YcK
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (FreeBSD)

iEYEARECAAYFAk4a+7YACgkQC3+MBN1Mb4gmgwCfUVmivVjIURnzUngyWGE5P9Mf
uEoAn3wVaWVpnufNVnAXpok+rJJWwPzB
=dmIw
-----END PGP SIGNATURE-----

--skzcsJvRJWOW8YcK--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110711133342.GT43872>