callstack context: use delimiter when stack is incomplete
[lttng-modules.git] / lttng-abi.c
index 77e5e9859e7f51099964f4002b932faf98531984..f155c76be5b3144e211aabdaf45914daede1101e 100644 (file)
@@ -56,6 +56,7 @@
 #include <lttng-abi-old.h>
 #include <lttng-events.h>
 #include <lttng-tracer.h>
+#include <lttng-tp-mempool.h>
 #include <lib/ringbuffer/frontend_types.h>
 
 /*
@@ -246,6 +247,9 @@ long lttng_abi_add_context(struct file *file,
                return lttng_add_preemptible_to_ctx(ctx);
        case LTTNG_KERNEL_CONTEXT_MIGRATABLE:
                return lttng_add_migratable_to_ctx(ctx);
+       case LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL:
+       case LTTNG_KERNEL_CONTEXT_CALLSTACK_USER:
+               return lttng_add_callstack_to_ctx(ctx, context_param->ctx);
        default:
                return -EINVAL;
        }
@@ -654,6 +658,38 @@ void lttng_metadata_ring_buffer_ioctl_put_next_subbuf(struct file *filp,
        stream->metadata_out = stream->metadata_in;
 }
 
+/*
+ * Reset the counter of how much metadata has been consumed to 0. That way,
+ * the consumer receives the content of the metadata cache unchanged. This is
+ * different from the metadata_regenerate where the offset from epoch is
+ * resampled, here we want the exact same content as the last time the metadata
+ * was generated. This command is only possible if all the metadata written
+ * in the cache has been output to the metadata stream to avoid corrupting the
+ * metadata file.
+ *
+ * Return 0 on success, a negative value on error.
+ */
+static
+int lttng_metadata_cache_dump(struct lttng_metadata_stream *stream)
+{
+       int ret;
+       struct lttng_metadata_cache *cache = stream->metadata_cache;
+
+       mutex_lock(&cache->lock);
+       if (stream->metadata_out != cache->metadata_written) {
+               ret = -EBUSY;
+               goto end;
+       }
+       stream->metadata_out = 0;
+       stream->metadata_in = 0;
+       wake_up_interruptible(&stream->read_wait);
+       ret = 0;
+
+end:
+       mutex_unlock(&cache->lock);
+       return ret;
+}
+
 static
 long lttng_metadata_ring_buffer_ioctl(struct file *filp,
                unsigned int cmd, unsigned long arg)
@@ -706,6 +742,12 @@ long lttng_metadata_ring_buffer_ioctl(struct file *filp,
 
                return put_u64(stream->version, arg);
        }
+       case RING_BUFFER_METADATA_CACHE_DUMP:
+       {
+               struct lttng_metadata_stream *stream = filp->private_data;
+
+               return lttng_metadata_cache_dump(stream);
+       }
        default:
                break;
        }
@@ -783,6 +825,12 @@ long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp,
 
                return put_u64(stream->version, arg);
        }
+       case RING_BUFFER_METADATA_CACHE_DUMP:
+       {
+               struct lttng_metadata_stream *stream = filp->private_data;
+
+               return lttng_metadata_cache_dump(stream);
+       }
        default:
                break;
        }
@@ -1727,6 +1775,12 @@ int __init lttng_abi_init(void)
 
        wrapper_vmalloc_sync_all();
        lttng_clock_ref();
+
+       ret = lttng_tp_mempool_init();
+       if (ret) {
+               goto error;
+       }
+
        lttng_proc_dentry = proc_create_data("lttng", S_IRUSR | S_IWUSR, NULL,
                                        &lttng_fops, NULL);
 
@@ -1739,6 +1793,7 @@ int __init lttng_abi_init(void)
        return 0;
 
 error:
+       lttng_tp_mempool_destroy();
        lttng_clock_unref();
        return ret;
 }
@@ -1746,6 +1801,7 @@ error:
 /* No __exit annotation because used by init error path too. */
 void lttng_abi_exit(void)
 {
+       lttng_tp_mempool_destroy();
        lttng_clock_unref();
        if (lttng_proc_dentry)
                remove_proc_entry("lttng", NULL);
This page took 0.023846 seconds and 4 git commands to generate.