X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=probes%2Flttng-kprobes.c;h=8e1ae832cd82abb14d0413a1aee5b13cb1cd9fc8;hb=09d8de2b842b6ead8822172adb56ae3ed4c1fdfa;hp=89cfe07364779f6a2094979b16c6f039252fac89;hpb=f167620537b558f8fabd6912d4ea5c46a92cd877;p=lttng-modules.git diff --git a/probes/lttng-kprobes.c b/probes/lttng-kprobes.c index 89cfe073..8e1ae832 100644 --- a/probes/lttng-kprobes.c +++ b/probes/lttng-kprobes.c @@ -25,8 +25,13 @@ int lttng_kprobes_handler_pre(struct kprobe *p, struct pt_regs *regs) int ret; unsigned long data = (unsigned long) p->addr; - if (!ACCESS_ONCE(chan->session->active)) + if (unlikely(!ACCESS_ONCE(chan->session->active))) return 0; + if (unlikely(!ACCESS_ONCE(chan->enabled))) + return 0; + if (unlikely(!ACCESS_ONCE(event->enabled))) + return 0; + lib_ring_buffer_ctx_init(&ctx, chan->chan, event, sizeof(data), ltt_alignof(data), -1); ret = chan->ops->event_reserve(&ctx, event->id); @@ -91,22 +96,28 @@ int lttng_kprobes_register(const char *name, { int ret; + /* Kprobes expects a NULL symbol name if unused */ + if (symbol_name[0] == '\0') + symbol_name = NULL; + ret = lttng_create_kprobe_event(name, event); if (ret) goto error; memset(&event->u.kprobe.kp, 0, sizeof(event->u.kprobe.kp)); event->u.kprobe.kp.pre_handler = lttng_kprobes_handler_pre; - event->u.kprobe.symbol_name = - kzalloc(LTTNG_SYM_NAME_LEN * sizeof(char), - GFP_KERNEL); - if (!event->u.kprobe.symbol_name) { - ret = -ENOMEM; - goto name_error; + if (symbol_name) { + event->u.kprobe.symbol_name = + kzalloc(LTTNG_SYM_NAME_LEN * sizeof(char), + GFP_KERNEL); + if (!event->u.kprobe.symbol_name) { + ret = -ENOMEM; + goto name_error; + } + memcpy(event->u.kprobe.symbol_name, symbol_name, + LTTNG_SYM_NAME_LEN * sizeof(char)); + event->u.kprobe.kp.symbol_name = + event->u.kprobe.symbol_name; } - memcpy(event->u.kprobe.symbol_name, symbol_name, - LTTNG_SYM_NAME_LEN * sizeof(char)); - event->u.kprobe.kp.symbol_name = - event->u.kprobe.symbol_name; event->u.kprobe.kp.offset = offset; event->u.kprobe.kp.addr = (void *) addr;