From 23c1c6557af76d506a28bcb3e864d3500e6dc565 Mon Sep 17 00:00:00 2001 From: David Smith Date: Tue, 24 Feb 2009 11:54:16 -0600 Subject: Major hacking to minimal config. 2009-02-24 David Smith * print.h: New file. * print.c: Includes new print.h file. * print_new.c (stp_print_flush): Commented out some code that needs replacing. * sym.c: Includes sym.h. * transport/debugfs.c: Includes transport.h. * transport/relayfs.c: Updated _stp_get_root_dir() call. * transport/transport.c: Ifdef'ed out most setup. * transport/transport.h: Ifdef'ed out all but basics. * transport/utt.c (utt_create_tree): Updated _stp_get_root_dir() call. * transport/utt.h: Commented out 'rchan' in struct utt_trace. (utt_reserve): Ifdef'ed out guts. --- runtime/transport/transport.c | 140 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 116 insertions(+), 24 deletions(-) (limited to 'runtime/transport/transport.c') diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index 7fcebd42..2d82270a 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -14,10 +14,21 @@ #ifndef _TRANSPORT_TRANSPORT_C_ #define _TRANSPORT_TRANSPORT_C_ -#include -#include #include "transport.h" -#include "time.c" +struct utt_trace { + int dummy; +}; +static struct utt_trace *_stp_utt = NULL; +static int _stp_ctl_write(int type, void *data, unsigned len) { + return 0; +} + +static int _stp_exit_flag = 0; + +#include +#include +#if 0 +#include #include "../mempool.c" #include "symbols.c" @@ -37,10 +48,15 @@ static int _stp_exit_flag = 0; #endif #include "control.c" +#endif /* if 0 */ +static unsigned _stp_nsubbufs = 8; +static unsigned _stp_subbuf_size = 65536*4; + /* module parameters */ static int _stp_bufsize; module_param(_stp_bufsize, int, 0); MODULE_PARM_DESC(_stp_bufsize, "buffer size"); +#if 0 /* forward declarations */ static void probe_exit(void); @@ -173,6 +189,7 @@ static void _stp_work_queue(void *data) if (likely(_stp_attached)) queue_delayed_work(_stp_wq, &_stp_work, STP_WORK_TIMER); } +#endif /* #if 0 */ /** * _stp_transport_close - close ctl and relayfs channels @@ -180,9 +197,11 @@ static void _stp_work_queue(void *data) * This is called automatically when the module is unloaded. * */ -static void _stp_transport_close() +static void _stp_transport_close(void) { - dbug_trans(1, "%d: ************** transport_close *************\n", current->pid); + dbug_trans(1, "%d: ************** transport_close *************\n", + current->pid); +#if 0 _stp_cleanup_and_exit(0); destroy_workqueue(_stp_wq); _stp_unregister_ctl_channel(); @@ -190,9 +209,13 @@ static void _stp_transport_close() utt_trace_remove(_stp_utt); _stp_print_cleanup(); /* free print buffers */ _stp_mem_debug_done(); +#endif + _stp_transport_fs_close(); + dbug_trans(1, "---- CLOSED ----\n"); } +#if 0 static struct utt_trace *_stp_utt_open(void) { struct utt_trace_setup utts; @@ -209,6 +232,7 @@ static struct utt_trace *_stp_utt_open(void) return utt_trace_setup(&utts); } +#endif /* #if 0 */ /** * _stp_transport_init() is called from the module initialization. @@ -217,7 +241,6 @@ static struct utt_trace *_stp_utt_open(void) static int _stp_transport_init(void) { dbug_trans(1, "transport_init\n"); - _stp_init_pid = current->pid; #ifdef STAPCONF_TASK_UID _stp_uid = current->uid; _stp_gid = current->gid; @@ -226,6 +249,8 @@ static int _stp_transport_init(void) _stp_gid = current_gid(); #endif +// DRS: is RELAY_GUEST/RELAY_HOST documented? does it work? are there +// test cases? #ifdef RELAY_GUEST /* Guest scripts use relay only for reporting warnings and errors */ _stp_subbuf_size = 65536; @@ -243,6 +268,10 @@ static int _stp_transport_init(void) dbug_trans(1, "Using %d subbufs of size %d\n", _stp_nsubbufs, _stp_subbuf_size); } + if (_stp_transport_fs_init(THIS_MODULE->name)) + return -1; + +#if 0 #if !defined (STP_OLD_TRANSPORT) || defined (STP_BULKMODE) /* open utt (relayfs) channel to send data to userspace */ _stp_utt = _stp_utt_open(); @@ -253,11 +282,13 @@ static int _stp_transport_init(void) /* create control channel */ if (_stp_register_ctl_channel() < 0) goto err1; +#endif /* #if 0 */ /* create print buffers */ if (_stp_print_init() < 0) goto err2; +#if 0 /* start transport */ utt_trace_startstop(_stp_utt, 1, &utt_seq); @@ -270,16 +301,19 @@ static int _stp_transport_init(void) /* Signal stapio to send us STP_START back (XXX: ?!?!?!). */ _stp_ctl_send(STP_TRANSPORT, NULL, 0); +#endif /* #if 0 */ return 0; err3: _stp_print_cleanup(); err2: +#if 0 _stp_unregister_ctl_channel(); err1: if (_stp_utt) utt_trace_remove(_stp_utt); +#endif /* #if 0 */ err0: return -1; } @@ -331,51 +365,109 @@ static void _stp_unlock_transport_dir(void) } } -/* _stp_get_root_dir(name) - creates root directory 'name' or */ -/* returns a pointer to it if it already exists. Used in */ -/* utt.c and relayfs.c. Will not be necessary if utt is included */ -/* in the kernel. */ +static struct dentry *__stp_root_dir = NULL; -static struct dentry *_stp_get_root_dir(const char *name) +/* _stp_get_root_dir() - creates root directory or returns + * a pointer to it if it already exists. */ + +static struct dentry *_stp_get_root_dir(void) { struct file_system_type *fs; - struct dentry *root; struct super_block *sb; + const char *name = "systemtap"; + + if (__stp_root_dir != NULL) { + return __stp_root_dir; + } #ifdef STP_OLD_TRANSPORT fs = get_fs_type("relayfs"); + if (!fs) { + errk("Couldn't find relayfs filesystem.\n"); + return NULL; + } #else fs = get_fs_type("debugfs"); -#endif if (!fs) { - errk("Couldn't find debugfs or relayfs filesystem.\n"); + errk("Couldn't find debugfs filesystem.\n"); return NULL; } +#endif if (!_stp_lock_transport_dir()) { errk("Couldn't lock transport directory.\n"); return NULL; } #ifdef STP_OLD_TRANSPORT - root = relayfs_create_dir(name, NULL); + __stp_root_dir = relayfs_create_dir(name, NULL); #else - root = debugfs_create_dir(name, NULL); + __stp_root_dir = debugfs_create_dir(name, NULL); #endif - if (!root) { - /* couldn't create it because it is already there, so find it. */ - sb = list_entry(fs->fs_supers.next, struct super_block, s_instances); + if (!__stp_root_dir) { + /* Couldn't create it because it is already there, so + * find it. */ + sb = list_entry(fs->fs_supers.next, struct super_block, + s_instances); _stp_lock_inode(sb->s_root->d_inode); - root = lookup_one_len(name, sb->s_root, strlen(name)); + __stp_root_dir = lookup_one_len(name, sb->s_root, + strlen(name)); _stp_unlock_inode(sb->s_root->d_inode); - if (!IS_ERR(root)) - dput(root); + if (!IS_ERR(__stp_root_dir)) + dput(__stp_root_dir); else { - root = NULL; + __stp_root_dir = NULL; errk("Could not create or find transport directory.\n"); } } _stp_unlock_transport_dir(); - return root; + return __stp_root_dir; +} + +static void _stp_remove_root_dir(void) +{ + if (__stp_root_dir) { + if (!_stp_lock_transport_dir()) { + errk("Unable to lock transport directory.\n"); + return; + } + if (simple_empty(__stp_root_dir)) + debugfs_remove(__stp_root_dir); + _stp_unlock_transport_dir(); + __stp_root_dir = NULL; + } } +static struct dentry *__stp_module_dir = NULL; + +static int _stp_transport_fs_init(const char *module_name) +{ + struct dentry *root_dir; + + if (module_name == NULL) + return -1; + + root_dir = _stp_get_root_dir(); + if (root_dir == NULL) + return -1; + + __stp_module_dir = debugfs_create_dir(module_name, root_dir); + if (!__stp_module_dir) { + _stp_remove_root_dir(); + return -1; + } + return 0; +} + +static void _stp_transport_fs_close(void) +{ + dbug_trans(1, "stp_transport_fs_close\n"); + if (__stp_module_dir) { + debugfs_remove(__stp_module_dir); + __stp_module_dir = NULL; + } + + _stp_remove_root_dir(); +} + + #endif /* _TRANSPORT_C_ */ -- cgit From 64c962fed5f50a7f82f8b570e000cdcff757862b Mon Sep 17 00:00:00 2001 From: David Smith Date: Wed, 25 Feb 2009 09:04:19 -0600 Subject: More cleanup. 2009-02-25 David Smith * debug.h: Removed unused variable '_stp_transport_state'. * print_new.c (stp_print_flush): Ifdef'ed out call to utt_reserve(). * runtime.h: Added _stp_warn() prototype. * transport/control.c: Includes control.h, mempool.c, and symbols.c. Renamed '_stp_attached' to '_stp_ctl_attached'. * transport/control.h: Removed _stp_pool_q declaration. * transport/debugfs.c (_stp_register_ctl_channel_fs): Uses _stp_get_module_dir(). * transport/transport.c: Cleanup. * transport/transport.h: Ditto. --- runtime/transport/transport.c | 68 ++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 21 deletions(-) (limited to 'runtime/transport/transport.c') diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index 2d82270a..12e98a38 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -15,29 +15,36 @@ #define _TRANSPORT_TRANSPORT_C_ #include "transport.h" +#include +#include +#include + struct utt_trace { int dummy; }; -static struct utt_trace *_stp_utt = NULL; -static int _stp_ctl_write(int type, void *data, unsigned len) { - return 0; +//static struct utt_trace *_stp_utt = NULL; + +static void utt_set_overwrite(int overwrite) +{ + return; } static int _stp_exit_flag = 0; -#include -#include +static uid_t _stp_uid = 0; +static gid_t _stp_gid = 0; +static int _stp_pid = 0; + +static int _stp_ctl_attached = 0; + +static pid_t _stp_target = 0; +static int _stp_probes_started = 0; + #if 0 #include -#include "../mempool.c" -#include "symbols.c" static struct utt_trace *_stp_utt = NULL; static unsigned int utt_seq = 1; -static int _stp_probes_started = 0; -static pid_t _stp_target = 0; -static int _stp_exit_called = 0; -static int _stp_exit_flag = 0; #include "control.h" #ifdef STP_OLD_TRANSPORT #include "relayfs.c" @@ -48,6 +55,10 @@ static int _stp_exit_flag = 0; #endif #include "control.c" +#else /* #if 0 */ +#include "control.h" +#include "debugfs.c" +#include "control.c" #endif /* if 0 */ static unsigned _stp_nsubbufs = 8; static unsigned _stp_subbuf_size = 65536*4; @@ -56,12 +67,13 @@ static unsigned _stp_subbuf_size = 65536*4; static int _stp_bufsize; module_param(_stp_bufsize, int, 0); MODULE_PARM_DESC(_stp_bufsize, "buffer size"); -#if 0 /* forward declarations */ static void probe_exit(void); static int probe_start(void); +#if 0 static void _stp_exit(void); +#endif /* #if 0 */ /* check for new workqueue API */ #ifdef DECLARE_DELAYED_WORK @@ -105,6 +117,8 @@ static void _stp_handle_start(struct _stp_msg_start *st) /* when someone does /sbin/rmmod on a loaded systemtap module. */ static void _stp_cleanup_and_exit(int send_exit) { + static int _stp_exit_called = 0; + if (!_stp_exit_called) { int failures; @@ -125,8 +139,10 @@ static void _stp_cleanup_and_exit(int send_exit) _stp_warn("There were %d transport failures.\n", failures); dbug_trans(1, "************** calling startstop 0 *************\n"); +#if 0 if (_stp_utt) utt_trace_startstop(_stp_utt, 0, &utt_seq); +#endif dbug_trans(1, "ctl_send STP_EXIT\n"); if (send_exit) @@ -141,7 +157,7 @@ static void _stp_cleanup_and_exit(int send_exit) static void _stp_detach(void) { dbug_trans(1, "detach\n"); - _stp_attached = 0; + _stp_ctl_attached = 0; _stp_pid = 0; if (!_stp_exit_flag) @@ -157,7 +173,7 @@ static void _stp_detach(void) static void _stp_attach(void) { dbug_trans(1, "attach\n"); - _stp_attached = 1; + _stp_ctl_attached = 1; _stp_pid = current->pid; utt_set_overwrite(0); queue_delayed_work(_stp_wq, &_stp_work, STP_WORK_TIMER); @@ -186,10 +202,9 @@ static void _stp_work_queue(void *data) /* if exit flag is set AND we have finished with probe_start() */ if (unlikely(_stp_exit_flag && _stp_probes_started)) _stp_cleanup_and_exit(1); - if (likely(_stp_attached)) + if (likely(_stp_ctl_attached)) queue_delayed_work(_stp_wq, &_stp_work, STP_WORK_TIMER); } -#endif /* #if 0 */ /** * _stp_transport_close - close ctl and relayfs channels @@ -203,13 +218,17 @@ static void _stp_transport_close(void) current->pid); #if 0 _stp_cleanup_and_exit(0); +#endif /* #if 0 */ destroy_workqueue(_stp_wq); _stp_unregister_ctl_channel(); +#if 0 if (_stp_utt) utt_trace_remove(_stp_utt); +#endif /* #if 0 */ _stp_print_cleanup(); /* free print buffers */ +#if 0 _stp_mem_debug_done(); -#endif +#endif /* #if 0 */ _stp_transport_fs_close(); dbug_trans(1, "---- CLOSED ----\n"); @@ -278,11 +297,11 @@ static int _stp_transport_init(void) if (!_stp_utt) goto err0; #endif +#endif /* #if 0 */ /* create control channel */ if (_stp_register_ctl_channel() < 0) goto err1; -#endif /* #if 0 */ /* create print buffers */ if (_stp_print_init() < 0) @@ -291,14 +310,14 @@ static int _stp_transport_init(void) #if 0 /* start transport */ utt_trace_startstop(_stp_utt, 1, &utt_seq); +#endif /* #if 0 */ /* create workqueue of kernel threads */ _stp_wq = create_workqueue("systemtap"); if (!_stp_wq) goto err3; - _stp_transport_state = 1; - +#if 0 /* Signal stapio to send us STP_START back (XXX: ?!?!?!). */ _stp_ctl_send(STP_TRANSPORT, NULL, 0); #endif /* #if 0 */ @@ -308,11 +327,13 @@ static int _stp_transport_init(void) err3: _stp_print_cleanup(); err2: -#if 0 _stp_unregister_ctl_channel(); err1: +#if 0 if (_stp_utt) utt_trace_remove(_stp_utt); +#else + _stp_transport_fs_close(); #endif /* #if 0 */ err0: return -1; @@ -439,6 +460,11 @@ static void _stp_remove_root_dir(void) static struct dentry *__stp_module_dir = NULL; +static inline struct dentry *_stp_get_module_dir(void) +{ + return __stp_module_dir; +} + static int _stp_transport_fs_init(const char *module_name) { struct dentry *root_dir; -- cgit From 176b56b261a711822f35e36ec5e2d5e0758770de Mon Sep 17 00:00:00 2001 From: David Smith Date: Wed, 4 Mar 2009 12:51:29 -0600 Subject: Start of new ring_buffer transport. 2009-03-04 David Smith * runtime.h: Added _stp_exit() prototype. * transport/ring_buffer.c: New file. * transport/transport.c: Removed unneeded utt_trace lines. Includes transport/ring_buffer.c. (_stp_transport_fs_init): Calls _stp_transport_data_fs_init(). (_stp_transport_fs_close): Calls _stp_transport_data_fs_close(). * transport/transport.h: Added prototypes. --- runtime/transport/transport.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'runtime/transport/transport.c') diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index 12e98a38..093d8b7b 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -19,11 +19,6 @@ #include #include -struct utt_trace { - int dummy; -}; -//static struct utt_trace *_stp_utt = NULL; - static void utt_set_overwrite(int overwrite) { return; @@ -59,6 +54,7 @@ static unsigned int utt_seq = 1; #include "control.h" #include "debugfs.c" #include "control.c" +#include "ring_buffer.c" #endif /* if 0 */ static unsigned _stp_nsubbufs = 8; static unsigned _stp_subbuf_size = 65536*4; @@ -71,9 +67,6 @@ MODULE_PARM_DESC(_stp_bufsize, "buffer size"); /* forward declarations */ static void probe_exit(void); static int probe_start(void); -#if 0 -static void _stp_exit(void); -#endif /* #if 0 */ /* check for new workqueue API */ #ifdef DECLARE_DELAYED_WORK @@ -287,8 +280,8 @@ static int _stp_transport_init(void) dbug_trans(1, "Using %d subbufs of size %d\n", _stp_nsubbufs, _stp_subbuf_size); } - if (_stp_transport_fs_init(THIS_MODULE->name)) - return -1; + if (_stp_transport_fs_init(THIS_MODULE->name) != 0) + goto err0; #if 0 #if !defined (STP_OLD_TRANSPORT) || defined (STP_BULKMODE) @@ -297,6 +290,7 @@ static int _stp_transport_init(void) if (!_stp_utt) goto err0; #endif +#else /* #if 0 */ #endif /* #if 0 */ /* create control channel */ @@ -322,20 +316,25 @@ static int _stp_transport_init(void) _stp_ctl_send(STP_TRANSPORT, NULL, 0); #endif /* #if 0 */ + dbug_trans(1, "returning 0...\n"); return 0; err3: + dbug_trans(1, "err3\n"); _stp_print_cleanup(); err2: + dbug_trans(1, "err2\n"); _stp_unregister_ctl_channel(); err1: #if 0 if (_stp_utt) utt_trace_remove(_stp_utt); #else + dbug_trans(1, "err1\n"); _stp_transport_fs_close(); #endif /* #if 0 */ err0: + dbug_trans(1, "err0\n"); return -1; } @@ -469,6 +468,7 @@ static int _stp_transport_fs_init(const char *module_name) { struct dentry *root_dir; + dbug_trans(1, "entry\n"); if (module_name == NULL) return -1; @@ -481,12 +481,21 @@ static int _stp_transport_fs_init(const char *module_name) _stp_remove_root_dir(); return -1; } + + if (_stp_transport_data_fs_init() != 0) { + _stp_remove_root_dir(); + return -1; + } + dbug_trans(1, "returning 0\n"); return 0; } static void _stp_transport_fs_close(void) { dbug_trans(1, "stp_transport_fs_close\n"); + + _stp_transport_data_fs_close(); + if (__stp_module_dir) { debugfs_remove(__stp_module_dir); __stp_module_dir = NULL; -- cgit From eb3101a40fe446cffab677a7d117f028bae9afba Mon Sep 17 00:00:00 2001 From: David Smith Date: Mon, 9 Mar 2009 10:06:20 -0500 Subject: First working version that actually produces output. 2009-03-09 David Smith * print_new.c (stp_print_flush): Calls _stp_data_write_reserve() and _stp_data_write_commit(). * transport/ring_buffer.c (__stp_alloc_ring_buffer): Sets up a default buffer size of STP_BUFFER_SIZE; (trace_seq_reset): New function. (peek_next_entry): New function. (__find_next_entry): New function. (find_next_entry_inc): New function. (_stp_data_read_trace): Uses find_next_entry_inc() to get the next entry, then calls _stp_entry_to_user() to copy it to the user's buffer, then calls ring_buffer_consume() to consume it. (_stp_data_write_reserve): New function. (_stp_data_write_commit): New function. * transport/transport.c (_stp_transport_close): Calls functions that were ifdef'ed out. * transport/transport.h (struct _stp_entry): Added _stp_entry definition and _stp_data_write_reserve()/_stp_data_write_commit() prototypes. --- runtime/transport/transport.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'runtime/transport/transport.c') diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index 093d8b7b..c4c9da1e 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -209,9 +209,7 @@ static void _stp_transport_close(void) { dbug_trans(1, "%d: ************** transport_close *************\n", current->pid); -#if 0 _stp_cleanup_and_exit(0); -#endif /* #if 0 */ destroy_workqueue(_stp_wq); _stp_unregister_ctl_channel(); #if 0 @@ -219,9 +217,7 @@ static void _stp_transport_close(void) utt_trace_remove(_stp_utt); #endif /* #if 0 */ _stp_print_cleanup(); /* free print buffers */ -#if 0 _stp_mem_debug_done(); -#endif /* #if 0 */ _stp_transport_fs_close(); dbug_trans(1, "---- CLOSED ----\n"); @@ -311,10 +307,8 @@ static int _stp_transport_init(void) if (!_stp_wq) goto err3; -#if 0 /* Signal stapio to send us STP_START back (XXX: ?!?!?!). */ _stp_ctl_send(STP_TRANSPORT, NULL, 0); -#endif /* #if 0 */ dbug_trans(1, "returning 0...\n"); return 0; -- cgit From 9b23198d73b782bc05dc2b834c7db3afbdefda86 Mon Sep 17 00:00:00 2001 From: David Smith Date: Thu, 2 Apr 2009 10:16:35 -0500 Subject: Renamed STP_OLD_TRANSPORT to STP_TRANSPORT_VERSION. 2009-04-02 David Smith * runtime.h: Defines STP_TRANSPORT_VERSION instead of STP_OLD_TRANSPORT. * staprun/staprun.h (STP_OLD_TRANSPORT): Ditto. * print.c: Changed STP_OLD_TRANSPORT to STP_TRANSPORT_VERSION. * staprun/mainloop.c (stp_main_loop): Ditto. * transport/transport.c: Ditto. * transport/transport.h: Ditto. * transport/transport_msgs.h: Ditto. * transport/utt.h: Ditto. --- runtime/transport/transport.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'runtime/transport/transport.c') diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index c4c9da1e..c0c97467 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -41,12 +41,17 @@ static int _stp_probes_started = 0; static struct utt_trace *_stp_utt = NULL; static unsigned int utt_seq = 1; #include "control.h" -#ifdef STP_OLD_TRANSPORT +#if STP_TRANSPORT_VERSION == 1 #include "relayfs.c" #include "procfs.c" -#else +#elif STP_TRANSPORT_VERSION == 2 #include "utt.c" #include "debugfs.c" +#elif STP_TRANSPORT_VERSION == 3 +#include "debugfs.c" +#include "ring_buffer.c" +#else +#error "Unknown STP_TRANSPORT_VERSION" #endif #include "control.c" @@ -355,7 +360,7 @@ static struct dentry *_stp_lockfile = NULL; static int _stp_lock_transport_dir(void) { int numtries = 0; -#ifdef STP_OLD_TRANSPORT +#if STP_TRANSPORT_VERSION == 1 while ((_stp_lockfile = relayfs_create_dir("systemtap_lock", NULL)) == NULL) { #else while ((_stp_lockfile = debugfs_create_dir("systemtap_lock", NULL)) == NULL) { @@ -370,7 +375,7 @@ static int _stp_lock_transport_dir(void) static void _stp_unlock_transport_dir(void) { if (_stp_lockfile) { -#ifdef STP_OLD_TRANSPORT +#if STP_TRANSPORT_VERSION == 1 relayfs_remove_dir(_stp_lockfile); #else debugfs_remove(_stp_lockfile); @@ -394,7 +399,7 @@ static struct dentry *_stp_get_root_dir(void) return __stp_root_dir; } -#ifdef STP_OLD_TRANSPORT +#if STP_TRANSPORT_VERSION == 1 fs = get_fs_type("relayfs"); if (!fs) { errk("Couldn't find relayfs filesystem.\n"); @@ -412,7 +417,7 @@ static struct dentry *_stp_get_root_dir(void) errk("Couldn't lock transport directory.\n"); return NULL; } -#ifdef STP_OLD_TRANSPORT +#if STP_TRANSPORT_VERSION == 1 __stp_root_dir = relayfs_create_dir(name, NULL); #else __stp_root_dir = debugfs_create_dir(name, NULL); -- cgit From 4a8c28f93fa29e47c604e80e383c826070d6c383 Mon Sep 17 00:00:00 2001 From: David Smith Date: Wed, 6 May 2009 12:25:02 -0500 Subject: Start of support for older transport and cleanup. * runtime/transport/control.c: Added inclusion of linux/delay.h to get declaration of msleep(). * runtime/transport/relay_v2.c: New skeleton file for transport version 2. * runtime/transport/ring_buffer.c: Cleanup. * runtime/transport/transport.c: Ditto. --- runtime/transport/transport.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'runtime/transport/transport.c') diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index c0c97467..5a499e8d 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -18,11 +18,14 @@ #include #include #include +#include +#if 0 static void utt_set_overwrite(int overwrite) { return; } +#endif static int _stp_exit_flag = 0; @@ -35,21 +38,19 @@ static int _stp_ctl_attached = 0; static pid_t _stp_target = 0; static int _stp_probes_started = 0; -#if 0 -#include - -static struct utt_trace *_stp_utt = NULL; -static unsigned int utt_seq = 1; +#if 1 +//static struct utt_trace *_stp_utt = NULL; +//static unsigned int utt_seq = 1; #include "control.h" #if STP_TRANSPORT_VERSION == 1 #include "relayfs.c" #include "procfs.c" #elif STP_TRANSPORT_VERSION == 2 -#include "utt.c" +#include "relay_v2.c" #include "debugfs.c" #elif STP_TRANSPORT_VERSION == 3 -#include "debugfs.c" #include "ring_buffer.c" +#include "debugfs.c" #else #error "Unknown STP_TRANSPORT_VERSION" #endif @@ -59,7 +60,6 @@ static unsigned int utt_seq = 1; #include "control.h" #include "debugfs.c" #include "control.c" -#include "ring_buffer.c" #endif /* if 0 */ static unsigned _stp_nsubbufs = 8; static unsigned _stp_subbuf_size = 65536*4; @@ -158,8 +158,10 @@ static void _stp_detach(void) _stp_ctl_attached = 0; _stp_pid = 0; +#if 0 if (!_stp_exit_flag) utt_set_overwrite(1); +#endif cancel_delayed_work(&_stp_work); wake_up_interruptible(&_stp_ctl_wq); @@ -173,7 +175,9 @@ static void _stp_attach(void) dbug_trans(1, "attach\n"); _stp_ctl_attached = 1; _stp_pid = current->pid; +#if 0 utt_set_overwrite(0); +#endif queue_delayed_work(_stp_wq, &_stp_work, STP_WORK_TIMER); } @@ -458,7 +462,7 @@ static void _stp_remove_root_dir(void) static struct dentry *__stp_module_dir = NULL; -static inline struct dentry *_stp_get_module_dir(void) +static struct dentry *_stp_get_module_dir(void) { return __stp_module_dir; } -- cgit From dd9a3bcbef65bde65491d959e9458bc641924811 Mon Sep 17 00:00:00 2001 From: David Smith Date: Tue, 12 May 2009 13:38:48 -0500 Subject: Start at supporting the original transport (STP_TRANSPORT_VERSION=1). * runtime/print.c: Only use print_new.c. * runtime/print_new.c (stp_print_flush): Add STP_TRANSPORT_VERSION 1 support. * runtime/transport/transport.c: Removed inclusion of procfs.c. * runtime/transport/procfs.c (_stp_proc_read): Adapt to new interface. (_stp_proc_write): Ditto. * runtime/transport/relayfs.c: Ditto. --- runtime/transport/transport.c | 1 - 1 file changed, 1 deletion(-) (limited to 'runtime/transport/transport.c') diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index 5a499e8d..3d0453bf 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -44,7 +44,6 @@ static int _stp_probes_started = 0; #include "control.h" #if STP_TRANSPORT_VERSION == 1 #include "relayfs.c" -#include "procfs.c" #elif STP_TRANSPORT_VERSION == 2 #include "relay_v2.c" #include "debugfs.c" -- cgit From e57421f400d17786c1fdbead5fbca27a1fbe4ec5 Mon Sep 17 00:00:00 2001 From: David Smith Date: Fri, 22 May 2009 10:50:30 -0500 Subject: Added error checking and other updates. * runtime/vsprintf.c: Added transport.h inclusion for STP_BUFFER_SIZE definition. * runtime/transport/debugfs.c (_stp_register_ctl_channel_fs): Added error checking. * runtime/transport/transport.c (_stp_get_root_dir): Ditto. (_stp_transport_fs_init): Added original transport support and error checking. * runtime/transport/relay_v2.c (__stp_relay_create_buf_file_callback): Added error checking. (_stp_transport_data_fs_init): Ditto. * runtime/transport/ring_buffer.c (_stp_transport_data_fs_init): Ditto. * runtime/transport/utt.c: Removed unused file. * runtime/transport/utt.h: Ditto. --- runtime/transport/transport.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'runtime/transport/transport.c') diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index 792ea815..ab0806f2 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -453,6 +453,12 @@ static struct dentry *_stp_get_root_dir(void) errk("Could not create or find transport directory.\n"); } } + else if (IS_ERR(__stp_root_dir)) { + __stp_root_dir = NULL; + errk("Could not create root directory \"%s\", error %ld\n", name, + -PTR_ERR(__stp_root_dir)); + } + _stp_unlock_transport_dir(); return __stp_root_dir; } @@ -490,8 +496,20 @@ static int _stp_transport_fs_init(const char *module_name) if (root_dir == NULL) return -1; +#if STP_TRANSPORT_VERSION == 1 + __stp_module_dir = relayfs_create_dir(module_name, root_dir); +#else __stp_module_dir = debugfs_create_dir(module_name, root_dir); +#endif if (!__stp_module_dir) { + errk("Could not create module directory \"%s\"\n", + module_name); + _stp_remove_root_dir(); + return -1; + } + else if (IS_ERR(__stp_module_dir)) { + errk("Could not create module directory \"%s\", error %ld\n", + module_name, -PTR_ERR(__stp_module_dir)); _stp_remove_root_dir(); return -1; } -- cgit From a655ff03c59722c229a40909d0de9e3dfe63483e Mon Sep 17 00:00:00 2001 From: David Smith Date: Tue, 26 May 2009 14:08:57 -0500 Subject: Cleanup and better original transport support. * runtime/print.h: Moved _stp_reserve_bytes() prototype here. * runtime/vsprintf.c (_stp_vsnprintf): Includes print.h to get _stp_reserve_bytes() prototype. * runtime/transport/transport.c (_stp_remove_root_dir): Better cleanup for STP_TRANSPORT_VERSION == 1. (_stp_transport_fs_close): Ditto. --- runtime/transport/transport.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'runtime/transport/transport.c') diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index ab0806f2..8425536a 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -470,8 +470,13 @@ static void _stp_remove_root_dir(void) errk("Unable to lock transport directory.\n"); return; } - if (simple_empty(__stp_root_dir)) + if (simple_empty(__stp_root_dir)) { +#if STP_TRANSPORT_VERSION == 1 + relayfs_remove_dir(__stp_root_dir); +#else debugfs_remove(__stp_root_dir); +#endif + } _stp_unlock_transport_dir(); __stp_root_dir = NULL; } @@ -529,7 +534,11 @@ static void _stp_transport_fs_close(void) _stp_transport_data_fs_close(); if (__stp_module_dir) { +#if STP_TRANSPORT_VERSION == 1 + relayfs_remove_dir(__stp_module_dir); +#else debugfs_remove(__stp_module_dir); +#endif __stp_module_dir = NULL; } -- cgit From 01adca5bca8d61e3fdf09017496deec8859fe12d Mon Sep 17 00:00:00 2001 From: David Smith Date: Wed, 3 Jun 2009 13:04:54 -0500 Subject: Fixed STP_TRANSPORT_VERSION 1 behavior. * runtime/transport/control.c (_stp_ctl_write_dbug): Added support for more messages. * runtime/transport/relay_v2.c (_stp_transport_data_fs_start): New function. (_stp_transport_data_fs_stop): Ditto. (_stp_transport_data_fs_close): Moved some functionality into _stp_transport_data_fs_stop() and calls _stp_transport_data_fs_stop() also. (_stp_transport_data_fs_init): Moved some functionality into _stp_transport_data_fs_start() and calls _stp_transport_data_fs_start() also. * runtime/transport/relayfs.c (_stp_transport_data_fs_start): New function. (_stp_transport_data_fs_stop): Ditto. (_stp_transport_data_fs_close): Moved some functionality into _stp_transport_data_fs_stop() and calls _stp_transport_data_fs_stop() also. (_stp_transport_data_fs_init): Moved some functionality into _stp_transport_data_fs_start() and calls _stp_transport_data_fs_start() also. * runtime/transport/ring_buffer.c (_stp_transport_data_fs_start): New empty function. (_stp_transport_data_fs_stop): Ditto. * runtime/transport/transport.h: Added _stp_transport_data_fs_start() and _stp_transport_data_fs_stop() prototypes. * runtime/transport/transport.c (_stp_cleanup_and_exit): Calls _stp_transport_data_fs_stop(). (_stp_transport_close): Calls _stp_transport_fs_close() earlier. (_stp_transport_init): Calls _stp_transport_data_fs_start(). --- runtime/transport/transport.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'runtime/transport/transport.c') diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index 8425536a..84959f71 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -135,11 +135,8 @@ static void _stp_cleanup_and_exit(int send_exit) if (failures) _stp_warn("There were %d transport failures.\n", failures); - dbug_trans(1, "************** calling startstop 0 *************\n"); -#if 0 - if (_stp_utt) - utt_trace_startstop(_stp_utt, 0, &utt_seq); -#endif + dbug_trans(1, "*** calling _stp_transport_data_fs_stop ***\n"); + _stp_transport_data_fs_stop(); dbug_trans(1, "ctl_send STP_EXIT\n"); if (send_exit) @@ -236,9 +233,9 @@ static void _stp_transport_close(void) if (_stp_utt) utt_trace_remove(_stp_utt); #endif /* #if 0 */ + _stp_transport_fs_close(); _stp_print_cleanup(); /* free print buffers */ _stp_mem_debug_done(); - _stp_transport_fs_close(); dbug_trans(1, "---- CLOSED ----\n"); } @@ -317,10 +314,8 @@ static int _stp_transport_init(void) if (_stp_print_init() < 0) goto err2; -#if 0 /* start transport */ - utt_trace_startstop(_stp_utt, 1, &utt_seq); -#endif /* #if 0 */ + _stp_transport_data_fs_start(); /* create workqueue of kernel threads */ _stp_wq = create_workqueue("systemtap"); -- cgit From 24a5e9a6a87b2f7c8b7264ceb94c65a3a9550d47 Mon Sep 17 00:00:00 2001 From: David Smith Date: Thu, 18 Jun 2009 13:09:31 -0500 Subject: Enabled overwrite processing on original transports. * runtime/transport/relay_v2.c (_stp_transport_data_fs_overwrite): Renamed from stp_relay_set_overwrite(). * runtime/transport/relayfs.c (stp_relay_set_overwrite): Ditto. * runtime/transport/ring_buffer.c (_stp_transport_data_fs_overwrite): New place holder function. * runtime/transport/transport.c (_stp_detach): Calls _stp_transport_data_fs_overwrite(). (_stp_attach): Calls _stp_transport_data_fs_overwrite(). * runtime/transport/transport.h: Added prototype for _stp_transport_data_fs_overwrite(). --- runtime/transport/transport.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'runtime/transport/transport.c') diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index 84959f71..a1d90dcf 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -20,13 +20,6 @@ #include #include -#if 0 -static void utt_set_overwrite(int overwrite) -{ - return; -} -#endif - static int _stp_exit_flag = 0; static uid_t _stp_uid = 0; @@ -166,10 +159,8 @@ static void _stp_detach(void) _stp_ctl_attached = 0; _stp_pid = 0; -#if 0 if (!_stp_exit_flag) - utt_set_overwrite(1); -#endif + _stp_transport_data_fs_overwrite(1); cancel_delayed_work(&_stp_work); wake_up_interruptible(&_stp_ctl_wq); @@ -183,9 +174,7 @@ static void _stp_attach(void) dbug_trans(1, "attach\n"); _stp_ctl_attached = 1; _stp_pid = current->pid; -#if 0 - utt_set_overwrite(0); -#endif + _stp_transport_data_fs_overwrite(0); queue_delayed_work(_stp_wq, &_stp_work, STP_WORK_TIMER); } -- cgit From 7c0bbff77507c69b706af667ac33770fb6180cbb Mon Sep 17 00:00:00 2001 From: David Smith Date: Thu, 18 Jun 2009 15:56:45 -0500 Subject: Removed unused code (and all references to 'utt'). --- runtime/transport/transport.c | 52 ------------------------------------------- 1 file changed, 52 deletions(-) (limited to 'runtime/transport/transport.c') diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index a1d90dcf..7f844f5d 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -31,9 +31,6 @@ static int _stp_ctl_attached = 0; static pid_t _stp_target = 0; static int _stp_probes_started = 0; -#if 1 -//static struct utt_trace *_stp_utt = NULL; -//static unsigned int utt_seq = 1; #include "control.h" #if STP_TRANSPORT_VERSION == 1 #include "relayfs.c" @@ -48,11 +45,6 @@ static int _stp_probes_started = 0; #endif #include "control.c" -#else /* #if 0 */ -#include "control.h" -#include "debugfs.c" -#include "control.c" -#endif /* if 0 */ static unsigned _stp_nsubbufs = 8; static unsigned _stp_subbuf_size = 65536*4; @@ -218,10 +210,6 @@ static void _stp_transport_close(void) _stp_cleanup_and_exit(0); destroy_workqueue(_stp_wq); _stp_unregister_ctl_channel(); -#if 0 - if (_stp_utt) - utt_trace_remove(_stp_utt); -#endif /* #if 0 */ _stp_transport_fs_close(); _stp_print_cleanup(); /* free print buffers */ _stp_mem_debug_done(); @@ -229,25 +217,6 @@ static void _stp_transport_close(void) dbug_trans(1, "---- CLOSED ----\n"); } -#if 0 -static struct utt_trace *_stp_utt_open(void) -{ - struct utt_trace_setup utts; - strlcpy(utts.root, "systemtap", sizeof(utts.root)); - strlcpy(utts.name, THIS_MODULE->name, sizeof(utts.name)); - utts.buf_size = _stp_subbuf_size; - utts.buf_nr = _stp_nsubbufs; - -#ifdef STP_BULKMODE - utts.is_global = 0; -#else - utts.is_global = 1; -#endif - - return utt_trace_setup(&utts); -} -#endif /* #if 0 */ - /** * _stp_transport_init() is called from the module initialization. * It does the bare minimum to exchange commands with staprun @@ -263,8 +232,6 @@ static int _stp_transport_init(void) _stp_gid = current_gid(); #endif -// DRS: is RELAY_GUEST/RELAY_HOST documented? does it work? are there -// test cases? #ifdef RELAY_GUEST /* Guest scripts use relay only for reporting warnings and errors */ _stp_subbuf_size = 65536; @@ -285,16 +252,6 @@ static int _stp_transport_init(void) if (_stp_transport_fs_init(THIS_MODULE->name) != 0) goto err0; -#if 0 -#if !defined (STP_OLD_TRANSPORT) || defined (STP_BULKMODE) - /* open utt (relayfs) channel to send data to userspace */ - _stp_utt = _stp_utt_open(); - if (!_stp_utt) - goto err0; -#endif -#else /* #if 0 */ -#endif /* #if 0 */ - /* create control channel */ if (_stp_register_ctl_channel() < 0) goto err1; @@ -318,21 +275,12 @@ static int _stp_transport_init(void) return 0; err3: - dbug_trans(1, "err3\n"); _stp_print_cleanup(); err2: - dbug_trans(1, "err2\n"); _stp_unregister_ctl_channel(); err1: -#if 0 - if (_stp_utt) - utt_trace_remove(_stp_utt); -#else - dbug_trans(1, "err1\n"); _stp_transport_fs_close(); -#endif /* #if 0 */ err0: - dbug_trans(1, "err0\n"); return -1; } -- cgit From 3aae22ce894f935ac1371f501a09cecfbde18727 Mon Sep 17 00:00:00 2001 From: David Smith Date: Fri, 19 Jun 2009 11:13:15 -0500 Subject: Disabled transport version 3 (for now). --- runtime/transport/transport.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'runtime/transport/transport.c') diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index 7f844f5d..1d029e53 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -31,6 +31,12 @@ static int _stp_ctl_attached = 0; static pid_t _stp_target = 0; static int _stp_probes_started = 0; +// For now, disable transport version 3 +#if STP_TRANSPORT_VERSION == 3 +#undef STP_TRANSPORT_VERSION +#define STP_TRANSPORT_VERSION 2 +#endif + #include "control.h" #if STP_TRANSPORT_VERSION == 1 #include "relayfs.c" -- cgit