Fix: file-descriptor: missing include guards
[lttng-tools.git] / src / bin / lttng-sessiond / buffer-registry.hpp
CommitLineData
7972aab2 1/*
ab5be9fa 2 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
7972aab2 3 *
ab5be9fa 4 * SPDX-License-Identifier: GPL-2.0-only
7972aab2 5 *
7972aab2
DG
6 */
7
8#ifndef LTTNG_BUFFER_REGISTRY_H
9#define LTTNG_BUFFER_REGISTRY_H
10
11#include <stdint.h>
7972aab2
DG
12#include <urcu/list.h>
13
14#include <lttng/lttng.h>
c9e313bc 15#include <common/hashtable/hashtable.hpp>
7972aab2 16
c9e313bc
SM
17#include "consumer.hpp"
18#include "lttng-ust-ctl.hpp"
19#include "ust-registry.hpp"
b0f2e8db 20#include "ust-registry-session.hpp"
7972aab2
DG
21
22struct buffer_reg_stream {
23 struct cds_list_head lnode;
24 union {
25 /* Original object data that MUST be copied over. */
fc4b93fa 26 struct lttng_ust_abi_object_data *ust;
7972aab2
DG
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;
5c786ded
JD
37 /* Total number of stream in the list. */
38 uint64_t stream_count;
7972aab2
DG
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;
8c924c7b
MD
43 /* Size of subbuffers in this channel. */
44 size_t subbuf_size;
d07ceecd
MD
45 /* Number of subbuffers per stream. */
46 size_t num_subbuf;
7972aab2
DG
47 union {
48 /* Original object data that MUST be copied over. */
fc4b93fa 49 struct lttng_ust_abi_object_data *ust;
7972aab2
DG
50 } obj;
51};
52
53struct buffer_reg_session {
54 /* Registry per domain. */
55 union {
b0f2e8db 56 lttng::sessiond::ust::registry_session *ust;
7972aab2
DG
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 */
d9bf3ca4 71 uint64_t session_id; /* Unique tracing session id. */
7972aab2
DG
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;
d7ba1388 82
3d071855 83 char root_shm_path[PATH_MAX];
d7ba1388 84 char shm_path[PATH_MAX];
7972aab2
DG
85};
86
87/*
88 * Registry object for per PID buffers.
89 */
90struct buffer_reg_pid {
d9bf3ca4 91 uint64_t session_id;
7972aab2
DG
92
93 struct buffer_reg_session *registry;
94
95 /* Indexed by session id. */
d9bf3ca4 96 struct lttng_ht_node_u64 node;
d7ba1388 97
3d071855 98 char root_shm_path[PATH_MAX];
d7ba1388 99 char shm_path[PATH_MAX];
7972aab2
DG
100};
101
102/* Buffer registry per UID. */
103void buffer_reg_init_uid_registry(void);
d9bf3ca4 104int buffer_reg_uid_create(uint64_t session_id, uint32_t bits_per_long, uid_t uid,
d7ba1388 105 enum lttng_domain_type domain, struct buffer_reg_uid **regp,
3d071855 106 const char *root_shm_path, const char *shm_path);
7972aab2 107void buffer_reg_uid_add(struct buffer_reg_uid *reg);
d9bf3ca4 108struct buffer_reg_uid *buffer_reg_uid_find(uint64_t session_id,
7972aab2
DG
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);
d7ba1388 116int buffer_reg_pid_create(uint64_t session_id, struct buffer_reg_pid **regp,
3d071855 117 const char *root_shm_path, const char *shm_path);
7972aab2 118void buffer_reg_pid_add(struct buffer_reg_pid *reg);
d9bf3ca4 119struct buffer_reg_pid *buffer_reg_pid_find(uint64_t session_id);
7972aab2
DG
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
7972aab2
DG
141/* Global registry. */
142void buffer_reg_destroy_registries(void);
143
fb83fe64
JD
144int buffer_reg_uid_consumer_channel_key(
145 struct cds_list_head *buffer_reg_uid_list,
76604852 146 uint64_t chan_key, uint64_t *consumer_chan_key);
fb83fe64 147
7972aab2 148#endif /* LTTNG_BUFFER_REGISTRY_H */
This page took 0.07714 seconds and 4 git commands to generate.