char err_unix_sock_path[PATH_MAX];
char cmd_unix_sock_path[PATH_MAX];
- /* Health check of the thread */
- struct health_state health;
-
/* communication lock */
pthread_mutex_t lock;
};
/* Declare TLS health state. */
extern DECLARE_URCU_TLS(struct health_state, health_state);
-/* Health state counters for the client command thread */
-extern struct health_state health_thread_cmd;
-
-/* Health state counters for the application management thread */
-extern struct health_state health_thread_app_manage;
-
-/* Health state counters for the application registration thread */
-extern struct health_state health_thread_app_reg;
-
-/* Health state counters for the kernel thread */
-extern struct health_state health_thread_kernel;
-
/*
* Update current counter by 1 to indicate that the thread entered or
* left a blocking state caused by a poll().
*/
-static inline void health_poll_update(struct health_state *state)
+static inline void health_poll_update(void)
{
uatomic_add(&URCU_TLS(health_state).current, HEALTH_POLL_VALUE);
}
* Update current counter by 2 indicates progress in execution of a
* thread.
*/
-static inline void health_code_update(struct health_state *state)
+static inline void health_code_update(void)
{
uatomic_add(&URCU_TLS(health_state).current, HEALTH_CODE_VALUE);
}
/*
* Set health "error" flag.
*/
-static inline void health_error(struct health_state *state)
+static inline void health_error(void)
{
uatomic_or(&URCU_TLS(health_state).flags, HEALTH_ERROR);
}
channel->channel->name,
channel->stream_count);
- health_code_update(&health_thread_kernel);
+ health_code_update();
ret = consumer_send_channel(sock, &lkm);
if (ret < 0) {
goto error;
}
- health_code_update(&health_thread_kernel);
+ health_code_update();
error:
return ret;
DEFAULT_METADATA_NAME,
1);
- health_code_update(&health_thread_kernel);
+ health_code_update();
ret = consumer_send_channel(sock, &lkm);
if (ret < 0) {
goto error;
}
- health_code_update(&health_thread_kernel);
+ health_code_update();
/* Prep stream message structure */
consumer_init_stream_comm_msg(&lkm,
pathname,
session->id);
- health_code_update(&health_thread_kernel);
+ health_code_update();
/* Send stream and file descriptor */
ret = consumer_send_stream(sock, consumer, &lkm,
goto error;
}
- health_code_update(&health_thread_kernel);
+ health_code_update();
error:
return ret;
pathname,
session->id);
- health_code_update(&health_thread_kernel);
+ health_code_update();
/* Send stream and file descriptor */
ret = consumer_send_stream(sock, consumer, &lkm, &stream->fd, 1);
goto error;
}
- health_code_update(&health_thread_kernel);
+ health_code_update();
error:
return ret;
static enum consumerd_state ust_consumerd_state;
static enum consumerd_state kernel_consumerd_state;
-/* Used for the health monitoring of the session daemon. See health.h */
-struct health_state health_thread_cmd;
-struct health_state health_thread_app_manage;
-struct health_state health_thread_app_reg;
-struct health_state health_thread_kernel;
-
/*
* Socket timeout for receiving and sending in seconds.
*/
goto error_testpoint;
}
- health_code_update(&health_thread_kernel);
+ health_code_update();
if (testpoint(thread_manage_kernel_before_loop)) {
goto error_testpoint;
}
while (1) {
- health_code_update(&health_thread_kernel);
+ health_code_update();
if (update_poll_flag == 1) {
/* Clean events object. We are about to populate it again. */
/* Poll infinite value of time */
restart:
- health_poll_update(&health_thread_kernel);
+ health_poll_update();
ret = lttng_poll_wait(&events, -1);
- health_poll_update(&health_thread_kernel);
+ health_poll_update();
if (ret < 0) {
/*
* Restart interrupted system call.
revents = LTTNG_POLL_GETEV(&events, i);
pollfd = LTTNG_POLL_GETFD(&events, i);
- health_code_update(&health_thread_kernel);
+ health_code_update();
/* Thread quit pipe has been closed. Killing thread. */
ret = check_thread_quit_pipe(pollfd, revents);
utils_close_pipe(kernel_poll_pipe);
kernel_poll_pipe[0] = kernel_poll_pipe[1] = -1;
if (err) {
- health_error(&health_thread_kernel);
+ health_error();
ERR("Health error occurred in %s", __func__);
WARN("Kernel thread died unexpectedly. "
"Kernel tracing can continue but CPU hotplug is disabled.");
* In a nutshell, the following poll update to the health state brings back
* the state to an even value meaning a code path.
*/
- health_poll_update(&consumer_data->health);
+ health_poll_update();
/*
* Pass 2 as size here for the thread quit pipe and kconsumerd_err_sock.
goto error;
}
- health_code_update(&consumer_data->health);
+ health_code_update();
/* Inifinite blocking call, waiting for transmission */
restart:
- health_poll_update(&consumer_data->health);
+ health_poll_update();
if (testpoint(thread_manage_consumer)) {
goto error;
}
ret = lttng_poll_wait(&events, -1);
- health_poll_update(&consumer_data->health);
+ health_poll_update();
if (ret < 0) {
/*
* Restart interrupted system call.
revents = LTTNG_POLL_GETEV(&events, i);
pollfd = LTTNG_POLL_GETFD(&events, i);
- health_code_update(&consumer_data->health);
+ health_code_update();
/* Thread quit pipe has been closed. Killing thread. */
ret = check_thread_quit_pipe(pollfd, revents);
*/
(void) utils_set_fd_cloexec(sock);
- health_code_update(&consumer_data->health);
+ health_code_update();
DBG2("Receiving code from consumer err_sock");
goto error;
}
- health_code_update(&consumer_data->health);
+ health_code_update();
if (code == LTTCOMM_CONSUMERD_COMMAND_SOCK_READY) {
consumer_data->cmd_sock =
goto error;
}
- health_code_update(&consumer_data->health);
+ health_code_update();
/* Inifinite blocking call, waiting for transmission */
restart_poll:
- health_poll_update(&consumer_data->health);
+ health_poll_update();
ret = lttng_poll_wait(&events, -1);
- health_poll_update(&consumer_data->health);
+ health_poll_update();
if (ret < 0) {
/*
* Restart interrupted system call.
revents = LTTNG_POLL_GETEV(&events, i);
pollfd = LTTNG_POLL_GETFD(&events, i);
- health_code_update(&consumer_data->health);
+ health_code_update();
/* Thread quit pipe has been closed. Killing thread. */
ret = check_thread_quit_pipe(pollfd, revents);
}
}
- health_code_update(&consumer_data->health);
+ health_code_update();
/* Wait for any kconsumerd error */
ret = lttcomm_recv_unix_sock(sock, &code,
lttng_poll_clean(&events);
error_poll:
if (err) {
- health_error(&consumer_data->health);
+ health_error();
ERR("Health error occurred in %s", __func__);
}
health_unregister();
goto error_testpoint;
}
- health_code_update(&health_thread_app_manage);
+ health_code_update();
ret = create_thread_poll_set(&events, 2);
if (ret < 0) {
goto error;
}
- health_code_update(&health_thread_app_manage);
+ health_code_update();
while (1) {
DBG("Apps thread polling on %d fds", LTTNG_POLL_GETNB(&events));
/* Inifinite blocking call, waiting for transmission */
restart:
- health_poll_update(&health_thread_app_manage);
+ health_poll_update();
ret = lttng_poll_wait(&events, -1);
- health_poll_update(&health_thread_app_manage);
+ health_poll_update();
if (ret < 0) {
/*
* Restart interrupted system call.
revents = LTTNG_POLL_GETEV(&events, i);
pollfd = LTTNG_POLL_GETFD(&events, i);
- health_code_update(&health_thread_app_manage);
+ health_code_update();
/* Thread quit pipe has been closed. Killing thread. */
ret = check_thread_quit_pipe(pollfd, revents);
goto error;
}
- health_code_update(&health_thread_app_manage);
+ health_code_update();
/* Register applicaton to the session daemon */
ret = ust_app_register(&ust_cmd.reg_msg,
break;
}
- health_code_update(&health_thread_app_manage);
+ health_code_update();
/*
* Validate UST version compatibility.
update_ust_app(ust_cmd.sock);
}
- health_code_update(&health_thread_app_manage);
+ health_code_update();
ret = ust_app_register_done(ust_cmd.sock);
if (ret < 0) {
ust_cmd.sock);
}
- health_code_update(&health_thread_app_manage);
+ health_code_update();
break;
}
}
}
- health_code_update(&health_thread_app_manage);
+ health_code_update();
}
}
*/
if (err) {
- health_error(&health_thread_app_manage);
+ health_error();
ERR("Health error occurred in %s", __func__);
}
health_unregister();
/* Inifinite blocking call, waiting for transmission */
restart:
- health_poll_update(&health_thread_app_reg);
+ health_poll_update();
ret = lttng_poll_wait(&events, -1);
- health_poll_update(&health_thread_app_reg);
+ health_poll_update();
if (ret < 0) {
/*
* Restart interrupted system call.
nb_fd = ret;
for (i = 0; i < nb_fd; i++) {
- health_code_update(&health_thread_app_reg);
+ health_code_update();
/* Fetch once the poll data */
revents = LTTNG_POLL_GETEV(&events, i);
sock = -1;
continue;
}
- health_code_update(&health_thread_app_reg);
+ health_code_update();
ret = lttcomm_recv_unix_sock(sock, &ust_cmd->reg_msg,
sizeof(struct ust_register_msg));
if (ret < 0 || ret < sizeof(struct ust_register_msg)) {
sock = -1;
continue;
}
- health_code_update(&health_thread_app_reg);
+ health_code_update();
ust_cmd->sock = sock;
sock = -1;
exit:
error:
if (err) {
- health_error(&health_thread_app_reg);
+ health_error();
ERR("Health error occurred in %s", __func__);
}
goto error_testpoint;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
ret = lttcomm_listen_unix_sock(client_sock);
if (ret < 0) {
goto error;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
while (1) {
DBG("Accepting client command ...");
/* Inifinite blocking call, waiting for transmission */
restart:
- health_poll_update(&health_thread_cmd);
+ health_poll_update();
ret = lttng_poll_wait(&events, -1);
- health_poll_update(&health_thread_cmd);
+ health_poll_update();
if (ret < 0) {
/*
* Restart interrupted system call.
revents = LTTNG_POLL_GETEV(&events, i);
pollfd = LTTNG_POLL_GETFD(&events, i);
- health_code_update(&health_thread_cmd);
+ health_code_update();
/* Thread quit pipe has been closed. Killing thread. */
ret = check_thread_quit_pipe(pollfd, revents);
DBG("Wait for client response");
- health_code_update(&health_thread_cmd);
+ health_code_update();
sock = lttcomm_accept_unix_sock(client_sock);
if (sock < 0) {
cmd_ctx->llm = NULL;
cmd_ctx->session = NULL;
- health_code_update(&health_thread_cmd);
+ health_code_update();
/*
* Data is received from the lttng client. The struct
continue;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
// TODO: Validate cmd_ctx including sanity check for
// security purpose.
continue;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
DBG("Sending response (size: %d, retcode: %s)",
cmd_ctx->lttng_msg_size,
clean_command_ctx(&cmd_ctx);
- health_code_update(&health_thread_cmd);
+ health_code_update();
}
exit:
}
if (err) {
- health_error(&health_thread_cmd);
+ health_error();
ERR("Health error occurred in %s", __func__);
}
{
int ret;
- health_code_update(&health_thread_cmd);
+ health_code_update();
ret = ustctl_add_context(app->sock, &ua_ctx->ctx,
ua_chan->obj, &ua_ctx->obj);
DBG2("UST app context created successfully for channel %s", ua_chan->name);
error:
- health_code_update(&health_thread_cmd);
+ health_code_update();
return ret;
}
{
int ret;
- health_code_update(&health_thread_cmd);
+ health_code_update();
if (!ua_event->filter) {
ret = 0;
DBG2("UST filter set successfully for event %s", ua_event->name);
error:
- health_code_update(&health_thread_cmd);
+ health_code_update();
return ret;
}
{
int ret;
- health_code_update(&health_thread_cmd);
+ health_code_update();
ret = ustctl_disable(app->sock, ua_event->obj);
if (ret < 0) {
ua_event->attr.name, app->pid);
error:
- health_code_update(&health_thread_cmd);
+ health_code_update();
return ret;
}
{
int ret;
- health_code_update(&health_thread_cmd);
+ health_code_update();
ret = ustctl_disable(app->sock, ua_chan->obj);
if (ret < 0) {
ua_chan->name, app->pid);
error:
- health_code_update(&health_thread_cmd);
+ health_code_update();
return ret;
}
{
int ret;
- health_code_update(&health_thread_cmd);
+ health_code_update();
ret = ustctl_enable(app->sock, ua_chan->obj);
if (ret < 0) {
ua_chan->name, app->pid);
error:
- health_code_update(&health_thread_cmd);
+ health_code_update();
return ret;
}
{
int ret;
- health_code_update(&health_thread_cmd);
+ health_code_update();
ret = ustctl_enable(app->sock, ua_event->obj);
if (ret < 0) {
ua_event->attr.name, app->pid);
error:
- health_code_update(&health_thread_cmd);
+ health_code_update();
return ret;
}
int ret;
struct lttng_ust_channel_attr uattr;
- health_code_update(&health_thread_cmd);
+ health_code_update();
uattr.overwrite = ua_sess->metadata->attr.overwrite;
uattr.subbuf_size = ua_sess->metadata->attr.subbuf_size;
ua_sess->metadata->handle = ua_sess->metadata->obj->handle;
error:
- health_code_update(&health_thread_cmd);
+ health_code_update();
return ret;
}
{
int ret;
- health_code_update(&health_thread_cmd);
+ health_code_update();
/* We are going to receive 2 fds, we need to reserve them. */
ret = lttng_fd_get(LTTNG_FD_APPS, 2);
}
error:
- health_code_update(&health_thread_cmd);
+ health_code_update();
return ret;
}
assert(ua_chan->obj);
assert(stream);
- health_code_update(&health_thread_cmd);
+ health_code_update();
/* We are going to receive 2 fds, we need to reserve them. */
ret = lttng_fd_get(LTTNG_FD_APPS, 2);
stream->handle = stream->obj->handle;
error:
- health_code_update(&health_thread_cmd);
+ health_code_update();
return ret;
}
{
int ret;
- health_code_update(&health_thread_cmd);
+ health_code_update();
/* We are going to receive 2 fds, we need to reserve them. */
ret = lttng_fd_get(LTTNG_FD_APPS, 2);
goto error;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
ret = ustctl_create_channel(app->sock, ua_sess->handle, &ua_chan->attr,
&ua_chan->obj);
DBG2("UST app channel %s created successfully for pid:%d and sock:%d",
ua_chan->name, app->pid, app->sock);
- health_code_update(&health_thread_cmd);
+ health_code_update();
/* If channel is not enabled, disable it on the tracer */
if (!ua_chan->enabled) {
}
error:
- health_code_update(&health_thread_cmd);
+ health_code_update();
return ret;
}
{
int ret = 0;
- health_code_update(&health_thread_cmd);
+ health_code_update();
/* Create UST event on tracer */
ret = ustctl_create_event(app->sock, &ua_event->attr, ua_chan->obj,
DBG2("UST app event %s created successfully for pid:%d",
ua_event->attr.name, app->pid);
- health_code_update(&health_thread_cmd);
+ health_code_update();
/* Set filter if one is present. */
if (ua_event->filter) {
}
error:
- health_code_update(&health_thread_cmd);
+ health_code_update();
return ret;
}
assert(app);
assert(ua_sess_ptr);
- health_code_update(&health_thread_cmd);
+ health_code_update();
ua_sess = lookup_session_by_app(usess, app);
if (ua_sess == NULL) {
created = 1;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
if (ua_sess->handle == -1) {
ret = ustctl_create_session(app->sock);
ret = 0;
error:
- health_code_update(&health_thread_cmd);
+ health_code_update();
return ret;
}
cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
struct lttng_ust_tracepoint_iter uiter;
- health_code_update(&health_thread_cmd);
+ health_code_update();
if (!app->compatible) {
/*
while ((ret = ustctl_tracepoint_list_get(app->sock, handle,
&uiter)) != -LTTNG_UST_ERR_NOENT) {
- health_code_update(&health_thread_cmd);
+ health_code_update();
if (count >= nbmem) {
/* In case the realloc fails, we free the memory */
void *ptr;
rcu_error:
rcu_read_unlock();
error:
- health_code_update(&health_thread_cmd);
+ health_code_update();
return ret;
}
cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
struct lttng_ust_field_iter uiter;
- health_code_update(&health_thread_cmd);
+ health_code_update();
if (!app->compatible) {
/*
while ((ret = ustctl_tracepoint_field_list_get(app->sock, handle,
&uiter)) != -LTTNG_UST_ERR_NOENT) {
- health_code_update(&health_thread_cmd);
+ health_code_update();
if (count >= nbmem) {
/* In case the realloc fails, we free the memory */
void *ptr;
rcu_error:
rcu_read_unlock();
error:
- health_code_update(&health_thread_cmd);
+ health_code_update();
return ret;
}
goto error_rcu_unlock;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
ret = create_ust_stream(app, ua_chan, ustream);
if (ret < 0) {
goto error_rcu_unlock;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
/* Order is important this is why a list is used. */
cds_list_add_tail(&ustream->list, &ua_chan->streams.head);
ustream->handle);
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
}
switch (app->bits_per_long) {
goto error_rcu_unlock;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
skip_setup:
/* This start the UST tracing */
/* Indicate that the session has been started once */
ua_sess->started = 1;
- health_code_update(&health_thread_cmd);
+ health_code_update();
/* Quiescent wait after starting trace */
ustctl_wait_quiescent(app->sock);
end:
rcu_read_unlock();
- health_code_update(&health_thread_cmd);
+ health_code_update();
return 0;
error_rcu_unlock:
rcu_read_unlock();
- health_code_update(&health_thread_cmd);
+ health_code_update();
return -1;
}
goto error_rcu_unlock;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
/* This inhibits UST tracing */
ret = ustctl_stop_session(app->sock, ua_sess->handle);
goto error_rcu_unlock;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
/* Quiescent wait after stopping trace */
ustctl_wait_quiescent(app->sock);
- health_code_update(&health_thread_cmd);
+ health_code_update();
/* Flushing buffers */
cds_lfht_for_each_entry(ua_sess->channels->ht, &iter.iter, ua_chan,
node.node) {
- health_code_update(&health_thread_cmd);
+ health_code_update();
ret = ustctl_sock_flush_buffer(app->sock, ua_chan->obj);
if (ret < 0) {
ERR("UST app PID %d channel %s flush failed with ret %d",
}
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
/* Flush all buffers before stopping */
ret = ustctl_sock_flush_buffer(app->sock, ua_sess->metadata->obj);
end:
rcu_read_unlock();
- health_code_update(&health_thread_cmd);
+ health_code_update();
return 0;
error_rcu_unlock:
rcu_read_unlock();
- health_code_update(&health_thread_cmd);
+ health_code_update();
return -1;
}
obj.shm_fd = -1;
obj.wait_fd = -1;
obj.memory_map_size = 0;
- health_code_update(&health_thread_cmd);
+ health_code_update();
ustctl_release_object(app->sock, &obj);
- health_code_update(&health_thread_cmd);
+ health_code_update();
delete_ust_app_session(app->sock, ua_sess);
/* Quiescent wait after stopping trace */
end:
rcu_read_unlock();
- health_code_update(&health_thread_cmd);
+ health_code_update();
return 0;
}
app = find_app_by_sock(sock);
assert(app);
- health_code_update(&health_thread_cmd);
+ health_code_update();
ret = ustctl_tracer_version(sock, &app->version);
if (ret < 0) {
UST_APP_MAJOR_VERSION);
app->compatible = 1;
rcu_read_unlock();
- health_code_update(&health_thread_cmd);
+ health_code_update();
return 0;
error:
UST_APP_MAJOR_VERSION);
app->compatible = 0;
rcu_read_unlock();
- health_code_update(&health_thread_cmd);
+ health_code_update();
return -1;
}
continue;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
ret = ustctl_calibrate(app->sock, calibrate);
if (ret < 0) {
rcu_read_unlock();
- health_code_update(&health_thread_cmd);
+ health_code_update();
return ret;
}
uchan->name,
uchan->streams.count);
- health_code_update(&health_thread_cmd);
+ health_code_update();
ret = consumer_send_channel(sock, &msg);
if (ret < 0) {
goto error;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
fd = uchan->obj->shm_fd;
ret = consumer_send_fds(sock, &fd, 1);
goto error;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
error:
return ret;
pathname,
usess->id);
- health_code_update(&health_thread_cmd);
+ health_code_update();
/* Send stream and file descriptor */
fds[0] = stream->obj->shm_fd;
goto error;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
error:
return ret;
DEFAULT_METADATA_NAME,
1);
- health_code_update(&health_thread_cmd);
+ health_code_update();
ret = consumer_send_channel(sock, &msg);
if (ret < 0) {
goto error;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
/* Sending metadata shared memory fd */
fd = usess->metadata->obj->shm_fd;
goto error;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
/* Get correct path name destination */
if (consumer->type == CONSUMER_DST_LOCAL) {
pathname,
usess->id);
- health_code_update(&health_thread_cmd);
+ health_code_update();
/* Send stream and file descriptor */
fds[0] = usess->metadata->stream_obj->shm_fd;
goto error;
}
- health_code_update(&health_thread_cmd);
+ health_code_update();
error:
return ret;