Clean-up: apply suggested clang-tidy fixes
[lttng-tools.git] / src / bin / lttng-sessiond / buffer-registry.hpp
... / ...
CommitLineData
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
23struct 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
31struct 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
54struct 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 */
67struct 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 */
91struct 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. */
104void buffer_reg_init_uid_registry();
105int 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);
112void buffer_reg_uid_add(struct buffer_reg_uid *reg);
113struct buffer_reg_uid *buffer_reg_uid_find(uint64_t session_id, uint32_t bits_per_long, uid_t uid);
114void buffer_reg_uid_remove(struct buffer_reg_uid *regp);
115void buffer_reg_uid_destroy(struct buffer_reg_uid *regp, struct consumer_output *consumer);
116
117/* Buffer registry per PID. */
118void buffer_reg_init_pid_registry();
119int 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);
123void buffer_reg_pid_add(struct buffer_reg_pid *reg);
124struct buffer_reg_pid *buffer_reg_pid_find(uint64_t session_id);
125void buffer_reg_pid_remove(struct buffer_reg_pid *regp);
126void buffer_reg_pid_destroy(struct buffer_reg_pid *regp);
127
128/* Channel */
129int buffer_reg_channel_create(uint64_t key, struct buffer_reg_channel **regp);
130void buffer_reg_channel_add(struct buffer_reg_session *session, struct buffer_reg_channel *channel);
131struct buffer_reg_channel *buffer_reg_channel_find(uint64_t key, struct buffer_reg_uid *reg);
132void buffer_reg_channel_remove(struct buffer_reg_session *session, struct buffer_reg_channel *regp);
133void buffer_reg_channel_destroy(struct buffer_reg_channel *regp, enum lttng_domain_type domain);
134
135/* Stream */
136int buffer_reg_stream_create(struct buffer_reg_stream **regp);
137void buffer_reg_stream_add(struct buffer_reg_stream *stream, struct buffer_reg_channel *channel);
138void buffer_reg_stream_destroy(struct buffer_reg_stream *regp, enum lttng_domain_type domain);
139
140/* Global registry. */
141void buffer_reg_destroy_registries();
142
143int 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.022716 seconds and 4 git commands to generate.