From 8fefc8a2d93a06a032c7983cf621ab3fb0c2acde Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 1 Jun 2011 14:22:50 -0400 Subject: [PATCH] Add task_prio symbol wrapper Signed-off-by: Mathieu Desnoyers --- Makefile | 3 ++- ltt-events.c | 3 +++ ltt-events.h | 4 ++++ lttng-context-prio.c | 2 +- wrapper/sched.c | 22 ++++++++++++++++++++++ wrapper/sched.h | 32 ++++++++++++++++++++++++++++++++ 6 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 wrapper/sched.c create mode 100644 wrapper/sched.h diff --git a/Makefile b/Makefile index fa337a0f..62698b2a 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,8 @@ obj-m += ltt-relay.o ltt-relay-objs := ltt-events.o ltt-debugfs-abi.o \ ltt-probes.o ltt-core.o ltt-context.o \ lttng-context-pid.o lttng-context-comm.o \ - lttng-context-prio.o lttng-context-nice.o + lttng-context-prio.o lttng-context-nice.o \ + wrapper/sched.o obj-m += probes/ obj-m += lib/ diff --git a/ltt-events.c b/ltt-events.c index f98ef309..7c08def9 100644 --- a/ltt-events.c +++ b/ltt-events.c @@ -860,6 +860,9 @@ static int __init ltt_events_init(void) { int ret; + ret = wrapper_task_prio_init(); + if (ret) + return ret; event_cache = KMEM_CACHE(ltt_event, 0); if (!event_cache) return -ENOMEM; diff --git a/ltt-events.h b/ltt-events.h index b9bb3bb9..975d1949 100644 --- a/ltt-events.h +++ b/ltt-events.h @@ -272,6 +272,10 @@ int ltt_probes_init(void); void ltt_probes_exit(void); struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx); void lttng_destroy_context(struct lttng_ctx *ctx); + +int wrapper_task_prio_init(void); +int wrapper_task_prio_sym(struct task_struct *t); + int lttng_add_pid_to_ctx(struct lttng_ctx **ctx); int lttng_add_comm_to_ctx(struct lttng_ctx **ctx); int lttng_add_prio_to_ctx(struct lttng_ctx **ctx); diff --git a/lttng-context-prio.c b/lttng-context-prio.c index c8f83f48..a62685f7 100644 --- a/lttng-context-prio.c +++ b/lttng-context-prio.c @@ -32,7 +32,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)); } diff --git a/wrapper/sched.c b/wrapper/sched.c new file mode 100644 index 00000000..229dc075 --- /dev/null +++ b/wrapper/sched.c @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2011 Mathieu Desnoyers (mathieu.desnoyers@efficios.com) + * + * Wrapper around task_prio call. + * + * Dual LGPL v2.1/GPL v2 license. + */ + +#include +#include + +void (*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; +} diff --git a/wrapper/sched.h b/wrapper/sched.h new file mode 100644 index 00000000..1332cfe6 --- /dev/null +++ b/wrapper/sched.h @@ -0,0 +1,32 @@ +#ifndef _LTT_WRAPPER_VMALLOC_H +#define _LTT_WRAPPER_VMALLOC_H + +/* + * Copyright (C) 2011 Mathieu Desnoyers (mathieu.desnoyers@efficios.com) + * + * Wrapper around task_prio call. + * + * Dual LGPL v2.1/GPL v2 license. + */ + +#ifdef CONFIG_KALLSYMS + +#include "../ltt-events.h" + +static inline +int wrapper_task_prio(struct task_struct *t) +{ + return wrapper_task_prio_sym(t); +} +#else + +#include + +static inline +int wrapper_task_prio(struct task_struct *t) +{ + return task_prio(t); +} +#endif + +#endif /* _LTT_WRAPPER_VMALLOC_H */ -- 2.34.1