Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Aug 2010 14:48:18 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Rui Paulo <rpaulo@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r211738 - head/sys/cddl/contrib/opensolaris/uts/common/dtrace
Message-ID:  <20100824114818.GJ2396@deviant.kiev.zoral.com.ua>
In-Reply-To: <201008241111.o7OBBwvn074031@svn.freebsd.org>
References:  <201008241111.o7OBBwvn074031@svn.freebsd.org>

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

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

On Tue, Aug 24, 2010 at 11:11:58AM +0000, Rui Paulo wrote:
> Author: rpaulo
> Date: Tue Aug 24 11:11:58 2010
> New Revision: 211738
> URL: http://svn.freebsd.org/changeset/base/211738
>=20
> Log:
>   Port the fasttrap provider to FreeBSD. This provider is responsible for
>   injecting debugging probes in the userland programs and is the basis for
>   the pid provider and the usdt provider.
>  =20
>   Sponsored by:	The FreeBSD Foundation
>=20
> Modified:
>   head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
>=20
> Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.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/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c	Tue Au=
g 24 09:57:06 2010	(r211737)
> +++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c	Tue Au=
g 24 11:11:58 2010	(r211738)
> @@ -17,6 +17,10 @@
>   * information: Portions Copyright [yyyy] [name of copyright owner]
>   *
>   * CDDL HEADER END
> + *
> + * Portions Copyright 2010 The FreeBSD Foundation
> + *
> + * $FreeBSD$
>   */
> =20
>  /*
> @@ -24,7 +28,9 @@
>   * Use is subject to license terms.
>   */
> =20
> +#if defined(sun)
>  #pragma ident	"%Z%%M%	%I%	%E% SMI"
> +#endif
> =20
>  #include <sys/atomic.h>
>  #include <sys/errno.h>
> @@ -32,11 +38,15 @@
>  #include <sys/modctl.h>
>  #include <sys/conf.h>
>  #include <sys/systm.h>
> +#if defined(sun)
>  #include <sys/ddi.h>
> +#endif
>  #include <sys/sunddi.h>
>  #include <sys/cpuvar.h>
>  #include <sys/kmem.h>
> +#if defined(sun)
>  #include <sys/strsubr.h>
> +#endif
>  #include <sys/fasttrap.h>
>  #include <sys/fasttrap_impl.h>
>  #include <sys/fasttrap_isa.h>
> @@ -44,9 +54,17 @@
>  #include <sys/dtrace_impl.h>
>  #include <sys/sysmacros.h>
>  #include <sys/proc.h>
> -#include <sys/priv.h>
>  #include <sys/policy.h>
> +#if defined(sun)
>  #include <util/qsort.h>
> +#endif
> +#include <sys/mutex.h>
> +#include <sys/kernel.h>
> +#if !defined(sun)
> +#include <sys/user.h>
> +#include <sys/dtrace_bsd.h>
> +#include <cddl/dev/dtrace/dtrace_cddl.h>
> +#endif
> =20
>  /*
>   * User-Land Trap-Based Tracing
> @@ -125,11 +143,20 @@
>   *	never hold the provider lock and creation lock simultaneously
>   */
> =20
> -static dev_info_t *fasttrap_devi;
> +static d_open_t fasttrap_open;
> +static d_ioctl_t fasttrap_ioctl;
> +
> +static struct cdevsw fasttrap_cdevsw =3D {
> +	.d_version	=3D D_VERSION,
> +	.d_open		=3D fasttrap_open,
> +	.d_ioctl	=3D fasttrap_ioctl,
> +	.d_name		=3D "fasttrap",
> +};
> +static struct cdev *fasttrap_cdev;
>  static dtrace_meta_provider_id_t fasttrap_meta_id;
> =20
> -static timeout_id_t fasttrap_timeout;
> -static kmutex_t fasttrap_cleanup_mtx;
> +static struct callout fasttrap_timeout;
> +static struct mtx fasttrap_cleanup_mtx;
>  static uint_t fasttrap_cleanup_work;
> =20
>  /*
> @@ -229,6 +256,7 @@ fasttrap_hash_str(const char *p)
>  void
>  fasttrap_sigtrap(proc_t *p, kthread_t *t, uintptr_t pc)
>  {
> +#if defined(sun)
>  	sigqueue_t *sqp =3D kmem_zalloc(sizeof (sigqueue_t), KM_SLEEP);
> =20
>  	sqp->sq_info.si_signo =3D SIGTRAP;
> @@ -241,6 +269,17 @@ fasttrap_sigtrap(proc_t *p, kthread_t *t
> =20
>  	if (t !=3D NULL)
>  		aston(t);
> +#else
> +	ksiginfo_t *ksi =3D kmem_zalloc(sizeof (ksiginfo_t), KM_SLEEP);
> +
> +	ksiginfo_init(ksi);
> +	ksi->ksi_signo =3D SIGTRAP;
> +	ksi->ksi_code =3D TRAP_DTRACE;
> +	ksi->ksi_addr =3D (caddr_t)pc;
> +	PROC_LOCK(p);
> +	(void) pksignal(p, SIGTRAP, ksi);
> +	PROC_UNLOCK(p);
> +#endif
=46rom the quick look at the solaris part of the code, I think that the
signal should be posted to the specific thread, and not to the process.

>  }
> =20
>  /*
> @@ -250,17 +289,24 @@ fasttrap_sigtrap(proc_t *p, kthread_t *t
>  static void
>  fasttrap_mod_barrier(uint64_t gen)
>  {
> +#if defined(sun)
>  	int i;
> +#endif
> =20
>  	if (gen < fasttrap_mod_gen)
>  		return;
> =20
>  	fasttrap_mod_gen++;
> =20
> +#if defined(sun)
>  	for (i =3D 0; i < NCPU; i++) {
>  		mutex_enter(&cpu_core[i].cpuc_pid_lock);
>  		mutex_exit(&cpu_core[i].cpuc_pid_lock);
>  	}
> +#else
> +	/* XXX */
> +	__asm __volatile("": : :"memory");
Indeed XXX. Semantic of acquiring/releasing a mutex, even on Solaris,
is much stricter then performing compiler-level memory barrier.

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

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

iEYEARECAAYFAkxzsYIACgkQC3+MBN1Mb4hPTQCfXTK0rzPjPNaWxkA9chaufUH/
6mUAoMIvXOY2syzVf2NhYBANbbwj4tjs
=Nfyt
-----END PGP SIGNATURE-----

--rkKICwW9XwtbZ5OV--



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