From b6bf28ecd4c07e7865d340f1600a35d6edc05ec8 Mon Sep 17 00:00:00 2001 From: Pierre-Marc Fournier Date: Tue, 10 Feb 2009 01:21:27 -0500 Subject: [PATCH] ust: continue work --- hello/Makefile | 2 +- hello/hello.c | 20 ++ hello/run | 2 +- libmarkers/Makefile | 2 +- libmarkers/marker.c | 2 +- libtracing/Makefile | 6 + libtracing/channels.c | 33 +- libtracing/channels.h | 6 +- libtracing/tracer.c | 677 ++++++++++++++++++---------------------- libtracing/tracer.h | 224 ++++++------- libtracing/tracercore.c | 47 +-- libtracing/tracercore.h | 1 + share/kernelcompat.h | 85 ++++- 13 files changed, 557 insertions(+), 550 deletions(-) create mode 100644 libtracing/Makefile diff --git a/hello/Makefile b/hello/Makefile index 1133d19..077f59b 100644 --- a/hello/Makefile +++ b/hello/Makefile @@ -1,7 +1,7 @@ all: hello hello: hello.c - gcc -g -I../libmarkers -I../share -L../libmarkers -lmarkers -L../libtracectl -ltracectl -o hello hello.c + gcc -g -I../libmarkers -I../share -L../libmarkers -lmarkers -L../libtracectl -ltracectl -L../libtracing -ltracing -o hello hello.c clean: rm -rf hello *.o diff --git a/hello/hello.c b/hello/hello.c index 0735fd6..5197986 100644 --- a/hello/hello.c +++ b/hello/hello.c @@ -1,5 +1,6 @@ #include #include +#include #include "../libmarkers/marker.h" @@ -10,8 +11,27 @@ void probe(const struct marker *mdata, printf("In probe\n"); } +void try_map() +{ + char *m; + + /* maybe add MAP_LOCKED */ + m = mmap(NULL, 4096, PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE , -1, 0); + if(m == (char*)-1) { + perror("mmap"); + return; + } + + printf("The mapping is at %p.\n", m); + strcpy(m, "Hello, Mapping!"); +} + int main() { + //ltt_trace_create(); + + try_map(); + printf("Hello, World!\n"); marker_probe_register("abc", "testmark", "", probe, NULL); diff --git a/hello/run b/hello/run index daf9aa8..6f72e22 100755 --- a/hello/run +++ b/hello/run @@ -1,3 +1,3 @@ #!/bin/sh -LD_LIBRARY_PATH=../libtracectl ./hello +LD_LIBRARY_PATH=../libtracectl:../libmarkers ./hello diff --git a/libmarkers/Makefile b/libmarkers/Makefile index e53283c..d4f8ecd 100644 --- a/libmarkers/Makefile +++ b/libmarkers/Makefile @@ -1,6 +1,6 @@ all: libmarkers.so libmarkers.so: marker.c *.c *.h - gcc -g -fPIC -I../share -I../libtracing -shared -o libmarkers.so marker.c ../share/kref.c + gcc -g -fPIC -I../share -I../libtracing -shared -o libmarkers.so marker.c ../share/kref.c ../libtracing/channels.c .PHONY: libmarkers.so all diff --git a/libmarkers/marker.c b/libmarkers/marker.c index 568cfb9..f9f82fb 100644 --- a/libmarkers/marker.c +++ b/libmarkers/marker.c @@ -707,7 +707,7 @@ static void marker_update_probes(void) marker_update_probe_range(__start___markers, __stop___markers); /* Markers in modules. */ //ust// module_update_markers(); - tracepoint_probe_update_all(); +//ust// tracepoint_probe_update_all(); /* Update immediate values */ core_imv_update(); //ust// module_imv_update(); diff --git a/libtracing/Makefile b/libtracing/Makefile new file mode 100644 index 0000000..dd58ce5 --- /dev/null +++ b/libtracing/Makefile @@ -0,0 +1,6 @@ +all: libtracing.so + +libtracing.so: *.c *.h + gcc -g -fPIC -I../share -I../libtracing -shared -o libtracing.so *.c + +.PHONY: libtracing.so all diff --git a/libtracing/channels.c b/libtracing/channels.c index bd9c508..1a23afe 100644 --- a/libtracing/channels.c +++ b/libtracing/channels.c @@ -9,10 +9,13 @@ * Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca) */ -#include -#include -#include -#include +//ust// #include +//ust// #include +//ust// #include +//ust// #include + +#include "kernelcompat.h" +#include "channels.h" /* * ltt_channel_mutex may be nested inside the LTT trace mutex. @@ -63,7 +66,7 @@ static void release_channel_setting(struct kref *kref) iter->index = free_index++; iter->free_event_id = 0; } - markers_compact_event_ids(); +//ust// markers_compact_event_ids(); } } @@ -115,7 +118,7 @@ end: mutex_unlock(<t_channel_mutex); return ret; } -EXPORT_SYMBOL_GPL(ltt_channels_register); +//ust// EXPORT_SYMBOL_GPL(ltt_channels_register); /** * ltt_channels_unregister - Unregister a trace channel. @@ -139,7 +142,7 @@ end: mutex_unlock(<t_channel_mutex); return ret; } -EXPORT_SYMBOL_GPL(ltt_channels_unregister); +//ust// EXPORT_SYMBOL_GPL(ltt_channels_unregister); /** * ltt_channels_set_default - Set channel default behavior. @@ -166,7 +169,7 @@ end: mutex_unlock(<t_channel_mutex); return ret; } -EXPORT_SYMBOL_GPL(ltt_channels_set_default); +//ust// EXPORT_SYMBOL_GPL(ltt_channels_set_default); /** * ltt_channels_get_name_from_index - get channel name from channel index @@ -184,7 +187,7 @@ const char *ltt_channels_get_name_from_index(unsigned int index) return iter->name; return NULL; } -EXPORT_SYMBOL_GPL(ltt_channels_get_name_from_index); +//ust// EXPORT_SYMBOL_GPL(ltt_channels_get_name_from_index); static struct ltt_channel_setting * ltt_channels_get_setting_from_name(const char *name) @@ -216,7 +219,7 @@ int ltt_channels_get_index_from_name(const char *name) else return -1; } -EXPORT_SYMBOL_GPL(ltt_channels_get_index_from_name); +//ust// EXPORT_SYMBOL_GPL(ltt_channels_get_index_from_name); /** * ltt_channels_trace_alloc - Allocate channel structures for a trace @@ -260,7 +263,7 @@ end: mutex_unlock(<t_channel_mutex); return channel; } -EXPORT_SYMBOL_GPL(ltt_channels_trace_alloc); +//ust// EXPORT_SYMBOL_GPL(ltt_channels_trace_alloc); /** * ltt_channels_trace_free - Free one trace's channels @@ -278,7 +281,7 @@ void ltt_channels_trace_free(struct ltt_channel_struct *channels) mutex_unlock(<t_channel_mutex); unlock_markers(); } -EXPORT_SYMBOL_GPL(ltt_channels_trace_free); +//ust// EXPORT_SYMBOL_GPL(ltt_channels_trace_free); /** * _ltt_channels_get_event_id - get next event ID for a marker @@ -333,6 +336,6 @@ int ltt_channels_get_event_id(const char *channel, const char *name) return ret; } -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Mathieu Desnoyers"); -MODULE_DESCRIPTION("Linux Trace Toolkit Next Generation Channel Management"); +//ust// MODULE_LICENSE("GPL"); +//ust// MODULE_AUTHOR("Mathieu Desnoyers"); +//ust// MODULE_DESCRIPTION("Linux Trace Toolkit Next Generation Channel Management"); diff --git a/libtracing/channels.h b/libtracing/channels.h index a7ff163..1c5c34f 100644 --- a/libtracing/channels.h +++ b/libtracing/channels.h @@ -10,9 +10,11 @@ #include //ust// #include //ust// #include -#include +#include -#include +#include "kernelcompat.h" +#include "kref.h" +#include "list.h" #define EVENTS_PER_CHANNEL 65536 diff --git a/libtracing/tracer.c b/libtracing/tracer.c index 8c3bcd8..2dfde4a 100644 --- a/libtracing/tracer.c +++ b/libtracing/tracer.c @@ -23,25 +23,29 @@ * 27/05/05, Modular redesign and rewrite. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static void async_wakeup(unsigned long data); - -static DEFINE_TIMER(ltt_async_wakeup_timer, async_wakeup, 0, 0); +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +#include "tracercore.h" +#include "tracer.h" +#include "kernelcompat.h" +#include "usterr.h" + +//ust// static void async_wakeup(unsigned long data); +//ust// +//ust// static DEFINE_TIMER(ltt_async_wakeup_timer, async_wakeup, 0, 0); /* Default callbacks for modules */ notrace int ltt_filter_control_default(enum ltt_filter_control_msg msg, @@ -78,91 +82,11 @@ struct chan_info_struct { LTT_DEFAULT_SUBBUF_SIZE_LOW, LTT_DEFAULT_N_SUBBUFS_LOW, }, - [LTT_CHANNEL_FD_STATE] = { - LTT_FD_STATE_CHANNEL, - LTT_DEFAULT_SUBBUF_SIZE_LOW, - LTT_DEFAULT_N_SUBBUFS_LOW, - }, - [LTT_CHANNEL_GLOBAL_STATE] = { - LTT_GLOBAL_STATE_CHANNEL, - LTT_DEFAULT_SUBBUF_SIZE_LOW, - LTT_DEFAULT_N_SUBBUFS_LOW, - }, - [LTT_CHANNEL_IRQ_STATE] = { - LTT_IRQ_STATE_CHANNEL, - LTT_DEFAULT_SUBBUF_SIZE_LOW, - LTT_DEFAULT_N_SUBBUFS_LOW, - }, - [LTT_CHANNEL_MODULE_STATE] = { - LTT_MODULE_STATE_CHANNEL, - LTT_DEFAULT_SUBBUF_SIZE_LOW, - LTT_DEFAULT_N_SUBBUFS_LOW, - }, - [LTT_CHANNEL_NETIF_STATE] = { - LTT_NETIF_STATE_CHANNEL, - LTT_DEFAULT_SUBBUF_SIZE_LOW, - LTT_DEFAULT_N_SUBBUFS_LOW, - }, - [LTT_CHANNEL_SOFTIRQ_STATE] = { - LTT_SOFTIRQ_STATE_CHANNEL, - LTT_DEFAULT_SUBBUF_SIZE_LOW, - LTT_DEFAULT_N_SUBBUFS_LOW, - }, - [LTT_CHANNEL_SWAP_STATE] = { - LTT_SWAP_STATE_CHANNEL, - LTT_DEFAULT_SUBBUF_SIZE_LOW, - LTT_DEFAULT_N_SUBBUFS_LOW, - }, - [LTT_CHANNEL_SYSCALL_STATE] = { - LTT_SYSCALL_STATE_CHANNEL, - LTT_DEFAULT_SUBBUF_SIZE_LOW, - LTT_DEFAULT_N_SUBBUFS_LOW, - }, - [LTT_CHANNEL_TASK_STATE] = { - LTT_TASK_STATE_CHANNEL, - LTT_DEFAULT_SUBBUF_SIZE_LOW, - LTT_DEFAULT_N_SUBBUFS_LOW, - }, - [LTT_CHANNEL_VM_STATE] = { - LTT_VM_STATE_CHANNEL, - LTT_DEFAULT_SUBBUF_SIZE_LOW, - LTT_DEFAULT_N_SUBBUFS_LOW, - }, - [LTT_CHANNEL_FS] = { - LTT_FS_CHANNEL, - LTT_DEFAULT_SUBBUF_SIZE_MED, - LTT_DEFAULT_N_SUBBUFS_MED, - }, - [LTT_CHANNEL_INPUT] = { - LTT_INPUT_CHANNEL, - LTT_DEFAULT_SUBBUF_SIZE_LOW, - LTT_DEFAULT_N_SUBBUFS_LOW, - }, - [LTT_CHANNEL_IPC] = { - LTT_IPC_CHANNEL, - LTT_DEFAULT_SUBBUF_SIZE_LOW, - LTT_DEFAULT_N_SUBBUFS_LOW, - }, - [LTT_CHANNEL_KERNEL] = { - LTT_KERNEL_CHANNEL, + [LTT_CHANNEL_UST] = { + LTT_UST_CHANNEL, LTT_DEFAULT_SUBBUF_SIZE_HIGH, LTT_DEFAULT_N_SUBBUFS_HIGH, }, - [LTT_CHANNEL_MM] = { - LTT_MM_CHANNEL, - LTT_DEFAULT_SUBBUF_SIZE_MED, - LTT_DEFAULT_N_SUBBUFS_MED, - }, - [LTT_CHANNEL_RCU] = { - LTT_RCU_CHANNEL, - LTT_DEFAULT_SUBBUF_SIZE_MED, - LTT_DEFAULT_N_SUBBUFS_MED, - }, - [LTT_CHANNEL_DEFAULT] = { - NULL, - LTT_DEFAULT_SUBBUF_SIZE_MED, - LTT_DEFAULT_N_SUBBUFS_MED, - }, }; static enum ltt_channels get_channel_type_from_name(const char *name) @@ -170,13 +94,13 @@ static enum ltt_channels get_channel_type_from_name(const char *name) int i; if (!name) - return LTT_CHANNEL_DEFAULT; + return LTT_CHANNEL_UST; for (i = 0; i < ARRAY_SIZE(chan_infos); i++) if (chan_infos[i].name && !strcmp(name, chan_infos[i].name)) return (enum ltt_channels)i; - return LTT_CHANNEL_DEFAULT; + return LTT_CHANNEL_UST; } /** @@ -192,79 +116,79 @@ static enum ltt_channels get_channel_type_from_name(const char *name) * the module allocates virtual memory after its registration must it * synchronize the TLBs. */ -int ltt_module_register(enum ltt_module_function name, void *function, - struct module *owner) -{ - int ret = 0; - - /* - * Make sure no page fault can be triggered by the module about to be - * registered. We deal with this here so we don't have to call - * vmalloc_sync_all() in each module's init. - */ - vmalloc_sync_all(); - - switch (name) { - case LTT_FUNCTION_RUN_FILTER: - if (ltt_run_filter_owner != NULL) { - ret = -EEXIST; - goto end; - } - ltt_filter_register((ltt_run_filter_functor)function); - ltt_run_filter_owner = owner; - break; - case LTT_FUNCTION_FILTER_CONTROL: - if (ltt_filter_control_owner != NULL) { - ret = -EEXIST; - goto end; - } - ltt_filter_control_functor = - (int (*)(enum ltt_filter_control_msg, - struct ltt_trace_struct *))function; - ltt_filter_control_owner = owner; - break; - case LTT_FUNCTION_STATEDUMP: - if (ltt_statedump_owner != NULL) { - ret = -EEXIST; - goto end; - } - ltt_statedump_functor = - (int (*)(struct ltt_trace_struct *))function; - ltt_statedump_owner = owner; - break; - } - -end: - - return ret; -} -EXPORT_SYMBOL_GPL(ltt_module_register); +//ust// int ltt_module_register(enum ltt_module_function name, void *function, +//ust// struct module *owner) +//ust// { +//ust// int ret = 0; +//ust// +//ust// /* +//ust// * Make sure no page fault can be triggered by the module about to be +//ust// * registered. We deal with this here so we don't have to call +//ust// * vmalloc_sync_all() in each module's init. +//ust// */ +//ust// vmalloc_sync_all(); +//ust// +//ust// switch (name) { +//ust// case LTT_FUNCTION_RUN_FILTER: +//ust// if (ltt_run_filter_owner != NULL) { +//ust// ret = -EEXIST; +//ust// goto end; +//ust// } +//ust// ltt_filter_register((ltt_run_filter_functor)function); +//ust// ltt_run_filter_owner = owner; +//ust// break; +//ust// case LTT_FUNCTION_FILTER_CONTROL: +//ust// if (ltt_filter_control_owner != NULL) { +//ust// ret = -EEXIST; +//ust// goto end; +//ust// } +//ust// ltt_filter_control_functor = +//ust// (int (*)(enum ltt_filter_control_msg, +//ust// struct ltt_trace_struct *))function; +//ust// ltt_filter_control_owner = owner; +//ust// break; +//ust// case LTT_FUNCTION_STATEDUMP: +//ust// if (ltt_statedump_owner != NULL) { +//ust// ret = -EEXIST; +//ust// goto end; +//ust// } +//ust// ltt_statedump_functor = +//ust// (int (*)(struct ltt_trace_struct *))function; +//ust// ltt_statedump_owner = owner; +//ust// break; +//ust// } +//ust// +//ust// end: +//ust// +//ust// return ret; +//ust// } +//ust// EXPORT_SYMBOL_GPL(ltt_module_register); /** * ltt_module_unregister - LTT module unregistration * @name: module type */ -void ltt_module_unregister(enum ltt_module_function name) -{ - switch (name) { - case LTT_FUNCTION_RUN_FILTER: - ltt_filter_unregister(); - ltt_run_filter_owner = NULL; - /* Wait for preempt sections to finish */ - synchronize_sched(); - break; - case LTT_FUNCTION_FILTER_CONTROL: - ltt_filter_control_functor = ltt_filter_control_default; - ltt_filter_control_owner = NULL; - break; - case LTT_FUNCTION_STATEDUMP: - ltt_statedump_functor = ltt_statedump_default; - ltt_statedump_owner = NULL; - break; - } - -} -EXPORT_SYMBOL_GPL(ltt_module_unregister); +//ust// void ltt_module_unregister(enum ltt_module_function name) +//ust// { +//ust// switch (name) { +//ust// case LTT_FUNCTION_RUN_FILTER: +//ust// ltt_filter_unregister(); +//ust// ltt_run_filter_owner = NULL; +//ust// /* Wait for preempt sections to finish */ +//ust// synchronize_sched(); +//ust// break; +//ust// case LTT_FUNCTION_FILTER_CONTROL: +//ust// ltt_filter_control_functor = ltt_filter_control_default; +//ust// ltt_filter_control_owner = NULL; +//ust// break; +//ust// case LTT_FUNCTION_STATEDUMP: +//ust// ltt_statedump_functor = ltt_statedump_default; +//ust// ltt_statedump_owner = NULL; +//ust// break; +//ust// } +//ust// +//ust// } +//ust// EXPORT_SYMBOL_GPL(ltt_module_unregister); static LIST_HEAD(ltt_transport_list); @@ -280,32 +204,32 @@ static LIST_HEAD(ltt_transport_list); * vmalloc_sync_all. Therefore, only if the module allocates virtual memory * after its registration must it synchronize the TLBs. */ -void ltt_transport_register(struct ltt_transport *transport) -{ - /* - * Make sure no page fault can be triggered by the module about to be - * registered. We deal with this here so we don't have to call - * vmalloc_sync_all() in each module's init. - */ - vmalloc_sync_all(); - - ltt_lock_traces(); - list_add_tail(&transport->node, <t_transport_list); - ltt_unlock_traces(); -} -EXPORT_SYMBOL_GPL(ltt_transport_register); +//ust// void ltt_transport_register(struct ltt_transport *transport) +//ust// { +//ust// /* +//ust// * Make sure no page fault can be triggered by the module about to be +//ust// * registered. We deal with this here so we don't have to call +//ust// * vmalloc_sync_all() in each module's init. +//ust// */ +//ust// vmalloc_sync_all(); +//ust// +//ust// ltt_lock_traces(); +//ust// list_add_tail(&transport->node, <t_transport_list); +//ust// ltt_unlock_traces(); +//ust// } +//ust// EXPORT_SYMBOL_GPL(ltt_transport_register); /** * ltt_transport_unregister - LTT transport unregistration * @transport: transport structure */ -void ltt_transport_unregister(struct ltt_transport *transport) -{ - ltt_lock_traces(); - list_del(&transport->node); - ltt_unlock_traces(); -} -EXPORT_SYMBOL_GPL(ltt_transport_unregister); +//ust// void ltt_transport_unregister(struct ltt_transport *transport) +//ust// { +//ust// ltt_lock_traces(); +//ust// list_del(&transport->node); +//ust// ltt_unlock_traces(); +//ust// } +//ust// EXPORT_SYMBOL_GPL(ltt_transport_unregister); static inline int is_channel_overwrite(enum ltt_channels chan, enum trace_mode mode) @@ -322,15 +246,10 @@ static inline int is_channel_overwrite(enum ltt_channels chan, } case LTT_TRACE_HYBRID: switch (chan) { - case LTT_CHANNEL_KERNEL: - case LTT_CHANNEL_FS: - case LTT_CHANNEL_MM: - case LTT_CHANNEL_RCU: - case LTT_CHANNEL_IPC: - case LTT_CHANNEL_INPUT: - return 1; - default: + case LTT_CHANNEL_METADATA: return 0; + default: + return 1; } default: return 0; @@ -355,7 +274,7 @@ void notrace ltt_write_trace_header(struct ltt_trace_struct *trace, header->start_freq = trace->start_freq; header->freq_scale = trace->freq_scale; } -EXPORT_SYMBOL_GPL(ltt_write_trace_header); +//ust// EXPORT_SYMBOL_GPL(ltt_write_trace_header); static void trace_async_wakeup(struct ltt_trace_struct *trace) { @@ -370,34 +289,34 @@ static void trace_async_wakeup(struct ltt_trace_struct *trace) } } -/* Timer to send async wakeups to the readers */ -static void async_wakeup(unsigned long data) -{ - struct ltt_trace_struct *trace; - - /* - * PREEMPT_RT does not allow spinlocks to be taken within preempt - * disable sections (spinlock taken in wake_up). However, mainline won't - * allow mutex to be taken in interrupt context. Ugly. - * A proper way to do this would be to turn the timer into a - * periodically woken up thread, but it adds to the footprint. - */ -#ifndef CONFIG_PREEMPT_RT - rcu_read_lock_sched(); -#else - ltt_lock_traces(); -#endif - list_for_each_entry_rcu(trace, <t_traces.head, list) { - trace_async_wakeup(trace); - } -#ifndef CONFIG_PREEMPT_RT - rcu_read_unlock_sched(); -#else - ltt_unlock_traces(); -#endif - - mod_timer(<t_async_wakeup_timer, jiffies + LTT_PERCPU_TIMER_INTERVAL); -} +//ust// /* Timer to send async wakeups to the readers */ +//ust// static void async_wakeup(unsigned long data) +//ust// { +//ust// struct ltt_trace_struct *trace; +//ust// +//ust// /* +//ust// * PREEMPT_RT does not allow spinlocks to be taken within preempt +//ust// * disable sections (spinlock taken in wake_up). However, mainline won't +//ust// * allow mutex to be taken in interrupt context. Ugly. +//ust// * A proper way to do this would be to turn the timer into a +//ust// * periodically woken up thread, but it adds to the footprint. +//ust// */ +//ust// #ifndef CONFIG_PREEMPT_RT +//ust// rcu_read_lock_sched(); +//ust// #else +//ust// ltt_lock_traces(); +//ust// #endif +//ust// list_for_each_entry_rcu(trace, <t_traces.head, list) { +//ust// trace_async_wakeup(trace); +//ust// } +//ust// #ifndef CONFIG_PREEMPT_RT +//ust// rcu_read_unlock_sched(); +//ust// #else +//ust// ltt_unlock_traces(); +//ust// #endif +//ust// +//ust// mod_timer(<t_async_wakeup_timer, jiffies + LTT_PERCPU_TIMER_INTERVAL); +//ust// } /** * _ltt_trace_find - find a trace by given name. @@ -431,7 +350,7 @@ struct ltt_trace_struct *_ltt_trace_find_setup(const char *trace_name) return NULL; } -EXPORT_SYMBOL_GPL(_ltt_trace_find_setup); +//ust// EXPORT_SYMBOL_GPL(_ltt_trace_find_setup); /** * ltt_release_transport - Release an LTT transport @@ -441,9 +360,9 @@ void ltt_release_transport(struct kref *kref) { struct ltt_trace_struct *trace = container_of(kref, struct ltt_trace_struct, ltt_transport_kref); - trace->ops->remove_dirs(trace); +//ust// trace->ops->remove_dirs(trace); } -EXPORT_SYMBOL_GPL(ltt_release_transport); +//ust// EXPORT_SYMBOL_GPL(ltt_release_transport); /** * ltt_release_trace - Release a LTT trace @@ -456,7 +375,7 @@ void ltt_release_trace(struct kref *kref) ltt_channels_trace_free(trace->channels); kfree(trace); } -EXPORT_SYMBOL_GPL(ltt_release_trace); +//ust// EXPORT_SYMBOL_GPL(ltt_release_trace); static inline void prepare_chan_size_num(unsigned int *subbuf_size, unsigned int *n_subbufs) @@ -541,7 +460,7 @@ trace_free: traces_error: return err; } -EXPORT_SYMBOL_GPL(_ltt_trace_setup); +//ust// EXPORT_SYMBOL_GPL(_ltt_trace_setup); int ltt_trace_setup(const char *trace_name) @@ -552,7 +471,7 @@ int ltt_trace_setup(const char *trace_name) ltt_unlock_traces(); return ret; } -EXPORT_SYMBOL_GPL(ltt_trace_setup); +//ust// EXPORT_SYMBOL_GPL(ltt_trace_setup); /* must be called from within a traces lock. */ static void _ltt_trace_free(struct ltt_trace_struct *trace) @@ -595,7 +514,7 @@ traces_error: ltt_unlock_traces(); return err; } -EXPORT_SYMBOL_GPL(ltt_trace_set_type); +//ust// EXPORT_SYMBOL_GPL(ltt_trace_set_type); int ltt_trace_set_channel_subbufsize(const char *trace_name, const char *channel_name, unsigned int size) @@ -625,7 +544,7 @@ traces_error: ltt_unlock_traces(); return err; } -EXPORT_SYMBOL_GPL(ltt_trace_set_channel_subbufsize); +//ust// EXPORT_SYMBOL_GPL(ltt_trace_set_channel_subbufsize); int ltt_trace_set_channel_subbufcount(const char *trace_name, const char *channel_name, unsigned int cnt) @@ -655,7 +574,7 @@ traces_error: ltt_unlock_traces(); return err; } -EXPORT_SYMBOL_GPL(ltt_trace_set_channel_subbufcount); +//ust// EXPORT_SYMBOL_GPL(ltt_trace_set_channel_subbufcount); int ltt_trace_set_channel_enable(const char *trace_name, const char *channel_name, unsigned int enable) @@ -696,7 +615,7 @@ traces_error: ltt_unlock_traces(); return err; } -EXPORT_SYMBOL_GPL(ltt_trace_set_channel_enable); +//ust// EXPORT_SYMBOL_GPL(ltt_trace_set_channel_enable); int ltt_trace_set_channel_overwrite(const char *trace_name, const char *channel_name, unsigned int overwrite) @@ -740,7 +659,7 @@ traces_error: ltt_unlock_traces(); return err; } -EXPORT_SYMBOL_GPL(ltt_trace_set_channel_overwrite); +//ust// EXPORT_SYMBOL_GPL(ltt_trace_set_channel_overwrite); int ltt_trace_alloc(const char *trace_name) { @@ -762,9 +681,9 @@ int ltt_trace_alloc(const char *trace_name) kref_init(&trace->kref); kref_init(&trace->ltt_transport_kref); - init_waitqueue_head(&trace->kref_wq); +//ust// init_waitqueue_head(&trace->kref_wq); trace->active = 0; - get_trace_clock(); +//ust// get_trace_clock(); trace->freq_scale = trace_clock_freq_scale(); if (!trace->transport) { @@ -772,25 +691,25 @@ int ltt_trace_alloc(const char *trace_name) err = -EINVAL; goto transport_error; } - if (!try_module_get(trace->transport->owner)) { - printk(KERN_ERR "LTT : Can't lock transport module.\n"); - err = -ENODEV; - goto transport_error; - } +//ust// if (!try_module_get(trace->transport->owner)) { +//ust// printk(KERN_ERR "LTT : Can't lock transport module.\n"); +//ust// err = -ENODEV; +//ust// goto transport_error; +//ust// } trace->ops = &trace->transport->ops; - err = trace->ops->create_dirs(trace); - if (err) { - printk(KERN_ERR "LTT : Can't create dir for trace %s.\n", - trace_name); - goto dirs_error; - } +//ust// err = trace->ops->create_dirs(trace); +//ust// if (err) { +//ust// printk(KERN_ERR "LTT : Can't create dir for trace %s.\n", +//ust// trace_name); +//ust// goto dirs_error; +//ust// } - local_irq_save(flags); +//ust// local_irq_save(flags); trace->start_freq = trace_clock_frequency(); trace->start_tsc = trace_clock_read64(); - do_gettimeofday(&trace->start_time); - local_irq_restore(flags); + gettimeofday(&trace->start_time, NULL); //ust// changed +//ust// local_irq_restore(flags); for (chan = 0; chan < trace->nr_channels; chan++) { if (!(trace->channels[chan].active)) @@ -816,13 +735,13 @@ int ltt_trace_alloc(const char *trace_name) } list_del(&trace->list); - if (list_empty(<t_traces.head)) { - mod_timer(<t_async_wakeup_timer, - jiffies + LTT_PERCPU_TIMER_INTERVAL); - set_kernel_trace_flag_all_tasks(); - } - list_add_rcu(&trace->list, <t_traces.head); - synchronize_sched(); +//ust// if (list_empty(<t_traces.head)) { +//ust// mod_timer(<t_async_wakeup_timer, +//ust// jiffies + LTT_PERCPU_TIMER_INTERVAL); +//ust// set_kernel_trace_flag_all_tasks(); +//ust// } +//ust// list_add_rcu(&trace->list, <t_traces.head); +//ust// synchronize_sched(); ltt_unlock_traces(); @@ -834,14 +753,14 @@ create_channel_error: trace->ops->remove_channel(&trace->channels[chan]); dirs_error: - module_put(trace->transport->owner); +//ust// module_put(trace->transport->owner); transport_error: - put_trace_clock(); +//ust// put_trace_clock(); traces_error: ltt_unlock_traces(); return err; } -EXPORT_SYMBOL_GPL(ltt_trace_alloc); +//ust// EXPORT_SYMBOL_GPL(ltt_trace_alloc); /* * It is worked as a wrapper for current version of ltt_control.ko. @@ -888,16 +807,16 @@ static int _ltt_trace_destroy(struct ltt_trace_struct *trace) goto active_error; } /* Everything went fine */ - list_del_rcu(&trace->list); - synchronize_sched(); +//ust// list_del_rcu(&trace->list); +//ust// synchronize_sched(); if (list_empty(<t_traces.head)) { - clear_kernel_trace_flag_all_tasks(); +//ust// clear_kernel_trace_flag_all_tasks(); /* * We stop the asynchronous delivery of reader wakeup, but * we must make one last check for reader wakeups pending * later in __ltt_trace_destroy. */ - del_timer_sync(<t_async_wakeup_timer); +//ust// del_timer_sync(<t_async_wakeup_timer); } return 0; @@ -919,7 +838,7 @@ static void __ltt_trace_destroy(struct ltt_trace_struct *trace) trace->ops->finish_channel(chan); } - flush_scheduled_work(); +//ust// flush_scheduled_work(); /* * The currently destroyed trace is not in the trace list anymore, @@ -936,17 +855,17 @@ static void __ltt_trace_destroy(struct ltt_trace_struct *trace) kref_put(&trace->ltt_transport_kref, ltt_release_transport); - module_put(trace->transport->owner); +//ust// module_put(trace->transport->owner); /* * Wait for lttd readers to release the files, therefore making sure * the last subbuffers have been read. */ - if (atomic_read(&trace->kref.refcount) > 1) { - int ret = 0; - __wait_event_interruptible(trace->kref_wq, - (atomic_read(&trace->kref.refcount) == 1), ret); - } +//ust// if (atomic_read(&trace->kref.refcount) > 1) { +//ust// int ret = 0; +//ust// __wait_event_interruptible(trace->kref_wq, +//ust// (atomic_read(&trace->kref.refcount) == 1), ret); +//ust// } kref_put(&trace->kref, ltt_release_trace); } @@ -966,7 +885,7 @@ int ltt_trace_destroy(const char *trace_name) ltt_unlock_traces(); __ltt_trace_destroy(trace); - put_trace_clock(); +//ust// put_trace_clock(); return 0; } @@ -985,7 +904,7 @@ error: ltt_unlock_traces(); return err; } -EXPORT_SYMBOL_GPL(ltt_trace_destroy); +//ust// EXPORT_SYMBOL_GPL(ltt_trace_destroy); /* must be called from within a traces lock. */ static int _ltt_trace_start(struct ltt_trace_struct *trace) @@ -999,11 +918,11 @@ static int _ltt_trace_start(struct ltt_trace_struct *trace) if (trace->active) printk(KERN_INFO "LTT : Tracing already active for trace %s\n", trace->trace_name); - if (!try_module_get(ltt_run_filter_owner)) { - err = -ENODEV; - printk(KERN_ERR "LTT : Can't lock filter module.\n"); - goto get_ltt_run_filter_error; - } +//ust// if (!try_module_get(ltt_run_filter_owner)) { +//ust// err = -ENODEV; +//ust// printk(KERN_ERR "LTT : Can't lock filter module.\n"); +//ust// goto get_ltt_run_filter_error; +//ust// } trace->active = 1; /* Read by trace points without protection : be careful */ ltt_traces.num_active_traces++; @@ -1037,16 +956,16 @@ int ltt_trace_start(const char *trace_name) * directly using this trace handle inside the logging function. */ - ltt_dump_marker_state(trace); +//ust// ltt_dump_marker_state(trace); - if (!try_module_get(ltt_statedump_owner)) { - err = -ENODEV; - printk(KERN_ERR - "LTT : Can't lock state dump module.\n"); - } else { +//ust// if (!try_module_get(ltt_statedump_owner)) { +//ust// err = -ENODEV; +//ust// printk(KERN_ERR +//ust// "LTT : Can't lock state dump module.\n"); +//ust// } else { ltt_statedump_functor(trace); - module_put(ltt_statedump_owner); - } +//ust// module_put(ltt_statedump_owner); +//ust// } return err; @@ -1055,7 +974,7 @@ no_trace: ltt_unlock_traces(); return err; } -EXPORT_SYMBOL_GPL(ltt_trace_start); +//ust// EXPORT_SYMBOL_GPL(ltt_trace_start); /* must be called from within traces lock */ static int _ltt_trace_stop(struct ltt_trace_struct *trace) @@ -1072,9 +991,9 @@ static int _ltt_trace_stop(struct ltt_trace_struct *trace) if (trace->active) { trace->active = 0; ltt_traces.num_active_traces--; - synchronize_sched(); /* Wait for each tracing to be finished */ +//ust// synchronize_sched(); /* Wait for each tracing to be finished */ } - module_put(ltt_run_filter_owner); +//ust// module_put(ltt_run_filter_owner); /* Everything went fine */ return 0; @@ -1094,7 +1013,7 @@ int ltt_trace_stop(const char *trace_name) ltt_unlock_traces(); return err; } -EXPORT_SYMBOL_GPL(ltt_trace_stop); +//ust// EXPORT_SYMBOL_GPL(ltt_trace_stop); /** * ltt_control - Trace control in-kernel API @@ -1103,40 +1022,40 @@ EXPORT_SYMBOL_GPL(ltt_trace_stop); * @trace_type: Type of trace (normal, flight, hybrid) * @args: Arguments specific to the action */ -int ltt_control(enum ltt_control_msg msg, const char *trace_name, - const char *trace_type, union ltt_control_args args) -{ - int err = -EPERM; - - printk(KERN_ALERT "ltt_control : trace %s\n", trace_name); - switch (msg) { - case LTT_CONTROL_START: - printk(KERN_DEBUG "Start tracing %s\n", trace_name); - err = ltt_trace_start(trace_name); - break; - case LTT_CONTROL_STOP: - printk(KERN_DEBUG "Stop tracing %s\n", trace_name); - err = ltt_trace_stop(trace_name); - break; - case LTT_CONTROL_CREATE_TRACE: - printk(KERN_DEBUG "Creating trace %s\n", trace_name); - err = ltt_trace_create(trace_name, trace_type, - args.new_trace.mode, - args.new_trace.subbuf_size_low, - args.new_trace.n_subbufs_low, - args.new_trace.subbuf_size_med, - args.new_trace.n_subbufs_med, - args.new_trace.subbuf_size_high, - args.new_trace.n_subbufs_high); - break; - case LTT_CONTROL_DESTROY_TRACE: - printk(KERN_DEBUG "Destroying trace %s\n", trace_name); - err = ltt_trace_destroy(trace_name); - break; - } - return err; -} -EXPORT_SYMBOL_GPL(ltt_control); +//ust// int ltt_control(enum ltt_control_msg msg, const char *trace_name, +//ust// const char *trace_type, union ltt_control_args args) +//ust// { +//ust// int err = -EPERM; +//ust// +//ust// printk(KERN_ALERT "ltt_control : trace %s\n", trace_name); +//ust// switch (msg) { +//ust// case LTT_CONTROL_START: +//ust// printk(KERN_DEBUG "Start tracing %s\n", trace_name); +//ust// err = ltt_trace_start(trace_name); +//ust// break; +//ust// case LTT_CONTROL_STOP: +//ust// printk(KERN_DEBUG "Stop tracing %s\n", trace_name); +//ust// err = ltt_trace_stop(trace_name); +//ust// break; +//ust// case LTT_CONTROL_CREATE_TRACE: +//ust// printk(KERN_DEBUG "Creating trace %s\n", trace_name); +//ust// err = ltt_trace_create(trace_name, trace_type, +//ust// args.new_trace.mode, +//ust// args.new_trace.subbuf_size_low, +//ust// args.new_trace.n_subbufs_low, +//ust// args.new_trace.subbuf_size_med, +//ust// args.new_trace.n_subbufs_med, +//ust// args.new_trace.subbuf_size_high, +//ust// args.new_trace.n_subbufs_high); +//ust// break; +//ust// case LTT_CONTROL_DESTROY_TRACE: +//ust// printk(KERN_DEBUG "Destroying trace %s\n", trace_name); +//ust// err = ltt_trace_destroy(trace_name); +//ust// break; +//ust// } +//ust// return err; +//ust// } +//ust// EXPORT_SYMBOL_GPL(ltt_control); /** * ltt_filter_control - Trace filter control in-kernel API @@ -1157,10 +1076,10 @@ int ltt_filter_control(enum ltt_filter_control_msg msg, const char *trace_name) err = -ENOENT; goto trace_error; } - if (!try_module_get(ltt_filter_control_owner)) { - err = -ENODEV; - goto get_module_error; - } +//ust// if (!try_module_get(ltt_filter_control_owner)) { +//ust// err = -ENODEV; +//ust// goto get_module_error; +//ust// } switch (msg) { case LTT_FILTER_DEFAULT_ACCEPT: printk(KERN_DEBUG @@ -1175,54 +1094,54 @@ int ltt_filter_control(enum ltt_filter_control_msg msg, const char *trace_name) default: err = -EPERM; } - module_put(ltt_filter_control_owner); +//ust// module_put(ltt_filter_control_owner); get_module_error: trace_error: ltt_unlock_traces(); return err; } -EXPORT_SYMBOL_GPL(ltt_filter_control); - -int __init ltt_init(void) -{ - /* Make sure no page fault can be triggered by this module */ - vmalloc_sync_all(); - return 0; -} - -module_init(ltt_init) - -static void __exit ltt_exit(void) -{ - struct ltt_trace_struct *trace; - struct list_head *pos, *n; - - ltt_lock_traces(); - /* Stop each trace, currently being read by RCU read-side */ - list_for_each_entry_rcu(trace, <t_traces.head, list) - _ltt_trace_stop(trace); - /* Wait for quiescent state. Readers have preemption disabled. */ - synchronize_sched(); - /* Safe iteration is now permitted. It does not have to be RCU-safe - * because no readers are left. */ - list_for_each_safe(pos, n, <t_traces.head) { - trace = container_of(pos, struct ltt_trace_struct, list); - /* _ltt_trace_destroy does a synchronize_sched() */ - _ltt_trace_destroy(trace); - __ltt_trace_destroy(trace); - } - /* free traces in pre-alloc status */ - list_for_each_safe(pos, n, <t_traces.setup_head) { - trace = container_of(pos, struct ltt_trace_struct, list); - _ltt_trace_free(trace); - } - - ltt_unlock_traces(); -} - -module_exit(ltt_exit) - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Mathieu Desnoyers"); -MODULE_DESCRIPTION("Linux Trace Toolkit Next Generation Tracer Kernel API"); +//ust// EXPORT_SYMBOL_GPL(ltt_filter_control); + +//ust// int __init ltt_init(void) +//ust// { +//ust// /* Make sure no page fault can be triggered by this module */ +//ust// vmalloc_sync_all(); +//ust// return 0; +//ust// } + +//ust// module_init(ltt_init) + +//ust// static void __exit ltt_exit(void) +//ust// { +//ust// struct ltt_trace_struct *trace; +//ust// struct list_head *pos, *n; +//ust// +//ust// ltt_lock_traces(); +//ust// /* Stop each trace, currently being read by RCU read-side */ +//ust// list_for_each_entry_rcu(trace, <t_traces.head, list) +//ust// _ltt_trace_stop(trace); +//ust// /* Wait for quiescent state. Readers have preemption disabled. */ +//ust// synchronize_sched(); +//ust// /* Safe iteration is now permitted. It does not have to be RCU-safe +//ust// * because no readers are left. */ +//ust// list_for_each_safe(pos, n, <t_traces.head) { +//ust// trace = container_of(pos, struct ltt_trace_struct, list); +//ust// /* _ltt_trace_destroy does a synchronize_sched() */ +//ust// _ltt_trace_destroy(trace); +//ust// __ltt_trace_destroy(trace); +//ust// } +//ust// /* free traces in pre-alloc status */ +//ust// list_for_each_safe(pos, n, <t_traces.setup_head) { +//ust// trace = container_of(pos, struct ltt_trace_struct, list); +//ust// _ltt_trace_free(trace); +//ust// } +//ust// +//ust// ltt_unlock_traces(); +//ust// } + +//ust// module_exit(ltt_exit) + +//ust// MODULE_LICENSE("GPL"); +//ust// MODULE_AUTHOR("Mathieu Desnoyers"); +//ust// MODULE_DESCRIPTION("Linux Trace Toolkit Next Generation Tracer Kernel API"); diff --git a/libtracing/tracer.h b/libtracing/tracer.h index 822311e..6e98f2b 100644 --- a/libtracing/tracer.h +++ b/libtracing/tracer.h @@ -7,21 +7,27 @@ #ifndef _LTT_TRACER_H #define _LTT_TRACER_H +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "relay.h" +#include "list.h" +#include "kernelcompat.h" +#include "channels.h" /* Number of bytes to log with a read/write event */ #define LTT_LOG_RW_SIZE 32L @@ -62,13 +68,13 @@ size_t ltt_serialize_data(struct rchan_buf *buf, size_t buf_offset, void *serialize_private, int *largest_align, const char *fmt, va_list *args); -struct ltt_available_probe { - const char *name; /* probe name */ - const char *format; - marker_probe_func *probe_func; - ltt_serialize_cb callbacks[LTT_NR_CALLBACKS]; - struct list_head node; /* registered probes list */ -}; +//ust// struct ltt_available_probe { +//ust// const char *name; /* probe name */ +//ust// const char *format; +//ust// marker_probe_func *probe_func; +//ust// ltt_serialize_cb callbacks[LTT_NR_CALLBACKS]; +//ust// struct list_head node; /* registered probes list */ +//ust// }; struct ltt_probe_private_data { struct ltt_trace_struct *trace; /* @@ -86,23 +92,7 @@ struct ltt_probe_private_data { enum ltt_channels { LTT_CHANNEL_METADATA, - LTT_CHANNEL_FD_STATE, - LTT_CHANNEL_GLOBAL_STATE, - LTT_CHANNEL_IRQ_STATE, - LTT_CHANNEL_MODULE_STATE, - LTT_CHANNEL_NETIF_STATE, - LTT_CHANNEL_SOFTIRQ_STATE, - LTT_CHANNEL_SWAP_STATE, - LTT_CHANNEL_SYSCALL_STATE, - LTT_CHANNEL_TASK_STATE, - LTT_CHANNEL_VM_STATE, - LTT_CHANNEL_FS, - LTT_CHANNEL_INPUT, - LTT_CHANNEL_IPC, - LTT_CHANNEL_KERNEL, - LTT_CHANNEL_MM, - LTT_CHANNEL_RCU, - LTT_CHANNEL_DEFAULT, + LTT_CHANNEL_UST, }; struct ltt_active_marker { @@ -113,6 +103,7 @@ struct ltt_active_marker { struct ltt_available_probe *probe; }; +struct marker; //ust// extern void ltt_vtrace(const struct marker *mdata, void *probe_data, void *call_data, const char *fmt, va_list *args); extern void ltt_trace(const struct marker *mdata, void *probe_data, @@ -138,7 +129,7 @@ static inline enum marker_id marker_id_type(uint16_t id) return MARKER_ID_DYNAMIC; } -#ifdef CONFIG_LTT +//ust// #ifdef CONFIG_LTT struct user_dbg_data { unsigned long avail_size; @@ -162,25 +153,25 @@ struct ltt_trace_ops { int (*user_blocking) (struct ltt_trace_struct *trace, unsigned int index, size_t data_size, struct user_dbg_data *dbg); - /* End of first 32 bytes cacheline */ - int (*create_dirs) (struct ltt_trace_struct *new_trace); - void (*remove_dirs) (struct ltt_trace_struct *new_trace); - int (*create_channel) (const char *trace_name, - struct ltt_trace_struct *trace, - struct dentry *dir, const char *channel_name, - struct ltt_channel_struct *ltt_chan, - unsigned int subbuf_size, - unsigned int n_subbufs, int overwrite); - void (*finish_channel) (struct ltt_channel_struct *channel); - void (*remove_channel) (struct ltt_channel_struct *channel); - void (*user_errors) (struct ltt_trace_struct *trace, - unsigned int index, size_t data_size, - struct user_dbg_data *dbg, int cpu); -#ifdef CONFIG_HOTPLUG_CPU - int (*handle_cpuhp) (struct notifier_block *nb, - unsigned long action, void *hcpu, - struct ltt_trace_struct *trace); -#endif +//ust// /* End of first 32 bytes cacheline */ +//ust// int (*create_dirs) (struct ltt_trace_struct *new_trace); +//ust// void (*remove_dirs) (struct ltt_trace_struct *new_trace); + int (*create_channel) (const char *trace_name, + struct ltt_trace_struct *trace, + struct dentry *dir, const char *channel_name, + struct ltt_channel_struct *ltt_chan, + unsigned int subbuf_size, + unsigned int n_subbufs, int overwrite); + void (*finish_channel) (struct ltt_channel_struct *channel); + void (*remove_channel) (struct ltt_channel_struct *channel); + void (*user_errors) (struct ltt_trace_struct *trace, + unsigned int index, size_t data_size, + struct user_dbg_data *dbg, int cpu); +//ust// #ifdef CONFIG_HOTPLUG_CPU +//ust// int (*handle_cpuhp) (struct notifier_block *nb, +//ust// unsigned long action, void *hcpu, +//ust// struct ltt_trace_struct *trace); +//ust// #endif } ____cacheline_aligned; struct ltt_transport { @@ -213,11 +204,11 @@ struct ltt_trace_struct { struct { struct dentry *trace_root; } dentry; - struct rchan_callbacks callbacks; +//ust// struct rchan_callbacks callbacks; struct kref kref; /* Each channel has a kref of the trace struct */ struct ltt_transport *transport; struct kref ltt_transport_kref; - wait_queue_head_t kref_wq; /* Place for ltt_trace_destroy to sleep */ +//ust// wait_queue_head_t kref_wq; /* Place for ltt_trace_destroy to sleep */ char trace_name[NAME_MAX]; } ____cacheline_aligned; @@ -547,26 +538,11 @@ static inline void ltt_commit_slot( * cpu channel : * cpu */ -#define LTT_RELAY_ROOT "ltt" -#define LTT_RELAY_LOCKED_ROOT "ltt-locked" +//ust// #define LTT_RELAY_ROOT "ltt" +//ust// #define LTT_RELAY_LOCKED_ROOT "ltt-locked" #define LTT_METADATA_CHANNEL "metadata_state" -#define LTT_FD_STATE_CHANNEL "fd_state" -#define LTT_GLOBAL_STATE_CHANNEL "global_state" -#define LTT_IRQ_STATE_CHANNEL "irq_state" -#define LTT_MODULE_STATE_CHANNEL "module_state" -#define LTT_NETIF_STATE_CHANNEL "netif_state" -#define LTT_SOFTIRQ_STATE_CHANNEL "softirq_state" -#define LTT_SWAP_STATE_CHANNEL "swap_state" -#define LTT_SYSCALL_STATE_CHANNEL "syscall_state" -#define LTT_TASK_STATE_CHANNEL "task_state" -#define LTT_VM_STATE_CHANNEL "vm_state" -#define LTT_FS_CHANNEL "fs" -#define LTT_INPUT_CHANNEL "input" -#define LTT_IPC_CHANNEL "ipc" -#define LTT_KERNEL_CHANNEL "kernel" -#define LTT_MM_CHANNEL "mm" -#define LTT_RCU_CHANNEL "rcu" +#define LTT_UST_CHANNEL "ust" #define LTT_FLIGHT_PREFIX "flight-" @@ -597,21 +573,21 @@ enum ltt_module_function { LTT_FUNCTION_STATEDUMP }; -extern int ltt_module_register(enum ltt_module_function name, void *function, - struct module *owner); -extern void ltt_module_unregister(enum ltt_module_function name); +//ust// extern int ltt_module_register(enum ltt_module_function name, void *function, +//ust// struct module *owner); +//ust// extern void ltt_module_unregister(enum ltt_module_function name); void ltt_transport_register(struct ltt_transport *transport); void ltt_transport_unregister(struct ltt_transport *transport); /* Exported control function */ -enum ltt_control_msg { - LTT_CONTROL_START, - LTT_CONTROL_STOP, - LTT_CONTROL_CREATE_TRACE, - LTT_CONTROL_DESTROY_TRACE -}; +//ust// enum ltt_control_msg { +//ust// LTT_CONTROL_START, +//ust// LTT_CONTROL_STOP, +//ust// LTT_CONTROL_CREATE_TRACE, +//ust// LTT_CONTROL_DESTROY_TRACE +//ust// }; union ltt_control_args { struct { @@ -642,8 +618,8 @@ int ltt_trace_destroy(const char *trace_name); int ltt_trace_start(const char *trace_name); int ltt_trace_stop(const char *trace_name); -extern int ltt_control(enum ltt_control_msg msg, const char *trace_name, - const char *trace_type, union ltt_control_args args); +//ust// extern int ltt_control(enum ltt_control_msg msg, const char *trace_name, +//ust// const char *trace_type, union ltt_control_args args); enum ltt_filter_control_msg { LTT_FILTER_DEFAULT_ACCEPT, @@ -677,40 +653,40 @@ extern void ltt_dump_marker_state(struct ltt_trace_struct *trace); void ltt_lock_traces(void); void ltt_unlock_traces(void); -extern void ltt_dump_softirq_vec(void *call_data); - -#ifdef CONFIG_HAVE_LTT_DUMP_TABLES -extern void ltt_dump_sys_call_table(void *call_data); -extern void ltt_dump_idt_table(void *call_data); -#else -static inline void ltt_dump_sys_call_table(void *call_data) -{ -} - -static inline void ltt_dump_idt_table(void *call_data) -{ -} -#endif - -#ifdef CONFIG_LTT_KPROBES -extern void ltt_dump_kprobes_table(void *call_data); -#else -static inline void ltt_dump_kprobes_table(void *call_data) -{ -} -#endif - -/* Relay IOCTL */ - -/* Get the next sub buffer that can be read. */ -#define RELAY_GET_SUBBUF _IOR(0xF5, 0x00, __u32) -/* Release the oldest reserved (by "get") sub buffer. */ -#define RELAY_PUT_SUBBUF _IOW(0xF5, 0x01, __u32) -/* returns the number of sub buffers in the per cpu channel. */ -#define RELAY_GET_N_SUBBUFS _IOR(0xF5, 0x02, __u32) -/* returns the size of the sub buffers. */ -#define RELAY_GET_SUBBUF_SIZE _IOR(0xF5, 0x03, __u32) - -#endif /* CONFIG_LTT */ +//ust// extern void ltt_dump_softirq_vec(void *call_data); +//ust// +//ust// #ifdef CONFIG_HAVE_LTT_DUMP_TABLES +//ust// extern void ltt_dump_sys_call_table(void *call_data); +//ust// extern void ltt_dump_idt_table(void *call_data); +//ust// #else +//ust// static inline void ltt_dump_sys_call_table(void *call_data) +//ust// { +//ust// } +//ust// +//ust// static inline void ltt_dump_idt_table(void *call_data) +//ust// { +//ust// } +//ust// #endif + +//ust// #ifdef CONFIG_LTT_KPROBES +//ust// extern void ltt_dump_kprobes_table(void *call_data); +//ust// #else +//ust// static inline void ltt_dump_kprobes_table(void *call_data) +//ust// { +//ust// } +//ust// #endif + +//ust// /* Relay IOCTL */ +//ust// +//ust// /* Get the next sub buffer that can be read. */ +//ust// #define RELAY_GET_SUBBUF _IOR(0xF5, 0x00, __u32) +//ust// /* Release the oldest reserved (by "get") sub buffer. */ +//ust// #define RELAY_PUT_SUBBUF _IOW(0xF5, 0x01, __u32) +//ust// /* returns the number of sub buffers in the per cpu channel. */ +//ust// #define RELAY_GET_N_SUBBUFS _IOR(0xF5, 0x02, __u32) +//ust// /* returns the size of the sub buffers. */ +//ust// #define RELAY_GET_SUBBUF_SIZE _IOR(0xF5, 0x03, __u32) + +//ust// #endif /* CONFIG_LTT */ #endif /* _LTT_TRACER_H */ diff --git a/libtracing/tracercore.c b/libtracing/tracercore.c index 18db91d..2c2dcfc 100644 --- a/libtracing/tracercore.c +++ b/libtracing/tracercore.c @@ -6,48 +6,49 @@ * Distributed under the GPL license */ -#include -#include -#include -#include +//ust// #include +//ust// #include +//ust// #include +//ust// #include +#include "tracercore.h" /* Traces structures */ struct ltt_traces ltt_traces = { .setup_head = LIST_HEAD_INIT(ltt_traces.setup_head), .head = LIST_HEAD_INIT(ltt_traces.head), }; -EXPORT_SYMBOL(ltt_traces); +//ust// EXPORT_SYMBOL(ltt_traces); /* Traces list writer locking */ static DEFINE_MUTEX(ltt_traces_mutex); /* dentry of ltt's root dir */ -static struct dentry *ltt_root_dentry; -struct dentry *get_ltt_root(void) -{ - if (!ltt_root_dentry) { - ltt_root_dentry = debugfs_create_dir(LTT_ROOT, NULL); - if (!ltt_root_dentry) - printk(KERN_ERR "LTT : create ltt root dir failed\n"); - } - return ltt_root_dentry; -} -EXPORT_SYMBOL_GPL(get_ltt_root); +//ust// static struct dentry *ltt_root_dentry; +//ust// struct dentry *get_ltt_root(void) +//ust// { +//ust// if (!ltt_root_dentry) { +//ust// ltt_root_dentry = debugfs_create_dir(LTT_ROOT, NULL); +//ust// if (!ltt_root_dentry) +//ust// printk(KERN_ERR "LTT : create ltt root dir failed\n"); +//ust// } +//ust// return ltt_root_dentry; +//ust// } +//ust// EXPORT_SYMBOL_GPL(get_ltt_root); void ltt_lock_traces(void) { mutex_lock(<t_traces_mutex); } -EXPORT_SYMBOL_GPL(ltt_lock_traces); +//ust// EXPORT_SYMBOL_GPL(ltt_lock_traces); void ltt_unlock_traces(void) { mutex_unlock(<t_traces_mutex); } -EXPORT_SYMBOL_GPL(ltt_unlock_traces); +//ust// EXPORT_SYMBOL_GPL(ltt_unlock_traces); -DEFINE_PER_CPU(unsigned int, ltt_nesting); -EXPORT_PER_CPU_SYMBOL(ltt_nesting); +//ust// DEFINE_PER_CPU(unsigned int, ltt_nesting); +//ust// EXPORT_PER_CPU_SYMBOL(ltt_nesting); int ltt_run_filter_default(void *trace, uint16_t eID) { @@ -56,16 +57,16 @@ int ltt_run_filter_default(void *trace, uint16_t eID) /* This function pointer is protected by a trace activation check */ ltt_run_filter_functor ltt_run_filter = ltt_run_filter_default; -EXPORT_SYMBOL_GPL(ltt_run_filter); +//ust// EXPORT_SYMBOL_GPL(ltt_run_filter); void ltt_filter_register(ltt_run_filter_functor func) { ltt_run_filter = func; } -EXPORT_SYMBOL_GPL(ltt_filter_register); +//ust// EXPORT_SYMBOL_GPL(ltt_filter_register); void ltt_filter_unregister(void) { ltt_run_filter = ltt_run_filter_default; } -EXPORT_SYMBOL_GPL(ltt_filter_unregister); +//ust// EXPORT_SYMBOL_GPL(ltt_filter_unregister); diff --git a/libtracing/tracercore.h b/libtracing/tracercore.h index 17322fc..3207f91 100644 --- a/libtracing/tracercore.h +++ b/libtracing/tracercore.h @@ -8,6 +8,7 @@ #define LTT_CORE_H #include "list.h" +#include "kernelcompat.h" //ust// #include /* ltt's root dir in debugfs */ diff --git a/share/kernelcompat.h b/share/kernelcompat.h index aa3d0fa..5bd8e87 100644 --- a/share/kernelcompat.h +++ b/share/kernelcompat.h @@ -9,8 +9,11 @@ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) -#define KERN_DEBUG -#define KERN_NOTICE +#define KERN_DEBUG "" +#define KERN_NOTICE "" +#define KERN_INFO "" +#define KERN_ERR "" +#define KERN_ALERT "" /* ERROR OPS */ @@ -43,6 +46,18 @@ typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; +#define min_t(type, x, y) ({ \ + type __min1 = (x); \ + type __min2 = (y); \ + __min1 < __min2 ? __min1: __min2; }) + +#define max_t(type, x, y) ({ \ + type __max1 = (x); \ + type __max2 = (y); \ + __max1 > __max2 ? __max1: __max2; }) + + +/* MUTEXES */ #include @@ -52,6 +67,7 @@ typedef uint64_t u64; #define mutex_unlock(m) pthread_mutex_unlock(m) +/* MALLOCATION */ #include @@ -60,11 +76,11 @@ typedef uint64_t u64; #define kfree(p) free((void *)p) #define kstrdup(s, t) strdup(s) +/* PRINTK */ #include #define printk(fmt, args...) printf(fmt, ## args) - /* MEMORY BARRIERS */ #define smp_rmb() do {} while(0) @@ -78,8 +94,11 @@ typedef uint64_t u64; /* RCU */ #define rcu_assign_pointer(a, b) do {} while(0) +#define call_rcu_sched(a,b) do {} while(0) +#define rcu_barrier_sched() do {} while(0) /* ATOMICITY */ + #include typedef struct { sig_atomic_t counter; } atomic_t; @@ -106,6 +125,66 @@ static int atomic_read(atomic_t *p) } /* CACHE */ + #define ____cacheline_aligned +/* MATH */ + +static inline unsigned int hweight32(unsigned int w) +{ + unsigned int res = w - ((w >> 1) & 0x55555555); + res = (res & 0x33333333) + ((res >> 2) & 0x33333333); + res = (res + (res >> 4)) & 0x0F0F0F0F; + res = res + (res >> 8); + return (res + (res >> 16)) & 0x000000FF; +} + +static inline int fls(int x) +{ + int r; +//ust// #ifdef CONFIG_X86_CMOV + asm("bsrl %1,%0\n\t" + "cmovzl %2,%0" + : "=&r" (r) : "rm" (x), "rm" (-1)); +//ust// #else +//ust// asm("bsrl %1,%0\n\t" +//ust// "jnz 1f\n\t" +//ust// "movl $-1,%0\n" +//ust// "1:" : "=r" (r) : "rm" (x)); +//ust// #endif + return r + 1; +} + +static __inline__ int get_count_order(unsigned int count) +{ + int order; + + order = fls(count) - 1; + if (count & (count - 1)) + order++; + return order; +} + + +/* ARRAYS */ + +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) + +/* TRACE CLOCK */ + +static inline u64 trace_clock_read64(void) +{ + return 0LL; +} + +static inline unsigned int trace_clock_frequency(void) +{ + return 0LL; +} + +static inline u32 trace_clock_freq_scale(void) +{ + return 0; +} + #endif /* KERNELCOMPAT_H */ -- 2.34.1