Rich Brown
2005-Aug-17 15:49 UTC
[dtrace-discuss] Detecting the presence of an active probe?
Is there a way in the kernel to tell if a specific static probe is currently enabled? It would seem useful to have a method to predict if a static kernel probe might fire or not in order to avoid pre-processing data for the probe. Sure, there''s a window where the probe is enabled after the check and it fires even though the pre-processing hasn''t been done, but that would happen if we were gathering data from multiple probes anyway. Thanks, Rich
Jonathan Haslam
2005-Aug-17 16:51 UTC
[dtrace-discuss] Detecting the presence of an active probe?
> Is there a way in the kernel to tell if a specific static probe is currently > enabled?Someone may well suggest something cleaner/smarter but you can check if a probe is enabled using mdb to see if there any ECBs for this probe. Taking a single nfs SDT probe as an example: # dtrace -l -n sdt:nfs:nfs4renew:nfs4-renew-start ID PROVIDER MODULE FUNCTION NAME 1260 sdt nfs nfs4renew nfs4-renew-start Firstly, without an enabling: # mdb -k Loading modules: [ unix krtld genunix specfs dtrace ufs ip sctp usba uhci s1394 random fctl nca lofs audiosup md nfs sppp ptm ipc logindmux ]> 0t1260::id2probe | ::print dtrace_probe_t dtpr_ecbdtpr_ecb = 0 Then with this probe enabled:> 0t1260::id2probe | ::print dtrace_probe_t dtpr_ecbdtpr_ecb = 0xffffffff85bd2de8 Cheers. Jon.> It would seem useful to have a method to predict if a static kernel probe > might fire or not in order to avoid pre-processing data for the probe. > Sure, there''s a window where the probe is enabled after the check and > it fires even though the pre-processing hasn''t been done, but that would > happen if we were gathering data from multiple probes anyway. > > Thanks, > > Rich > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org
Jonathan Adams
2005-Aug-17 17:48 UTC
[dtrace-discuss] Detecting the presence of an active probe?
On Wed, Aug 17, 2005 at 10:49:57AM -0500, Rich Brown wrote:> Is there a way in the kernel to tell if a specific static probe is currently > enabled? > > It would seem useful to have a method to predict if a static kernel probe > might fire or not in order to avoid pre-processing data for the probe. > Sure, there''s a window where the probe is enabled after the check and > it fires even though the pre-processing hasn''t been done, but that would > happen if we were gathering data from multiple probes anyway.Generally, a better approach is to not do *any* processing of arguments; just pass in the base pointers that can''t be derived in any other way, and let the D script do the processing if it needs to. This is easier to do if your module has CTF data, of course... Cheers, - jonathan -- Jonathan Adams, Solaris Kernel Development
Jonathan Haslam
2005-Aug-18 10:54 UTC
[dtrace-discuss] Detecting the presence of an active probe?
Rich, I''m posting this more for the amusement factor rather than it being of any use to you...> Is there a way in the kernel to tell if a specific static probe is currently > enabled?You can actually use DTrace to figure this one out. Just pass the probe id into the following script: # cat enabled.d BEGIN { printf("Probe %d %s enabled\n", $1, `dtrace_probes[$1 - 1]->dtpr_ecb == 0 ? "NOT" : "IS"); exit(0); } # dtrace -qs ./enabled.d 1259 Probe 1259 NOT enabled <enable probe id 1259> # dtrace -qs ./enabled.d 1259 Probe 1259 IS enabled Cheers. Jon.
Rich Brown
2005-Aug-19 13:10 UTC
[dtrace-discuss] Detecting the presence of an active probe?
(Sorry for the delay, thought I sent this on Wednesday and I was out yesterday.) Hi Jonathan, Thanks for the advice. In general, I agree that the D script should do as much of the work as possible. A few of us were kicking around some ideas where using D to format the data was a bit clumsy (e.g., deciphering an IPv6 address. Not impossible, just clumsy). Hence the original question. Thanks, Rich Jonathan Adams wrote:>On Wed, Aug 17, 2005 at 10:49:57AM -0500, Rich Brown wrote: > > >>Is there a way in the kernel to tell if a specific static probe is currently >>enabled? >> >>It would seem useful to have a method to predict if a static kernel probe >>might fire or not in order to avoid pre-processing data for the probe. >>Sure, there''s a window where the probe is enabled after the check and >>it fires even though the pre-processing hasn''t been done, but that would >>happen if we were gathering data from multiple probes anyway. >> >> > >Generally, a better approach is to not do *any* processing of arguments; >just pass in the base pointers that can''t be derived in any other way, and >let the D script do the processing if it needs to. > >This is easier to do if your module has CTF data, of course... > >Cheers, >- jonathan > > >
Rich Brown
2005-Aug-19 13:12 UTC
[dtrace-discuss] Detecting the presence of an active probe?
Using Dtrace to observe itself? I like it! :-) Rich Jonathan Haslam wrote:>Rich, > >I''m posting this more for the amusement factor rather than >it being of any use to you... > > > >>Is there a way in the kernel to tell if a specific static probe is currently >>enabled? >> >> > >You can actually use DTrace to figure this one out. Just pass >the probe id into the following script: > > ># cat enabled.d >BEGIN >{ > printf("Probe %d %s enabled\n", $1, > `dtrace_probes[$1 - 1]->dtpr_ecb == 0 ? "NOT" : "IS"); > exit(0); >} > > ># dtrace -qs ./enabled.d 1259 >Probe 1259 NOT enabled > ><enable probe id 1259> > ># dtrace -qs ./enabled.d 1259 >Probe 1259 IS enabled > > >Cheers. > >Jon. > > >