X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=libringbuffer%2Fring_buffer_backend.c;h=769e24bffa0c35475aee4ddcec62b60b4b618d93;hb=2e707419baf97942e59a9d13bb23e0392bc48c15;hp=c32ba982259a2099a7aa0f8bf65a7f6ecadfc1b4;hpb=a3f61e7f689a5fc60b833a773f462989dc6cc78f;p=lttng-ust.git diff --git a/libringbuffer/ring_buffer_backend.c b/libringbuffer/ring_buffer_backend.c index c32ba982..769e24bf 100644 --- a/libringbuffer/ring_buffer_backend.c +++ b/libringbuffer/ring_buffer_backend.c @@ -6,11 +6,12 @@ * Dual LGPL v2.1/GPL v2 license. */ +#define _GNU_SOURCE #include - -#include "lttng/core.h" +#include #include +#include "vatomic.h" #include "backend.h" #include "frontend.h" #include "smp.h" @@ -129,14 +130,6 @@ int lib_ring_buffer_backend_create(struct lttng_ust_lib_ring_buffer_backend *buf handle, shmobj); } -void lib_ring_buffer_backend_free(struct lttng_ust_lib_ring_buffer_backend *bufb) -{ - /* bufb->buf_wsb will be freed by shm teardown */ - /* bufb->array[i] will be freed by shm teardown */ - /* bufb->array will be freed by shm teardown */ - bufb->allocated = 0; -} - void lib_ring_buffer_backend_reset(struct lttng_ust_lib_ring_buffer_backend *bufb, struct lttng_ust_shm_handle *handle) { @@ -227,8 +220,10 @@ int channel_backend_init(struct channel_backend *chanb, /* * Make sure the number of subbuffers and subbuffer size are power of 2. */ - CHAN_WARN_ON(chanb, hweight32(subbuf_size) != 1); - CHAN_WARN_ON(chanb, hweight32(num_subbuf) != 1); + if (hweight32(subbuf_size) != 1) + return -EINVAL; + if (hweight32(num_subbuf) != 1) + return -EINVAL; ret = subbuffer_id_check_index(config, num_subbuf); if (ret) @@ -301,6 +296,7 @@ int channel_backend_init(struct channel_backend *chanb, buf = shmp(handle, chanb->buf[0].shmp); if (!buf) goto end; + set_shmp(buf->self, chanb->buf[0].shmp._ref); ret = lib_ring_buffer_create(buf, chanb, -1, handle, shmobj); if (ret) @@ -311,15 +307,6 @@ int channel_backend_init(struct channel_backend *chanb, return 0; free_bufs: - if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) { - for_each_possible_cpu(i) { - struct lttng_ust_lib_ring_buffer *buf = shmp(handle, chanb->buf[i].shmp); - - if (!buf->backend.allocated) - continue; - lib_ring_buffer_free(buf, handle); - } - } /* We only free the buffer data upon shm teardown */ end: return -ENOMEM; @@ -334,24 +321,7 @@ end: void channel_backend_free(struct channel_backend *chanb, struct lttng_ust_shm_handle *handle) { - const struct lttng_ust_lib_ring_buffer_config *config = &chanb->config; - unsigned int i; - - if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) { - for_each_possible_cpu(i) { - struct lttng_ust_lib_ring_buffer *buf = shmp(handle, chanb->buf[i].shmp); - - if (!buf->backend.allocated) - continue; - lib_ring_buffer_free(buf, handle); - } - } else { - struct lttng_ust_lib_ring_buffer *buf = shmp(handle, chanb->buf[0].shmp); - - CHAN_WARN_ON(chanb, !buf->backend.allocated); - lib_ring_buffer_free(buf, handle); - } - /* We only free the buffer data upon shm teardown */ + /* SHM teardown takes care of everything */ } /**