From owner-freebsd-dtrace@FreeBSD.ORG Tue Sep 16 02:03:59 2014 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7ED6A9E; Tue, 16 Sep 2014 02:03:59 +0000 (UTC) Received: from smtp1.multiplay.co.uk (smtp1.multiplay.co.uk [85.236.96.35]) by mx1.freebsd.org (Postfix) with ESMTP id 4425DFDC; Tue, 16 Sep 2014 02:03:58 +0000 (UTC) Received: by smtp1.multiplay.co.uk (Postfix, from userid 65534) id C65B820E7088D; Tue, 16 Sep 2014 02:03:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.multiplay.co.uk X-Spam-Level: ** X-Spam-Status: No, score=2.2 required=8.0 tests=AWL,BAYES_00,DOS_OE_TO_MX, FSL_HELO_NON_FQDN_1,RDNS_DYNAMIC,STOX_REPLY_TYPE, STOX_REPLY_TYPE_WITHOUT_QUOTES autolearn=no version=3.3.1 Received: from r2d2 (82-69-141-170.dsl.in-addr.zen.co.uk [82.69.141.170]) by smtp1.multiplay.co.uk (Postfix) with ESMTP id 255E220E70886; Tue, 16 Sep 2014 02:03:55 +0000 (UTC) Message-ID: From: "Steven Hartland" To: Subject: ZFS SET_ERROR dtrace probe possible under FreeBSD? Date: Tue, 16 Sep 2014 03:03:51 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Cc: hackers@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:03:59 -0000 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 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" > From owner-freebsd-dtrace@FreeBSD.ORG Tue Sep 16 03:13:22 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 DB6D08B0; Tue, 16 Sep 2014 03:13:22 +0000 (UTC) Received: from mail-pd0-x22a.google.com (mail-pd0-x22a.google.com [IPv6:2607:f8b0:400e:c02::22a]) (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 A00D08BF; Tue, 16 Sep 2014 03:13:22 +0000 (UTC) Received: by mail-pd0-f170.google.com with SMTP id fp1so7708247pdb.1 for ; Mon, 15 Sep 2014 20:13:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=QMMYsCFVjzcAGS1Fm8gSJdKEH2u7fklKQcul7IXUo2Y=; b=fZ/ElARs9m3gPErSxdzyIGTs1Krv0dTE/+bAgv4zZ5GLnQxK7l7o32EFYUY1AJZQyG Mz4GJBC3k+ugUFTlSdgvn9E2LZ3NN2YjCwk91XlphC3wkNmURbGsfCu38KuOxf+shlAf XzraPHtvtzi87Hl+eQ62k2WyLasF2rScW6mC4YoBqlUQBY2sZxivavRf+Ycy8xIxNVpo gyjPTz4gVjq1mw3bPdwE/H4EIZ7Xy9+M18KxpT1/32sbH3erj7nsaU90pEw6j4jvqYZa +hmb3ACrKCK4OPBi5iv2vmtguhKXifKAWwp4BRIQ44hCtPRb8DwFQC4fH7FZi3xnUCy2 cjcQ== X-Received: by 10.66.182.227 with SMTP id eh3mr45375966pac.68.1410837202191; Mon, 15 Sep 2014 20:13:22 -0700 (PDT) Received: from charmander.picturesperfect.net (c-67-182-131-225.hsd1.wa.comcast.net. [67.182.131.225]) by mx.google.com with ESMTPSA id wc5sm13182102pab.2.2014.09.15.20.13.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Sep 2014 20:13:21 -0700 (PDT) Sender: Mark Johnston Date: Mon, 15 Sep 2014 20:13:19 -0700 From: Mark Johnston To: Matthew Ahrens Subject: Re: ZFS SET_ERROR dtrace probe possible under FreeBSD? Message-ID: <20140916031318.GB26720@charmander.picturesperfect.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Cc: Steven Hartland , 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 03:13:23 -0000 On Mon, Sep 15, 2014 at 07:59:50PM -0700, Matthew Ahrens wrote: > 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) I think it would need to be SDT_PROBE_DECLARE(sdt, , , set__error); #define SET_ERROR(err) ... in the compat sdt.h, and then kern_dtrace.c or so would contain SDT_PROBE_DEFINE1(sdt, , , set__error, "int"); Note that the module shouldn't be hard-coded - it'll be filled in when the probes are created by the SDT code. -Mark > > 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 From owner-freebsd-dtrace@FreeBSD.ORG Tue Sep 16 03:19:06 2014 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 387E89EF for ; Tue, 16 Sep 2014 03:19:06 +0000 (UTC) Received: from mail-lb0-x234.google.com (mail-lb0-x234.google.com [IPv6:2a00:1450:4010:c04::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 AD37E8F4 for ; Tue, 16 Sep 2014 03:19:05 +0000 (UTC) Received: by mail-lb0-f180.google.com with SMTP id b12so5615967lbj.25 for ; Mon, 15 Sep 2014 20:19:03 -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=tX5IM6J6fDWgZENsn/sayZndAj6bQxFNLbH52ADUWU4=; b=ZZTKXBckA/kH8djmpKX3czYaMCD1c92IkA9XSqvRdUiolt8nmOYDTxnkV6yEm1w/qE lK3KpGBKDFeB9XnvJZAHIWujNEfpHJYfMx9sM+usc1QxwUsZi0akLiGiyo0z2cb75EOH 3yIA43Ic++6HVxvKmiA4pDImWg7h2Pgafm1SE= 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=tX5IM6J6fDWgZENsn/sayZndAj6bQxFNLbH52ADUWU4=; b=CF9TIsx9ZDCQP9+hvJueLA2W6OWiYoYGToxr2GJ6XN1YHE5fwhWd/XXzmkXZO/Tg6/ BG9fsfrzeZseHAU0VN/63XoGAYuG+sNuyf3ApoD66UvCiBRMeFHrNQy/ShDiaNHo0NIf /YQi7bRpPY14FayKLUyvDE1dmYqt5w4zaxcLfb6vzZAF4U5jLd7tjY6vQCZd6wh2eq3h zxDC5TJJ3WLmoEdfwS5K/qli9W1mgnAAqut4JDhKIEP8GxQQfOdyHnK2M2gOCvVGCmnC vMQIwYwHbbfWPuO54OR/nOXbK/6B9A2LD72yroE/UoRzKYeQncyvIPfzrbYuPy2vC6qX 09fg== X-Gm-Message-State: ALoCoQnJFp6GRGMPEZcJesgP7FD28lD3s7HWpquA9aPoCvY5r3WiRuaCDTL0gfMZCboFrVS/PvNZ MIME-Version: 1.0 X-Received: by 10.112.4.33 with SMTP id h1mr30519046lbh.67.1410837543411; Mon, 15 Sep 2014 20:19:03 -0700 (PDT) Received: by 10.25.170.148 with HTTP; Mon, 15 Sep 2014 20:19:03 -0700 (PDT) In-Reply-To: <20140916031318.GB26720@charmander.picturesperfect.net> References: <20140916031318.GB26720@charmander.picturesperfect.net> Date: Mon, 15 Sep 2014 20:19:03 -0700 Message-ID: Subject: Re: ZFS SET_ERROR dtrace probe possible under FreeBSD? From: Matthew Ahrens To: Mark Johnston Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: Steven Hartland , 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 03:19:06 -0000 On Mon, Sep 15, 2014 at 8:13 PM, Mark Johnston wrote: > On Mon, Sep 15, 2014 at 07:59:50PM -0700, Matthew Ahrens wrote: > > 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: > ... > > > > 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) > > I think it would need to be > > SDT_PROBE_DECLARE(sdt, , , set__error); > > #define SET_ERROR(err) ... > > in the compat sdt.h, and then kern_dtrace.c or so would contain > > SDT_PROBE_DEFINE1(sdt, , , set__error, "int"); > > Note that the module shouldn't be hard-coded - it'll be filled in when > the probes are created by the SDT code. Ah, yes, that makes sense. --matt From owner-freebsd-dtrace@FreeBSD.ORG Tue Sep 16 10:05:27 2014 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8619BB6C; Tue, 16 Sep 2014 10:05:27 +0000 (UTC) Received: from smtp1.multiplay.co.uk (smtp1.multiplay.co.uk [85.236.96.35]) by mx1.freebsd.org (Postfix) with ESMTP id EE35918F; Tue, 16 Sep 2014 10:05:26 +0000 (UTC) Received: by smtp1.multiplay.co.uk (Postfix, from userid 65534) id F093320E7088F; Tue, 16 Sep 2014 10:05:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.multiplay.co.uk X-Spam-Level: * X-Spam-Status: No, score=1.3 required=8.0 tests=AWL,BAYES_00,DOS_OE_TO_MX, FSL_HELO_NON_FQDN_1,RDNS_DYNAMIC,STOX_REPLY_TYPE autolearn=no version=3.3.1 Received: from r2d2 (82-69-141-170.dsl.in-addr.zen.co.uk [82.69.141.170]) by smtp1.multiplay.co.uk (Postfix) with ESMTP id 1A4D720E70886; Tue, 16 Sep 2014 10:05:13 +0000 (UTC) Message-ID: From: "Steven Hartland" To: "Mark Johnston" , "Matthew Ahrens" References: <20140916031318.GB26720@charmander.picturesperfect.net> Subject: Re: ZFS SET_ERROR dtrace probe possible under FreeBSD? Date: Tue, 16 Sep 2014 11:05:09 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 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 10:05:27 -0000 ----- Original Message ----- From: "Mark Johnston" > On Mon, Sep 15, 2014 at 07:59:50PM -0700, Matthew Ahrens wrote: >> 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) > > I think it would need to be > > SDT_PROBE_DECLARE(sdt, , , set__error); > > #define SET_ERROR(err) ... > > in the compat sdt.h, and then kern_dtrace.c or so would contain > > SDT_PROBE_DEFINE1(sdt, , , set__error, "int"); > > Note that the module shouldn't be hard-coded - it'll be filled in when > the probes are created by the SDT code. Thanks guys for the pointers, I tried the following slightly ammended from Matts original due to sdt_probe_func being a void return: Index: sys/cddl/compat/opensolaris/sys/sdt.h =================================================================== --- sys/cddl/compat/opensolaris/sys/sdt.h (revision 271518) +++ sys/cddl/compat/opensolaris/sys/sdt.h (working copy) @@ -34,6 +34,11 @@ #endif #include_next -#define SET_ERROR(err) (err) +SDT_PROBE_DECLARE(sdt, , , set__error); +#define SET_ERROR(err) \ + ((sdt_sdt___set__error->id ? \ + (*sdt_probe_func)(sdt_sdt___set__error->id, \ + (uintptr_t)err, 0, 0, 0, 0) : 0), err) + #endif /* _OPENSOLARIS_SYS_SDT_H_ */ Index: sys/kern/kern_dtrace.c =================================================================== --- sys/kern/kern_dtrace.c (revision 271518) +++ sys/kern/kern_dtrace.c (working copy) @@ -48,6 +48,8 @@ FEATURE(kdtrace_hooks, static MALLOC_DEFINE(M_KDTRACE, "kdtrace", "DTrace hooks"); +SDT_PROBE_DEFINE1(sdt, , , set__error, "int"); + /* Hooks used in the machine-dependent trap handlers. */ dtrace_trap_func_t dtrace_trap_func; dtrace_doubletrap_func_t dtrace_doubletrap_func; But it fails with:- /usr/src/sys/kern/kern_dtrace.c:51:24: error: expected identifier SDT_PROBE_DEFINE1(sdt, , , set__error, "int"); ^ /usr/src/sys/kern/kern_dtrace.c:51:1: error: type specifier missing, defaults to 'int' [-Werror,-Wimplicit-int] SDT_PROBE_DEFINE1(sdt, , , set__error, "int"); All other calls to SDT_PROBE_DEFINE1 seem to define all args e.g. sys/kern/kern_exit.c:SDT_PROBE_DEFINE1(proc, kernel, , exit, "int"); Are you sure they should be ommited? Also is kern_dtrace.c the correct place for the probe define given its zfs specific? Regards Steve From owner-freebsd-dtrace@FreeBSD.ORG Tue Sep 16 16:39:50 2014 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 591C2F93; Tue, 16 Sep 2014 16:39:50 +0000 (UTC) Received: from mail-pa0-x22d.google.com (mail-pa0-x22d.google.com [IPv6:2607:f8b0:400e:c03::22d]) (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 1B22D94D; Tue, 16 Sep 2014 16:39:50 +0000 (UTC) Received: by mail-pa0-f45.google.com with SMTP id rd3so130451pab.32 for ; Tue, 16 Sep 2014 09:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=+jQasUqFR6AdLMLCMImEIhRZBrhWURC3D1kiUehdSIw=; b=p1rzfvOyztlyn+xeaTqhWolEd8o+h0ia+F8HnRovtZVok7zKgGZGMDa6Vwwd8/SwRb X+ovhjFeWbrTf47gpoGwz5khj0CftrYxKxI2zbkPl40mYoJMOYGzy8TIWwzr/hT1RH0/ wRQmrgf6eWrTAYKghIDepbiOWwqIuspu/LO6rQ8rqqZpD1RomEQBFmTq6+/uTPxWgcZw yjf94rzTuE06crhJtlLKlN3cGJ48DmyGsM/iUuegz28tCSUNNmkfb81/elK6NG/kvZhv NK8RL5V5qEDmh3d4pEYWbUVnSy3nh2ukzO9FIlja/gu/XCDNyBSDCq7n8ZPWVD+5HffD glRQ== X-Received: by 10.66.139.16 with SMTP id qu16mr17170212pab.153.1410885589467; Tue, 16 Sep 2014 09:39:49 -0700 (PDT) Received: from charmander.picturesperfect.net (c-67-182-131-225.hsd1.wa.comcast.net. [67.182.131.225]) by mx.google.com with ESMTPSA id ca4sm7120449pad.0.2014.09.16.09.39.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Sep 2014 09:39:48 -0700 (PDT) Sender: Mark Johnston Date: Tue, 16 Sep 2014 09:39:27 -0700 From: Mark Johnston To: Steven Hartland Subject: Re: ZFS SET_ERROR dtrace probe possible under FreeBSD? Message-ID: <20140916163927.GA36108@charmander.picturesperfect.net> References: <20140916031318.GB26720@charmander.picturesperfect.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) 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 16:39:50 -0000 On Tue, Sep 16, 2014 at 11:05:09AM +0100, Steven Hartland wrote: > > ----- Original Message ----- > From: "Mark Johnston" > > > > On Mon, Sep 15, 2014 at 07:59:50PM -0700, Matthew Ahrens wrote: > >> 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) > > > > I think it would need to be > > > > SDT_PROBE_DECLARE(sdt, , , set__error); > > > > #define SET_ERROR(err) ... > > > > in the compat sdt.h, and then kern_dtrace.c or so would contain > > > > SDT_PROBE_DEFINE1(sdt, , , set__error, "int"); > > > > Note that the module shouldn't be hard-coded - it'll be filled in when > > the probes are created by the SDT code. > > Thanks guys for the pointers, I tried the following slightly ammended > from Matts original due to sdt_probe_func being a void return: > > Index: sys/cddl/compat/opensolaris/sys/sdt.h > =================================================================== > --- sys/cddl/compat/opensolaris/sys/sdt.h (revision 271518) > +++ sys/cddl/compat/opensolaris/sys/sdt.h (working copy) > @@ -34,6 +34,11 @@ > #endif > #include_next > > -#define SET_ERROR(err) (err) > +SDT_PROBE_DECLARE(sdt, , , set__error); > > +#define SET_ERROR(err) \ > + ((sdt_sdt___set__error->id ? \ > + (*sdt_probe_func)(sdt_sdt___set__error->id, \ > + (uintptr_t)err, 0, 0, 0, 0) : 0), err) > + > #endif /* _OPENSOLARIS_SYS_SDT_H_ */ > Index: sys/kern/kern_dtrace.c > =================================================================== > --- sys/kern/kern_dtrace.c (revision 271518) > +++ sys/kern/kern_dtrace.c (working copy) > @@ -48,6 +48,8 @@ FEATURE(kdtrace_hooks, > > static MALLOC_DEFINE(M_KDTRACE, "kdtrace", "DTrace hooks"); > > +SDT_PROBE_DEFINE1(sdt, , , set__error, "int"); > + > /* Hooks used in the machine-dependent trap handlers. */ > dtrace_trap_func_t dtrace_trap_func; > dtrace_doubletrap_func_t dtrace_doubletrap_func; > > But it fails with:- > /usr/src/sys/kern/kern_dtrace.c:51:24: error: expected identifier > SDT_PROBE_DEFINE1(sdt, , , set__error, "int"); > ^ > /usr/src/sys/kern/kern_dtrace.c:51:1: error: type specifier missing, defaults to 'int' [-Werror,-Wimplicit-int] > SDT_PROBE_DEFINE1(sdt, , , set__error, "int"); > > All other calls to SDT_PROBE_DEFINE1 seem to define all args e.g. > sys/kern/kern_exit.c:SDT_PROBE_DEFINE1(proc, kernel, , exit, "int"); > > Are you sure they should be ommited? You'll need to #include in kern_dtrace.c. > > Also is kern_dtrace.c the correct place for the probe define given > its zfs specific? I was just thinking that it might be useful elsewhere too. For now, perhaps the best place is in a new file under sys/cddl/compat/opensolaris/kern. Then it'll be part of opensolaris.ko and SET_ERROR will work for any illumos code in the tree, not just ZFS. -Mark From owner-freebsd-dtrace@FreeBSD.ORG Tue Sep 16 19:02:18 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 920C86E0; Tue, 16 Sep 2014 19:02:18 +0000 (UTC) Received: from smtp1.multiplay.co.uk (smtp1.multiplay.co.uk [85.236.96.35]) by mx1.freebsd.org (Postfix) with ESMTP id 5368DCF1; Tue, 16 Sep 2014 19:02:18 +0000 (UTC) Received: by smtp1.multiplay.co.uk (Postfix, from userid 65534) id 1B58220E7088D; Tue, 16 Sep 2014 19:02:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.multiplay.co.uk X-Spam-Level: ** X-Spam-Status: No, score=2.2 required=8.0 tests=AWL,BAYES_00,DOS_OE_TO_MX, FSL_HELO_NON_FQDN_1,RDNS_DYNAMIC,STOX_REPLY_TYPE autolearn=no version=3.3.1 Received: from r2d2 (82-69-141-170.dsl.in-addr.zen.co.uk [82.69.141.170]) by smtp1.multiplay.co.uk (Postfix) with ESMTPS id A2C9B20E70886; Tue, 16 Sep 2014 19:02:14 +0000 (UTC) Message-ID: <4B404F031430407C98A6A553A5FF1843@multiplay.co.uk> From: "Steven Hartland" To: "Mark Johnston" References: <20140916031318.GB26720@charmander.picturesperfect.net> <20140916163927.GA36108@charmander.picturesperfect.net> Subject: Re: ZFS SET_ERROR dtrace probe possible under FreeBSD? Date: Tue, 16 Sep 2014 20:02:11 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 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 19:02:18 -0000 ----- Original Message ----- From: "Mark Johnston" > You'll need to #include in kern_dtrace.c. > >> >> Also is kern_dtrace.c the correct place for the probe define given >> its zfs specific? > > I was just thinking that it might be useful elsewhere too. > > For now, perhaps the best place is in a new file under > sys/cddl/compat/opensolaris/kern. Then it'll be part of opensolaris.ko > and SET_ERROR will work for any illumos code in the tree, not just ZFS. Thanks again. I've created a review for this change below if you would be so kind: https://reviews.freebsd.org/D790 Regards Steve