X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ftrace-kernel.c;h=a8154a3cc32c98d3286394c9238f48a54d7ed546;hp=22c602ceec7f714ef83666c45b82169b927e7698;hb=c863e5a69d06f11312e8e5a7d9c1b20d56f2cb6e;hpb=55c9e7cac24318259d4f2549c97f7577b7b52db4 diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index 22c602cee..a8154a3cc 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -1,18 +1,8 @@ /* - * Copyright (C) 2011 - David Goulet + * Copyright (C) 2011 David Goulet * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #define _LGPL_SOURCE @@ -29,6 +19,7 @@ #include #include #include +#include #include "consumer.h" #include "trace-kernel.h" @@ -164,28 +155,28 @@ struct ltt_kernel_session *trace_kernel_create_session(void) lks->metadata = NULL; CDS_INIT_LIST_HEAD(&lks->channel_list.head); - lks->tracker_list_pid = lttng_tracker_list_create(); - if (!lks->tracker_list_pid) { + lks->tracker_pid = process_attr_tracker_create(); + if (!lks->tracker_pid) { goto error; } - lks->tracker_list_vpid = lttng_tracker_list_create(); - if (!lks->tracker_list_vpid) { + lks->tracker_vpid = process_attr_tracker_create(); + if (!lks->tracker_vpid) { goto error; } - lks->tracker_list_uid = lttng_tracker_list_create(); - if (!lks->tracker_list_uid) { + lks->tracker_uid = process_attr_tracker_create(); + if (!lks->tracker_uid) { goto error; } - lks->tracker_list_vuid = lttng_tracker_list_create(); - if (!lks->tracker_list_vuid) { + lks->tracker_vuid = process_attr_tracker_create(); + if (!lks->tracker_vuid) { goto error; } - lks->tracker_list_gid = lttng_tracker_list_create(); - if (!lks->tracker_list_gid) { + lks->tracker_gid = process_attr_tracker_create(); + if (!lks->tracker_gid) { goto error; } - lks->tracker_list_vgid = lttng_tracker_list_create(); - if (!lks->tracker_list_vgid) { + lks->tracker_vgid = process_attr_tracker_create(); + if (!lks->tracker_vgid) { goto error; } lks->consumer = consumer_create_output(CONSUMER_DST_LOCAL); @@ -196,12 +187,12 @@ struct ltt_kernel_session *trace_kernel_create_session(void) return lks; error: - lttng_tracker_list_destroy(lks->tracker_list_pid); - lttng_tracker_list_destroy(lks->tracker_list_vpid); - lttng_tracker_list_destroy(lks->tracker_list_uid); - lttng_tracker_list_destroy(lks->tracker_list_vuid); - lttng_tracker_list_destroy(lks->tracker_list_gid); - lttng_tracker_list_destroy(lks->tracker_list_vgid); + process_attr_tracker_destroy(lks->tracker_pid); + process_attr_tracker_destroy(lks->tracker_vpid); + process_attr_tracker_destroy(lks->tracker_uid); + process_attr_tracker_destroy(lks->tracker_vuid); + process_attr_tracker_destroy(lks->tracker_gid); + process_attr_tracker_destroy(lks->tracker_vgid); free(lks); alloc_error: @@ -400,16 +391,10 @@ enum lttng_error_code trace_kernel_create_event( /* * Save a reference to the probe location used during - * the listing of events. Close its FD since it won't - * be needed for listing. + * the listing of events. */ userspace_probe_location = lttng_userspace_probe_location_copy(location); - ret = lttng_userspace_probe_location_function_set_binary_fd( - userspace_probe_location, -1); - if (ret) { - goto error; - } break; case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT: /* Get the file descriptor on the target binary. */ @@ -418,15 +403,10 @@ enum lttng_error_code trace_kernel_create_event( /* * Save a reference to the probe location used during the listing of - * events. Close its FD since it won't be needed for listing. + * events. */ userspace_probe_location = lttng_userspace_probe_location_copy(location); - ret = lttng_userspace_probe_location_tracepoint_set_binary_fd( - userspace_probe_location, -1); - if (ret) { - goto error; - } break; default: DBG("Unsupported lookup method type"); @@ -454,6 +434,9 @@ enum lttng_error_code trace_kernel_create_event( break; case LTTNG_EVENT_SYSCALL: attr->instrumentation = LTTNG_KERNEL_SYSCALL; + attr->u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_ALL; + attr->u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_ENTRYEXIT; + attr->u.syscall.match = LTTNG_KERNEL_SYSCALL_MATCH_NAME; break; case LTTNG_EVENT_ALL: attr->instrumentation = LTTNG_KERNEL_ALL; @@ -495,6 +478,7 @@ error: */ struct ltt_kernel_metadata *trace_kernel_create_metadata(void) { + int ret; struct ltt_kernel_metadata *lkm; struct lttng_channel *chan; @@ -505,13 +489,38 @@ struct ltt_kernel_metadata *trace_kernel_create_metadata(void) goto error; } + ret = lttng_strncpy( + chan->name, DEFAULT_METADATA_NAME, sizeof(chan->name)); + if (ret) { + ERR("Failed to initialize metadata channel name to `%s`", + DEFAULT_METADATA_NAME); + goto error; + } + /* Set default attributes */ - chan->attr.overwrite = DEFAULT_CHANNEL_OVERWRITE; + chan->attr.overwrite = DEFAULT_METADATA_OVERWRITE; chan->attr.subbuf_size = default_get_metadata_subbuf_size(); chan->attr.num_subbuf = DEFAULT_METADATA_SUBBUF_NUM; - chan->attr.switch_timer_interval = DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER; - chan->attr.read_timer_interval = DEFAULT_KERNEL_CHANNEL_READ_TIMER; - chan->attr.output = DEFAULT_KERNEL_CHANNEL_OUTPUT; + chan->attr.switch_timer_interval = DEFAULT_METADATA_SWITCH_TIMER; + chan->attr.read_timer_interval = DEFAULT_METADATA_READ_TIMER;; + + + /* + * The metadata channel of kernel sessions must use the "mmap" + * back-end since the consumer daemon accumulates complete + * metadata units before sending them to the relay daemon in + * live mode. The consumer daemon also needs to extract the contents + * of the metadata cache when computing a rotation position. + * + * In both cases, it is not possible to rely on the splice + * back-end as the consumer daemon may need to accumulate more + * content than can be backed by the ring buffer's underlying + * pages. + */ + chan->attr.output = LTTNG_EVENT_MMAP; + chan->attr.tracefile_size = 0; + chan->attr.tracefile_count = 0; + chan->attr.live_timer_interval = 0; /* Init metadata */ lkm->fd = -1; @@ -748,12 +757,12 @@ void trace_kernel_free_session(struct ltt_kernel_session *session) /* Wipe consumer output object */ consumer_output_put(session->consumer); - lttng_tracker_list_destroy(session->tracker_list_pid); - lttng_tracker_list_destroy(session->tracker_list_vpid); - lttng_tracker_list_destroy(session->tracker_list_uid); - lttng_tracker_list_destroy(session->tracker_list_vuid); - lttng_tracker_list_destroy(session->tracker_list_gid); - lttng_tracker_list_destroy(session->tracker_list_vgid); + process_attr_tracker_destroy(session->tracker_pid); + process_attr_tracker_destroy(session->tracker_vpid); + process_attr_tracker_destroy(session->tracker_uid); + process_attr_tracker_destroy(session->tracker_vuid); + process_attr_tracker_destroy(session->tracker_gid); + process_attr_tracker_destroy(session->tracker_vgid); free(session); }