Fix: clarify tracefile size/count in lttng.1 man
[lttng-tools.git] / src / bin / lttng-sessiond / trace-ust.c
CommitLineData
97ee3a89
DG
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
d14d33bf
AM
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2 only,
6 * as published by the Free Software Foundation.
97ee3a89 7 *
d14d33bf
AM
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
97ee3a89 12 *
d14d33bf
AM
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
97ee3a89
DG
16 */
17
18#define _GNU_SOURCE
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22#include <unistd.h>
23
990570ed
DG
24#include <common/common.h>
25#include <common/defaults.h>
97ee3a89 26
7972aab2 27#include "buffer-registry.h"
97ee3a89 28#include "trace-ust.h"
0b2dc8df 29#include "utils.h"
97ee3a89 30
025faf73
DG
31/*
32 * Match function for the events hash table lookup.
33 *
34 * Matches by name only. Used by the disable command.
35 */
18eace3b
DG
36int trace_ust_ht_match_event_by_name(struct cds_lfht_node *node,
37 const void *_key)
38{
39 struct ltt_ust_event *event;
40 const char *name;
41
42 assert(node);
43 assert(_key);
44
45 event = caa_container_of(node, struct ltt_ust_event, node.node);
46 name = _key;
47
48 /* Event name */
49 if (strncmp(event->attr.name, name, sizeof(event->attr.name)) != 0) {
50 goto no_match;
51 }
52
025faf73 53 /* Match */
18eace3b
DG
54 return 1;
55
56no_match:
57 return 0;
58}
59
025faf73
DG
60/*
61 * Match function for the hash table lookup.
62 *
63 * It matches an ust event based on three attributes which are the event name,
64 * the filter bytecode and the loglevel.
65 */
18eace3b
DG
66int trace_ust_ht_match_event(struct cds_lfht_node *node, const void *_key)
67{
68 struct ltt_ust_event *event;
69 const struct ltt_ust_ht_key *key;
70
71 assert(node);
72 assert(_key);
73
74 event = caa_container_of(node, struct ltt_ust_event, node.node);
75 key = _key;
76
77 /* Match the 3 elements of the key: name, filter and loglevel. */
78
79 /* Event name */
80 if (strncmp(event->attr.name, key->name, sizeof(event->attr.name)) != 0) {
18eace3b
DG
81 goto no_match;
82 }
83
84 /* Event loglevel. */
85 if (event->attr.loglevel != key->loglevel) {
025faf73
DG
86 if (event->attr.loglevel_type == LTTNG_UST_LOGLEVEL_ALL
87 && key->loglevel == 0 && event->attr.loglevel == -1) {
18eace3b 88 /*
025faf73
DG
89 * Match is accepted. This is because on event creation, the
90 * loglevel is set to -1 if the event loglevel type is ALL so 0 and
91 * -1 are accepted for this loglevel type since 0 is the one set by
92 * the API when receiving an enable event.
18eace3b
DG
93 */
94 } else {
18eace3b
DG
95 goto no_match;
96 }
97 }
98
99 /* Only one of the filters is NULL, fail. */
100 if ((key->filter && !event->filter) || (!key->filter && event->filter)) {
18eace3b
DG
101 goto no_match;
102 }
103
025faf73
DG
104 if (key->filter && event->filter) {
105 /* Both filters exists, check length followed by the bytecode. */
106 if (event->filter->len != key->filter->len ||
107 memcmp(event->filter->data, key->filter->data,
108 event->filter->len) != 0) {
109 goto no_match;
110 }
18eace3b
DG
111 }
112
025faf73
DG
113 /* Match. */
114 return 1;
18eace3b
DG
115
116no_match:
117 return 0;
18eace3b
DG
118}
119
0177d773 120/*
2223c96f
DG
121 * Find the channel in the hashtable and return channel pointer. RCU read side
122 * lock MUST be acquired before calling this.
0177d773 123 */
bec39940 124struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
f6a9efaa 125 char *name)
0177d773 126{
bec39940
DG
127 struct lttng_ht_node_str *node;
128 struct lttng_ht_iter iter;
0177d773 129
bec39940
DG
130 lttng_ht_lookup(ht, (void *)name, &iter);
131 node = lttng_ht_iter_get_node_str(&iter);
f6a9efaa 132 if (node == NULL) {
44d3bd01
DG
133 goto error;
134 }
135
f6a9efaa 136 DBG2("Trace UST channel %s found by name", name);
0177d773 137
f6a9efaa 138 return caa_container_of(node, struct ltt_ust_channel, node);
97ee3a89
DG
139
140error:
f6a9efaa 141 DBG2("Trace UST channel %s not found by name", name);
97ee3a89
DG
142 return NULL;
143}
144
145/*
2223c96f
DG
146 * Find the event in the hashtable and return event pointer. RCU read side lock
147 * MUST be acquired before calling this.
97ee3a89 148 */
18eace3b
DG
149struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht,
150 char *name, struct lttng_filter_bytecode *filter, int loglevel)
97ee3a89 151{
bec39940
DG
152 struct lttng_ht_node_str *node;
153 struct lttng_ht_iter iter;
18eace3b 154 struct ltt_ust_ht_key key;
97ee3a89 155
18eace3b
DG
156 assert(name);
157 assert(ht);
158
159 key.name = name;
160 key.filter = filter;
161 key.loglevel = loglevel;
162
18eace3b
DG
163 cds_lfht_lookup(ht->ht, ht->hash_fct((void *) name, lttng_ht_seed),
164 trace_ust_ht_match_event, &key, &iter.iter);
bec39940 165 node = lttng_ht_iter_get_node_str(&iter);
f6a9efaa 166 if (node == NULL) {
97ee3a89
DG
167 goto error;
168 }
169
18eace3b 170 DBG2("Trace UST event %s found", key.name);
f6a9efaa
DG
171
172 return caa_container_of(node, struct ltt_ust_event, node);
97ee3a89
DG
173
174error:
18eace3b 175 DBG2("Trace UST event %s NOT found", key.name);
97ee3a89
DG
176 return NULL;
177}
178
179/*
180 * Allocate and initialize a ust session data structure.
181 *
182 * Return pointer to structure or NULL.
183 */
dec56f6c 184struct ltt_ust_session *trace_ust_create_session(unsigned int session_id)
97ee3a89
DG
185{
186 struct ltt_ust_session *lus;
187
188 /* Allocate a new ltt ust session */
ba7f0ae5 189 lus = zmalloc(sizeof(struct ltt_ust_session));
97ee3a89 190 if (lus == NULL) {
ba7f0ae5 191 PERROR("create ust session zmalloc");
97ee3a89
DG
192 goto error;
193 }
194
195 /* Init data structure */
a991f516 196 lus->id = session_id;
36dc12cc 197 lus->start_trace = 0;
97ee3a89 198
7972aab2
DG
199 /*
200 * Default buffer type. This can be changed through an enable channel
201 * requesting a different type. Note that this can only be changed once
202 * during the session lifetime which is at the first enable channel and
203 * only before start. The flag buffer_type_changed indicates the status.
204 */
205 lus->buffer_type = LTTNG_BUFFER_PER_PID;
206 /* Once set to 1, the buffer_type is immutable for the session. */
207 lus->buffer_type_changed = 0;
208 /* Init it in case it get used after allocation. */
209 CDS_INIT_LIST_HEAD(&lus->buffer_reg_uid_list);
f6a9efaa
DG
210
211 /* Alloc UST global domain channels' HT */
bec39940 212 lus->domain_global.channels = lttng_ht_new(0, LTTNG_HT_TYPE_STRING);
44d3bd01 213
00e2e675
DG
214 lus->consumer = consumer_create_output(CONSUMER_DST_LOCAL);
215 if (lus->consumer == NULL) {
09a90bcd 216 goto error_consumer;
00e2e675
DG
217 }
218
219 /*
220 * The tmp_consumer stays NULL until a set_consumer_uri command is
221 * executed. At this point, the consumer should be nullify until an
222 * enable_consumer command. This assignment is symbolic since we've zmalloc
223 * the struct.
224 */
225 lus->tmp_consumer = NULL;
226
44d3bd01
DG
227 DBG2("UST trace session create successful");
228
97ee3a89
DG
229 return lus;
230
09a90bcd 231error_consumer:
0b2dc8df 232 ht_cleanup_push(lus->domain_global.channels);
44844c29 233 free(lus);
97ee3a89
DG
234error:
235 return NULL;
236}
237
238/*
239 * Allocate and initialize a ust channel data structure.
240 *
241 * Return pointer to structure or NULL.
242 */
dec56f6c 243struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan)
97ee3a89 244{
97ee3a89
DG
245 struct ltt_ust_channel *luc;
246
0525e9ae 247 assert(chan);
0525e9ae 248
37357452 249 luc = zmalloc(sizeof(struct ltt_ust_channel));
97ee3a89 250 if (luc == NULL) {
df0f840b 251 PERROR("ltt_ust_channel zmalloc");
97ee3a89
DG
252 goto error;
253 }
254
44d3bd01 255 /* Copy UST channel attributes */
48842b30
DG
256 luc->attr.overwrite = chan->attr.overwrite;
257 luc->attr.subbuf_size = chan->attr.subbuf_size;
258 luc->attr.num_subbuf = chan->attr.num_subbuf;
259 luc->attr.switch_timer_interval = chan->attr.switch_timer_interval;
260 luc->attr.read_timer_interval = chan->attr.read_timer_interval;
6775595e 261 luc->attr.output = (enum lttng_ust_output) chan->attr.output;
44d3bd01
DG
262
263 /* Translate to UST output enum */
264 switch (luc->attr.output) {
265 default:
266 luc->attr.output = LTTNG_UST_MMAP;
267 break;
97ee3a89 268 }
97ee3a89 269
97ee3a89 270 /* Copy channel name */
0a1459bb 271 strncpy(luc->name, chan->name, sizeof(luc->name));
97ee3a89
DG
272 luc->name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
273
f6a9efaa 274 /* Init node */
bec39940 275 lttng_ht_node_init_str(&luc->node, luc->name);
f6a9efaa 276 /* Alloc hash tables */
bec39940
DG
277 luc->events = lttng_ht_new(0, LTTNG_HT_TYPE_STRING);
278 luc->ctx = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG);
f6a9efaa 279
1624d5b7
JD
280 /* On-disk circular buffer parameters */
281 luc->tracefile_size = chan->attr.tracefile_size;
282 luc->tracefile_count = chan->attr.tracefile_count;
283
f6a9efaa
DG
284 DBG2("Trace UST channel %s created", luc->name);
285
97ee3a89 286error:
7972aab2 287 return luc;
97ee3a89
DG
288}
289
290/*
291 * Allocate and initialize a ust event. Set name and event type.
292 *
293 * Return pointer to structure or NULL.
294 */
025faf73
DG
295struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev,
296 struct lttng_filter_bytecode *filter)
97ee3a89
DG
297{
298 struct ltt_ust_event *lue;
97ee3a89 299
0525e9ae
DG
300 assert(ev);
301
37357452 302 lue = zmalloc(sizeof(struct ltt_ust_event));
44d3bd01 303 if (lue == NULL) {
ba7f0ae5 304 PERROR("ust event zmalloc");
97ee3a89
DG
305 goto error;
306 }
307
308 switch (ev->type) {
309 case LTTNG_EVENT_PROBE:
44d3bd01 310 lue->attr.instrumentation = LTTNG_UST_PROBE;
97ee3a89
DG
311 break;
312 case LTTNG_EVENT_FUNCTION:
44d3bd01 313 lue->attr.instrumentation = LTTNG_UST_FUNCTION;
97ee3a89
DG
314 break;
315 case LTTNG_EVENT_FUNCTION_ENTRY:
44d3bd01 316 lue->attr.instrumentation = LTTNG_UST_FUNCTION;
97ee3a89
DG
317 break;
318 case LTTNG_EVENT_TRACEPOINT:
44d3bd01 319 lue->attr.instrumentation = LTTNG_UST_TRACEPOINT;
97ee3a89
DG
320 break;
321 default:
322 ERR("Unknown ust instrumentation type (%d)", ev->type);
44844c29 323 goto error_free_event;
97ee3a89
DG
324 }
325
326 /* Copy event name */
44d3bd01
DG
327 strncpy(lue->attr.name, ev->name, LTTNG_UST_SYM_NAME_LEN);
328 lue->attr.name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
97ee3a89 329
0cda4f28 330 switch (ev->loglevel_type) {
8005f29a
MD
331 case LTTNG_EVENT_LOGLEVEL_ALL:
332 lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL_ALL;
22e25b71 333 lue->attr.loglevel = -1; /* Force to -1 */
0cda4f28 334 break;
8005f29a
MD
335 case LTTNG_EVENT_LOGLEVEL_RANGE:
336 lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL_RANGE;
22e25b71 337 lue->attr.loglevel = ev->loglevel;
8005f29a
MD
338 break;
339 case LTTNG_EVENT_LOGLEVEL_SINGLE:
340 lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL_SINGLE;
22e25b71 341 lue->attr.loglevel = ev->loglevel;
0cda4f28
MD
342 break;
343 default:
4431494b 344 ERR("Unknown ust loglevel type (%d)", ev->loglevel_type);
0cda4f28
MD
345 goto error_free_event;
346 }
347
025faf73
DG
348 /* Same layout. */
349 lue->filter = (struct lttng_ust_filter_bytecode *) filter;
0cda4f28 350
f6a9efaa 351 /* Init node */
bec39940 352 lttng_ht_node_init_str(&lue->node, lue->attr.name);
97ee3a89 353
300b8fd5
MD
354 DBG2("Trace UST event %s, loglevel (%d,%d) created",
355 lue->attr.name, lue->attr.loglevel_type,
356 lue->attr.loglevel);
284d8f55 357
97ee3a89
DG
358 return lue;
359
44844c29
MD
360error_free_event:
361 free(lue);
97ee3a89
DG
362error:
363 return NULL;
364}
365
366/*
367 * Allocate and initialize a ust metadata.
368 *
369 * Return pointer to structure or NULL.
370 */
371struct ltt_ust_metadata *trace_ust_create_metadata(char *path)
372{
373 int ret;
374 struct ltt_ust_metadata *lum;
97ee3a89 375
0525e9ae
DG
376 assert(path);
377
3a009adb 378 lum = zmalloc(sizeof(struct ltt_ust_metadata));
44d3bd01 379 if (lum == NULL) {
df0f840b 380 PERROR("ust metadata zmalloc");
97ee3a89
DG
381 goto error;
382 }
383
384 /* Set default attributes */
44d3bd01 385 lum->attr.overwrite = DEFAULT_CHANNEL_OVERWRITE;
3e230f92 386 lum->attr.subbuf_size = default_get_metadata_subbuf_size();
44d3bd01 387 lum->attr.num_subbuf = DEFAULT_METADATA_SUBBUF_NUM;
0a9c6494
DG
388 lum->attr.switch_timer_interval = DEFAULT_METADATA_SWITCH_TIMER;
389 lum->attr.read_timer_interval = DEFAULT_METADATA_READ_TIMER;
d41f73b7 390 lum->attr.output = LTTNG_UST_MMAP;
44d3bd01 391
97ee3a89
DG
392 lum->handle = -1;
393 /* Set metadata trace path */
30079b6b 394 ret = snprintf(lum->pathname, PATH_MAX, "%s/" DEFAULT_METADATA_NAME, path);
97ee3a89 395 if (ret < 0) {
df0f840b 396 PERROR("asprintf ust metadata");
44844c29 397 goto error_free_metadata;
97ee3a89
DG
398 }
399
400 return lum;
401
44844c29
MD
402error_free_metadata:
403 free(lum);
97ee3a89
DG
404error:
405 return NULL;
406}
407
55cc08a6
DG
408/*
409 * Allocate and initialize an UST context.
410 *
411 * Return pointer to structure or NULL.
412 */
413struct ltt_ust_context *trace_ust_create_context(
414 struct lttng_event_context *ctx)
415{
416 struct ltt_ust_context *uctx;
9197c5c4
MD
417 enum lttng_ust_context_type utype;
418
0525e9ae
DG
419 assert(ctx);
420
9197c5c4
MD
421 switch (ctx->ctx) {
422 case LTTNG_EVENT_CONTEXT_VTID:
423 utype = LTTNG_UST_CONTEXT_VTID;
424 break;
425 case LTTNG_EVENT_CONTEXT_VPID:
426 utype = LTTNG_UST_CONTEXT_VPID;
427 break;
428 case LTTNG_EVENT_CONTEXT_PTHREAD_ID:
429 utype = LTTNG_UST_CONTEXT_PTHREAD_ID;
430 break;
431 case LTTNG_EVENT_CONTEXT_PROCNAME:
432 utype = LTTNG_UST_CONTEXT_PROCNAME;
433 break;
434 default:
435 ERR("Invalid UST context");
436 return NULL;
437 }
55cc08a6
DG
438
439 uctx = zmalloc(sizeof(struct ltt_ust_context));
440 if (uctx == NULL) {
441 PERROR("zmalloc ltt_ust_context");
442 goto error;
443 }
444
9197c5c4 445 uctx->ctx.ctx = utype;
bec39940 446 lttng_ht_node_init_ulong(&uctx->node, (unsigned long) uctx->ctx.ctx);
55cc08a6
DG
447
448 return uctx;
449
450error:
451 return NULL;
452}
453
f6a9efaa
DG
454/*
455 * RCU safe free context structure.
456 */
457static void destroy_context_rcu(struct rcu_head *head)
458{
bec39940
DG
459 struct lttng_ht_node_ulong *node =
460 caa_container_of(head, struct lttng_ht_node_ulong, head);
f6a9efaa
DG
461 struct ltt_ust_context *ctx =
462 caa_container_of(node, struct ltt_ust_context, node);
463
464 free(ctx);
465}
466
467/*
468 * Cleanup UST context hash table.
469 */
7bd39047 470static void destroy_contexts(struct lttng_ht *ht)
f6a9efaa
DG
471{
472 int ret;
bec39940
DG
473 struct lttng_ht_node_ulong *node;
474 struct lttng_ht_iter iter;
f6a9efaa 475
0525e9ae
DG
476 assert(ht);
477
36b588ed 478 rcu_read_lock();
bec39940
DG
479 cds_lfht_for_each_entry(ht->ht, &iter.iter, node, node) {
480 ret = lttng_ht_del(ht, &iter);
f6a9efaa
DG
481 if (!ret) {
482 call_rcu(&node->head, destroy_context_rcu);
483 }
f6a9efaa 484 }
36b588ed 485 rcu_read_unlock();
ed52805d 486
0b2dc8df 487 ht_cleanup_push(ht);
f6a9efaa
DG
488}
489
97ee3a89
DG
490/*
491 * Cleanup ust event structure.
492 */
493void trace_ust_destroy_event(struct ltt_ust_event *event)
494{
0525e9ae
DG
495 assert(event);
496
f6a9efaa 497 DBG2("Trace destroy UST event %s", event->attr.name);
53a80697 498 free(event->filter);
97ee3a89
DG
499 free(event);
500}
501
f6a9efaa
DG
502/*
503 * URCU intermediate call to complete destroy event.
504 */
505static void destroy_event_rcu(struct rcu_head *head)
506{
bec39940
DG
507 struct lttng_ht_node_str *node =
508 caa_container_of(head, struct lttng_ht_node_str, head);
f6a9efaa
DG
509 struct ltt_ust_event *event =
510 caa_container_of(node, struct ltt_ust_event, node);
511
512 trace_ust_destroy_event(event);
513}
514
284d8f55
DG
515/*
516 * Cleanup UST events hashtable.
517 */
7bd39047 518static void destroy_events(struct lttng_ht *events)
ed52805d
DG
519{
520 int ret;
bec39940
DG
521 struct lttng_ht_node_str *node;
522 struct lttng_ht_iter iter;
ed52805d 523
0525e9ae
DG
524 assert(events);
525
36b588ed 526 rcu_read_lock();
bec39940
DG
527 cds_lfht_for_each_entry(events->ht, &iter.iter, node, node) {
528 ret = lttng_ht_del(events, &iter);
7bd39047
DG
529 assert(!ret);
530 call_rcu(&node->head, destroy_event_rcu);
ed52805d 531 }
36b588ed 532 rcu_read_unlock();
ed52805d 533
0b2dc8df 534 ht_cleanup_push(events);
ed52805d
DG
535}
536
97ee3a89
DG
537/*
538 * Cleanup ust channel structure.
36b588ed
MD
539 *
540 * Should _NOT_ be called with RCU read lock held.
97ee3a89 541 */
36b588ed 542static void _trace_ust_destroy_channel(struct ltt_ust_channel *channel)
97ee3a89 543{
0525e9ae
DG
544 assert(channel);
545
f6a9efaa 546 DBG2("Trace destroy UST channel %s", channel->name);
97ee3a89 547
7bd39047
DG
548 /* Destroying all events of the channel */
549 destroy_events(channel->events);
550 /* Destroying all context of the channel */
551 destroy_contexts(channel->ctx);
97ee3a89 552
97ee3a89 553 free(channel);
f6a9efaa
DG
554}
555
556/*
557 * URCU intermediate call to complete destroy channel.
558 */
559static void destroy_channel_rcu(struct rcu_head *head)
560{
bec39940
DG
561 struct lttng_ht_node_str *node =
562 caa_container_of(head, struct lttng_ht_node_str, head);
f6a9efaa
DG
563 struct ltt_ust_channel *channel =
564 caa_container_of(node, struct ltt_ust_channel, node);
565
36b588ed
MD
566 _trace_ust_destroy_channel(channel);
567}
568
569void trace_ust_destroy_channel(struct ltt_ust_channel *channel)
570{
571 call_rcu(&channel->node.head, destroy_channel_rcu);
97ee3a89
DG
572}
573
574/*
575 * Cleanup ust metadata structure.
576 */
577void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata)
578{
0525e9ae
DG
579 assert(metadata);
580
abc9138a
MD
581 if (!metadata->handle) {
582 return;
583 }
f6a9efaa 584 DBG2("Trace UST destroy metadata %d", metadata->handle);
97ee3a89
DG
585 free(metadata);
586}
587
588/*
f6a9efaa 589 * Iterate over a hash table containing channels and cleanup safely.
97ee3a89 590 */
bec39940 591static void destroy_channels(struct lttng_ht *channels)
f6a9efaa
DG
592{
593 int ret;
bec39940
DG
594 struct lttng_ht_node_str *node;
595 struct lttng_ht_iter iter;
f6a9efaa 596
0525e9ae
DG
597 assert(channels);
598
24d1723f
DG
599 rcu_read_lock();
600
bec39940
DG
601 cds_lfht_for_each_entry(channels->ht, &iter.iter, node, node) {
602 ret = lttng_ht_del(channels, &iter);
7bd39047
DG
603 assert(!ret);
604 call_rcu(&node->head, destroy_channel_rcu);
f6a9efaa 605 }
36b588ed 606 rcu_read_unlock();
ed52805d 607
0b2dc8df 608 ht_cleanup_push(channels);
f6a9efaa
DG
609}
610
f6a9efaa
DG
611/*
612 * Cleanup UST global domain.
613 */
614static void destroy_domain_global(struct ltt_ust_domain_global *dom)
615{
0525e9ae
DG
616 assert(dom);
617
f6a9efaa
DG
618 destroy_channels(dom->channels);
619}
97ee3a89 620
f6a9efaa
DG
621/*
622 * Cleanup ust session structure
36b588ed
MD
623 *
624 * Should *NOT* be called with RCU read-side lock held.
f6a9efaa
DG
625 */
626void trace_ust_destroy_session(struct ltt_ust_session *session)
627{
7972aab2
DG
628 struct buffer_reg_uid *reg, *sreg;
629
0525e9ae 630 assert(session);
97ee3a89 631
fc4705fe 632 DBG2("Trace UST destroy session %u", session->id);
f6a9efaa 633
f6a9efaa
DG
634 /* Cleaning up UST domain */
635 destroy_domain_global(&session->domain_global);
7972aab2
DG
636
637 /* Cleanup UID buffer registry object(s). */
638 cds_list_for_each_entry_safe(reg, sreg, &session->buffer_reg_uid_list,
639 lnode) {
640 cds_list_del(&reg->lnode);
641 buffer_reg_uid_remove(reg);
642 buffer_reg_uid_destroy(reg, session->consumer);
643 }
44d3bd01 644
3f8e211f
DG
645 consumer_destroy_output(session->consumer);
646 consumer_destroy_output(session->tmp_consumer);
647
97ee3a89
DG
648 free(session);
649}
This page took 0.10919 seconds and 4 git commands to generate.