rculfhash: check for callers from RCU read-side C.S.
[lttng-tools.git] / src / bin / lttng-sessiond / buffer-registry.h
1 /*
2 * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18 #ifndef LTTNG_BUFFER_REGISTRY_H
19 #define LTTNG_BUFFER_REGISTRY_H
20
21 #include <stdint.h>
22 #include <urcu/list.h>
23
24 #include <lttng/lttng.h>
25 #include <common/hashtable/hashtable.h>
26
27 #include "consumer.h"
28 #include "ust-ctl.h"
29 #include "ust-registry.h"
30
31 struct buffer_reg_stream {
32 struct cds_list_head lnode;
33 union {
34 /* Original object data that MUST be copied over. */
35 struct lttng_ust_object_data *ust;
36 } obj;
37 };
38
39 struct buffer_reg_channel {
40 /* This key is the same as a tracing channel key. */
41 uint32_t key;
42 /* Key of the channel on the consumer side. */
43 uint64_t consumer_key;
44 /* Stream registry object of this channel registry. */
45 struct cds_list_head streams;
46 /* Used to ensure mutual exclusion to the stream's list. */
47 pthread_mutex_t stream_list_lock;
48 /* Node for hash table usage. */
49 struct lttng_ht_node_u64 node;
50 union {
51 /* Original object data that MUST be copied over. */
52 struct lttng_ust_object_data *ust;
53 } obj;
54 };
55
56 struct buffer_reg_session {
57 /* Registry per domain. */
58 union {
59 struct ust_registry_session *ust;
60 } reg;
61
62 /* Contains buffer registry channel indexed by tracing channel key. */
63 struct lttng_ht *channels;
64 };
65
66 /*
67 * Registry object for per UID buffers.
68 */
69 struct buffer_reg_uid {
70 /*
71 * Keys to match this object in a hash table. The following three variables
72 * identify a unique per UID buffer registry.
73 */
74 int session_id; /* Unique tracing session id. */
75 int bits_per_long; /* ABI */
76 uid_t uid; /* Owner. */
77
78 enum lttng_domain_type domain;
79 struct buffer_reg_session *registry;
80
81 /* Indexed by session id. */
82 struct lttng_ht_node_u64 node;
83 /* Node of a linked list used to teardown object at a destroy session. */
84 struct cds_list_head lnode;
85 };
86
87 /*
88 * Registry object for per PID buffers.
89 */
90 struct buffer_reg_pid {
91 int session_id;
92
93 struct buffer_reg_session *registry;
94
95 /* Indexed by session id. */
96 struct lttng_ht_node_ulong node;
97 };
98
99 /* Buffer registry per UID. */
100 void buffer_reg_init_uid_registry(void);
101 int buffer_reg_uid_create(int session_id, uint32_t bits_per_long, uid_t uid,
102 enum lttng_domain_type domain, struct buffer_reg_uid **regp);
103 void buffer_reg_uid_add(struct buffer_reg_uid *reg);
104 struct buffer_reg_uid *buffer_reg_uid_find(int session_id,
105 uint32_t bits_per_long, uid_t uid);
106 void buffer_reg_uid_remove(struct buffer_reg_uid *regp);
107 void buffer_reg_uid_destroy(struct buffer_reg_uid *regp,
108 struct consumer_output *consumer);
109
110 /* Buffer registry per PID. */
111 void buffer_reg_init_pid_registry(void);
112 int buffer_reg_pid_create(int session_id, struct buffer_reg_pid **regp);
113 void buffer_reg_pid_add(struct buffer_reg_pid *reg);
114 struct buffer_reg_pid *buffer_reg_pid_find(int session_id);
115 void buffer_reg_pid_remove(struct buffer_reg_pid *regp);
116 void buffer_reg_pid_destroy(struct buffer_reg_pid *regp);
117
118 /* Channel */
119 int buffer_reg_channel_create(uint64_t key, struct buffer_reg_channel **regp);
120 void buffer_reg_channel_add(struct buffer_reg_session *session,
121 struct buffer_reg_channel *channel);
122 struct buffer_reg_channel *buffer_reg_channel_find(uint64_t key,
123 struct buffer_reg_uid *reg);
124 void buffer_reg_channel_remove(struct buffer_reg_session *session,
125 struct buffer_reg_channel *regp);
126 void buffer_reg_channel_destroy(struct buffer_reg_channel *regp,
127 enum lttng_domain_type domain);
128
129 /* Stream */
130 int buffer_reg_stream_create(struct buffer_reg_stream **regp);
131 void buffer_reg_stream_add(struct buffer_reg_stream *stream,
132 struct buffer_reg_channel *channel);
133 void buffer_reg_stream_destroy(struct buffer_reg_stream *regp,
134 enum lttng_domain_type domain);
135
136 /* Session */
137 void buffer_reg_session_destroy(struct buffer_reg_session *regp,
138 enum lttng_domain_type domain);
139
140 /* Global registry. */
141 void buffer_reg_destroy_registries(void);
142
143 #endif /* LTTNG_BUFFER_REGISTRY_H */
This page took 0.031558 seconds and 4 git commands to generate.