From owner-freebsd-dtrace@FreeBSD.ORG Tue Sep 16 02:59:53 2014 Return-Path: Delivered-To: freebsd-dtrace@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 A2B2556D for ; Tue, 16 Sep 2014 02:59:53 +0000 (UTC) Received: from mail-la0-x234.google.com (mail-la0-x234.google.com [IPv6:2a00:1450:4010:c03::234]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 01F83640 for ; Tue, 16 Sep 2014 02:59:52 +0000 (UTC) Received: by mail-la0-f52.google.com with SMTP id gq15so3224190lab.25 for ; Mon, 15 Sep 2014 19:59:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=delphix.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Acp2PpEfglERLCcGmC6oz3isxgDG/QV38pcx+pONJn8=; b=Tw1NREm+m1M3RJunpxgjWCpBDc1D9gGeyc229FhY0PLkzvJj95JR75FHw8hF+4zwbh YMfaGjhscU2hfoI33413+Ea/S3NmpXZ1Zrn8ZZ5OD5f8gY3yhvFosrIsXENKmnwV6bkC AweEr4EHElE05tztcTqX+koKBQbEXf6ytRqgI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=Acp2PpEfglERLCcGmC6oz3isxgDG/QV38pcx+pONJn8=; b=IdGP6U9vJJSFEdGuOmiC11+7lVEfO2C3fVGQRlLHwf2+B+bAlocPppIcRkZDXAmiZX CIviyY0UftGzn5o+BNWxtyF14bOWaYEzu2EX509NwPaie6rcbnSwhtiz/wsHjkMU/gFu lzHrOdyrW0yVqpJh1NJ/qGBbP3f/l7+VDtXzI5BVWXB7eDRbeNUMjJ3aJLcfu4pYZuht 7kx4q/i+G/VmWeQlCf2scXIhyASQwSBzARKiA3qCnM0zytol9t7sZ0YKKLLe2VJ333kJ 3VrEyuSqApJn841g8Q0uLwFK42h8LQUlfVnZGC8xzpfGBB2lMvOI2R8xHlg7k8ZqiTHw dbmA== X-Gm-Message-State: ALoCoQlrRgV9tz2LAk39pmAKLLffzgYYfQscHgCSkAz6KWcas+dtyzbKvJdQNnvgtfGzWjluqa3r MIME-Version: 1.0 X-Received: by 10.112.118.141 with SMTP id km13mr31205644lbb.37.1410836390629; Mon, 15 Sep 2014 19:59:50 -0700 (PDT) Received: by 10.25.170.148 with HTTP; Mon, 15 Sep 2014 19:59:50 -0700 (PDT) In-Reply-To: References: Date: Mon, 15 Sep 2014 19:59:50 -0700 Message-ID: Subject: Re: ZFS SET_ERROR dtrace probe possible under FreeBSD? From: Matthew Ahrens To: Steven Hartland Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: hackers@freebsd.org, freebsd-dtrace@freebsd.org X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Sep 2014 02:59:53 -0000 Disclaimer: I'm not an expert in FreeBSD dtrace. It looks like the FreeBSD kernel uses these declaration for kernel SDT probes, in sdt.h: 333 #*define* DTRACE_PROBE1 (name , type0 , arg0 ) \334 DTRACE_PROBE_IMPL_START (name , arg0 , 0, 0, 0, 0) \335 SDT_PROBE_ARGTYPE (sdt , , , name , 0, #type0 , NULL ); \336 DTRACE_PROBE_IMPL_END 324 #*define* DTRACE_PROBE_IMPL_START (name , arg0 , arg1 , arg2 , arg3 , arg4 ) *do* { \325 *static* SDT_PROBE_DEFINE (sdt , , , name ); \326 SDT_PROBE (sdt , , , name , arg0 , arg1 , arg2 , arg3 , arg4 );327 #*define* DTRACE_PROBE_IMPL_END } *while* (0) 163 #*define* SDT_PROBE (prov , mod , func , name , arg0 , arg1 , arg2 , arg3 , arg4 ) *do* { \164 *if* (sdt_ ##prov ##_##mod ##_##func ##_##name ->id ) \165 (*sdt_probe_func )(sdt_ ##prov ##_##mod ##_##func ##_##name ->id , \166 (uintptr_t ) arg0 , (uintptr_t ) arg1 , (uintptr_t ) arg2 , \167 (uintptr_t ) arg3 , (uintptr_t ) arg4 ); \168 } *while* (0) To do the equivalent "extra static" magic, you will need to expand out the DTRACE_PROBE1 macro. I think it should look something like: SDT_PROBE_DEFINE1(sdt, zfs, , set__error, "int"); #define SET_ERROR(err) \ ((sdt_sdt_zfs__set__error->id && \ (*sdt_probe_func)(sdt_sdt_zfs__set__error->id, (uintptr_t)err, 0, 0, 0, 0)), \ err) Note that SET_ERROR is an expansion of SDT_PROBE, but rewritten to be a single statement, so that we can do the same trick with the comma operator. --matt On Mon, Sep 15, 2014 at 7:03 PM, Steven Hartland wrote: > The following commit added SET_ERROR dtrace probes to illumos > https://github.com/illumos/illumos-gate/commit/be6fd75 > > Now we have all the SET_ERROR calls but the FreeBSD's ZFS implementation > but our SET_ERROR in sys/cddl/compat/opensolaris/sys/sdt.h is simply: > #define SET_ERROR(err) (err) > > I tried using the illumos version but that resulted being unable > to mount ZFS root, so clearly not right. > > /* > * the set-error SDT probe is extra static, in that we declare its fake > * function literally, rather than with the DTRACE_PROBE1() macro. This is > * necessary so that SET_ERROR() can evaluate to a value, which wouldn't > * be possible if it required multiple statements (to declare the function > * and then call it). > * > * SET_ERROR() uses the comma operator so that it can be used without much > * additional code. For example, "return (EINVAL);" becomes > * "return (SET_ERROR(EINVAL));". Note that the argument will be evaluated > * twice, so it should not have side effects (e.g. something like: > * "return (SET_ERROR(log_error(EINVAL, info)));" would log the error > twice). > */ > extern void __dtrace_probe_set__error(uintptr_t); > #define SET_ERROR(err) (__dtrace_probe_set__error(err), err) > > > For those that know the the ins and outs of our dtrace is it > possible for us to add support for this trace point? > > Regards > Steve > _______________________________________________ > freebsd-dtrace@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace > To unsubscribe, send any mail to "freebsd-dtrace-unsubscribe@freebsd.org" >