#include <stddef.h>
#include <unistd.h>
+#include "ust-helper.h"
+
/* Internal helpers */
#include "backend_internal.h"
#include "frontend_internal.h"
/* Ring buffer backend access (read/write) */
+LTTNG_HIDDEN
extern size_t lib_ring_buffer_read(struct lttng_ust_lib_ring_buffer_backend *bufb,
size_t offset, void *dest, size_t len,
struct lttng_ust_shm_handle *handle);
+LTTNG_HIDDEN
extern int lib_ring_buffer_read_cstr(struct lttng_ust_lib_ring_buffer_backend *bufb,
size_t offset, void *dest, size_t len,
struct lttng_ust_shm_handle *handle);
* it's never on a page boundary, it's safe to write directly to this address,
* as long as the write is never bigger than a page size.
*/
+LTTNG_HIDDEN
extern void *
lib_ring_buffer_offset_address(struct lttng_ust_lib_ring_buffer_backend *bufb,
size_t offset,
struct lttng_ust_shm_handle *handle);
+LTTNG_HIDDEN
extern void *
lib_ring_buffer_read_offset_address(struct lttng_ust_lib_ring_buffer_backend *bufb,
size_t offset,
#include "backend_types.h"
#include "frontend_types.h"
#include "shm.h"
+#include "ust-helper.h"
/* Ring buffer backend API presented to the frontend */
/* Ring buffer and channel backend create/free */
+LTTNG_HIDDEN
int lib_ring_buffer_backend_create(struct lttng_ust_lib_ring_buffer_backend *bufb,
struct channel_backend *chan, int cpu,
struct lttng_ust_shm_handle *handle,
struct shm_object *shmobj);
+LTTNG_HIDDEN
void channel_backend_unregister_notifiers(struct channel_backend *chanb);
+LTTNG_HIDDEN
void lib_ring_buffer_backend_free(struct lttng_ust_lib_ring_buffer_backend *bufb);
+LTTNG_HIDDEN
int channel_backend_init(struct channel_backend *chanb,
const char *name,
const struct lttng_ust_lib_ring_buffer_config *config,
size_t subbuf_size,
size_t num_subbuf, struct lttng_ust_shm_handle *handle,
const int *stream_fds);
+LTTNG_HIDDEN
void channel_backend_free(struct channel_backend *chanb,
struct lttng_ust_shm_handle *handle);
+LTTNG_HIDDEN
void lib_ring_buffer_backend_reset(struct lttng_ust_lib_ring_buffer_backend *bufb,
struct lttng_ust_shm_handle *handle);
+LTTNG_HIDDEN
void channel_backend_reset(struct channel_backend *chanb);
+LTTNG_HIDDEN
int lib_ring_buffer_backend_init(void);
+LTTNG_HIDDEN
void lib_ring_buffer_backend_exit(void);
+LTTNG_HIDDEN
extern void _lib_ring_buffer_write(struct lttng_ust_lib_ring_buffer_backend *bufb,
size_t offset, const void *src, size_t len,
ssize_t pagecpy);
#include <urcu/uatomic.h>
#include "smp.h"
+#include "ust-helper.h"
+
/* Internal helpers */
#include "frontend_internal.h"
* private data area.
*/
+LTTNG_HIDDEN
extern
struct lttng_ust_shm_handle *channel_create(const struct lttng_ust_lib_ring_buffer_config *config,
const char *name,
* channel_destroy finalizes all channel's buffers, waits for readers to
* release all references, and destroys the channel.
*/
+LTTNG_HIDDEN
extern
void channel_destroy(struct channel *chan, struct lttng_ust_shm_handle *handle,
int consumer);
#define for_each_channel_cpu(cpu, chan) \
for_each_possible_cpu(cpu)
+LTTNG_HIDDEN
extern struct lttng_ust_lib_ring_buffer *channel_get_ring_buffer(
const struct lttng_ust_lib_ring_buffer_config *config,
struct channel *chan, int cpu,
int *shm_fd, int *wait_fd,
int *wakeup_fd,
uint64_t *memory_map_size);
+LTTNG_HIDDEN
extern
int ring_buffer_channel_close_wait_fd(const struct lttng_ust_lib_ring_buffer_config *config,
struct channel *chan,
struct lttng_ust_shm_handle *handle);
+LTTNG_HIDDEN
extern
int ring_buffer_channel_close_wakeup_fd(const struct lttng_ust_lib_ring_buffer_config *config,
struct channel *chan,
struct lttng_ust_shm_handle *handle);
+LTTNG_HIDDEN
extern
int ring_buffer_stream_close_wait_fd(const struct lttng_ust_lib_ring_buffer_config *config,
struct channel *chan,
struct lttng_ust_shm_handle *handle,
int cpu);
+LTTNG_HIDDEN
extern
int ring_buffer_stream_close_wakeup_fd(const struct lttng_ust_lib_ring_buffer_config *config,
struct channel *chan,
struct lttng_ust_shm_handle *handle,
int cpu);
+LTTNG_HIDDEN
extern int lib_ring_buffer_open_read(struct lttng_ust_lib_ring_buffer *buf,
struct lttng_ust_shm_handle *handle);
+LTTNG_HIDDEN
extern void lib_ring_buffer_release_read(struct lttng_ust_lib_ring_buffer *buf,
struct lttng_ust_shm_handle *handle);
* Initialize signals for ring buffer. Should be called early e.g. by
* main() in the program to affect all threads.
*/
+LTTNG_HIDDEN
void lib_ringbuffer_signal_init(void);
/*
* Read sequence: snapshot, many get_subbuf/put_subbuf, move_consumer.
*/
+LTTNG_HIDDEN
extern int lib_ring_buffer_snapshot(struct lttng_ust_lib_ring_buffer *buf,
unsigned long *consumed,
unsigned long *produced,
struct lttng_ust_shm_handle *handle);
+LTTNG_HIDDEN
extern int lib_ring_buffer_snapshot_sample_positions(
struct lttng_ust_lib_ring_buffer *buf,
unsigned long *consumed,
unsigned long *produced,
struct lttng_ust_shm_handle *handle);
+LTTNG_HIDDEN
extern void lib_ring_buffer_move_consumer(struct lttng_ust_lib_ring_buffer *buf,
unsigned long consumed_new,
struct lttng_ust_shm_handle *handle);
+LTTNG_HIDDEN
extern int lib_ring_buffer_get_subbuf(struct lttng_ust_lib_ring_buffer *buf,
unsigned long consumed,
struct lttng_ust_shm_handle *handle);
+LTTNG_HIDDEN
extern void lib_ring_buffer_put_subbuf(struct lttng_ust_lib_ring_buffer *buf,
struct lttng_ust_shm_handle *handle);
handle);
}
+LTTNG_HIDDEN
extern void channel_reset(struct channel *chan);
+LTTNG_HIDDEN
extern void lib_ring_buffer_reset(struct lttng_ust_lib_ring_buffer *buf,
struct lttng_ust_shm_handle *handle);
#include "backend_types.h"
#include "frontend_types.h"
#include "shm.h"
+#include "ust-helper.h"
/* Buffer offset macros */
}
#endif
+LTTNG_HIDDEN
extern
int lib_ring_buffer_reserve_slow(struct lttng_ust_lib_ring_buffer_ctx *ctx,
void *client_ctx);
+LTTNG_HIDDEN
extern
void lib_ring_buffer_switch_slow(struct lttng_ust_lib_ring_buffer *buf,
enum switch_mode mode,
struct lttng_ust_shm_handle *handle);
+LTTNG_HIDDEN
void lib_ring_buffer_check_deliver_slow(const struct lttng_ust_lib_ring_buffer_config *config,
struct lttng_ust_lib_ring_buffer *buf,
struct channel *chan,
v_set(config, &cc_hot->seq, commit_count);
}
+LTTNG_HIDDEN
extern int lib_ring_buffer_create(struct lttng_ust_lib_ring_buffer *buf,
struct channel_backend *chanb, int cpu,
struct lttng_ust_shm_handle *handle,
struct shm_object *shmobj);
+LTTNG_HIDDEN
extern void lib_ring_buffer_free(struct lttng_ust_lib_ring_buffer *buf,
struct lttng_ust_shm_handle *handle);
/* Keep track of trap nesting inside ring buffer code */
+LTTNG_HIDDEN
extern DECLARE_URCU_TLS(unsigned int, lib_ring_buffer_nesting);
#endif /* _LTTNG_RING_BUFFER_FRONTEND_INTERNAL_H */
#include <urcu/system.h>
#include <urcu/arch.h>
+#include "ust-helper.h"
+
+LTTNG_HIDDEN
void lttng_ust_getcpu_init(void);
+LTTNG_HIDDEN
extern int (*lttng_get_cpu)(void);
#ifdef LTTNG_UST_DEBUG_VALGRIND
#ifndef _LTTNG_RING_BUFFER_NOHZ_H
#define _LTTNG_RING_BUFFER_NOHZ_H
+#include "ust-helper.h"
+
#ifdef CONFIG_LIB_RING_BUFFER
+LTTNG_HIDDEN
void lib_ring_buffer_tick_nohz_flush(void);
+LTTNG_HIDDEN
void lib_ring_buffer_tick_nohz_stop(void);
+LTTNG_HIDDEN
void lib_ring_buffer_tick_nohz_restart(void);
#else
static inline void lib_ring_buffer_tick_nohz_flush(void)
#ifndef _LTTNG_UST_LIB_RINGBUFFER_RB_INIT_H
#define _LTTNG_UST_LIB_RINGBUFFER_RB_INIT_H
+#include "ust-helper.h"
+
+LTTNG_HIDDEN
void lttng_fixup_ringbuffer_tls(void);
+LTTNG_HIDDEN
void lttng_ust_ringbuffer_set_allow_blocking(void);
#endif /* _LTTNG_UST_LIB_RINGBUFFER_RB_INIT_H */
#include <usterr-signal-safe.h>
#include <urcu/compiler.h>
#include "shm_types.h"
+#include "ust-helper.h"
/* channel_handle_create - for UST. */
+LTTNG_HIDDEN
extern
struct lttng_ust_shm_handle *channel_handle_create(void *data,
uint64_t memory_map_size, int wakeup_fd);
/* channel_handle_add_stream - for UST. */
+LTTNG_HIDDEN
extern
int channel_handle_add_stream(struct lttng_ust_shm_handle *handle,
int shm_fd, int wakeup_fd, uint32_t stream_nr,
uint64_t memory_map_size);
+LTTNG_HIDDEN
unsigned int channel_handle_get_nr_streams(struct lttng_ust_shm_handle *handle);
+LTTNG_HIDDEN
extern
void channel_destroy(struct channel *chan, struct lttng_ust_shm_handle *handle,
int consumer);
#define set_shmp(ref, src) _set_shmp(&(ref)._ref, src)
+LTTNG_HIDDEN
struct shm_object_table *shm_object_table_create(size_t max_nb_obj);
+LTTNG_HIDDEN
struct shm_object *shm_object_table_alloc(struct shm_object_table *table,
size_t memory_map_size,
enum shm_object_type type,
const int stream_fd,
int cpu);
+LTTNG_HIDDEN
struct shm_object *shm_object_table_append_shm(struct shm_object_table *table,
int shm_fd, int wakeup_fd, uint32_t stream_nr,
size_t memory_map_size);
/* mem ownership is passed to shm_object_table_append_mem(). */
+LTTNG_HIDDEN
struct shm_object *shm_object_table_append_mem(struct shm_object_table *table,
void *mem, size_t memory_map_size, int wakeup_fd);
+LTTNG_HIDDEN
void shm_object_table_destroy(struct shm_object_table *table, int consumer);
/*
* *NOT* multithread-safe (should be protected by mutex).
* Returns a -1, -1 tuple on error.
*/
+LTTNG_HIDDEN
struct shm_ref zalloc_shm(struct shm_object *obj, size_t len);
+LTTNG_HIDDEN
void align_shm(struct shm_object *obj, size_t align);
static inline
#ifndef _LIBRINGBUFFER_SMP_H
#define _LIBRINGBUFFER_SMP_H
+#include "ust-helper.h"
#include "getcpu.h"
/*
*/
#define PER_CPU_MEM_SIZE 4096
+LTTNG_HIDDEN
extern int __num_possible_cpus;
+LTTNG_HIDDEN
extern void _get_num_possible_cpus(void);
static inline