From owner-svn-src-head@FreeBSD.ORG Tue Aug 24 11:59:35 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 738761065695; Tue, 24 Aug 2010 11:59:35 +0000 (UTC) (envelope-from rpaulo@freebsd.org) Received: from karen.lavabit.com (karen.lavabit.com [72.249.41.33]) by mx1.freebsd.org (Postfix) with ESMTP id 34A218FC20; Tue, 24 Aug 2010 11:59:35 +0000 (UTC) Received: from d.earth.lavabit.com (d.earth.lavabit.com [192.168.111.13]) by karen.lavabit.com (Postfix) with ESMTP id 6F0E624ED83; Tue, 24 Aug 2010 06:59:34 -0500 (CDT) Received: from 10.0.10.3 (221.163.108.93.rev.vodafone.pt [93.108.163.221]) by lavabit.com with ESMTP id 6STAX0DHCVY6; Tue, 24 Aug 2010 06:59:34 -0500 Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: text/plain; charset=us-ascii From: Rui Paulo In-Reply-To: <20100824114818.GJ2396@deviant.kiev.zoral.com.ua> Date: Tue, 24 Aug 2010 12:59:30 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <0329C085-13EF-47F1-B8BB-DB7679444FAE@freebsd.org> References: <201008241111.o7OBBwvn074031@svn.freebsd.org> <20100824114818.GJ2396@deviant.kiev.zoral.com.ua> To: Kostik Belousov X-Mailer: Apple Mail (2.1081) 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 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Tue, 24 Aug 2010 11:59:35 -0000 On 24 Aug 2010, at 12:48, Kostik Belousov wrote: > 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 Aug 24 09:57:06 2010 (r211737) >> +++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c = Tue Aug 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 >> #include >> @@ -32,11 +38,15 @@ >> #include >> #include >> #include >> +#if defined(sun) >> #include >> +#endif >> #include >> #include >> #include >> +#if defined(sun) >> #include >> +#endif >> #include >> #include >> #include >> @@ -44,9 +54,17 @@ >> #include >> #include >> #include >> -#include >> #include >> +#if defined(sun) >> #include >> +#endif >> +#include >> +#include >> +#if !defined(sun) >> +#include >> +#include >> +#include >> +#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 I'll use tdsignal, thanks. >> } >>=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. I don't know what kind of mutexes we have in FreeBSD to mimc this = behavior. Regards, -- Rui Paulo