From 071dec4386ff4c89d8b0f92ab1a8dbf079abd50c Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Tue, 2 Mar 2021 12:41:15 -0500 Subject: [PATCH] Hide libringbuffer private symbols The major SONAME bump to '1' gives us the opportunity to hide private symbols that should never have been visible. Change-Id: I605c3d560ad03affe79d3518ec35ba484e892c3b Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- libringbuffer/backend.h | 6 ++++++ libringbuffer/backend_internal.h | 11 +++++++++++ libringbuffer/frontend.h | 19 +++++++++++++++++++ libringbuffer/frontend_internal.h | 7 +++++++ libringbuffer/getcpu.h | 4 ++++ libringbuffer/nohz.h | 5 +++++ libringbuffer/rb-init.h | 4 ++++ libringbuffer/shm.h | 12 ++++++++++++ libringbuffer/smp.h | 3 +++ 9 files changed, 71 insertions(+) diff --git a/libringbuffer/backend.h b/libringbuffer/backend.h index 98c194ca..dbb5d735 100644 --- a/libringbuffer/backend.h +++ b/libringbuffer/backend.h @@ -15,6 +15,8 @@ #include #include +#include "ust-helper.h" + /* Internal helpers */ #include "backend_internal.h" #include "frontend_internal.h" @@ -23,10 +25,12 @@ /* 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); @@ -37,10 +41,12 @@ extern int lib_ring_buffer_read_cstr(struct lttng_ust_lib_ring_buffer_backend *b * 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, diff --git a/libringbuffer/backend_internal.h b/libringbuffer/backend_internal.h index 53817614..b8a16990 100644 --- a/libringbuffer/backend_internal.h +++ b/libringbuffer/backend_internal.h @@ -18,33 +18,44 @@ #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); diff --git a/libringbuffer/frontend.h b/libringbuffer/frontend.h index bac86d17..9bc22df8 100644 --- a/libringbuffer/frontend.h +++ b/libringbuffer/frontend.h @@ -18,6 +18,8 @@ #include #include "smp.h" +#include "ust-helper.h" + /* Internal helpers */ #include "frontend_internal.h" @@ -39,6 +41,7 @@ * 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, @@ -57,6 +60,7 @@ struct lttng_ust_shm_handle *channel_create(const struct lttng_ust_lib_ring_buff * 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); @@ -73,6 +77,7 @@ void channel_destroy(struct channel *chan, struct lttng_ust_shm_handle *handle, #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, @@ -80,27 +85,33 @@ extern struct lttng_ust_lib_ring_buffer *channel_get_ring_buffer( 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); @@ -108,27 +119,33 @@ extern void lib_ring_buffer_release_read(struct lttng_ust_lib_ring_buffer *buf, * 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); @@ -163,7 +180,9 @@ void lib_ring_buffer_put_next_subbuf(struct lttng_ust_lib_ring_buffer *buf, 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); diff --git a/libringbuffer/frontend_internal.h b/libringbuffer/frontend_internal.h index 9c6a8db7..c8a54e96 100644 --- a/libringbuffer/frontend_internal.h +++ b/libringbuffer/frontend_internal.h @@ -21,6 +21,7 @@ #include "backend_types.h" #include "frontend_types.h" #include "shm.h" +#include "ust-helper.h" /* Buffer offset macros */ @@ -138,15 +139,18 @@ int last_tsc_overflow(const struct lttng_ust_lib_ring_buffer_config *config, } #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, @@ -337,14 +341,17 @@ void lib_ring_buffer_write_commit_counter(const struct lttng_ust_lib_ring_buffer 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 */ diff --git a/libringbuffer/getcpu.h b/libringbuffer/getcpu.h index bb815e66..8785d496 100644 --- a/libringbuffer/getcpu.h +++ b/libringbuffer/getcpu.h @@ -11,8 +11,12 @@ #include #include +#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 diff --git a/libringbuffer/nohz.h b/libringbuffer/nohz.h index 078d154c..2898cc43 100644 --- a/libringbuffer/nohz.h +++ b/libringbuffer/nohz.h @@ -7,9 +7,14 @@ #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) diff --git a/libringbuffer/rb-init.h b/libringbuffer/rb-init.h index 46157a90..319cf414 100644 --- a/libringbuffer/rb-init.h +++ b/libringbuffer/rb-init.h @@ -7,7 +7,11 @@ #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 */ diff --git a/libringbuffer/shm.h b/libringbuffer/shm.h index e4a466e5..ee843858 100644 --- a/libringbuffer/shm.h +++ b/libringbuffer/shm.h @@ -13,17 +13,22 @@ #include #include #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); @@ -73,18 +78,23 @@ void _set_shmp(struct shm_ref *ref, struct shm_ref src) #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); /* @@ -94,7 +104,9 @@ 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 diff --git a/libringbuffer/smp.h b/libringbuffer/smp.h index ebeae667..b04401e1 100644 --- a/libringbuffer/smp.h +++ b/libringbuffer/smp.h @@ -7,6 +7,7 @@ #ifndef _LIBRINGBUFFER_SMP_H #define _LIBRINGBUFFER_SMP_H +#include "ust-helper.h" #include "getcpu.h" /* @@ -15,7 +16,9 @@ */ #define PER_CPU_MEM_SIZE 4096 +LTTNG_HIDDEN extern int __num_possible_cpus; +LTTNG_HIDDEN extern void _get_num_possible_cpus(void); static inline -- 2.34.1