]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
dtrace: SDT cleanup and bring in line with kernel
authorKris Van Hees <kris.van.hees@oracle.com>
Sat, 17 Dec 2016 23:08:44 +0000 (18:08 -0500)
committerKris Van Hees <kris.van.hees@oracle.com>
Sat, 24 Dec 2016 06:27:19 +0000 (01:27 -0500)
This commit performs some cleanup on the SDT provider, removing some
housekeeping tasks that are no longer needed (such as the need for an
arch-specific sdt_provide_module_arch() function).

This commit also contains a fix for the loop used in enabling and
disabling probes.  It was failing to ensure that the enable/disable
function was being called with the correct SDT probe.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
dtrace/include/sparc64/dtrace/sdt_arch.h
dtrace/include/x86_64/dtrace/sdt_arch.h
dtrace/sdt_dev.c
dtrace/sdt_sparc64.c
dtrace/sdt_x86_64.c

index c21ef6126fe938f78933c9e93ef661baa68fef8f..096b9ae944b70e38d0a776d3741aeef14610df74 100644 (file)
@@ -32,7 +32,6 @@
  * Use is subject to license terms.
  */
 
-
 #define SDT_AFRAMES    1
 
 #endif /* _SPARC64_SDT_ARCH_H */
index 0179400a2e3b2bcc616e1cae8a09a0ac4b368bbf..a24ec3c7e3e52746f592feb9dee878aaa8d3f4da 100644 (file)
@@ -32,7 +32,6 @@
  * Use is subject to license terms.
  */
 
-
 #define SDT_AFRAMES    4
 
 #endif /* _X86_64_SDT_ARCH_H */
index 4b29b66d2ed178672796afea22331eb696cfcc33..a672fb57561a28d7ec737f4fd4b1ca5891442d19 100644 (file)
@@ -288,9 +288,6 @@ void sdt_provide_module(void *arg, struct module *mp)
                        return;
        }
 
-       if (!sdt_provide_module_arch(arg, mp))
-               return;
-
        for (idx = 0, sdpd = mp->sdt_probes; idx < mp->sdt_probec;
             idx++, sdpd++) {
                char                    *name = sdpd->sdpd_name, *nname;
@@ -379,6 +376,7 @@ void sdt_provide_module(void *arg, struct module *mp)
 int _sdt_enable(void *arg, dtrace_id_t id, void *parg)
 {
        sdt_probe_t     *sdp = parg;
+       sdt_probe_t     *curr;
 
        /*
         * Ensure that we have a reference to the module.
@@ -391,14 +389,12 @@ int _sdt_enable(void *arg, dtrace_id_t id, void *parg)
         * reference we took above, because we only need one to prevent the
         * module from being unloaded.
         */
-       PDATA(sdp->sdp_module)->sdt_enabled++;
-       if (PDATA(sdp->sdp_module)->sdt_enabled > 1)
+       PDATA(sdp->sdp_module)->enabled_cnt++;
+       if (PDATA(sdp->sdp_module)->enabled_cnt > 1)
                module_put(sdp->sdp_module);
 
-       while (sdp != NULL) {
-               sdt_enable_arch(sdp, id, arg);
-               sdp = sdp->sdp_next;
-       }
+       for (curr = sdp; curr != NULL; curr = curr->sdp_next)
+               sdt_enable_arch(curr, id, arg);
 
        return 0;
 }
@@ -406,6 +402,10 @@ int _sdt_enable(void *arg, dtrace_id_t id, void *parg)
 void _sdt_disable(void *arg, dtrace_id_t id, void *parg)
 {
        sdt_probe_t     *sdp = parg;
+       sdt_probe_t     *curr;
+
+       for (curr = sdp; curr != NULL; curr = curr->sdp_next)
+               sdt_disable_arch(curr, id, arg);
 
        /*
         * If we are disabling a probe, we know it was enabled, and therefore
@@ -413,14 +413,9 @@ void _sdt_disable(void *arg, dtrace_id_t id, void *parg)
         * being unloaded.  If we disable the last probe on the module, we can
         * drop the reference.
         */
-       PDATA(sdp->sdp_module)->sdt_enabled--;
-       if (PDATA(sdp->sdp_module)->sdt_enabled == 0)
+       PDATA(sdp->sdp_module)->enabled_cnt--;
+       if (PDATA(sdp->sdp_module)->enabled_cnt == 0)
                module_put(sdp->sdp_module);
-
-       while (sdp != NULL) {
-               sdt_disable_arch(sdp, id, arg);
-               sdp = sdp->sdp_next;
-       }
 }
 
 void sdt_getargdesc(void *arg, dtrace_id_t id, void *parg,
index 65bc8d07ca41c12a056919c843a5d72786be1c0e..1c744ba11bdc965d1412d4b2658b50ef3329aaa3 100644 (file)
@@ -44,7 +44,7 @@
  *     mov     %i1, %o2
  *     mov     %i2, %o3
  *     mov     %i3, %o4
- *     call    <diff > 0xfff>
+ *     call    dtrace_probe
  *      mov    %i4, %o5
  *     ret
  *      restore
@@ -56,7 +56,7 @@
  *     mov     %i1, %o2
  *     mov     %i2, %o3
  *     mov     %i3, %o4
- *     call    <diff <= 0xfff>
+ *     call    dtrace_probe
  *      mov    %i4, %o5
  *     ret
  *      restore
  * For is-enabled probes, we just drop an "or %g0, 1, %o0"
  * directly into the delay slot.
  */
-#if SDT_TRAMP_SIZE < 11
-# error SDT_TRAMP_SIZE is less than the required 11 instructions.
+#ifndef SDT_TRAMP_SIZE
+# error The kernel must define SDT_TRAMP_SIZE!
+#elif SDT_TRAMP_SIZE < 11
+# error SDT_TRAMP_SIZE must be at least 11 instructions!
 #endif
 
 #define SA(x)                  ((long)ALIGN((x), 4))
@@ -194,12 +196,6 @@ void sdt_disable_arch(sdt_probe_t *sdp, dtrace_id_t id, void *arg)
 
 int sdt_dev_init_arch(void)
 {
-       /*
-        * Sanity check to ensure that the memory allocated by the kernel is
-        * sufficient for what PDATA needs.
-        */
-       ASSERT(sizeof(dtrace_module_t) < DTRACE_PDATA_SIZE);
-
        return 0;
 }
 
index 69440d2ce2e86a54befe6bb00e703e5df2e07aba..b8f1ef440f2b0729bb1e8e82d7126da36fe527cc 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/slab.h>
 #include <linux/uaccess.h>
 #include <linux/vmalloc.h>
+#include <asm/dtrace_util.h>
 
 #include "dtrace.h"
 #include "dtrace_dev.h"
@@ -53,7 +54,7 @@ static uint8_t sdt_invop(struct pt_regs *regs)
                                this_cpu_core->cpu_dtrace_regs = NULL;
                        }
 
-                       return ASM_CALL_SIZE;
+                       return DTRACE_INVOP_NOPS;
                }
        }
 
@@ -66,11 +67,6 @@ void sdt_provide_probe_arch(sdt_probe_t *sdp, struct module *mp, int idx)
        sdp->sdp_savedval = *sdp->sdp_patchpoint;
 }
 
-int sdt_provide_module_arch(void *arg, struct module *mp)
-{
-       return 1;
-}
-
 void sdt_enable_arch(sdt_probe_t *sdp, dtrace_id_t id, void *arg)
 {
        dtrace_invop_enable((uint8_t *)sdp->sdp_patchpoint);
@@ -120,12 +116,6 @@ uint64_t sdt_getarg(void *arg, dtrace_id_t id, void *parg, int argno,
 
 int sdt_dev_init_arch(void)
 {
-       /*
-        * Sanity check to ensure that the memory allocated by the kernel is
-        * sufficient for what PDATA needs.
-        */
-       ASSERT(sizeof(dtrace_module_t) < DTRACE_PDATA_SIZE);
-
        return dtrace_invop_add(sdt_invop);
 }