6 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; only
11 * version 2.1 of the License.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * Mimic system calls for:
24 * - session creation, returns an object descriptor or failure.
25 * - channel creation, returns an object descriptor or failure.
26 * - Operates on a session object descriptor
27 * - Takes all channel options as parameters.
28 * - stream get, returns an object descriptor or failure.
29 * - Operates on a channel object descriptor.
30 * - stream notifier get, returns an object descriptor or failure.
31 * - Operates on a channel object descriptor.
32 * - event creation, returns an object descriptor or failure.
33 * - Operates on a channel object descriptor
34 * - Takes an event name as parameter
35 * - Takes an instrumentation source as parameter
36 * - e.g. tracepoints, dynamic_probes...
37 * - Takes instrumentation source specific arguments.
40 #include <lttng/ust-abi.h>
41 #include <lttng/ust-error.h>
42 #include <urcu/compiler.h>
43 #include <urcu/list.h>
44 #include <lttng/ust-events.h>
45 #include <lttng/ust-version.h>
46 #include <lttng/tracepoint.h>
47 #include "tracepoint-internal.h"
48 #include <usterr-signal-safe.h>
50 #include "lttng-tracer.h"
52 #define OBJ_NAME_LEN 16
54 static int lttng_ust_abi_close_in_progress
;
57 int lttng_abi_tracepoint_list(void *owner
);
59 int lttng_abi_tracepoint_field_list(void *owner
);
62 * Object descriptor table. Should be protected from concurrent access
66 struct lttng_ust_obj
{
70 const struct lttng_ust_objd_ops
*ops
;
72 int owner_ref
; /* has ref from owner */
74 char name
[OBJ_NAME_LEN
];
76 int freelist_next
; /* offset freelist. end is -1. */
80 struct lttng_ust_objd_table
{
81 struct lttng_ust_obj
*array
;
82 unsigned int len
, allocated_len
;
83 int freelist_head
; /* offset freelist head. end is -1 */
86 static struct lttng_ust_objd_table objd_table
= {
91 int objd_alloc(void *private_data
, const struct lttng_ust_objd_ops
*ops
,
92 void *owner
, const char *name
)
94 struct lttng_ust_obj
*obj
;
96 if (objd_table
.freelist_head
!= -1) {
97 obj
= &objd_table
.array
[objd_table
.freelist_head
];
98 objd_table
.freelist_head
= obj
->u
.freelist_next
;
102 if (objd_table
.len
>= objd_table
.allocated_len
) {
103 unsigned int new_allocated_len
, old_allocated_len
;
104 struct lttng_ust_obj
*new_table
, *old_table
;
106 old_allocated_len
= objd_table
.allocated_len
;
107 old_table
= objd_table
.array
;
108 if (!old_allocated_len
)
109 new_allocated_len
= 1;
111 new_allocated_len
= old_allocated_len
<< 1;
112 new_table
= zmalloc(sizeof(struct lttng_ust_obj
) * new_allocated_len
);
115 memcpy(new_table
, old_table
,
116 sizeof(struct lttng_ust_obj
) * old_allocated_len
);
118 objd_table
.array
= new_table
;
119 objd_table
.allocated_len
= new_allocated_len
;
121 obj
= &objd_table
.array
[objd_table
.len
];
124 obj
->u
.s
.private_data
= private_data
;
126 obj
->u
.s
.f_count
= 2; /* count == 1 : object is allocated */
127 /* count == 2 : allocated + hold ref */
128 obj
->u
.s
.owner_ref
= 1; /* One owner reference */
129 obj
->u
.s
.owner
= owner
;
130 strncpy(obj
->u
.s
.name
, name
, OBJ_NAME_LEN
);
131 obj
->u
.s
.name
[OBJ_NAME_LEN
- 1] = '\0';
132 return obj
- objd_table
.array
;
136 struct lttng_ust_obj
*_objd_get(int id
)
138 if (id
>= objd_table
.len
)
140 if (!objd_table
.array
[id
].u
.s
.f_count
)
142 return &objd_table
.array
[id
];
146 void *objd_private(int id
)
148 struct lttng_ust_obj
*obj
= _objd_get(id
);
150 return obj
->u
.s
.private_data
;
154 void objd_set_private(int id
, void *private_data
)
156 struct lttng_ust_obj
*obj
= _objd_get(id
);
158 obj
->u
.s
.private_data
= private_data
;
161 const struct lttng_ust_objd_ops
*objd_ops(int id
)
163 struct lttng_ust_obj
*obj
= _objd_get(id
);
171 void objd_free(int id
)
173 struct lttng_ust_obj
*obj
= _objd_get(id
);
176 obj
->u
.freelist_next
= objd_table
.freelist_head
;
177 objd_table
.freelist_head
= obj
- objd_table
.array
;
178 assert(obj
->u
.s
.f_count
== 1);
179 obj
->u
.s
.f_count
= 0; /* deallocated */
183 void objd_ref(int id
)
185 struct lttng_ust_obj
*obj
= _objd_get(id
);
189 int lttng_ust_objd_unref(int id
, int is_owner
)
191 struct lttng_ust_obj
*obj
= _objd_get(id
);
195 if (obj
->u
.s
.f_count
== 1) {
196 ERR("Reference counting error\n");
200 if (!obj
->u
.s
.owner_ref
) {
201 ERR("Error decrementing owner reference");
204 obj
->u
.s
.owner_ref
--;
206 if ((--obj
->u
.s
.f_count
) == 1) {
207 const struct lttng_ust_objd_ops
*ops
= objd_ops(id
);
217 void objd_table_destroy(void)
221 for (i
= 0; i
< objd_table
.allocated_len
; i
++) {
222 struct lttng_ust_obj
*obj
;
227 if (!obj
->u
.s
.owner_ref
)
228 continue; /* only unref owner ref. */
229 (void) lttng_ust_objd_unref(i
, 1);
231 free(objd_table
.array
);
232 objd_table
.array
= NULL
;
234 objd_table
.allocated_len
= 0;
235 objd_table
.freelist_head
= -1;
238 void lttng_ust_objd_table_owner_cleanup(void *owner
)
242 for (i
= 0; i
< objd_table
.allocated_len
; i
++) {
243 struct lttng_ust_obj
*obj
;
249 continue; /* skip root handles */
250 if (!obj
->u
.s
.owner_ref
)
251 continue; /* only unref owner ref. */
252 if (obj
->u
.s
.owner
== owner
)
253 (void) lttng_ust_objd_unref(i
, 1);
258 * This is LTTng's own personal way to create an ABI for sessiond.
259 * We send commands over a socket.
262 static const struct lttng_ust_objd_ops lttng_ops
;
263 static const struct lttng_ust_objd_ops lttng_session_ops
;
264 static const struct lttng_ust_objd_ops lttng_channel_ops
;
265 static const struct lttng_ust_objd_ops lttng_metadata_ops
;
266 static const struct lttng_ust_objd_ops lttng_enabler_ops
;
267 static const struct lttng_ust_objd_ops lib_ring_buffer_objd_ops
;
268 static const struct lttng_ust_objd_ops lttng_tracepoint_list_ops
;
269 static const struct lttng_ust_objd_ops lttng_tracepoint_field_list_ops
;
276 int lttng_abi_create_root_handle(void)
280 /* root handles have NULL owners */
281 root_handle
= objd_alloc(NULL
, <tng_ops
, NULL
, "root");
286 int lttng_abi_create_session(void *owner
)
288 struct lttng_session
*session
;
289 int session_objd
, ret
;
291 session
= lttng_session_create();
294 session_objd
= objd_alloc(session
, <tng_session_ops
, owner
, "session");
295 if (session_objd
< 0) {
299 session
->objd
= session_objd
;
303 lttng_session_destroy(session
);
308 long lttng_abi_tracer_version(int objd
,
309 struct lttng_ust_tracer_version
*v
)
311 v
->major
= LTTNG_UST_INTERNAL_MAJOR_VERSION
;
312 v
->minor
= LTTNG_UST_INTERNAL_MINOR_VERSION
;
313 v
->patchlevel
= LTTNG_UST_INTERNAL_PATCHLEVEL_VERSION
;
318 long lttng_abi_add_context(int objd
,
319 struct lttng_ust_context
*context_param
,
320 struct lttng_ctx
**ctx
, struct lttng_session
*session
)
322 return lttng_attach_context(context_param
, ctx
, session
);
326 * lttng_cmd - lttng control through socket commands
328 * @objd: the object descriptor
331 * @uargs: UST arguments (internal)
334 * This descriptor implements lttng commands:
336 * Returns a LTTng trace session object descriptor
337 * LTTNG_UST_TRACER_VERSION
338 * Returns the LTTng kernel tracer version
339 * LTTNG_UST_TRACEPOINT_LIST
340 * Returns a file descriptor listing available tracepoints
341 * LTTNG_UST_TRACEPOINT_FIELD_LIST
342 * Returns a file descriptor listing available tracepoint fields
343 * LTTNG_UST_WAIT_QUIESCENT
344 * Returns after all previously running probes have completed
346 * The returned session will be deleted when its file descriptor is closed.
349 long lttng_cmd(int objd
, unsigned int cmd
, unsigned long arg
,
350 union ust_args
*uargs
, void *owner
)
353 case LTTNG_UST_SESSION
:
354 return lttng_abi_create_session(owner
);
355 case LTTNG_UST_TRACER_VERSION
:
356 return lttng_abi_tracer_version(objd
,
357 (struct lttng_ust_tracer_version
*) arg
);
358 case LTTNG_UST_TRACEPOINT_LIST
:
359 return lttng_abi_tracepoint_list(owner
);
360 case LTTNG_UST_TRACEPOINT_FIELD_LIST
:
361 return lttng_abi_tracepoint_field_list(owner
);
362 case LTTNG_UST_WAIT_QUIESCENT
:
370 static const struct lttng_ust_objd_ops lttng_ops
= {
375 * We tolerate no failure in this function (if one happens, we print a dmesg
376 * error, but cannot return any error, because the channel information is
380 void lttng_metadata_create_events(int channel_objd
)
382 struct lttng_channel
*chan
= objd_private(channel_objd
);
383 struct lttng_enabler
*enabler
;
384 static struct lttng_ust_event metadata_params
= {
385 .instrumentation
= LTTNG_UST_TRACEPOINT
,
386 .name
= "lttng_ust:metadata",
387 .loglevel_type
= LTTNG_UST_LOGLEVEL_ALL
,
388 .loglevel
= TRACE_DEFAULT
,
392 * We tolerate no failure path after event creation. It will stay
393 * invariant for the rest of the session.
395 enabler
= lttng_enabler_create(LTTNG_ENABLER_EVENT
,
396 &metadata_params
, chan
);
404 return; /* not allowed to return error */
407 int lttng_abi_create_channel(int session_objd
,
408 struct lttng_ust_channel
*chan_param
,
409 enum channel_type channel_type
,
410 union ust_args
*uargs
,
413 struct lttng_session
*session
= objd_private(session_objd
);
414 const struct lttng_ust_objd_ops
*ops
;
415 const char *transport_name
;
416 struct lttng_channel
*chan
;
419 struct lttng_channel chan_priv_init
;
421 switch (channel_type
) {
422 case PER_CPU_CHANNEL
:
423 if (chan_param
->output
== LTTNG_UST_MMAP
) {
424 transport_name
= chan_param
->overwrite
?
425 "relay-overwrite-mmap" : "relay-discard-mmap";
429 ops
= <tng_channel_ops
;
431 case METADATA_CHANNEL
:
432 if (chan_param
->output
== LTTNG_UST_MMAP
)
433 transport_name
= "relay-metadata-mmap";
436 ops
= <tng_metadata_ops
;
439 transport_name
= "<unknown>";
442 chan_objd
= objd_alloc(NULL
, ops
, owner
, "channel");
447 memset(&chan_priv_init
, 0, sizeof(chan_priv_init
));
448 /* Copy of session UUID for consumer (availability through shm) */
449 memcpy(chan_priv_init
.uuid
, session
->uuid
, sizeof(session
->uuid
));
452 * We tolerate no failure path after channel creation. It will stay
453 * invariant for the rest of the session.
455 chan
= lttng_channel_create(session
, transport_name
, NULL
,
456 chan_param
->subbuf_size
,
457 chan_param
->num_subbuf
,
458 chan_param
->switch_timer_interval
,
459 chan_param
->read_timer_interval
,
460 &uargs
->channel
.shm_fd
,
461 &uargs
->channel
.wait_fd
,
462 &uargs
->channel
.memory_map_size
,
468 objd_set_private(chan_objd
, chan
);
469 chan
->objd
= chan_objd
;
470 if (channel_type
== METADATA_CHANNEL
) {
471 session
->metadata
= chan
;
472 lttng_metadata_create_events(chan_objd
);
474 /* The channel created holds a reference on the session */
475 objd_ref(session_objd
);
483 err
= lttng_ust_objd_unref(chan_objd
, 1);
491 * lttng_session_cmd - lttng session object command
496 * @uargs: UST arguments (internal)
499 * This descriptor implements lttng commands:
501 * Returns a LTTng channel object descriptor
503 * Enables tracing for a session (weak enable)
505 * Disables tracing for a session (strong disable)
507 * Returns a LTTng metadata object descriptor
509 * The returned channel will be deleted when its file descriptor is closed.
512 long lttng_session_cmd(int objd
, unsigned int cmd
, unsigned long arg
,
513 union ust_args
*uargs
, void *owner
)
515 struct lttng_session
*session
= objd_private(objd
);
518 case LTTNG_UST_CHANNEL
:
519 return lttng_abi_create_channel(objd
,
520 (struct lttng_ust_channel
*) arg
,
521 PER_CPU_CHANNEL
, uargs
, owner
);
522 case LTTNG_UST_SESSION_START
:
523 case LTTNG_UST_ENABLE
:
524 return lttng_session_enable(session
);
525 case LTTNG_UST_SESSION_STOP
:
526 case LTTNG_UST_DISABLE
:
527 return lttng_session_disable(session
);
528 case LTTNG_UST_METADATA
:
529 return lttng_abi_create_channel(objd
,
530 (struct lttng_ust_channel
*) arg
,
531 METADATA_CHANNEL
, uargs
, owner
);
538 * Called when the last file reference is dropped.
540 * Big fat note: channels and events are invariant for the whole session after
541 * their creation. So this session destruction also destroys all channel and
542 * event structures specific to this session (they are not destroyed when their
543 * individual file is released).
546 int lttng_release_session(int objd
)
548 struct lttng_session
*session
= objd_private(objd
);
551 lttng_session_destroy(session
);
558 static const struct lttng_ust_objd_ops lttng_session_ops
= {
559 .release
= lttng_release_session
,
560 .cmd
= lttng_session_cmd
,
564 long lttng_tracepoint_list_cmd(int objd
, unsigned int cmd
, unsigned long arg
,
565 union ust_args
*uargs
, void *owner
)
567 struct lttng_ust_tracepoint_list
*list
= objd_private(objd
);
568 struct lttng_ust_tracepoint_iter
*tp
=
569 (struct lttng_ust_tracepoint_iter
*) arg
;
570 struct lttng_ust_tracepoint_iter
*iter
;
573 case LTTNG_UST_TRACEPOINT_LIST_GET
:
576 iter
= lttng_ust_tracepoint_list_get_iter_next(list
);
578 return -LTTNG_UST_ERR_NOENT
;
579 if (!strcmp(iter
->name
, "lttng_ust:metadata"))
581 memcpy(tp
, iter
, sizeof(*tp
));
590 int lttng_abi_tracepoint_list(void *owner
)
593 struct lttng_ust_tracepoint_list
*list
;
595 list_objd
= objd_alloc(NULL
, <tng_tracepoint_list_ops
, owner
, "tp_list");
600 list
= zmalloc(sizeof(*list
));
605 objd_set_private(list_objd
, list
);
607 /* populate list by walking on all registered probes. */
608 ret
= lttng_probes_get_event_list(list
);
620 err
= lttng_ust_objd_unref(list_objd
, 1);
628 int lttng_release_tracepoint_list(int objd
)
630 struct lttng_ust_tracepoint_list
*list
= objd_private(objd
);
633 lttng_probes_prune_event_list(list
);
641 static const struct lttng_ust_objd_ops lttng_tracepoint_list_ops
= {
642 .release
= lttng_release_tracepoint_list
,
643 .cmd
= lttng_tracepoint_list_cmd
,
647 long lttng_tracepoint_field_list_cmd(int objd
, unsigned int cmd
,
648 unsigned long arg
, union ust_args
*uargs
, void *owner
)
650 struct lttng_ust_field_list
*list
= objd_private(objd
);
651 struct lttng_ust_field_iter
*tp
= &uargs
->field_list
.entry
;
652 struct lttng_ust_field_iter
*iter
;
655 case LTTNG_UST_TRACEPOINT_FIELD_LIST_GET
:
658 iter
= lttng_ust_field_list_get_iter_next(list
);
660 return -LTTNG_UST_ERR_NOENT
;
661 if (!strcmp(iter
->event_name
, "lttng_ust:metadata"))
663 memcpy(tp
, iter
, sizeof(*tp
));
672 int lttng_abi_tracepoint_field_list(void *owner
)
675 struct lttng_ust_field_list
*list
;
677 list_objd
= objd_alloc(NULL
, <tng_tracepoint_field_list_ops
, owner
,
683 list
= zmalloc(sizeof(*list
));
688 objd_set_private(list_objd
, list
);
690 /* populate list by walking on all registered probes. */
691 ret
= lttng_probes_get_field_list(list
);
703 err
= lttng_ust_objd_unref(list_objd
, 1);
711 int lttng_release_tracepoint_field_list(int objd
)
713 struct lttng_ust_field_list
*list
= objd_private(objd
);
716 lttng_probes_prune_field_list(list
);
724 static const struct lttng_ust_objd_ops lttng_tracepoint_field_list_ops
= {
725 .release
= lttng_release_tracepoint_field_list
,
726 .cmd
= lttng_tracepoint_field_list_cmd
,
729 struct stream_priv_data
{
730 struct lttng_ust_lib_ring_buffer
*buf
;
731 struct lttng_channel
*lttng_chan
;
735 int lttng_abi_open_stream(int channel_objd
, struct lttng_ust_stream
*info
,
736 union ust_args
*uargs
, void *owner
)
738 struct lttng_channel
*channel
= objd_private(channel_objd
);
739 struct lttng_ust_lib_ring_buffer
*buf
;
740 struct stream_priv_data
*priv
;
741 int stream_objd
, ret
;
743 buf
= channel
->ops
->buffer_read_open(channel
->chan
, channel
->handle
,
744 &uargs
->stream
.shm_fd
,
745 &uargs
->stream
.wait_fd
,
746 &uargs
->stream
.memory_map_size
);
750 priv
= zmalloc(sizeof(*priv
));
756 priv
->lttng_chan
= channel
;
757 stream_objd
= objd_alloc(priv
, &lib_ring_buffer_objd_ops
, owner
, "open_stream");
758 if (stream_objd
< 0) {
762 /* Hold a reference on the channel object descriptor */
763 objd_ref(channel_objd
);
769 channel
->ops
->buffer_read_close(buf
, channel
->handle
);
774 int lttng_abi_create_enabler(int channel_objd
,
775 struct lttng_ust_event
*event_param
,
777 enum lttng_enabler_type type
)
779 struct lttng_channel
*channel
= objd_private(channel_objd
);
780 struct lttng_enabler
*enabler
;
783 event_param
->name
[LTTNG_UST_SYM_NAME_LEN
- 1] = '\0';
784 event_objd
= objd_alloc(NULL
, <tng_enabler_ops
, owner
, "enabler");
785 if (event_objd
< 0) {
790 * We tolerate no failure path after event creation. It will stay
791 * invariant for the rest of the session.
793 enabler
= lttng_enabler_create(type
, event_param
, channel
);
798 objd_set_private(event_objd
, enabler
);
799 /* The event holds a reference on the channel */
800 objd_ref(channel_objd
);
807 err
= lttng_ust_objd_unref(event_objd
, 1);
815 * lttng_channel_cmd - lttng control through object descriptors
817 * @objd: the object descriptor
820 * @uargs: UST arguments (internal)
823 * This object descriptor implements lttng commands:
825 * Returns an event stream object descriptor or failure.
826 * (typically, one event stream records events from one CPU)
828 * Returns an event object descriptor or failure.
830 * Prepend a context field to each event in the channel
832 * Enable recording for events in this channel (weak enable)
834 * Disable recording for events in this channel (strong disable)
836 * Channel and event file descriptors also hold a reference on the session.
839 long lttng_channel_cmd(int objd
, unsigned int cmd
, unsigned long arg
,
840 union ust_args
*uargs
, void *owner
)
842 struct lttng_channel
*channel
= objd_private(objd
);
845 case LTTNG_UST_STREAM
:
847 struct lttng_ust_stream
*stream
;
849 stream
= (struct lttng_ust_stream
*) arg
;
850 /* stream used as output */
851 return lttng_abi_open_stream(objd
, stream
, uargs
, owner
);
853 case LTTNG_UST_EVENT
:
855 struct lttng_ust_event
*event_param
=
856 (struct lttng_ust_event
*) arg
;
857 if (event_param
->name
[strlen(event_param
->name
) - 1] == '*') {
858 /* If ends with wildcard, create wildcard. */
859 return lttng_abi_create_enabler(objd
, event_param
,
860 owner
, LTTNG_ENABLER_WILDCARD
);
862 return lttng_abi_create_enabler(objd
, event_param
,
863 owner
, LTTNG_ENABLER_EVENT
);
866 case LTTNG_UST_CONTEXT
:
867 return lttng_abi_add_context(objd
,
868 (struct lttng_ust_context
*) arg
,
869 &channel
->ctx
, channel
->session
);
870 case LTTNG_UST_ENABLE
:
871 return lttng_channel_enable(channel
);
872 case LTTNG_UST_DISABLE
:
873 return lttng_channel_disable(channel
);
874 case LTTNG_UST_FLUSH_BUFFER
:
875 return channel
->ops
->flush_buffer(channel
->chan
, channel
->handle
);
882 * lttng_metadata_cmd - lttng control through object descriptors
884 * @objd: the object descriptor
887 * @uargs: UST arguments (internal)
890 * This object descriptor implements lttng commands:
892 * Returns an event stream file descriptor or failure.
894 * Channel and event file descriptors also hold a reference on the session.
897 long lttng_metadata_cmd(int objd
, unsigned int cmd
, unsigned long arg
,
898 union ust_args
*uargs
, void *owner
)
900 struct lttng_channel
*channel
= objd_private(objd
);
903 case LTTNG_UST_STREAM
:
905 struct lttng_ust_stream
*stream
;
907 stream
= (struct lttng_ust_stream
*) arg
;
908 /* stream used as output */
909 return lttng_abi_open_stream(objd
, stream
, uargs
, owner
);
911 case LTTNG_UST_FLUSH_BUFFER
:
912 return channel
->ops
->flush_buffer(channel
->chan
, channel
->handle
);
919 int lttng_channel_release(int objd
)
921 struct lttng_channel
*channel
= objd_private(objd
);
924 return lttng_ust_objd_unref(channel
->session
->objd
, 0);
928 static const struct lttng_ust_objd_ops lttng_channel_ops
= {
929 .release
= lttng_channel_release
,
930 .cmd
= lttng_channel_cmd
,
933 static const struct lttng_ust_objd_ops lttng_metadata_ops
= {
934 .release
= lttng_channel_release
,
935 .cmd
= lttng_metadata_cmd
,
939 * lttng_rb_cmd - lttng ring buffer control through object descriptors
941 * @objd: the object descriptor
944 * @uargs: UST arguments (internal)
947 * This object descriptor implements lttng commands:
948 * (None for now. Access is done directly though shm.)
951 long lttng_rb_cmd(int objd
, unsigned int cmd
, unsigned long arg
,
952 union ust_args
*uargs
, void *owner
)
961 int lttng_rb_release(int objd
)
963 struct stream_priv_data
*priv
= objd_private(objd
);
964 struct lttng_ust_lib_ring_buffer
*buf
;
965 struct lttng_channel
*channel
;
969 channel
= priv
->lttng_chan
;
972 * If we are at ABI exit, we don't want to close the
973 * buffer opened for read: it is being shared between
974 * the parent and child (right after fork), and we don't
975 * want the child to close it for the parent. For a real
976 * exit, we don't care about marking it as closed, as
977 * the consumer daemon (if there is one) will do fine
978 * even if we don't mark it as "closed" for reading on
980 * We only mark it as closed if it is being explicitely
981 * released by the session daemon with an explicit
984 if (!lttng_ust_abi_close_in_progress
)
985 channel
->ops
->buffer_read_close(buf
, channel
->handle
);
987 return lttng_ust_objd_unref(channel
->objd
, 0);
992 static const struct lttng_ust_objd_ops lib_ring_buffer_objd_ops
= {
993 .release
= lttng_rb_release
,
998 * lttng_enabler_cmd - lttng control through object descriptors
1000 * @objd: the object descriptor
1003 * @uargs: UST arguments (internal)
1004 * @owner: objd owner
1006 * This object descriptor implements lttng commands:
1008 * Prepend a context field to each record of events of this
1011 * Enable recording for this enabler
1013 * Disable recording for this enabler
1015 * Attach a filter to an enabler.
1018 long lttng_enabler_cmd(int objd
, unsigned int cmd
, unsigned long arg
,
1019 union ust_args
*uargs
, void *owner
)
1021 struct lttng_enabler
*enabler
= objd_private(objd
);
1024 case LTTNG_UST_CONTEXT
:
1025 return lttng_enabler_attach_context(enabler
,
1026 (struct lttng_ust_context
*) arg
);
1027 case LTTNG_UST_ENABLE
:
1028 return lttng_enabler_enable(enabler
);
1029 case LTTNG_UST_DISABLE
:
1030 return lttng_enabler_disable(enabler
);
1031 case LTTNG_UST_FILTER
:
1035 ret
= lttng_enabler_attach_bytecode(enabler
,
1036 (struct lttng_ust_filter_bytecode_node
*) arg
);
1047 int lttng_enabler_release(int objd
)
1049 struct lttng_enabler
*enabler
= objd_private(objd
);
1052 return lttng_ust_objd_unref(enabler
->chan
->objd
, 0);
1056 static const struct lttng_ust_objd_ops lttng_enabler_ops
= {
1057 .release
= lttng_enabler_release
,
1058 .cmd
= lttng_enabler_cmd
,
1061 void lttng_ust_abi_exit(void)
1063 lttng_ust_abi_close_in_progress
= 1;
1064 objd_table_destroy();
1065 lttng_ust_abi_close_in_progress
= 0;