From 1950109e7a08d8064ef5b1f446524274b4fa72d5 Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Thu, 27 Jun 2013 17:57:06 -0400 Subject: [PATCH] Fix: send per-pid session id in channel creation The registry indexing for per-pid sessions is done with a per-pid session id. So for per-pid buffers, we need to send the per-pid session id as well as the global session id to the consumer in order to give it enough information if it needs to request metadata later. This patch adds the session_id_per_pid to the channel creation message and to the consumer. When the sessiond receives a metadata_request, depending on the buffer type (per-pid or per-uid), it selects the right id to do the registry lookup. Signed-off-by: Julien Desfossez Signed-off-by: David Goulet Conflicts: src/bin/lttng-sessiond/consumer.c src/bin/lttng-sessiond/consumer.h src/bin/lttng-sessiond/ust-consumer.c src/common/consumer.c src/common/consumer.h src/common/kernel-consumer/kernel-consumer.c src/common/sessiond-comm/sessiond-comm.h src/common/ust-consumer/ust-consumer.c --- src/bin/lttng-sessiond/consumer.c | 2 ++ src/bin/lttng-sessiond/consumer.h | 1 + src/bin/lttng-sessiond/ust-consumer.c | 9 +++++---- src/common/consumer.c | 2 ++ src/common/consumer.h | 6 ++++++ src/common/kernel-consumer/kernel-consumer.c | 2 +- src/common/sessiond-comm/sessiond-comm.h | 4 +++- src/common/ust-consumer/ust-consumer.c | 15 ++++++++++----- 8 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index 8198629f3..368837669 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -723,6 +723,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, uint32_t chan_id, uint64_t tracefile_size, uint64_t tracefile_count, + uint64_t session_id_per_pid, unsigned int monitor) { assert(msg); @@ -739,6 +740,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, msg->u.ask_channel.output = output; msg->u.ask_channel.type = type; msg->u.ask_channel.session_id = session_id; + msg->u.ask_channel.session_id_per_pid = session_id_per_pid; msg->u.ask_channel.uid = uid; msg->u.ask_channel.gid = gid; msg->u.ask_channel.relayd_id = relayd_id; diff --git a/src/bin/lttng-sessiond/consumer.h b/src/bin/lttng-sessiond/consumer.h index 4d8f66a72..c3c8dfb7f 100644 --- a/src/bin/lttng-sessiond/consumer.h +++ b/src/bin/lttng-sessiond/consumer.h @@ -212,6 +212,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, uint32_t chan_id, uint64_t tracefile_size, uint64_t tracefile_count, + uint64_t session_id_per_pid, unsigned int monitor); void consumer_init_stream_comm_msg(struct lttcomm_consumer_msg *msg, enum lttng_consumer_command cmd, diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index 72b68bb7f..d85e32aa0 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -158,6 +158,7 @@ static int ask_channel_creation(struct ust_app_session *ua_sess, chan_id, ua_chan->tracefile_size, ua_chan->tracefile_count, + ua_sess->id, ua_sess->output_traces); health_code_update(); @@ -446,7 +447,7 @@ int ust_consumer_metadata_request(struct consumer_socket *socket) goto end; } - DBG("Metadata request received for session %u, key %" PRIu64, + DBG("Metadata request received for session %" PRIu64 ", key %" PRIu64, request.session_id, request.key); reg_uid = buffer_reg_uid_find(request.session_id, @@ -455,10 +456,10 @@ int ust_consumer_metadata_request(struct consumer_socket *socket) ust_reg = reg_uid->registry->reg.ust; } else { struct buffer_reg_pid *reg_pid = - buffer_reg_pid_find(request.session_id); + buffer_reg_pid_find(request.session_id_per_pid); if (!reg_pid) { - DBG("PID registry not found for session id %u", - request.session_id); + DBG("PID registry not found for session id %" PRIu64, + request.session_id_per_pid); msg.cmd_type = LTTNG_ERR_UND; (void) consumer_send_msg(socket, &msg); diff --git a/src/common/consumer.c b/src/common/consumer.c index 5574c5f0e..57322ae08 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -769,6 +769,7 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, enum lttng_event_output output, uint64_t tracefile_size, uint64_t tracefile_count, + uint64_t session_id_per_pid, unsigned int monitor) { struct lttng_consumer_channel *channel; @@ -782,6 +783,7 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, channel->key = key; channel->refcount = 0; channel->session_id = session_id; + channel->session_id_per_pid = session_id_per_pid; channel->uid = uid; channel->gid = gid; channel->relayd_id = relayd_id; diff --git a/src/common/consumer.h b/src/common/consumer.h index f804b7260..ca567d7ff 100644 --- a/src/common/consumer.h +++ b/src/common/consumer.h @@ -106,6 +106,11 @@ struct lttng_consumer_channel { int refcount; /* Tracing session id on the session daemon side. */ uint64_t session_id; + /* + * Session id when requesting metadata to the session daemon for + * a session with per-PID buffers. + */ + uint64_t session_id_per_pid; /* Channel trace file path name. */ char pathname[PATH_MAX]; /* Channel name. */ @@ -493,6 +498,7 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, enum lttng_event_output output, uint64_t tracefile_size, uint64_t tracefile_count, + uint64_t session_id_per_pid, unsigned int monitor); void consumer_del_stream(struct lttng_consumer_stream *stream, struct lttng_ht *ht); diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index 84be2db46..354a0424e 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -480,7 +480,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, msg.u.channel.name, msg.u.channel.uid, msg.u.channel.gid, msg.u.channel.relayd_id, msg.u.channel.output, msg.u.channel.tracefile_size, - msg.u.channel.tracefile_count, + msg.u.channel.tracefile_count, 0, msg.u.channel.monitor); if (new_channel == NULL) { lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR); diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index 07c3ff1f5..e984cb1a9 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -155,7 +155,8 @@ enum lttcomm_metadata_command { * per PID registry indexed by session id ignoring the other values. */ struct lttcomm_metadata_request_msg { - unsigned int session_id; /* Tracing session id */ + uint64_t session_id; /* Tracing session id */ + uint64_t session_id_per_pid; /* Tracing session id for per-pid */ uint32_t bits_per_long; /* Consumer ABI */ uint32_t uid; uint64_t key; /* Metadata channel key. */ @@ -362,6 +363,7 @@ struct lttcomm_consumer_msg { uint32_t chan_id; /* Channel ID on the tracer side. */ uint64_t tracefile_size; /* bytes */ uint32_t tracefile_count; /* number of tracefiles */ + uint64_t session_id_per_pid; /* Per-pid session ID. */ /* Tells the consumer if the stream should be or not monitored. */ uint32_t monitor; } LTTNG_PACKED ask_channel; diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index f24b5fa3e..46644a907 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -115,13 +115,14 @@ static struct lttng_consumer_channel *allocate_channel(uint64_t session_id, const char *pathname, const char *name, uid_t uid, gid_t gid, int relayd_id, uint64_t key, enum lttng_event_output output, uint64_t tracefile_size, uint64_t tracefile_count, - unsigned int monitor) + uint64_t session_id_per_pid, unsigned int monitor) { assert(pathname); assert(name); - return consumer_allocate_channel(key, session_id, pathname, name, uid, gid, - relayd_id, output, tracefile_size, tracefile_count, monitor); + return consumer_allocate_channel(key, session_id, pathname, name, uid, + gid, relayd_id, output, tracefile_size, + tracefile_count, session_id_per_pid, monitor); } /* @@ -926,6 +927,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, (enum lttng_event_output) msg.u.ask_channel.output, msg.u.ask_channel.tracefile_size, msg.u.ask_channel.tracefile_count, + msg.u.ask_channel.session_id_per_pid, msg.u.ask_channel.monitor); if (!channel) { goto end_channel_error; @@ -1511,10 +1513,13 @@ int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx, } request.session_id = channel->session_id; + request.session_id_per_pid = channel->session_id_per_pid; request.uid = channel->uid; request.key = channel->key; - DBG("Sending metadata request to sessiond, session %" PRIu64, - channel->session_id); + DBG("Sending metadata request to sessiond, session id %" PRIu64 + ", per-pid %" PRIu64, + channel->session_id, + channel->session_id_per_pid); ret = lttcomm_send_unix_sock(ctx->consumer_metadata_socket, &request, sizeof(request)); -- 2.34.1