From owner-freebsd-dtrace@FreeBSD.ORG Sat Oct 26 18:06:50 2013 Return-Path: Delivered-To: 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 ESMTP id 506FEC3; Sat, 26 Oct 2013 18:06:50 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-ie0-x22e.google.com (mail-ie0-x22e.google.com [IPv6:2607:f8b0:4001:c03::22e]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 15A472B2D; Sat, 26 Oct 2013 18:06:50 +0000 (UTC) Received: by mail-ie0-f174.google.com with SMTP id qd12so8562537ieb.5 for ; Sat, 26 Oct 2013 11:06: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=wvV055pKpvrfveGKxU7ZoU6+vIyVCVCxhWdWcdFCVe8=; b=h/K/BKC6HfG4G4Yz+vojE1ikxPxTbwtfzwUOi/ekZ6iek42SsJGUHn9iatiCB8oWR0 1pAaQnz/ZmOo4NWjxG05Wr+nf3yEdXanr1vMtO/zFnkF/XWEZqQ55LDH3+C3jbyAyIRj puhMcDCxMxS2KPHZPooDS5as/s8bDAPG8M34TqdyNEIvteK7I2ha+a0rKRHPpJEeyNxk Vj7w2D7Ka0Er+BBnprK7QDXiW2it9mMCk45caHtSZduJ8zSQjfsrJNxKJbSqZ8c7Zy49 aR7IY6WJP/vQtxmO6eV2oTni+4zIl08WAlZkTfXM771BQelj5U+OJ4206Q69nxsOvAaH 9W0w== X-Received: by 10.50.39.51 with SMTP id m19mr2885797igk.51.1382810809088; Sat, 26 Oct 2013 11:06:49 -0700 (PDT) Received: from raichu (24-212-218-13.cable.teksavvy.com. [24.212.218.13]) by mx.google.com with ESMTPSA id cy15sm9613430igc.1.2013.10.26.11.06.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 26 Oct 2013 11:06:48 -0700 (PDT) Sender: Mark Johnston Date: Sat, 26 Oct 2013 14:06:43 -0400 From: Mark Johnston To: Andriy Gapon Subject: Re: "unstable" sdt probes Message-ID: <20131026180643.GA98676@raichu> References: <5268F461.7080504@FreeBSD.org> <20131024161620.GA1710@charmander> <526A9CB5.2050207@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <526A9CB5.2050207@FreeBSD.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: dtrace@FreeBSD.org X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.14 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: Sat, 26 Oct 2013 18:06:50 -0000 On Fri, Oct 25, 2013 at 07:30:45PM +0300, Andriy Gapon wrote: > on 24/10/2013 19:16 Mark Johnston said the following: > > On Thu, Oct 24, 2013 at 01:20:17PM +0300, Andriy Gapon wrote: > >> > >> Can our SDT (for kernel) implementation support probes with unspecified types > >> for arguments? > >> I would like to get DTRACE_PROBE*() which can be found in the code with > >> OpenSolaris origins (e.g. ZFS) to work. With minimal efforts :-) > > > > Hm, it looks like illumos uses the first argument to DTRACE_PROBE* to > > specify both the provider name and probe name; if no provider name is > > given (based on a lookup in a table in sdt_subr.c), a default "sdt" > > provider is used. It looks like this is what's happening for the ZFS > > probes. > > > > I'd suggest something like the following: > > - to kern_sdt.c, add > > > > SDT_PROVIDER_DEFINE(sdt); > > > > - add DTRACE_PROBE* macros to sdt.h which invoke SDT_PROBE* with the sdt > > provider, i.e. something like > > > > #define DTRACE_PROBE1(name, type, arg) \ > > SDT_PROBE1(sdt, , , name, arg) > > > > - add a FreeBSD-only zfs_dtrace.c which contains the SDT_PROBE_DEFINE* > > invocations for the ZFS probes. You can define the types there, or not > > (using an empty string or NULL should work, I'm not sure). > > > > This won't work for illumos code where the probes specify a provider, > > but I think that's ok. I can do the first two steps if you agree with > > this approach. I don't have any way to test the ZFS probes at the > > moment, but I guess I can provide a zfs_dtrace.c too if you (or anyone > > else) can test. > > Mark, > > thank you for the ideas! The approach sounds fine to me. > I plan to have some time to work on this next week. > I will definitely be able to test things and maybe even develop something. > So, thank you again. The patch here is what I had in mind: http://people.freebsd.org/~markj/patches/zfs_probes.diff I've only compile-tested it, but it should create illumos-compatible ZFS probes without changing any ZFS code, assuming I understand exactly how they're creating/naming probes. :) -Mark > > BTW, I've been pondering an idea of reimplementing how the SDT probes get > called. In FreeBSD we have a special hook function pointer that we check for > not being NULL and then make a function call. > In illumos they compile the code with an unconditional function call. This way > the probe parameters are placed into the proper registers (or stack locations). > But during run-time linking the call instructions are replaced with series of > 1-byte NOP instructions (5 x 0x90 for amd64). When a probe gets activated then > the first of those NOPs gets replaced with 0xf0 (lock prefix), which results in > an invalid instruction (and that happens atomically). So, that allows for the > SDT hook to be invoked via the trap handler. > > So, I think that that results in less overhead for inactive probes, but probably > in more overhead for active probes. There is a trade off, but I believe that > less overhead for inactive probes is preferred. > > -- > Andriy Gapon