Cleanup: libringbuffer: remove duplicate shmp() invocations in slow paths
[lttng-ust.git] / libringbuffer / ring_buffer_backend.c
index 2e688b40f4810e1a80c57b7296edafaed7e97c14..3dca862712ef4116a315eb2754a2b417fdeea7a1 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #define _GNU_SOURCE
+#define _LGPL_SOURCE
 #include <unistd.h>
 #include <urcu/arch.h>
 #include <limits.h>
@@ -117,6 +118,14 @@ int lib_ring_buffer_backend_allocate(const struct lttng_ust_lib_ring_buffer_conf
        else
                bufb->buf_rsb.id = subbuffer_id(config, 0, 1, 0);
 
+       /* Allocate subbuffer packet counter table */
+       align_shm(shmobj, __alignof__(struct lttng_ust_lib_ring_buffer_backend_subbuffer));
+       set_shmp(bufb->buf_cnt, zalloc_shm(shmobj,
+                               sizeof(struct lttng_ust_lib_ring_buffer_backend_counts)
+                               * num_subbuf));
+       if (caa_unlikely(!shmp(handle, bufb->buf_cnt)))
+               goto free_wsb;
+
        /* Assign pages to page index */
        for (i = 0; i < num_subbuf_alloc; i++) {
                struct lttng_ust_lib_ring_buffer_backend_pages_shmp *sbp;
@@ -141,6 +150,8 @@ int lib_ring_buffer_backend_allocate(const struct lttng_ust_lib_ring_buffer_conf
        }
        return 0;
 
+free_wsb:
+       /* bufb->buf_wsb will be freed by shm teardown */
 free_array:
        /* bufb->array[i] will be freed by shm teardown */
 memory_map_error:
This page took 0.023639 seconds and 4 git commands to generate.