summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Smith <dsmith@redhat.com>2009-02-25 09:04:19 -0600
committerDavid Smith <dsmith@redhat.com>2009-02-25 09:04:19 -0600
commit64c962fed5f50a7f82f8b570e000cdcff757862b (patch)
tree9f60ad3c67c7719f9448f3355e600eefa27c009c
parent23c1c6557af76d506a28bcb3e864d3500e6dc565 (diff)
downloadsystemtap-steved-64c962fed5f50a7f82f8b570e000cdcff757862b.tar.gz
systemtap-steved-64c962fed5f50a7f82f8b570e000cdcff757862b.tar.xz
systemtap-steved-64c962fed5f50a7f82f8b570e000cdcff757862b.zip
More cleanup.
2009-02-25 David Smith <dsmith@redhat.com> * 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.
-rw-r--r--runtime/debug.h1
-rw-r--r--runtime/print_new.c4
-rw-r--r--runtime/runtime.h1
-rw-r--r--runtime/transport/control.c8
-rw-r--r--runtime/transport/control.h1
-rw-r--r--runtime/transport/debugfs.c7
-rw-r--r--runtime/transport/transport.c68
-rw-r--r--runtime/transport/transport.h18
8 files changed, 68 insertions, 40 deletions
diff --git a/runtime/debug.h b/runtime/debug.h
index e8b2e701..ce0c3943 100644
--- a/runtime/debug.h
+++ b/runtime/debug.h
@@ -14,7 +14,6 @@
* _dbug() writes to systemtap stderr.
* errk() writes to the system log.
*/
-static int _stp_transport_state = 0;
#define _dbug(args...) _stp_dbug(__FUNCTION__, __LINE__, args)
diff --git a/runtime/print_new.c b/runtime/print_new.c
index 43e37822..bebaa19c 100644
--- a/runtime/print_new.c
+++ b/runtime/print_new.c
@@ -57,7 +57,11 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb)
void *buf;
unsigned long flags;
spin_lock_irqsave(&_stp_print_lock, flags);
+#if 0
buf = utt_reserve(_stp_utt, len);
+#else
+ buf = NULL;
+#endif
if (likely(buf))
memcpy(buf, pb->buf, len);
else
diff --git a/runtime/runtime.h b/runtime/runtime.h
index fc5d454f..25456beb 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -45,6 +45,7 @@
static void _stp_dbug (const char *func, int line, const char *fmt, ...);
static void _stp_error (const char *fmt, ...);
+static void _stp_warn (const char *fmt, ...);
#include "debug.h"
diff --git a/runtime/transport/control.c b/runtime/transport/control.c
index edde244d..7626305a 100644
--- a/runtime/transport/control.c
+++ b/runtime/transport/control.c
@@ -9,6 +9,10 @@
* later version.
*/
+#include "control.h"
+#include "../mempool.c"
+#include "symbols.c"
+
static _stp_mempool_t *_stp_pool_q;
static struct list_head _stp_ctl_ready_q;
static DEFINE_SPINLOCK(_stp_ctl_ready_lock);
@@ -192,7 +196,7 @@ static ssize_t _stp_ctl_read_cmd(struct file *file, char __user *buf,
static int _stp_ctl_open_cmd(struct inode *inode, struct file *file)
{
- if (_stp_attached)
+ if (_stp_ctl_attached)
return -1;
_stp_attach();
return 0;
@@ -200,7 +204,7 @@ static int _stp_ctl_open_cmd(struct inode *inode, struct file *file)
static int _stp_ctl_close_cmd(struct inode *inode, struct file *file)
{
- if (_stp_attached)
+ if (_stp_ctl_attached)
_stp_detach();
return 0;
}
diff --git a/runtime/transport/control.h b/runtime/transport/control.h
index 5e7204ee..48289276 100644
--- a/runtime/transport/control.h
+++ b/runtime/transport/control.h
@@ -15,7 +15,6 @@
#include <linux/spinlock.h>
#include <linux/list.h>
-static _stp_mempool_t *_stp_pool_q;
static struct list_head _stp_ctl_ready_q;
static spinlock_t _stp_ctl_ready_lock;
static wait_queue_head_t _stp_ctl_wq;
diff --git a/runtime/transport/debugfs.c b/runtime/transport/debugfs.c
index 7de57335..7a08982a 100644
--- a/runtime/transport/debugfs.c
+++ b/runtime/transport/debugfs.c
@@ -23,13 +23,14 @@ static struct dentry *_stp_cmd_file = NULL;
static int _stp_register_ctl_channel_fs(void)
{
- if (_stp_utt == NULL) {
- errk("_expected _stp_utt to be set.\n");
+ struct dentry *module_dir = _stp_get_module_dir();
+ if (module_dir == NULL) {
+ errk("no module directory found.\n");
return -1;
}
/* create [debugfs]/systemtap/module_name/.cmd */
- _stp_cmd_file = debugfs_create_file(".cmd", 0600, _stp_utt->dir,
+ _stp_cmd_file = debugfs_create_file(".cmd", 0600, module_dir,
NULL, &_stp_ctl_fops_cmd);
if (_stp_cmd_file == NULL) {
errk("Error creating systemtap debugfs entries.\n");
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 <linux/debugfs.h>
+#include <linux/namei.h>
+#include <linux/workqueue.h>
+
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 <linux/debugfs.h>
-#include <linux/namei.h>
+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 <linux/delay.h>
-#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;
diff --git a/runtime/transport/transport.h b/runtime/transport/transport.h
index c6d850ef..dec23c72 100644
--- a/runtime/transport/transport.h
+++ b/runtime/transport/transport.h
@@ -24,7 +24,6 @@ static inline void *utt_reserve(struct utt_trace *utt, size_t length)
}
-#if 0
/* STP_CTL_BUFFER_SIZE is the maximum size of a message */
/* exchanged on the control channel. */
#ifdef STP_OLD_TRANSPORT
@@ -37,7 +36,6 @@ static inline void *utt_reserve(struct utt_trace *utt, size_t length)
/* how often the work queue wakes up and checks buffers */
#define STP_WORK_TIMER (HZ/100)
-#endif /* #if 0 */
static unsigned _stp_nsubbufs;
static unsigned _stp_subbuf_size;
@@ -48,22 +46,18 @@ static int _stp_lock_transport_dir(void);
static void _stp_unlock_transport_dir(void);
static struct dentry *_stp_get_root_dir(void);
+static struct dentry *_stp_get_module_dir(void);
static int _stp_transport_fs_init(const char *module_name);
static void _stp_transport_fs_close(void);
-#if 0
-static void _stp_warn (const char *fmt, ...);
-
static void _stp_attach(void);
static void _stp_detach(void);
static void _stp_handle_start(struct _stp_msg_start *st);
-static int _stp_pid = 0;
-#endif
-static uid_t _stp_uid = 0;
-static gid_t _stp_gid = 0;
-#if 0
-static int _stp_attached = 0;
-#endif
+static uid_t _stp_uid;
+static gid_t _stp_gid;
+
+static int _stp_ctl_attached;
+
#endif /* _TRANSPORT_TRANSPORT_H_ */