]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
dtrace: finish the implementation of is-enabled USDT probes
authorKris Van Hees <kris.van.hees@oracle.com>
Thu, 23 May 2013 14:52:00 +0000 (10:52 -0400)
committerNick Alcock <nick.alcock@oracle.com>
Mon, 29 Jun 2015 21:41:44 +0000 (22:41 +0100)
This commit completes the implementation of is-enabled USDT probes, i.e. probes
that when fired cause an execution flow change.  This makes it possible (when
using USDT) to encode more complex code sections that are only executed if a
specific USDT probe has been enabled, i.e. when a consumer is listening for
s specific USDT probe.  This is most commonly used for cases where a USDT probe
might require additional computation for one or more of its arguments, and so
it would be too expensive to always do that computation, whether the probe is
enabled or not.  With is-enabled probes, the overhead when DTrace is not used
is negligible (2 NOPs), and when DTrace is in use but the guarded probe is not
enabled, the cost is a single probe firing (without calling dtrace_probe()).

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
include/linux/dtrace_os.h
kernel/dtrace/dtrace_os.c

index 7f5430e30af0643fb967195250f0923baf868614..3d2a71c6ae747f5419369c3ff789179d1fe8c0b7 100644 (file)
@@ -88,7 +88,7 @@ typedef struct fasttrap_machtp {
 
 extern void (*dtrace_helpers_cleanup)(struct task_struct *);
 extern void (*dtrace_fasttrap_probes_cleanup)(struct task_struct *);
-extern void (*dtrace_tracepoint_hit)(fasttrap_machtp_t *, struct pt_regs *);
+extern int (*dtrace_tracepoint_hit)(fasttrap_machtp_t *, struct pt_regs *);
 
 extern int dtrace_tracepoint_enable(pid_t, uintptr_t, fasttrap_machtp_t *);
 extern int dtrace_tracepoint_disable(pid_t, fasttrap_machtp_t *);
index 823960c37cbbb9cf0c8a6ef7315155140c2f404d..2eadab19017b47e4d1cfe6ea15e7904109dab533 100644 (file)
@@ -951,7 +951,7 @@ void (*dtrace_helpers_cleanup)(struct task_struct *);
 EXPORT_SYMBOL(dtrace_helpers_cleanup);
 void (*dtrace_fasttrap_probes_cleanup)(struct task_struct *);
 EXPORT_SYMBOL(dtrace_fasttrap_probes_cleanup);
-void (*dtrace_tracepoint_hit)(fasttrap_machtp_t *, struct pt_regs *);
+int (*dtrace_tracepoint_hit)(fasttrap_machtp_t *, struct pt_regs *);
 EXPORT_SYMBOL(dtrace_tracepoint_hit);
 
 void dtrace_task_init(struct task_struct *tsk)
@@ -980,16 +980,17 @@ static int handler(struct uprobe_consumer *self, struct pt_regs *regs)
 {
        fasttrap_machtp_t       *mtp = container_of(self, fasttrap_machtp_t,
                                                    fmtp_cns);
+       int                     rc = 0;
 
        pr_info("USDT-HANDLER: Called for PC %lx\n", GET_IP(regs));
        read_lock(&this_cpu_core->cpu_ft_lock);
        if (dtrace_tracepoint_hit == NULL)
                pr_warn("Fasttrap probes, but no handler\n");
        else
-               (*dtrace_tracepoint_hit)(mtp, regs);
+               rc = (*dtrace_tracepoint_hit)(mtp, regs);
        read_unlock(&this_cpu_core->cpu_ft_lock);
 
-       return 0;
+       return rc;
 }
 
 int dtrace_tracepoint_enable(pid_t pid, uintptr_t addr,