X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=probes%2Flttng-ftrace.c;h=c18a4702c90be4d8df6ef06490b2445385ed7e4d;hb=9e7e489272e646b39c51e3074de800e928bb5cec;hp=27f4e2bef81117b6bb1e0dc257b838f1c97162c0;hpb=16a9a591f233adc076cc59462f37bd697d952604;p=lttng-modules.git diff --git a/probes/lttng-ftrace.c b/probes/lttng-ftrace.c index 27f4e2be..c18a4702 100644 --- a/probes/lttng-ftrace.c +++ b/probes/lttng-ftrace.c @@ -38,7 +38,7 @@ void lttng_ftrace_handler(unsigned long ip, unsigned long parent_ip, void **data return; lib_ring_buffer_ctx_init(&ctx, chan->chan, NULL, sizeof(payload), ltt_alignof(payload), -1); - ret = chan->ops->event_reserve(&ctx); + ret = chan->ops->event_reserve(&ctx, event->id); if (ret < 0) return; payload.ip = ip; @@ -70,28 +70,35 @@ int lttng_create_ftrace_event(const char *name, struct ltt_event *event) desc->nr_fields = 2; desc->fields = fields = kzalloc(2 * sizeof(struct lttng_event_field), GFP_KERNEL); + if (!desc->fields) { + ret = -ENOMEM; + goto error_fields; + } fields[0].name = "ip"; fields[0].type.atype = atype_integer; - fields[0].type.u.basic.integer.size = sizeof(unsigned long); - fields[0].type.u.basic.integer.alignment = ltt_alignof(unsigned long); - fields[0].type.u.basic.integer.signedness = 0; + fields[0].type.u.basic.integer.size = sizeof(unsigned long) * CHAR_BIT; + fields[0].type.u.basic.integer.alignment = ltt_alignof(unsigned long) * CHAR_BIT; + fields[0].type.u.basic.integer.signedness = is_signed_type(unsigned long); fields[0].type.u.basic.integer.reverse_byte_order = 0; fields[0].type.u.basic.integer.base = 16; fields[0].type.u.basic.integer.encoding = lttng_encode_none; fields[1].name = "parent_ip"; fields[1].type.atype = atype_integer; - fields[1].type.u.basic.integer.size = sizeof(unsigned long); - fields[1].type.u.basic.integer.alignment = ltt_alignof(unsigned long); - fields[1].type.u.basic.integer.signedness = 0; + fields[1].type.u.basic.integer.size = sizeof(unsigned long) * CHAR_BIT; + fields[1].type.u.basic.integer.alignment = ltt_alignof(unsigned long) * CHAR_BIT; + fields[1].type.u.basic.integer.signedness = is_signed_type(unsigned long); fields[1].type.u.basic.integer.reverse_byte_order = 0; fields[1].type.u.basic.integer.base = 16; fields[1].type.u.basic.integer.encoding = lttng_encode_none; + desc->owner = THIS_MODULE; event->desc = desc; return 0; +error_fields: + kfree(desc->name); error_str: kfree(desc); return ret; @@ -112,7 +119,7 @@ int lttng_ftrace_register(const char *name, if (ret) goto error; - event->u.ftrace.symbol_name = kstrdup(name, GFP_KERNEL); + event->u.ftrace.symbol_name = kstrdup(symbol_name, GFP_KERNEL); if (!event->u.ftrace.symbol_name) goto name_error; @@ -121,7 +128,7 @@ int lttng_ftrace_register(const char *name, ret = wrapper_register_ftrace_function_probe(event->u.ftrace.symbol_name, <tng_ftrace_ops, event); - if (ret) + if (ret < 0) goto register_error; return 0; @@ -139,13 +146,18 @@ void lttng_ftrace_unregister(struct ltt_event *event) { wrapper_unregister_ftrace_function_probe(event->u.ftrace.symbol_name, <tng_ftrace_ops, event); +} +EXPORT_SYMBOL_GPL(lttng_ftrace_unregister); + +void lttng_ftrace_destroy_private(struct ltt_event *event) +{ kfree(event->u.ftrace.symbol_name); + kfree(event->desc->fields); kfree(event->desc->name); kfree(event->desc); } -EXPORT_SYMBOL_GPL(lttng_ftrace_unregister); +EXPORT_SYMBOL_GPL(lttng_ftrace_destroy_private); -/* This module is permanent. */ int lttng_ftrace_init(void) { wrapper_vmalloc_sync_all(); @@ -153,6 +165,15 @@ int lttng_ftrace_init(void) } module_init(lttng_ftrace_init) +/* + * Ftrace takes care of waiting for a grace period (RCU sched) at probe + * unregistration, and disables preemption around probe call. + */ +void lttng_ftrace_exit(void) +{ +} +module_exit(lttng_ftrace_exit) + MODULE_LICENSE("GPL and additional rights"); MODULE_AUTHOR("Mathieu Desnoyers"); MODULE_DESCRIPTION("Linux Trace Toolkit Ftrace Support");