From owner-freebsd-hackers@FreeBSD.ORG Thu Sep 4 17:48:12 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 B8C6CC36; Thu, 4 Sep 2014 17:48:12 +0000 (UTC) Received: from h2.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "funkthat.com", Issuer "funkthat.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 91B251D18; Thu, 4 Sep 2014 17:48:12 +0000 (UTC) Received: from h2.funkthat.com (localhost [127.0.0.1]) by h2.funkthat.com (8.14.3/8.14.3) with ESMTP id s84HmBK3000535 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 4 Sep 2014 10:48:11 -0700 (PDT) (envelope-from jmg@h2.funkthat.com) Received: (from jmg@localhost) by h2.funkthat.com (8.14.3/8.14.3/Submit) id s84HmBZV000534; Thu, 4 Sep 2014 10:48:11 -0700 (PDT) (envelope-from jmg) Date: Thu, 4 Sep 2014 10:48:11 -0700 From: John-Mark Gurney To: Shrikanth Kamath Subject: Re: Usage of DTRACE_PROBE macro from sdt.h in kernel modules Message-ID: <20140904174811.GK82175@funkthat.com> Mail-Followup-To: Shrikanth Kamath , Mark Johnston , freebsd-hackers@freebsd.org, freebsd-dtrace@freebsd.org, avg@freebsd.org References: <20140902204413.GC59246@charmander.home> <540711ED.2050909@FreeBSD.org> <20140903234950.GB38016@charmander.home> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Operating-System: FreeBSD 7.2-RELEASE i386 X-PGP-Fingerprint: 54BA 873B 6515 3F10 9E88 9322 9CB1 8F74 6D3F A396 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html X-TipJar: bitcoin:13Qmb6AeTgQecazTWph4XasEsP7nGRbAPE X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.2.2 (h2.funkthat.com [127.0.0.1]); Thu, 04 Sep 2014 10:48:11 -0700 (PDT) Cc: freebsd-hackers@freebsd.org, Mark Johnston , avg@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: Thu, 04 Sep 2014 17:48:12 -0000 Shrikanth Kamath wrote this message on Thu, Sep 04, 2014 at 02:23 -0700: > On Wed, Sep 3, 2014 at 4:49 PM, Mark Johnston wrote: > > On Wed, Sep 03, 2014 at 02:09:48PM -0700, Shrikanth Kamath wrote: > >> Thanks Mark/Andriy for helping with this query. I checked the define > >> KDTRACE_HOOKS define that is set. Rather I tried this, I defined a > >> fake provider just to check if that prompts sdt_kld_load to create the > >> SDT probes from my kernel module. > >> > >> + SDT_PROVIDER_DEFINE(fake); > >> And it does help load the SDT probes I created, even though I am not > >> using the fake provider I defined. I feel that sdt_kld_load is flawed > >> when it is looking for sdt_providers_set in the module. It expects at > >> least a provider define and cannot use one of the defined ones in > >> kernel by just declaring it. > >> > >> if (linker_file_lookup_set(lf, "sdt_providers_set", &begin, > >> &end, NULL)) > >> return; > > > > You're completely right; this issue was fixed in > > http://svnweb.freebsd.org/base?view=revision&revision=267706 > > > >> > >> I intended to use DTRACE_PROBE() instead of the conventional > >> SDT_PROBE_DEFINE/SDT_PROBE usage because I wanted to create probes > >> which have probe names based on __LINE__ macro...disclaimer...this was > >> just for experiment sakes... > >> > >> E.g > >> func_foo() > >> { > >> .... > >> if () > >> return EINVAL; > >> ... > >> if () > >> return EINVAL; > >> ... > >> if () > >> return EINVAL; > >> } > >> > >> which I replaced with > >> func_foo() > >> { > >> ... > >> if () > >> RETSDT(func_foo, EINVAL); > >> ... > >> if () > >> RETSDT(func_foo, EINVAL); > >> ... > >> if () > >> RETSDT(func_foo, EINVAL); > >> } > >> where RETSDT macro and other macros are defined as > >> > >> #define PROBENAME1(func, __LINE__) func ## __LINE__ > >> #define PROBENAME(func, line) PROBENAME1(func, line) > >> > >> #define RETSDT(func, error_code) \ > >> do { \ > >> DTRACE_PROBE(PROBENAME(func, __LINE__));\ > >> return (error_code); \ > >> } while (0) > >> > >> With the fake provider I defined I get to see and execute my SDT probes > >> % dtrace -l | grep func_foo > >> 56455 sdt netstack func_foo1592 > >> > >> Here netstack is my module, and I have a probe name based on __LINE__ > >> which is 1592. > > > > Why not just use a single probe and make the line number and function > > name arguments to the probe? That is, write something like > > > > #define RETSDT(error_code) do { \ > > DTRACE_PROBE2(error__return, __func__, __LINE__) > > return (error_code); > > } while (0) > > > Mark, for some reason using a single probe does not seem to fire the probe. I'm doing something similar in my code: cryptodev.c:SDT_PROBE_DEFINE1(opencrypto, dev, ioctl, error, "int"/*line number*/); cryptodev.c: SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); and it worked for me... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."