Compilation fixes
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 2 Dec 2010 21:06:32 +0000 (16:06 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 2 Dec 2010 21:06:32 +0000 (16:06 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Makefile
ltt-debugfs-abi.c
ltt-events.c
ltt-events.h
ltt-tracer.h

index b16c4c6fdb0b90ffea628d176623249693f0a19c..6e4da6c94cfd8140bf31d0f23ba0929bb40503c8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,22 +3,26 @@
 #
 
 ifneq ($(KERNELRELEASE),)
-ifneq ($(CONFIG_MARKERS),)
+ifneq ($(CONFIG_TRACEPOINTS),)
 
 obj-m += ltt-core.o
-obj-m += ltt-tracer.o
-obj-m += ltt-marker-control.o
+obj-m += ltt-debugfs-abi.o
+obj-m += ltt-events.o
+obj-m += ltt-ring-buffer-client-discard.o
+obj-m += ltt-ring-buffer-client-overwrite.o
 
 obj-m += ltt-relay.o
 ltt-relay-objs :=  ltt-event-header.o ltt-serialize.o ltt-type-serializer.o
+
+#obj-m += ltt-marker-control.o
+#obj-m += ltt-trace-control.o
 #ltt-ascii.o
 
-obj-m += ltt-statedump.o
-obj-m += ltt-trace-control.o
-obj-m += ltt-userspace-event.o
-obj-m += ltt-filter.o
-obj-m += ltt-kprobes.o
-obj-m += probes/
+#obj-m += ltt-statedump.o
+#obj-m += ltt-userspace-event.o
+#obj-m += ltt-filter.o
+#obj-m += ltt-kprobes.o
+#obj-m += probes/
 
 endif
 
index f856fc8f775c1307e7e994c7a7a0b2d9e7439ba4..a10236134a287a47207825fbb3bd49d831168600 100644 (file)
  *     - Takes instrumentation source specific arguments.
  */
 
+#include <linux/module.h>
 #include <linux/debugfs.h>
+#include <linux/anon_inodes.h>
+#include <linux/file.h>
+#include <linux/uaccess.h>
+#include <linux/slab.h>
+#include <linux/ringbuffer/vfs.h>
+#include "ltt-debugfs-abi.h"
 #include "ltt-events.h"
 
 /*
@@ -36,29 +43,12 @@ static const struct file_operations lttng_session_fops;
 static const struct file_operations lttng_channel_fops;
 static const struct file_operations lttng_event_fops;
 
-/*
- * LTTng DebugFS ABI structures.
- */
-
-struct lttng_channel {
-       int overwrite;                  /* 1: overwrite, 0: discard */
-       u64 subbuf_size;
-       u64 num_subbuf;
-       unsigned int switch_timer_interval;
-       unsigned int read_timer_interval;
-};
-
-struct lttng_event {
-       enum instrum_type itype;
-       char name[];
-};
-
 static
 int lttng_abi_create_session(void)
 {
        struct ltt_session *session;
        struct file *session_file;
-       int session_fd;
+       int session_fd, ret;
 
        session = ltt_session_create();
        if (!session)
@@ -115,7 +105,7 @@ static const struct file_operations lttng_fops = {
 #ifdef CONFIG_COMPAT
        .compat_ioctl = lttng_ioctl,
 #endif
-}
+};
 
 int lttng_abi_create_channel(struct file *session_file,
                             struct lttng_channel __user *uchan_param)
@@ -145,16 +135,16 @@ int lttng_abi_create_channel(struct file *session_file,
         * We tolerate no failure path after channel creation. It will stay
         * invariant for the rest of the session.
         */
-       chan = ltt_channel_create(session, chan_param->overwrite, NULL,
-                                 chan_param->subbuf_size,
-                                 chan_param->num_subbuf,
-                                 chan_param->switch_timer_interval,
-                                 chan_param->read_timer_interval);
+       chan = ltt_channel_create(session, chan_param.overwrite, NULL,
+                                 chan_param.subbuf_size,
+                                 chan_param.num_subbuf,
+                                 chan_param.switch_timer_interval,
+                                 chan_param.read_timer_interval);
        if (!chan) {
                ret = -ENOMEM;
                goto chan_error;
        }
-       channel->file = chan_file;
+       chan->file = chan_file;
        chan_file->private_data = chan;
        fd_install(chan_fd, chan_file);
        /* The channel created holds a reference on the session */
@@ -195,8 +185,6 @@ long lttng_session_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                return ltt_session_start(session);
        case LTTNG_SESSION_STOP:
                return ltt_session_stop(session);
-       case LTTNG_SESSION_FINALIZE:
-               return ltt_session_finalize(session);
        default:
                return -ENOIOCTLCMD;
        }
@@ -214,7 +202,8 @@ static
 int lttng_session_release(struct inode *inode, struct file *file)
 {
        struct ltt_session *session = file->private_data;
-       return ltt_session_destroy(session);
+       ltt_session_destroy(session);
+       return 0;
 }
 
 static const struct file_operations lttng_session_fops = {
@@ -223,7 +212,7 @@ static const struct file_operations lttng_session_fops = {
 #ifdef CONFIG_COMPAT
        .compat_ioctl = lttng_session_ioctl,
 #endif
-}
+};
 
 static
 int lttng_abi_open_stream(struct file *channel_file)
@@ -231,8 +220,9 @@ int lttng_abi_open_stream(struct file *channel_file)
        struct ltt_channel *channel = channel_file->private_data;
        struct lib_ring_buffer *buf;
        int stream_fd, ret;
+       struct file *stream_file;
 
-       buf = ltt_buffer_read_open(channel->chan);
+       buf = channel->ops->buffer_read_open(channel->chan);
        if (!buf)
                return -ENOENT;
 
@@ -256,7 +246,7 @@ int lttng_abi_open_stream(struct file *channel_file)
 file_error:
        put_unused_fd(stream_fd);
 fd_error:
-       ltt_buffer_read_close(buf);
+       channel->ops->buffer_read_close(buf);
        return ret;
 }
 
@@ -269,13 +259,14 @@ int lttng_abi_create_event(struct file *channel_file,
        char *event_name;
        struct lttng_event event_param;
        int event_fd, ret;
+       struct file *event_file;
 
        if (copy_from_user(&event_param, uevent_param, sizeof(event_param)))
                return -EFAULT;
        event_name = kmalloc(PATH_MAX, GFP_KERNEL);
        if (!event_name)
                return -ENOMEM;
-       if (strncpy_from_user(event_name, &uevent_param->name, PATH_MAX)) {
+       if (strncpy_from_user(event_name, uevent_param->name, PATH_MAX)) {
                ret = -EFAULT;
                goto name_error;
        }
@@ -296,7 +287,8 @@ int lttng_abi_create_event(struct file *channel_file,
         * We tolerate no failure path after event creation. It will stay
         * invariant for the rest of the session.
         */
-       event = ltt_event_create(channel, event_param->itype, event_name, NULL);
+       event = ltt_event_create(channel, event_name, event_param.itype,
+                                NULL, NULL);   /* TODO non-null probe */
        if (!event) {
                goto event_error;
                ret = -EEXIST;
@@ -394,7 +386,7 @@ static const struct file_operations lttng_channel_fops = {
 #ifdef CONFIG_COMPAT
        .compat_ioctl = lttng_channel_ioctl,
 #endif
-}
+};
 
 static
 int lttng_event_release(struct inode *inode, struct file *file)
@@ -407,14 +399,15 @@ int lttng_event_release(struct inode *inode, struct file *file)
 /* TODO: filter control ioctl */
 static const struct file_operations lttng_event_fops = {
        .release = lttng_event_release,
-}
+};
 
 static int __init ltt_debugfs_abi_init(void)
 {
        int ret = 0;
 
-       lttng_dentry = debugfs_create_file("lttng", NULL);
-       if (IS_ERR(lttng_dentry) || !lttng_dentry)
+       lttng_dentry = debugfs_create_file("lttng", S_IWUSR, NULL, NULL,
+                                          &lttng_session_fops);
+       if (IS_ERR(lttng_dentry) || !lttng_dentry) {
                printk(KERN_ERR "Error creating LTTng control file\n");
                ret = -ENOMEM;
                goto error;
@@ -423,7 +416,15 @@ error:
        return ret;
 }
 
+module_init(ltt_debugfs_abi_init);
+
 static void __exit ltt_debugfs_abi_exit(void)
 {
-       debugfs_remote(lttng_dentry);
+       debugfs_remove(lttng_dentry);
 }
+
+module_exit(ltt_debugfs_abi_exit);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit Next Generation DebugFS ABI");
index d6cb397e6a61d44a83c1e8eaa898e8f18976107f..7c7cda6525a4250379521ddf40b4a4bcce389dc2 100644 (file)
@@ -10,6 +10,8 @@
 #include <linux/list.h>
 #include <linux/mutex.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>     /* For vmalloc_sync_all */
 #include "ltt-events.h"
 
 static LIST_HEAD(sessions);
@@ -30,20 +32,16 @@ struct ltt_session *ltt_session_create(void)
        struct ltt_session *session;
 
        mutex_lock(&sessions_mutex);
-       session = kmalloc(sizeof(struct ltt_session));
+       session = kmalloc(sizeof(struct ltt_session), GFP_KERNEL);
        if (!session)
                return NULL;
        INIT_LIST_HEAD(&session->chan);
        list_add(&session->list, &sessions);
        mutex_unlock(&sessions_mutex);
        return session;
-
-exist:
-       mutex_unlock(&sessions_mutex);
-       return NULL;
 }
 
-int ltt_session_destroy(struct ltt_session *session)
+void ltt_session_destroy(struct ltt_session *session)
 {
        struct ltt_channel *chan, *tmpchan;
        struct ltt_event *event, *tmpevent;
@@ -73,7 +71,7 @@ int ltt_session_start(struct ltt_session *session)
        synchronize_trace();    /* Wait for in-flight events to complete */
 end:
        mutex_unlock(&sessions_mutex);
-       return ret
+       return ret;
 }
 
 int ltt_session_stop(struct ltt_session *session)
@@ -89,7 +87,7 @@ int ltt_session_stop(struct ltt_session *session)
        synchronize_trace();    /* Wait for in-flight events to complete */
 end:
        mutex_unlock(&sessions_mutex);
-       return ret
+       return ret;
 }
 
 struct ltt_channel *ltt_channel_create(struct ltt_session *session,
@@ -119,9 +117,10 @@ struct ltt_channel *ltt_channel_create(struct ltt_session *session,
                goto nomem;
        chan->session = session;
        init_waitqueue_head(&chan->notify_wait);
-       transport->ops.channel_create(session, buf_addr, subbuf_size,
-                                     num_subbuf, switch_timer_interval,
-                                     read_timer_interval);
+       chan->chan = transport->ops.channel_create("[lttng]", session, buf_addr,
+                       subbuf_size, num_subbuf, switch_timer_interval,
+                       read_timer_interval);
+       chan->ops = &transport->ops;
        list_add(&chan->list, &session->chan);
        mutex_unlock(&sessions_mutex);
        return chan;
@@ -136,9 +135,9 @@ active:
 /*
  * Only used internally at session destruction.
  */
-int _ltt_channel_destroy(struct ltt_channel *chan)
+void _ltt_channel_destroy(struct ltt_channel *chan)
 {
-       transport->ops.channel_destroy(chan);
+       chan->ops->channel_destroy(chan->chan);
        list_del(&chan->list);
        kfree(chan);
 }
@@ -163,32 +162,36 @@ struct ltt_event *ltt_event_create(struct ltt_channel *chan, char *name,
        list_for_each_entry(event, &chan->session->events, list)
                if (!strcmp(event->name, name))
                        goto exist;
-       event = kmem_cache_zalloc(events_cache, GFP_KERNEL);
+       event = kmem_cache_zalloc(event_cache, GFP_KERNEL);
        if (!event)
                goto cache_error;
        event->name = kmalloc(strlen(name) + 1, GFP_KERNEL);
        if (!event->name)
-               goto error;
+               goto name_error;
        strcpy(event->name, name);
        event->chan = chan;
        event->probe = probe;
        event->filter = filter;
        event->id = chan->free_event_id++;
        event->itype = itype;
-       mutex_unlock(&sessions_mutex);
        /* Populate ltt_event structure before tracepoint registration. */
        smp_wmb();
        switch (itype) {
        case INSTRUM_TRACEPOINTS:
                ret = tracepoint_probe_register(name, probe, event);
+               if (ret)
+                       goto register_error;
                break;
        default:
                WARN_ON_ONCE(1);
        }
+       mutex_unlock(&sessions_mutex);
        return event;
 
-error:
-       kmem_cache_free(event);
+register_error:
+       kfree(event->name);
+name_error:
+       kmem_cache_free(event_cache, event);
 cache_error:
 exist:
 full:
@@ -201,15 +204,21 @@ full:
  */
 int _ltt_event_destroy(struct ltt_event *event)
 {
+       int ret = -EINVAL;
+
        switch (event->itype) {
        case INSTRUM_TRACEPOINTS:
-               ret = tracepoint_probe_unregister(name, event->probe, event);
+               ret = tracepoint_probe_unregister(event->name, event->probe,
+                                                 event);
+               if (ret)
+                       return ret;
                break;
        default:
                WARN_ON_ONCE(1);
        }
        kfree(event->name);
-       kmem_cache_free(event);
+       kmem_cache_free(event_cache, event);
+       return ret;
 }
 
 /**
@@ -254,23 +263,25 @@ EXPORT_SYMBOL_GPL(ltt_transport_unregister);
 
 static int __init ltt_events_init(void)
 {
-       int ret;
-
-       events_cache = KMEM_CACHE(ltt_event, 0);
-       if (!events_cache)
+       event_cache = KMEM_CACHE(ltt_event, 0);
+       if (!event_cache)
                return -ENOMEM;
        return 0;
 }
 
+module_init(ltt_events_init);
+
 static void __exit ltt_events_exit(void)
 {
        struct ltt_session *session, *tmpsession;
 
        list_for_each_entry_safe(session, tmpsession, &sessions, list)
                ltt_session_destroy(session);
-       kmem_cache_destroy(events_cache);
+       kmem_cache_destroy(event_cache);
 }
 
+module_exit(ltt_events_exit);
+
 MODULE_LICENSE("GPL and additional rights");
 MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
 MODULE_DESCRIPTION("LTTng Events");
index b8485c35accbb62eecffae6da191bcf87905d888..6711341c86f60ac7d13eb952d706a0174b9a062e 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _LTT_EVENTS_H
+#define _LTT_EVENTS_H
+
 /*
  * ltt-events.h
  *
  */
 
 #include <linux/list.h>
+#include "ltt-debugfs-abi.h"
 
 struct ltt_channel;
 struct ltt_session;
 
-enum instrum_type itype {
-       INSTRUM_TRACEPOINTS,
-};
-
 /*
  * ltt_event structure is referred to by the tracing fast path. It must be
  * kept small.
@@ -29,6 +29,18 @@ struct ltt_event {
        struct list_head list;          /* Event list */
 };
 
+struct ltt_channel_ops {
+       struct channel *(*channel_create)(const char *name,
+                               struct ltt_session *session,
+                               void *buf_addr,
+                               size_t subbuf_size, size_t num_subbuf,
+                               unsigned int switch_timer_interval,
+                               unsigned int read_timer_interval);
+       void (*channel_destroy)(struct channel *chan);
+       struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan);
+       struct lib_ring_buffer *(*buffer_read_close)(struct lib_ring_buffer *buf);
+};
+
 struct ltt_channel {
        struct channel *chan;           /* Channel buffers */
        /* Event ID management */
@@ -37,6 +49,7 @@ struct ltt_channel {
        unsigned int free_event_id;     /* Next event ID to allocate */
        struct list_head list;          /* Channel list */
        wait_queue_head_t notify_wait;  /* Channel addition notif. waitqueue */
+       struct ltt_channel_ops *ops;
 };
 
 struct ltt_session {
@@ -47,42 +60,32 @@ struct ltt_session {
        struct list_head list;          /* Session list */
 };
 
-struct ltt_trace_ops {
-       struct channel *(*channel_create)(const char *name,
-                               struct ltt_trace *trace,
-                               void *buf_addr,
-                               size_t subbuf_size, size_t num_subbuf,
-                               unsigned int switch_timer_interval,
-                               unsigned int read_timer_interval);
-       void (*channel_destroy)(struct channel *chan);
-       struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan);
-       struct lib_ring_buffer *(*buffer_read_close)(struct lib_ring_buffer *buf);
-};
-
 struct ltt_transport {
        char *name;
        struct module *owner;
        struct list_head node;
-       struct ltt_trace_ops ops;
+       struct ltt_channel_ops ops;
 };
 
 struct ltt_session *ltt_session_create(void);
 int ltt_session_start(struct ltt_session *session);
 int ltt_session_stop(struct ltt_session *session);
-int ltt_session_destroy(struct ltt_session *session);
+void ltt_session_destroy(struct ltt_session *session);
 
 struct ltt_channel *ltt_channel_create(struct ltt_session *session,
                                       int overwrite, void *buf_addr,
                                       size_t subbuf_size, size_t num_subbuf,
                                       unsigned int switch_timer_interval,
                                       unsigned int read_timer_interval);
-int _ltt_channel_destroy(struct ltt_channel *chan);
+void _ltt_channel_destroy(struct ltt_channel *chan);
 
 struct ltt_event *ltt_event_create(struct ltt_channel *chan,
-                                  enum instrum_type itype,
                                   char *name,
-                                  void *filter);
+                                  enum instrum_type itype,
+                                  void *probe, void *filter);
 int _ltt_event_destroy(struct ltt_event *event);
 
 void ltt_transport_register(struct ltt_transport *transport);
 void ltt_transport_unregister(struct ltt_transport *transport);
+
+#endif /* _LTT_EVENTS_H */
index ca6187bfa6e1d0f2fa607efa16b384f861e07a93..6ed4fa94d623e968feef29323ae18dedf7dc89d0 100644 (file)
 #include <linux/kernel.h>
 #include <linux/timex.h>
 #include <linux/wait.h>
-#include <linux/marker.h>
 #include <linux/trace-clock.h>
 #include <asm/atomic.h>
 #include <asm/local.h>
 
 #include "ltt-tracer-core.h"
-#include "ltt-channels.h"
 
 /* Number of bytes to log with a read/write event */
 #define LTT_LOG_RW_SIZE                        32L
 
-struct ltt_active_marker;
-
 /* Maximum number of callbacks per marker */
 #define LTT_NR_CALLBACKS       10
 
+struct ltt_serialize_closure;
+
+/* Serialization callback */
+typedef size_t (*ltt_serialize_cb)(struct lib_ring_buffer *buf,
+                                  size_t buf_offset,
+                                  struct ltt_serialize_closure *closure,
+                                  void *serialize_private,
+                                  unsigned int stack_pos_ctx,
+                                  int *largest_align,
+                                  const char *fmt, va_list *args);
+
 struct ltt_serialize_closure {
        ltt_serialize_cb *callbacks;
        long cb_args[LTT_NR_CALLBACKS];
        unsigned int cb_idx;
 };
 
-size_t ltt_serialize_data(struct ltt_chanbuf *buf, size_t buf_offset,
+size_t ltt_serialize_data(struct lib_ring_buffer *buf, size_t buf_offset,
                          struct ltt_serialize_closure *closure,
                          void *serialize_private, unsigned int stack_pos_ctx,
                          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 */
-};
-
 enum ltt_channels {
        LTT_CHANNEL_METADATA,
        LTT_CHANNEL_FD_STATE,
@@ -80,20 +79,8 @@ enum ltt_channels {
        LTT_CHANNEL_DEFAULT,
 };
 
-struct ltt_active_marker {
-       struct list_head node;          /* active markers list */
-       const char *channel;
-       const char *name;
-       const char *format;
-       struct ltt_available_probe *probe;
-};
-
-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,
-                     void *call_data, const char *fmt, ...);
-
-size_t ltt_serialize_printf(struct ltt_chanbuf *buf, unsigned long buf_offset,
+#if 0
+size_t ltt_serialize_printf(struct lib_ring_buffer *buf, unsigned long buf_offset,
                            size_t *msg_size, char *output, size_t outlen,
                            const char *fmt);
 
@@ -127,6 +114,7 @@ enum trace_mode { LTT_TRACE_NORMAL, LTT_TRACE_FLIGHT, LTT_TRACE_HYBRID };
 
 #define CHANNEL_FLAG_ENABLE    (1U<<0)
 #define CHANNEL_FLAG_OVERWRITE (1U<<1)
+#endif //0
 
 #if 0
 /* Per-trace information - each trace/flight recorder represented by one */
@@ -313,10 +301,9 @@ unsigned char record_header_size(const struct lib_ring_buffer_config *config,
 #include <linux/ringbuffer/api.h>
 
 extern
-size_t ltt_write_event_header_slow(struct ltt_chanbuf_alloc *bufa,
-                                  struct ltt_chan_alloc *chana,
-                                  long buf_offset, u16 eID, u32 event_size,
-                                  u64 tsc, unsigned int rflags);
+size_t ltt_write_event_header_slow(const struct lib_ring_buffer_config *config,
+                                  struct lib_ring_buffer_ctx *ctx,
+                                  u16 eID, u32 event_size);
 
 /*
  * ltt_write_event_header
@@ -463,17 +450,17 @@ static __inline__
 void ltt_write_trace_header(void *priv,
                            struct subbuffer_header *header)
 {
-       struct ltt_trace *trace = priv;
+       struct ltt_session *session = priv;
 
        header->magic_number = LTT_TRACER_MAGIC_NUMBER;
        header->major_version = LTT_TRACER_VERSION_MAJOR;
        header->minor_version = LTT_TRACER_VERSION_MINOR;
        header->arch_size = sizeof(void *);
        header->alignment = lib_ring_buffer_get_alignment();
-       header->start_time_sec = trace->start_time.tv_sec;
-       header->start_time_usec = trace->start_time.tv_usec;
-       header->start_freq = trace->start_freq;
-       header->freq_scale = trace->freq_scale;
+       header->start_time_sec = session->start_time.tv_sec;
+       header->start_time_usec = session->start_time.tv_usec;
+       header->start_freq = session->start_freq;
+       header->freq_scale = session->freq_scale;
 }
 
 /*
@@ -521,8 +508,6 @@ void ltt_core_register(int (*function)(u8, void *));
 
 void ltt_core_unregister(void);
 
-extern int ltt_probe_register(struct ltt_available_probe *pdata);
-extern int ltt_probe_unregister(struct ltt_available_probe *pdata);
 extern int ltt_marker_connect(const char *channel, const char *mname,
                              const char *pname);
 extern int ltt_marker_disconnect(const char *channel, const char *mname,
This page took 0.034611 seconds and 4 git commands to generate.