X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fmanage-kernel.cpp;h=49730f497654fe1af8d09be8f6920fa41bce1620;hb=cd9adb8b829564212158943a0d279bb35322ab30;hp=0920852501d486e2d1a6bbdf7ba07189a54a6423;hpb=8a00688e1d58cc5a2e77eba206ff23bd6105130c;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/manage-kernel.cpp b/src/bin/lttng-sessiond/manage-kernel.cpp index 092085250..49730f497 100644 --- a/src/bin/lttng-sessiond/manage-kernel.cpp +++ b/src/bin/lttng-sessiond/manage-kernel.cpp @@ -7,16 +7,16 @@ * */ -#include -#include - +#include "health-sessiond.hpp" +#include "kernel-consumer.hpp" +#include "kernel.hpp" #include "manage-kernel.hpp" #include "testpoint.hpp" -#include "health-sessiond.hpp" -#include "utils.hpp" #include "thread.hpp" -#include "kernel.hpp" -#include "kernel-consumer.hpp" +#include "utils.hpp" + +#include +#include namespace { struct thread_notifiers { @@ -39,19 +39,19 @@ static int update_kernel_poll(struct lttng_poll_event *events) DBG("Updating kernel poll set"); session_lock_list(); - cds_list_for_each_entry(session, &session_list->head, list) { + cds_list_for_each_entry (session, &session_list->head, list) { if (!session_get(session)) { continue; } session_lock(session); - if (session->kernel_session == NULL) { + if (session->kernel_session == nullptr) { session_unlock(session); session_put(session); continue; } - cds_list_for_each_entry(channel, - &session->kernel_session->channel_list.head, list) { + cds_list_for_each_entry ( + channel, &session->kernel_session->channel_list.head, list) { /* Add channel fd to the kernel poll set */ ret = lttng_poll_add(events, channel->fd, LPOLLIN | LPOLLRDNORM); if (ret < 0) { @@ -90,20 +90,19 @@ static int update_kernel_stream(int fd) DBG("Updating kernel streams for channel fd %d", fd); session_lock_list(); - cds_list_for_each_entry(session, &session_list->head, list) { + cds_list_for_each_entry (session, &session_list->head, list) { if (!session_get(session)) { continue; } session_lock(session); - if (session->kernel_session == NULL) { + if (session->kernel_session == nullptr) { session_unlock(session); session_put(session); continue; } ksess = session->kernel_session; - cds_list_for_each_entry(channel, - &ksess->channel_list.head, list) { + cds_list_for_each_entry (channel, &ksess->channel_list.head, list) { struct lttng_ht_iter iter; struct consumer_socket *socket; @@ -123,19 +122,17 @@ static int update_kernel_stream(int fd) * means that tracing is started so it is safe to send * our updated stream fds. */ - if (ksess->consumer_fds_sent != 1 - || ksess->consumer == NULL) { + if (ksess->consumer_fds_sent != 1 || ksess->consumer == nullptr) { ret = -1; goto error; } rcu_read_lock(); - cds_lfht_for_each_entry(ksess->consumer->socks->ht, - &iter.iter, socket, node.node) { + cds_lfht_for_each_entry ( + ksess->consumer->socks->ht, &iter.iter, socket, node.node) { pthread_mutex_lock(socket->lock); - ret = kernel_consumer_send_channel_streams(socket, - channel, ksess, - session->output_traces ? 1 : 0); + ret = kernel_consumer_send_channel_streams( + socket, channel, ksess, session->output_traces ? 1 : 0); pthread_mutex_unlock(socket->lock); if (ret < 0) { rcu_read_unlock(); @@ -192,7 +189,7 @@ static void *thread_kernel_management(void *data) goto error_testpoint; } - while (1) { + while (true) { health_code_update(); if (update_poll_flag == 1) { @@ -204,16 +201,12 @@ static void *thread_kernel_management(void *data) goto error_poll_create; } - ret = lttng_poll_add(&events, - notifiers->kernel_poll_pipe_read_fd, - LPOLLIN); + ret = lttng_poll_add(&events, notifiers->kernel_poll_pipe_read_fd, LPOLLIN); if (ret < 0) { goto error; } - ret = lttng_poll_add(&events, - thread_quit_pipe_fd, - LPOLLIN); + ret = lttng_poll_add(&events, thread_quit_pipe_fd, LPOLLIN); if (ret < 0) { goto error; } @@ -232,8 +225,7 @@ static void *thread_kernel_management(void *data) restart: health_poll_entry(); ret = lttng_poll_wait(&events, -1); - DBG("Thread kernel return from poll on %d fds", - LTTNG_POLL_GETNB(&events)); + DBG("Thread kernel return from poll on %d fds", LTTNG_POLL_GETNB(&events)); health_poll_exit(); if (ret < 0) { /* @@ -246,7 +238,7 @@ static void *thread_kernel_management(void *data) } else if (ret == 0) { /* Should not happen since timeout is infinite */ ERR("Return value of poll is 0 with an infinite timeout.\n" - "This should not have happened! Continuing..."); + "This should not have happened! Continuing..."); continue; } @@ -269,11 +261,11 @@ static void *thread_kernel_management(void *data) /* Check for data on kernel pipe */ if (revents & LPOLLIN) { if (pollfd == notifiers->kernel_poll_pipe_read_fd) { - (void) lttng_read(notifiers->kernel_poll_pipe_read_fd, - &tmp, 1); + (void) lttng_read( + notifiers->kernel_poll_pipe_read_fd, &tmp, 1); /* - * Ret value is useless here, if this pipe gets any actions an - * update is required anyway. + * Ret value is useless here, if this pipe gets any actions + * an update is required anyway. */ update_poll_flag = 1; continue; @@ -307,11 +299,11 @@ error_testpoint: health_error(); ERR("Health error occurred in %s", __func__); WARN("Kernel thread died unexpectedly. " - "Kernel tracing can continue but CPU hotplug is disabled."); + "Kernel tracing can continue but CPU hotplug is disabled."); } health_unregister(the_health_sessiond); DBG("Kernel thread dying"); - return NULL; + return nullptr; } static bool shutdown_kernel_management_thread(void *data) @@ -333,7 +325,7 @@ static void cleanup_kernel_management_thread(void *data) bool launch_kernel_management_thread(int kernel_poll_pipe_read_fd) { struct lttng_pipe *quit_pipe; - struct thread_notifiers *notifiers = NULL; + struct thread_notifiers *notifiers = nullptr; struct lttng_thread *thread; notifiers = zmalloc(); @@ -348,10 +340,10 @@ bool launch_kernel_management_thread(int kernel_poll_pipe_read_fd) notifiers->kernel_poll_pipe_read_fd = kernel_poll_pipe_read_fd; thread = lttng_thread_create("Kernel management", - thread_kernel_management, - shutdown_kernel_management_thread, - cleanup_kernel_management_thread, - notifiers); + thread_kernel_management, + shutdown_kernel_management_thread, + cleanup_kernel_management_thread, + notifiers); if (!thread) { goto error; }