From nobody Fri Feb 11 15:47:12 2022 X-Original-To: dtrace@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 529B919B465B for ; Fri, 11 Feb 2022 15:47:20 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JwJ043pv8z3P1d for ; Fri, 11 Feb 2022 15:47:16 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qv1-xf2d.google.com with SMTP id x3so3124485qvd.8 for ; Fri, 11 Feb 2022 07:47:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=k1T8gVJkcMUpVj1/0QdClQW1KMoI4gLxiLlwvpDl/3E=; b=EuB4HhkSzDv2vxL8q8PnSHS1GYCnb2x4SdoRSYcH/hZEjUkLFazQhhZCxHIKI/mWfH zjR6gJdDjafpP//iv+VPBm9eGKEgMPJoRYAgwvtTU36wu6bkxEwSKogF4UZPVNKFpkMG /9UOG+rEF+ggQ2bxtq7fBOdSn4ALlMJsdpiSNibYgm+sNHMcCK+Kujth5NioXbZEYN9+ QIYcojAoEtQBMRe8h6fBX07/lkKqF0gnRzJOvR55iigPPY3bE+W8q38I193Wc1O6wfYx 7fPq9FPJb7OYvs1PL/x8KTO8afjqetXufkzv8TzxSdoMntwHkO1PtWKocrea+cOt0Y3v stKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=k1T8gVJkcMUpVj1/0QdClQW1KMoI4gLxiLlwvpDl/3E=; b=p/DVUB679zEIkjfxsseoEbfqs7aAypvGMN+W7TZ88cwVA3RE74OIMbmIHjBjbpnj9V u8eGViLQdVbWhujT/n2HLLUXjGMM3/GwugJCDJ3UWZ+ycCMT99wvxubCOl/Vv0aU3ByJ hPm8HTuqcOba041Z5xtr0Z9k/XfP7COmuoE2pZ681tpgRaMaCuZ8/qhOBFdRtIOGfBVh l7+AUjgoigsnET5fFIZuv4RE2iHCjVLd6+0W5bDJjK+X5sQSN3oKyhH4MnxY++Sz0JfY WcEtwgovDnGWno+NZdEho0vl5jjorhr/CTYk8/uJoV9DIoPuMHw9pi8Q4ccgiaOSqLXz wpDw== X-Gm-Message-State: AOAM530HvJJknIYBO2lJ47fOefASIHPYyKrkcaACa4WbLfUQffO1y8ue ZT0oHviuPsF5cUeT1kYy7grcKe6NLp4= X-Google-Smtp-Source: ABdhPJxo6eGmH42DYGBcO8K44GaAEQxDoz+OlLJJpWLW4Ts4LT6ihPtDfvrvyjE+f+YmLK6KaRd04w== X-Received: by 2002:a05:6214:1c05:: with SMTP id u5mr1504775qvc.46.1644594436007; Fri, 11 Feb 2022 07:47:16 -0800 (PST) Received: from nuc (198-84-189-58.cpe.teksavvy.com. [198.84.189.58]) by smtp.gmail.com with ESMTPSA id a14sm13015062qtb.92.2022.02.11.07.47.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 07:47:15 -0800 (PST) Date: Fri, 11 Feb 2022 10:47:12 -0500 From: Mark Johnston To: "Bjoern A. Zeeb" Cc: dtrace@freebsd.org Subject: Re: DTrace, kernel loader, unknown probes, enable on load? Message-ID: References: List-Id: A discussion list for developers working on DTrace in FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-dtrace List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-dtrace@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4JwJ043pv8z3P1d X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=EuB4HhkS; dmarc=none; spf=pass (mx1.freebsd.org: domain of markjdb@gmail.com designates 2607:f8b0:4864:20::f2d as permitted sender) smtp.mailfrom=markjdb@gmail.com X-Spamd-Result: default: False [-1.70 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FORGED_SENDER(0.30)[markj@freebsd.org,markjdb@gmail.com]; SUBJECT_ENDS_QUESTION(1.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[markj@freebsd.org,markjdb@gmail.com]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[dtrace@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; BLOCKLISTDE_FAIL(0.00)[198.84.189.58:server fail,2607:f8b0:4864:20::f2d:server fail]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::f2d:from]; MLMMJ_DEST(0.00)[dtrace]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N On Fri, Feb 11, 2022 at 09:23:47AM -0500, Mark Johnston wrote: > On Fri, Feb 11, 2022 at 02:10:30PM +0000, Bjoern A. Zeeb wrote: > > Hi, > > > > one of the drawbacks of Dtrace (and other tracing frameworks out there > > on various OSes) is that they do need a list of probes upfront before > > they can enable. > > The probes don't have to exist, add -Z to the dtrace(1) parameters. > > > Say I want to trace a kernel module from the moment it is loaded, that > > is currently not possible. > > So something like: > > # dtrace -n 'fbt::coretemp_identify:entry {stack();}' -Z > # kldload coretemp > > ought to work, I think, but it doesn't. It's been a while since I > looked at this code but I think it might be related to the unimplemented > (on FreeBSD) portion of dtrace_probe_provide(). IIRC that's due to a > lock order reversal... I see now: the problem is that FBT registers probes after KLD SYSINITs and module hooks are invoked. See dtrace_module_loaded(), which (asynchronously) calls dtrace_enabling_matchall() to see if any newly registered probes match pending "retained enablings", in this case, enablings created by dtrace -Z. We could perhaps add a new eventhandler that gets called before anything in the KLD is executed, and register probes at that point. Or, if the code you're interested runs after SYSINITs are finished, then -Z might be sufficient today. > > What I am wondering is how hard it would be to "ignore" unknown probes > > but enable them the moment on loading matching ones. I assume that > > will probably need a callback through user space to complicate things > > but it should not be impossible. > > > > In case anyone has some spare time to draft this up, I'll be happily a > > first tester; otherwise the idea is out at least for someone to find > > it one day ... > > > > Lots of health, > > /bz > > > > -- > > Bjoern A. Zeeb r15:7 > >