From 979133c547728a541098dd7051e1e72ab7631788 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 1 Jun 2011 15:01:18 -0400 Subject: [PATCH] Prio context: fix symbol lookup Signed-off-by: Mathieu Desnoyers --- Makefile | 3 +-- ltt-events.c | 3 --- ltt-events.h | 4 ---- lttng-context-prio.c | 19 +++++++++++++++++++ wrapper/sched.c | 22 ---------------------- wrapper/sched.h | 32 -------------------------------- 6 files changed, 20 insertions(+), 63 deletions(-) delete mode 100644 wrapper/sched.c delete mode 100644 wrapper/sched.h diff --git a/Makefile b/Makefile index 62698b2a..fa337a0f 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,7 @@ 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 \ - wrapper/sched.o + lttng-context-prio.o lttng-context-nice.o obj-m += probes/ obj-m += lib/ diff --git a/ltt-events.c b/ltt-events.c index 7c08def9..f98ef309 100644 --- a/ltt-events.c +++ b/ltt-events.c @@ -860,9 +860,6 @@ 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 975d1949..b9bb3bb9 100644 --- a/ltt-events.h +++ b/ltt-events.h @@ -272,10 +272,6 @@ 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 a62685f7..d159e02d 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) { @@ -42,6 +55,12 @@ 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; diff --git a/wrapper/sched.c b/wrapper/sched.c deleted file mode 100644 index 229dc075..00000000 --- a/wrapper/sched.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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 deleted file mode 100644 index 1332cfe6..00000000 --- a/wrapper/sched.h +++ /dev/null @@ -1,32 +0,0 @@ -#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