Clean-up: run format-cpp on the tree
[lttng-tools.git] / src / bin / lttng-sessiond / buffer-registry.hpp
1 /*
2 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8 #ifndef LTTNG_BUFFER_REGISTRY_H
9 #define LTTNG_BUFFER_REGISTRY_H
10
11 #include "consumer.hpp"
12 #include "lttng-ust-ctl.hpp"
13 #include "ust-registry-session.hpp"
14 #include "ust-registry.hpp"
15
16 #include <common/hashtable/hashtable.hpp>
17
18 #include <lttng/lttng.h>
19
20 #include <stdint.h>
21 #include <urcu/list.h>
22
23 struct buffer_reg_stream {
24 struct cds_list_head lnode;
25 union {
26 /* Original object data that MUST be copied over. */
27 struct lttng_ust_abi_object_data *ust;
28 } obj;
29 };
30
31 struct buffer_reg_channel {
32 /* This key is the same as a tracing channel key. */
33 uint32_t key;
34 /* Key of the channel on the consumer side. */
35 uint64_t consumer_key;
36 /* Stream registry object of this channel registry. */
37 struct cds_list_head streams;
38 /* Total number of stream in the list. */
39 uint64_t stream_count;
40 /* Used to ensure mutual exclusion to the stream's list. */
41 pthread_mutex_t stream_list_lock;
42 /* Node for hash table usage. */
43 struct lttng_ht_node_u64 node;
44 /* Size of subbuffers in this channel. */
45 size_t subbuf_size;
46 /* Number of subbuffers per stream. */
47 size_t num_subbuf;
48 union {
49 /* Original object data that MUST be copied over. */
50 struct lttng_ust_abi_object_data *ust;
51 } obj;
52 };
53
54 struct buffer_reg_session {
55 /* Registry per domain. */
56 union {
57 lttng::sessiond::ust::registry_session *ust;
58 } reg;
59
60 /* Contains buffer registry channel indexed by tracing channel key. */
61 struct lttng_ht *channels;
62 };
63
64 /*
65 * Registry object for per UID buffers.
66 */
67 struct buffer_reg_uid {
68 /*
69 * Keys to match this object in a hash table. The following three variables
70 * identify a unique per UID buffer registry.
71 */
72 uint64_t session_id; /* Unique tracing session id. */
73 int bits_per_long; /* ABI */
74 uid_t uid; /* Owner. */
75
76 enum lttng_domain_type domain;
77 struct buffer_reg_session *registry;
78
79 /* Indexed by session id. */
80 struct lttng_ht_node_u64 node;
81 /* Node of a linked list used to teardown object at a destroy session. */
82 struct cds_list_head lnode;
83
84 char root_shm_path[PATH_MAX];
85 char shm_path[PATH_MAX];
86 };
87
88 /*
89 * Registry object for per PID buffers.
90 */
91 struct buffer_reg_pid {
92 uint64_t session_id;
93
94 struct buffer_reg_session *registry;
95
96 /* Indexed by session id. */
97 struct lttng_ht_node_u64 node;
98
99 char root_shm_path[PATH_MAX];
100 char shm_path[PATH_MAX];
101 };
102
103 /* Buffer registry per UID. */
104 void buffer_reg_init_uid_registry(void);
105 int buffer_reg_uid_create(uint64_t session_id,
106 uint32_t bits_per_long,
107 uid_t uid,
108 enum lttng_domain_type domain,
109 struct buffer_reg_uid **regp,
110 const char *root_shm_path,
111 const char *shm_path);
112 void buffer_reg_uid_add(struct buffer_reg_uid *reg);
113 struct buffer_reg_uid *buffer_reg_uid_find(uint64_t session_id, uint32_t bits_per_long, uid_t uid);
114 void buffer_reg_uid_remove(struct buffer_reg_uid *regp);
115 void buffer_reg_uid_destroy(struct buffer_reg_uid *regp, struct consumer_output *consumer);
116
117 /* Buffer registry per PID. */
118 void buffer_reg_init_pid_registry(void);
119 int buffer_reg_pid_create(uint64_t session_id,
120 struct buffer_reg_pid **regp,
121 const char *root_shm_path,
122 const char *shm_path);
123 void buffer_reg_pid_add(struct buffer_reg_pid *reg);
124 struct buffer_reg_pid *buffer_reg_pid_find(uint64_t session_id);
125 void buffer_reg_pid_remove(struct buffer_reg_pid *regp);
126 void buffer_reg_pid_destroy(struct buffer_reg_pid *regp);
127
128 /* Channel */
129 int buffer_reg_channel_create(uint64_t key, struct buffer_reg_channel **regp);
130 void buffer_reg_channel_add(struct buffer_reg_session *session, struct buffer_reg_channel *channel);
131 struct buffer_reg_channel *buffer_reg_channel_find(uint64_t key, struct buffer_reg_uid *reg);
132 void buffer_reg_channel_remove(struct buffer_reg_session *session, struct buffer_reg_channel *regp);
133 void buffer_reg_channel_destroy(struct buffer_reg_channel *regp, enum lttng_domain_type domain);
134
135 /* Stream */
136 int buffer_reg_stream_create(struct buffer_reg_stream **regp);
137 void buffer_reg_stream_add(struct buffer_reg_stream *stream, struct buffer_reg_channel *channel);
138 void buffer_reg_stream_destroy(struct buffer_reg_stream *regp, enum lttng_domain_type domain);
139
140 /* Global registry. */
141 void buffer_reg_destroy_registries(void);
142
143 int buffer_reg_uid_consumer_channel_key(struct cds_list_head *buffer_reg_uid_list,
144 uint64_t chan_key,
145 uint64_t *consumer_chan_key);
146
147 #endif /* LTTNG_BUFFER_REGISTRY_H */
This page took 0.033468 seconds and 5 git commands to generate.