X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=lttng-context-prio.c;h=842717ca7c74def7f4368aae807083c5b2b34666;hb=494a81f5773f6ecc11c4fdc4733d8d422bfc81df;hp=c8f83f485c334ac3bd423a499f333341afa61629;hpb=53f1f0ca4eb1890673992697c19e4e1507ec4ac5;p=lttng-modules.git diff --git a/lttng-context-prio.c b/lttng-context-prio.c index c8f83f48..842717ca 100644 --- a/lttng-context-prio.c +++ b/lttng-context-prio.c @@ -15,6 +15,19 @@ #include "wrapper/vmalloc.h" #include "ltt-tracer.h" +static +int (*wrapper_task_prio_sym)(struct task_struct *t); + +int wrapper_task_prio_init(void) +{ + wrapper_task_prio_sym = (void *) kallsyms_lookup_name("task_prio"); + if (!wrapper_task_prio_sym) { + printk(KERN_WARNING "LTTng: task_prio symbol lookup failed.\n"); + return -EINVAL; + } + return 0; +} + static size_t prio_get_size(size_t offset) { @@ -32,7 +45,7 @@ void prio_record(struct lttng_ctx_field *field, { int prio; - prio = task_prio(current); + prio = wrapper_task_prio_sym(current); lib_ring_buffer_align_ctx(ctx, ltt_alignof(prio)); chan->ops->event_write(ctx, &prio, sizeof(prio)); } @@ -42,9 +55,15 @@ int lttng_add_prio_to_ctx(struct lttng_ctx **ctx) struct lttng_ctx_field *field; int ret; + if (!wrapper_task_prio_sym) { + ret = wrapper_task_prio_init(); + if (ret) + return ret; + } + field = lttng_append_context(ctx); if (!field) - return ret; + return -ENOMEM; field->event_field.name = "prio"; field->event_field.type.atype = atype_integer; field->event_field.type.u.basic.integer.size = sizeof(int) * CHAR_BIT;