From: Kris Van Hees Date: Thu, 23 May 2013 14:52:00 +0000 (-0400) Subject: dtrace: finish the implementation of is-enabled USDT probes X-Git-Tag: v4.1.12-92~313^2~79 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=14435776dc30a52c63f8e1b9006aa47cb045c4af;p=users%2Fjedix%2Flinux-maple.git dtrace: finish the implementation of is-enabled USDT probes 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 --- diff --git a/include/linux/dtrace_os.h b/include/linux/dtrace_os.h index 7f5430e30af0..3d2a71c6ae74 100644 --- a/include/linux/dtrace_os.h +++ b/include/linux/dtrace_os.h @@ -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 *); diff --git a/kernel/dtrace/dtrace_os.c b/kernel/dtrace/dtrace_os.c index 823960c37cbb..2eadab19017b 100644 --- a/kernel/dtrace/dtrace_os.c +++ b/kernel/dtrace/dtrace_os.c @@ -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,