From owner-freebsd-hackers@FreeBSD.ORG Tue Sep 2 20:44:47 2014 Return-Path: Delivered-To: freebsd-hackers@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 15415E15; Tue, 2 Sep 2014 20:44:47 +0000 (UTC) Received: from mail-qa0-x233.google.com (mail-qa0-x233.google.com [IPv6:2607:f8b0:400d:c00::233]) (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 B5EAE110D; Tue, 2 Sep 2014 20:44:46 +0000 (UTC) Received: by mail-qa0-f51.google.com with SMTP id j7so6774921qaq.24 for ; Tue, 02 Sep 2014 13:44:45 -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=48LRUFGHwpxhGMJz82XrVxpnjH/xLk2ePxORjYPbE3U=; b=hGcU6LGB5ca1yVNX2cBDVnNdlSuqYw0gnzBVG9055d16fZwPP2DGswztUsAn6T90vG 7D3wR88yuM3LprArkFcx0d3+d3yA9P48aGoBgtAgXtgRVzO8E9m3VzFEtx5LXRGXe93V /l501hg0X0NqwtlOaJM6AnekcR1GpKtdAxKaFQBSaQQzEeVDAl/YjvDfqiE/WOWY6C/g YOm39lcF7h8xqisSMDG/L6Hxro+NZX34pqYuYnIdo56eqCp4i43HVWB8VrQQnJbyZmhs Aw6qQCvZP7R31xir7CBh1WPvpSJo6D22C8Mc736nUa6zy5fIqhVQkBa/H0cf23p3WSLL 0M1Q== X-Received: by 10.224.44.14 with SMTP id y14mr58461359qae.34.1409690685696; Tue, 02 Sep 2014 13:44:45 -0700 (PDT) Received: from charmander.home ([64.229.13.35]) by mx.google.com with ESMTPSA id j3sm12616965qaa.32.2014.09.02.13.44.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Sep 2014 13:44:45 -0700 (PDT) Sender: Mark Johnston Date: Tue, 2 Sep 2014 16:44:13 -0400 From: Mark Johnston To: Shrikanth Kamath Subject: Re: Usage of DTRACE_PROBE macro from sdt.h in kernel modules Message-ID: <20140902204413.GC59246@charmander.home> 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: freebsd-hackers@freebsd.org, freebsd-dtrace@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Sep 2014 20:44:47 -0000 On Tue, Sep 02, 2014 at 01:24:47PM -0700, Shrikanth Kamath wrote: > Adding a DTRACE_PROBE(name) in a kernel module does not create the SDT > probe. I added > the following to the module file before using DTRACE_PROBE. Somewhat confusingly, DTRACE_PROBE* shouldn't be used in the kernel. It's there for compatibility with the DTrace probes in ZFS, which use the SDT interfaces in illumos. The SDT_PROBE* macros should be used instead. If you grep the kernel sources, you'll find lots of examples of SDT providers and probes. > #include "opt_kdtrace.h" > #include > > function_foo() { > ... > + DTRACE_PROBE(name); > ... > } > > I figured the sdt.h does declare SDT_PROVIDER_DECLARE(set); but that > is not helping. Was expecting a sdt probe added under provider 'set'. SDT_PROVIDER_DEFINE() is used to define a provider. SDT_PROVIDER_DECLARE() just adds a declaration, so it won't result in anything being added to the SDT provider linker set in the corresponding kld. So SDT_PROVIDER_DEFINE() should be used once to define a new provider, and the provider can be made visible across multiple files using SDT_PROVIDER_DECLARE(). > > The SDT probe creation returns from sdt_kld_load from here > > if (linker_file_lookup_set(lf, "sdt_providers_set", &begin, &end, NULL)) > return; > > I did a nm on the kernel module and did not find anything matching > "sdt_providers_set" > > nm -a module.ko | grep sdt > > 00000000 r __set_sdt_probes_set_sym_sdt_sdt______func____LINE__.103790 > > U __start_set_sdt_probes_set > > U __stop_set_sdt_probes_set > > U sdt_probe_func > > U sdt_provider_sdt > > 000006c0 d sdt_sdt______func____LINE__.103789 > > Can't seem to figure how to get the SDT probe created by using > DTRACE_PROBE macro in a kernel module. In addition to the comments above, I suggest taking a look at the SDT(9) man page, which has a few examples. Thanks, -Mark