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