2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
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.
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.
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.
26 #include <common/common.h>
27 #include <common/kernel-ctl/kernel-ctl.h>
28 #include <common/kernel-ctl/kernel-ioctl.h>
29 #include <common/sessiond-comm/sessiond-comm.h>
33 #include "kernel-consumer.h"
34 #include "kern-modules.h"
36 #include "rotation-thread.h"
39 * Add context on a kernel channel.
41 * Assumes the ownership of ctx.
43 int kernel_add_channel_context(struct ltt_kernel_channel
*chan
,
44 struct ltt_kernel_context
*ctx
)
51 DBG("Adding context to channel %s", chan
->channel
->name
);
52 ret
= kernctl_add_context(chan
->fd
, &ctx
->ctx
);
56 /* Exists but not available for this kernel */
57 ret
= LTTNG_ERR_KERN_CONTEXT_UNAVAILABLE
;
60 /* If EEXIST, we just ignore the error */
64 PERROR("add context ioctl");
65 ret
= LTTNG_ERR_KERN_CONTEXT_FAIL
;
72 cds_list_add_tail(&ctx
->list
, &chan
->ctx_list
);
77 trace_kernel_destroy_context(ctx
);
83 * Create a new kernel session, register it to the kernel tracer and add it to
84 * the session daemon session.
86 int kernel_create_session(struct ltt_session
*session
, int tracer_fd
)
89 struct ltt_kernel_session
*lks
;
93 /* Allocate data structure */
94 lks
= trace_kernel_create_session();
100 /* Kernel tracer session creation */
101 ret
= kernctl_create_session(tracer_fd
);
103 PERROR("ioctl kernel create session");
108 /* Prevent fd duplication after execlp() */
109 ret
= fcntl(lks
->fd
, F_SETFD
, FD_CLOEXEC
);
111 PERROR("fcntl session fd");
114 lks
->id
= session
->id
;
115 lks
->consumer_fds_sent
= 0;
116 session
->kernel_session
= lks
;
118 DBG("Kernel session created (fd: %d)", lks
->fd
);
124 trace_kernel_destroy_session(lks
);
130 * Create a kernel channel, register it to the kernel tracer and add it to the
133 int kernel_create_channel(struct ltt_kernel_session
*session
,
134 struct lttng_channel
*chan
)
137 struct ltt_kernel_channel
*lkc
;
142 /* Allocate kernel channel */
143 lkc
= trace_kernel_create_channel(chan
);
148 DBG3("Kernel create channel %s with attr: %d, %" PRIu64
", %" PRIu64
", %u, %u, %d, %d",
149 chan
->name
, lkc
->channel
->attr
.overwrite
,
150 lkc
->channel
->attr
.subbuf_size
, lkc
->channel
->attr
.num_subbuf
,
151 lkc
->channel
->attr
.switch_timer_interval
, lkc
->channel
->attr
.read_timer_interval
,
152 lkc
->channel
->attr
.live_timer_interval
, lkc
->channel
->attr
.output
);
154 /* Kernel tracer channel creation */
155 ret
= kernctl_create_channel(session
->fd
, &lkc
->channel
->attr
);
157 PERROR("ioctl kernel create channel");
161 /* Setup the channel fd */
163 /* Prevent fd duplication after execlp() */
164 ret
= fcntl(lkc
->fd
, F_SETFD
, FD_CLOEXEC
);
166 PERROR("fcntl session fd");
169 /* Add channel to session */
170 cds_list_add(&lkc
->list
, &session
->channel_list
.head
);
171 session
->channel_count
++;
172 lkc
->session
= session
;
174 DBG("Kernel channel %s created (fd: %d)", lkc
->channel
->name
, lkc
->fd
);
187 * Create a kernel event, enable it to the kernel tracer and add it to the
188 * channel event list of the kernel session.
189 * We own filter_expression and filter.
191 int kernel_create_event(struct lttng_event
*ev
,
192 struct ltt_kernel_channel
*channel
,
193 char *filter_expression
,
194 struct lttng_filter_bytecode
*filter
)
197 struct ltt_kernel_event
*event
;
202 /* We pass ownership of filter_expression and filter */
203 event
= trace_kernel_create_event(ev
, filter_expression
,
210 ret
= kernctl_create_event(channel
->fd
, event
->event
);
216 WARN("Event type not implemented");
219 WARN("Event %s not found!", ev
->name
);
222 PERROR("create event ioctl");
227 event
->type
= ev
->type
;
229 /* Prevent fd duplication after execlp() */
230 ret
= fcntl(event
->fd
, F_SETFD
, FD_CLOEXEC
);
232 PERROR("fcntl session fd");
236 ret
= kernctl_filter(event
->fd
, filter
);
242 ret
= kernctl_enable(event
->fd
);
246 ret
= LTTNG_ERR_KERN_EVENT_EXIST
;
249 PERROR("enable kernel event");
255 /* Add event to event list */
256 cds_list_add(&event
->list
, &channel
->events_list
.head
);
257 channel
->event_count
++;
259 DBG("Event %s created (fd: %d)", ev
->name
, event
->fd
);
268 closeret
= close(event
->fd
);
270 PERROR("close event fd");
280 * Disable a kernel channel.
282 int kernel_disable_channel(struct ltt_kernel_channel
*chan
)
288 ret
= kernctl_disable(chan
->fd
);
290 PERROR("disable chan ioctl");
295 DBG("Kernel channel %s disabled (fd: %d)", chan
->channel
->name
, chan
->fd
);
304 * Enable a kernel channel.
306 int kernel_enable_channel(struct ltt_kernel_channel
*chan
)
312 ret
= kernctl_enable(chan
->fd
);
313 if (ret
< 0 && ret
!= -EEXIST
) {
314 PERROR("Enable kernel chan");
319 DBG("Kernel channel %s enabled (fd: %d)", chan
->channel
->name
, chan
->fd
);
328 * Enable a kernel event.
330 int kernel_enable_event(struct ltt_kernel_event
*event
)
336 ret
= kernctl_enable(event
->fd
);
340 ret
= LTTNG_ERR_KERN_EVENT_EXIST
;
343 PERROR("enable kernel event");
350 DBG("Kernel event %s enabled (fd: %d)", event
->event
->name
, event
->fd
);
359 * Disable a kernel event.
361 int kernel_disable_event(struct ltt_kernel_event
*event
)
367 ret
= kernctl_disable(event
->fd
);
371 ret
= LTTNG_ERR_KERN_EVENT_EXIST
;
374 PERROR("disable kernel event");
381 DBG("Kernel event %s disabled (fd: %d)", event
->event
->name
, event
->fd
);
390 int kernel_track_pid(struct ltt_kernel_session
*session
, int pid
)
394 DBG("Kernel track PID %d for session id %" PRIu64
".",
396 ret
= kernctl_track_pid(session
->fd
, pid
);
402 return LTTNG_ERR_INVALID
;
404 return LTTNG_ERR_NOMEM
;
406 return LTTNG_ERR_PID_TRACKED
;
408 return LTTNG_ERR_UNK
;
412 int kernel_untrack_pid(struct ltt_kernel_session
*session
, int pid
)
416 DBG("Kernel untrack PID %d for session id %" PRIu64
".",
418 ret
= kernctl_untrack_pid(session
->fd
, pid
);
424 return LTTNG_ERR_INVALID
;
426 return LTTNG_ERR_NOMEM
;
428 return LTTNG_ERR_PID_NOT_TRACKED
;
430 return LTTNG_ERR_UNK
;
434 ssize_t
kernel_list_tracker_pids(struct ltt_kernel_session
*session
,
439 ssize_t nbmem
, count
= 0;
443 fd
= kernctl_list_tracker_pids(session
->fd
);
445 PERROR("kernel tracker pids list");
449 fp
= fdopen(fd
, "r");
451 PERROR("kernel tracker pids list fdopen");
455 nbmem
= KERNEL_TRACKER_PIDS_INIT_LIST_SIZE
;
456 pids
= zmalloc(sizeof(*pids
) * nbmem
);
458 PERROR("alloc list pids");
463 while (fscanf(fp
, "process { pid = %u; };\n", &pid
) == 1) {
464 if (count
>= nbmem
) {
468 new_nbmem
= nbmem
<< 1;
469 DBG("Reallocating pids list from %zu to %zu entries",
471 new_pids
= realloc(pids
, new_nbmem
* sizeof(*new_pids
));
472 if (new_pids
== NULL
) {
473 PERROR("realloc list events");
478 /* Zero the new memory */
479 memset(new_pids
+ nbmem
, 0,
480 (new_nbmem
- nbmem
) * sizeof(*new_pids
));
488 DBG("Kernel list tracker pids done (%zd pids)", count
);
490 ret
= fclose(fp
); /* closes both fp and fd */
506 * Create kernel metadata, open from the kernel tracer and add it to the
509 int kernel_open_metadata(struct ltt_kernel_session
*session
)
512 struct ltt_kernel_metadata
*lkm
= NULL
;
516 /* Allocate kernel metadata */
517 lkm
= trace_kernel_create_metadata();
522 /* Kernel tracer metadata creation */
523 ret
= kernctl_open_metadata(session
->fd
, &lkm
->conf
->attr
);
529 /* Prevent fd duplication after execlp() */
530 ret
= fcntl(lkm
->fd
, F_SETFD
, FD_CLOEXEC
);
532 PERROR("fcntl session fd");
535 session
->metadata
= lkm
;
537 DBG("Kernel metadata opened (fd: %d)", lkm
->fd
);
542 trace_kernel_destroy_metadata(lkm
);
548 * Start tracing session.
550 int kernel_start_session(struct ltt_kernel_session
*session
)
556 ret
= kernctl_start_session(session
->fd
);
558 PERROR("ioctl start session");
562 DBG("Kernel session started");
571 * Make a kernel wait to make sure in-flight probe have completed.
573 void kernel_wait_quiescent(int fd
)
577 DBG("Kernel quiescent wait on %d", fd
);
579 ret
= kernctl_wait_quiescent(fd
);
581 PERROR("wait quiescent ioctl");
582 ERR("Kernel quiescent wait failed");
587 * Force flush buffer of metadata.
589 int kernel_metadata_flush_buffer(int fd
)
593 DBG("Kernel flushing metadata buffer on fd %d", fd
);
595 ret
= kernctl_buffer_flush(fd
);
597 ERR("Fail to flush metadata buffers %d (ret: %d)", fd
, ret
);
604 * Force flush buffer for channel.
606 int kernel_flush_buffer(struct ltt_kernel_channel
*channel
)
609 struct ltt_kernel_stream
*stream
;
613 DBG("Flush buffer for channel %s", channel
->channel
->name
);
615 cds_list_for_each_entry(stream
, &channel
->stream_list
.head
, list
) {
616 DBG("Flushing channel stream %d", stream
->fd
);
617 ret
= kernctl_buffer_flush(stream
->fd
);
620 ERR("Fail to flush buffer for stream %d (ret: %d)",
629 * Stop tracing session.
631 int kernel_stop_session(struct ltt_kernel_session
*session
)
637 ret
= kernctl_stop_session(session
->fd
);
642 DBG("Kernel session stopped");
651 * Open stream of channel, register it to the kernel tracer and add it
652 * to the stream list of the channel.
654 * Note: given that the streams may appear in random order wrt CPU
655 * number (e.g. cpu hotplug), the index value of the stream number in
656 * the stream name is not necessarily linked to the CPU number.
658 * Return the number of created stream. Else, a negative value.
660 int kernel_open_channel_stream(struct ltt_kernel_channel
*channel
)
663 struct ltt_kernel_stream
*lks
;
667 while ((ret
= kernctl_create_stream(channel
->fd
)) >= 0) {
668 lks
= trace_kernel_create_stream(channel
->channel
->name
,
669 channel
->stream_count
);
679 /* Prevent fd duplication after execlp() */
680 ret
= fcntl(lks
->fd
, F_SETFD
, FD_CLOEXEC
);
682 PERROR("fcntl session fd");
685 lks
->tracefile_size
= channel
->channel
->attr
.tracefile_size
;
686 lks
->tracefile_count
= channel
->channel
->attr
.tracefile_count
;
688 /* Add stream to channel stream list */
689 cds_list_add(&lks
->list
, &channel
->stream_list
.head
);
690 channel
->stream_count
++;
692 DBG("Kernel stream %s created (fd: %d, state: %d)", lks
->name
, lks
->fd
,
696 return channel
->stream_count
;
703 * Open the metadata stream and set it to the kernel session.
705 int kernel_open_metadata_stream(struct ltt_kernel_session
*session
)
711 ret
= kernctl_create_stream(session
->metadata
->fd
);
713 PERROR("kernel create metadata stream");
717 DBG("Kernel metadata stream created (fd: %d)", ret
);
718 session
->metadata_stream_fd
= ret
;
719 /* Prevent fd duplication after execlp() */
720 ret
= fcntl(session
->metadata_stream_fd
, F_SETFD
, FD_CLOEXEC
);
722 PERROR("fcntl session fd");
732 * Get the event list from the kernel tracer and return the number of elements.
734 ssize_t
kernel_list_events(int tracer_fd
, struct lttng_event
**events
)
738 size_t nbmem
, count
= 0;
740 struct lttng_event
*elist
;
744 fd
= kernctl_tracepoint_list(tracer_fd
);
746 PERROR("kernel tracepoint list");
750 fp
= fdopen(fd
, "r");
752 PERROR("kernel tracepoint list fdopen");
757 * Init memory size counter
758 * See kernel-ctl.h for explanation of this value
760 nbmem
= KERNEL_EVENT_INIT_LIST_SIZE
;
761 elist
= zmalloc(sizeof(struct lttng_event
) * nbmem
);
763 PERROR("alloc list events");
768 while (fscanf(fp
, "event { name = %m[^;]; };\n", &event
) == 1) {
769 if (count
>= nbmem
) {
770 struct lttng_event
*new_elist
;
773 new_nbmem
= nbmem
<< 1;
774 DBG("Reallocating event list from %zu to %zu bytes",
776 new_elist
= realloc(elist
, new_nbmem
* sizeof(struct lttng_event
));
777 if (new_elist
== NULL
) {
778 PERROR("realloc list events");
784 /* Zero the new memory */
785 memset(new_elist
+ nbmem
, 0,
786 (new_nbmem
- nbmem
) * sizeof(struct lttng_event
));
790 strncpy(elist
[count
].name
, event
, LTTNG_SYMBOL_NAME_LEN
);
791 elist
[count
].name
[LTTNG_SYMBOL_NAME_LEN
- 1] = '\0';
792 elist
[count
].enabled
= -1;
798 DBG("Kernel list events done (%zu events)", count
);
800 ret
= fclose(fp
); /* closes both fp and fd */
816 * Get kernel version and validate it.
818 int kernel_validate_version(int tracer_fd
)
821 struct lttng_kernel_tracer_version version
;
822 struct lttng_kernel_tracer_abi_version abi_version
;
824 ret
= kernctl_tracer_version(tracer_fd
, &version
);
826 ERR("Failed to retrieve the lttng-modules version");
830 /* Validate version */
831 if (version
.major
!= VERSION_MAJOR
) {
832 ERR("Kernel tracer major version (%d) is not compatible with lttng-tools major version (%d)",
833 version
.major
, VERSION_MAJOR
);
836 ret
= kernctl_tracer_abi_version(tracer_fd
, &abi_version
);
838 ERR("Failed to retrieve lttng-modules ABI version");
841 if (abi_version
.major
!= LTTNG_MODULES_ABI_MAJOR_VERSION
) {
842 ERR("Kernel tracer ABI version (%d.%d) does not match the expected ABI major version (%d.*)",
843 abi_version
.major
, abi_version
.minor
,
844 LTTNG_MODULES_ABI_MAJOR_VERSION
);
847 DBG2("Kernel tracer version validated (%d.%d, ABI %d.%d)",
848 version
.major
, version
.minor
,
849 abi_version
.major
, abi_version
.minor
);
856 ERR("Kernel tracer version check failed; kernel tracing will not be available");
861 * Kernel work-arounds called at the start of sessiond main().
863 int init_kernel_workarounds(void)
869 * boot_id needs to be read once before being used concurrently
870 * to deal with a Linux kernel race. A fix is proposed for
871 * upstream, but the work-around is needed for older kernels.
873 fp
= fopen("/proc/sys/kernel/random/boot_id", "r");
880 ret
= fread(buf
, 1, sizeof(buf
), fp
);
882 /* Ignore error, we don't really care */
894 * Complete teardown of a kernel session.
896 void kernel_destroy_session(struct ltt_kernel_session
*ksess
)
899 DBG3("No kernel session when tearing down session");
903 DBG("Tearing down kernel session");
906 * Destroy channels on the consumer if at least one FD has been sent and we
907 * are in no output mode because the streams are in *no* monitor mode so we
908 * have to send a command to clean them up or else they leaked.
910 if (!ksess
->output_traces
&& ksess
->consumer_fds_sent
) {
912 struct consumer_socket
*socket
;
913 struct lttng_ht_iter iter
;
915 /* For each consumer socket. */
917 cds_lfht_for_each_entry(ksess
->consumer
->socks
->ht
, &iter
.iter
,
919 struct ltt_kernel_channel
*chan
;
921 /* For each channel, ask the consumer to destroy it. */
922 cds_list_for_each_entry(chan
, &ksess
->channel_list
.head
, list
) {
923 ret
= kernel_consumer_destroy_channel(socket
, chan
);
925 /* Consumer is probably dead. Use next socket. */
933 /* Close any relayd session */
934 consumer_output_send_destroy_relayd(ksess
->consumer
);
936 trace_kernel_destroy_session(ksess
);
940 * Destroy a kernel channel object. It does not do anything on the tracer side.
942 void kernel_destroy_channel(struct ltt_kernel_channel
*kchan
)
944 struct ltt_kernel_session
*ksess
= NULL
;
947 assert(kchan
->channel
);
949 DBG3("Kernel destroy channel %s", kchan
->channel
->name
);
951 /* Update channel count of associated session. */
952 if (kchan
->session
) {
953 /* Keep pointer reference so we can update it after the destroy. */
954 ksess
= kchan
->session
;
957 trace_kernel_destroy_channel(kchan
);
960 * At this point the kernel channel is not visible anymore. This is safe
961 * since in order to work on a visible kernel session, the tracing session
962 * lock (ltt_session.lock) MUST be acquired.
965 ksess
->channel_count
--;
970 * Take a snapshot for a given kernel session.
972 * Return 0 on success or else return a LTTNG_ERR code.
974 int kernel_snapshot_record(struct ltt_kernel_session
*ksess
,
975 struct snapshot_output
*output
, int wait
,
976 uint64_t nb_packets_per_stream
)
978 int err
, ret
, saved_metadata_fd
;
979 struct consumer_socket
*socket
;
980 struct lttng_ht_iter iter
;
981 struct ltt_kernel_metadata
*saved_metadata
;
984 assert(ksess
->consumer
);
987 DBG("Kernel snapshot record started");
989 /* Save current metadata since the following calls will change it. */
990 saved_metadata
= ksess
->metadata
;
991 saved_metadata_fd
= ksess
->metadata_stream_fd
;
995 ret
= kernel_open_metadata(ksess
);
997 ret
= LTTNG_ERR_KERN_META_FAIL
;
1001 ret
= kernel_open_metadata_stream(ksess
);
1003 ret
= LTTNG_ERR_KERN_META_FAIL
;
1004 goto error_open_stream
;
1007 /* Send metadata to consumer and snapshot everything. */
1008 cds_lfht_for_each_entry(ksess
->consumer
->socks
->ht
, &iter
.iter
,
1009 socket
, node
.node
) {
1010 struct consumer_output
*saved_output
;
1011 struct ltt_kernel_channel
*chan
;
1014 * Temporarly switch consumer output for our snapshot output. As long
1015 * as the session lock is taken, this is safe.
1017 saved_output
= ksess
->consumer
;
1018 ksess
->consumer
= output
->consumer
;
1020 pthread_mutex_lock(socket
->lock
);
1021 /* This stream must not be monitored by the consumer. */
1022 ret
= kernel_consumer_add_metadata(socket
, ksess
, 0);
1023 pthread_mutex_unlock(socket
->lock
);
1024 /* Put back the saved consumer output into the session. */
1025 ksess
->consumer
= saved_output
;
1027 ret
= LTTNG_ERR_KERN_CONSUMER_FAIL
;
1028 goto error_consumer
;
1031 /* For each channel, ask the consumer to snapshot it. */
1032 cds_list_for_each_entry(chan
, &ksess
->channel_list
.head
, list
) {
1033 pthread_mutex_lock(socket
->lock
);
1034 ret
= consumer_snapshot_channel(socket
, chan
->fd
, output
, 0,
1035 ksess
->uid
, ksess
->gid
,
1036 DEFAULT_KERNEL_TRACE_DIR
, wait
,
1037 nb_packets_per_stream
);
1038 pthread_mutex_unlock(socket
->lock
);
1040 ret
= LTTNG_ERR_KERN_CONSUMER_FAIL
;
1041 (void) kernel_consumer_destroy_metadata(socket
,
1043 goto error_consumer
;
1047 /* Snapshot metadata, */
1048 pthread_mutex_lock(socket
->lock
);
1049 ret
= consumer_snapshot_channel(socket
, ksess
->metadata
->fd
, output
,
1050 1, ksess
->uid
, ksess
->gid
,
1051 DEFAULT_KERNEL_TRACE_DIR
, wait
, 0);
1052 pthread_mutex_unlock(socket
->lock
);
1054 ret
= LTTNG_ERR_KERN_CONSUMER_FAIL
;
1055 goto error_consumer
;
1059 * The metadata snapshot is done, ask the consumer to destroy it since
1060 * it's not monitored on the consumer side.
1062 (void) kernel_consumer_destroy_metadata(socket
, ksess
->metadata
);
1068 /* Close newly opened metadata stream. It's now on the consumer side. */
1069 err
= close(ksess
->metadata_stream_fd
);
1071 PERROR("close snapshot kernel");
1075 trace_kernel_destroy_metadata(ksess
->metadata
);
1077 /* Restore metadata state.*/
1078 ksess
->metadata
= saved_metadata
;
1079 ksess
->metadata_stream_fd
= saved_metadata_fd
;
1086 * Get the syscall mask array from the kernel tracer.
1088 * Return 0 on success else a negative value. In both case, syscall_mask should
1091 int kernel_syscall_mask(int chan_fd
, char **syscall_mask
, uint32_t *nr_bits
)
1093 assert(syscall_mask
);
1096 return kernctl_syscall_mask(chan_fd
, syscall_mask
, nr_bits
);
1100 * Check for the support of the RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS via abi
1103 * Return 1 on success, 0 when feature is not supported, negative value in case
1106 int kernel_supports_ring_buffer_snapshot_sample_positions(int tracer_fd
)
1108 int ret
= 0; // Not supported by default
1109 struct lttng_kernel_tracer_abi_version abi
;
1111 ret
= kernctl_tracer_abi_version(tracer_fd
, &abi
);
1113 ERR("Failed to retrieve lttng-modules ABI version");
1118 * RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS was introduced in 2.3
1120 if (abi
.major
>= 2 && abi
.minor
>= 3) {
1132 * Rotate a kernel session.
1134 * Return 0 on success or else return a LTTNG_ERR code.
1136 int kernel_rotate_session(struct ltt_session
*session
)
1139 struct consumer_socket
*socket
;
1140 struct lttng_ht_iter iter
;
1141 struct ltt_kernel_session
*ksess
= session
->kernel_session
;
1144 assert(ksess
->consumer
);
1146 DBG("Rotate kernel session started");
1150 cds_lfht_for_each_entry(ksess
->consumer
->socks
->ht
, &iter
.iter
,
1151 socket
, node
.node
) {
1152 struct ltt_kernel_channel
*chan
;
1155 * Account the metadata channel first to make sure the
1156 * number of channels waiting for a rotation cannot
1157 * reach 0 before we complete the iteration over all
1160 ret
= rotate_add_channel_pending(ksess
->metadata
->fd
,
1161 LTTNG_DOMAIN_KERNEL
, session
);
1163 ret
= LTTNG_ERR_KERN_CONSUMER_FAIL
;
1164 pthread_mutex_unlock(socket
->lock
);
1168 /* For each channel, ask the consumer to rotate it. */
1169 cds_list_for_each_entry(chan
, &ksess
->channel_list
.head
, list
) {
1170 /* FIXME: is that lock necessary, we don't do it in UST ? */
1171 pthread_mutex_lock(socket
->lock
);
1172 ret
= rotate_add_channel_pending(chan
->fd
,
1173 LTTNG_DOMAIN_KERNEL
, session
);
1175 ret
= LTTNG_ERR_KERN_CONSUMER_FAIL
;
1176 pthread_mutex_unlock(socket
->lock
);
1180 ret
= consumer_rotate_channel(socket
, chan
->fd
,
1181 ksess
->uid
, ksess
->gid
, ksess
->consumer
,
1184 ret
= LTTNG_ERR_KERN_CONSUMER_FAIL
;
1185 pthread_mutex_unlock(socket
->lock
);
1189 pthread_mutex_unlock(socket
->lock
);
1193 * Rotate the metadata channel.
1195 pthread_mutex_lock(socket
->lock
);
1196 ret
= consumer_rotate_channel(socket
, ksess
->metadata
->fd
,
1197 ksess
->uid
, ksess
->gid
, ksess
->consumer
, "", 1);
1199 ret
= LTTNG_ERR_KERN_CONSUMER_FAIL
;
1200 pthread_mutex_unlock(socket
->lock
);
1203 pthread_mutex_unlock(socket
->lock
);
1205 ret
= kernctl_session_metadata_cache_dump(ksess
->fd
);
1207 ERR("Dump the kernel metadata cache");