From owner-freebsd-hackers@FreeBSD.ORG Thu Sep 4 09:23:29 2014 Return-Path: Delivered-To: freebsd-hackers@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 C80F238A; Thu, 4 Sep 2014 09:23:29 +0000 (UTC) Received: from mail-la0-x22a.google.com (mail-la0-x22a.google.com [IPv6:2a00:1450:4010:c03::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 B97AB1B1B; Thu, 4 Sep 2014 09:23:28 +0000 (UTC) Received: by mail-la0-f42.google.com with SMTP id mc6so11587275lab.29 for ; Thu, 04 Sep 2014 02:23:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=W1QI0/USO/27FH/hPfCrA9bA734UIm30Z8PE4LvoZac=; b=mN7EGmAOLA3OeWqjwOltTY1x/DQYFv1KL0s2GYin40S/jl7jYbbdMIYUxoUg1xV+Ig xu/PgkTXjtYOB+v2K5jGSST5VxZ7bfJDc+uNwukmxTj7s2nD304XEt12jKd2kfgPONA9 BkVA0X1UrF9noE4nMdwL9J56VN9P61zu5cKn+SogeBnQdpDO+mrfIk+ojUiDPDzQOk3k Kt9qs+T9xQaLmj0TY/zZPFyogZxs2oqvBY5aQgEap7aIznBvTJlISB3n3HyRXNTvYM2H dEqP2zCnAWpkSUzgVREAItkzSVjUn9Bca1GX/T7SJK85GNddaufOKZtMZPQBYDy2FDng Tnxg== MIME-Version: 1.0 X-Received: by 10.112.209.36 with SMTP id mj4mr3224027lbc.26.1409822606498; Thu, 04 Sep 2014 02:23:26 -0700 (PDT) Received: by 10.25.205.2 with HTTP; Thu, 4 Sep 2014 02:23:26 -0700 (PDT) In-Reply-To: <20140903234950.GB38016@charmander.home> References: <20140902204413.GC59246@charmander.home> <540711ED.2050909@FreeBSD.org> <20140903234950.GB38016@charmander.home> Date: Thu, 4 Sep 2014 02:23:26 -0700 Message-ID: Subject: Re: Usage of DTRACE_PROBE macro from sdt.h in kernel modules From: Shrikanth Kamath To: Mark Johnston Content-Type: text/plain; charset=UTF-8 Cc: freebsd-hackers@freebsd.org, freebsd-dtrace@freebsd.org, avg@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 09:23:30 -0000 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. -- Shrikanth R K