From owner-freebsd-dtrace@FreeBSD.ORG Wed Sep 3 21:09:51 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 5991AEC4; Wed, 3 Sep 2014 21:09:51 +0000 (UTC) Received: from mail-lb0-x22b.google.com (mail-lb0-x22b.google.com [IPv6:2a00:1450:4010:c04::22b]) (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 540F015BB; Wed, 3 Sep 2014 21:09:50 +0000 (UTC) Received: by mail-lb0-f171.google.com with SMTP id 10so1820458lbg.30 for ; Wed, 03 Sep 2014 14:09:48 -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 :content-type; bh=5TUAsTdFDAT1EMz29YOwXKMyE7bwfxVe+kANDoh1YwY=; b=wIfT2MPVe4THb5QTeTSSBjQSgqZD/XLM3e6bUJLX5bbq9ZoVrkvOua2tCRaLRwkhMp RxW+pJ0MXGlb8VYXPgrjaNB1Llih3ELQyKtP2E0G7Cb5YAllRafKJ9pcLXfAzlKPC0uG +4UV47ZRJu2hWDqswdVwfRY34LLp//rugpOWYSvnkb8xqYOn9xK8RC0WfmaLCoQCgzon lTSVxeZIgPpxxLN1gZShen/MOiAZzeZc7XxtSyadg4oN7yXxNu9W6Vor0D6QJMabO3i9 wde/aMxvQdPMCo14GgJH+9Ptz51df2iE/8ALns26GnvG7+yIE+q4iIexBoTS5N1NlFAD lQdw== MIME-Version: 1.0 X-Received: by 10.112.199.42 with SMTP id jh10mr174202lbc.49.1409778588091; Wed, 03 Sep 2014 14:09:48 -0700 (PDT) Received: by 10.25.205.2 with HTTP; Wed, 3 Sep 2014 14:09:48 -0700 (PDT) In-Reply-To: <540711ED.2050909@FreeBSD.org> References: <20140902204413.GC59246@charmander.home> <540711ED.2050909@FreeBSD.org> Date: Wed, 3 Sep 2014 14:09:48 -0700 Message-ID: Subject: Re: Usage of DTRACE_PROBE macro from sdt.h in kernel modules From: Shrikanth Kamath To: avg@freebsd.org, markj@freebsd.org, freebsd-hackers@freebsd.org, freebsd-dtrace@freebsd.org Content-Type: text/plain; charset=UTF-8 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: Wed, 03 Sep 2014 21:09:51 -0000 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; 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. Don't know if that is good way to do it but using SDT_PROBE_DEFINE looks like a problem because of the presence of __LINE__ in the probename. Thanks for reaching out... -- Shrikanth R K On Wed, Sep 3, 2014 at 6:04 AM, Andriy Gapon wrote: > on 02/09/2014 23:44 Mark Johnston said the following: >> Somewhat confusingly, DTRACE_PROBE* shouldn't be used in the kernel. > > But it can be used. > > Shrikanth, please double check that KDTRACE_HOOKS is defined when you compile > your module. > > -- > Andriy Gapon