From: Julien Desfossez Date: Mon, 7 Mar 2016 20:20:25 +0000 (-0500) Subject: Contexts for RT debugging X-Git-Tag: v2.8.0-rc1~73 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=1ae5e83e58569f50b38fde0afe3f2aa08010f354;p=lttng-tools.git Contexts for RT debugging Enables the interruptible, preemptible, need_reschedule and migratable kernel contexts. Signed-off-by: Julien Desfossez Signed-off-by: Jérémie Galarneau --- diff --git a/include/lttng/event.h b/include/lttng/event.h index b2e4b7d89..16b4d4f59 100644 --- a/include/lttng/event.h +++ b/include/lttng/event.h @@ -138,6 +138,10 @@ enum lttng_event_context_type { LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER = 13, LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER = 14, LTTNG_EVENT_CONTEXT_APP_CONTEXT = 15, + LTTNG_EVENT_CONTEXT_INTERRUPTIBLE = 16, + LTTNG_EVENT_CONTEXT_PREEMPTIBLE = 17, + LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE = 18, + LTTNG_EVENT_CONTEXT_MIGRATABLE = 19, }; enum lttng_event_field_type { diff --git a/include/lttng/lttng-error.h b/include/lttng/lttng-error.h index b55d9478c..c96322351 100644 --- a/include/lttng/lttng-error.h +++ b/include/lttng/lttng-error.h @@ -141,6 +141,7 @@ enum lttng_error_code { LTTNG_ERR_SESSION_NOT_STARTED = 118, /* Session not started */ LTTNG_ERR_LIVE_SESSION = 119, /* Live session unsupported */ LTTNG_ERR_PER_PID_SESSION = 120, /* Per-PID sessions unsupported */ + LTTNG_ERR_KERN_CONTEXT_UNAVAILABLE = 121, /* Context unavailable on this kernel */ /* MUST be last element */ LTTNG_ERR_NR, /* Last element */ diff --git a/src/bin/lttng-sessiond/context.c b/src/bin/lttng-sessiond/context.c index 9a5738799..9c3a394ed 100644 --- a/src/bin/lttng-sessiond/context.c +++ b/src/bin/lttng-sessiond/context.c @@ -49,8 +49,7 @@ static int add_kctx_all_channels(struct ltt_kernel_session *ksession, /* Go over all channels */ cds_list_for_each_entry(kchan, &ksession->channel_list.head, list) { ret = kernel_add_channel_context(kchan, kctx); - if (ret < 0) { - ret = LTTNG_ERR_KERN_CONTEXT_FAIL; + if (ret != 0) { goto error; } } @@ -75,8 +74,7 @@ static int add_kctx_to_channel(struct ltt_kernel_context *kctx, DBG("Add kernel context to channel '%s'", kchan->channel->name); ret = kernel_add_channel_context(kchan, kctx); - if (ret < 0) { - ret = LTTNG_ERR_KERN_CONTEXT_FAIL; + if (ret != 0) { goto error; } @@ -231,6 +229,18 @@ int context_kernel_add(struct ltt_kernel_session *ksession, case LTTNG_EVENT_CONTEXT_PERF_COUNTER: kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_PERF_CPU_COUNTER; break; + case LTTNG_EVENT_CONTEXT_INTERRUPTIBLE: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE; + break; + case LTTNG_EVENT_CONTEXT_PREEMPTIBLE: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_PREEMPTIBLE; + break; + case LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE; + break; + case LTTNG_EVENT_CONTEXT_MIGRATABLE: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_MIGRATABLE; + break; default: ret = LTTNG_ERR_KERN_CONTEXT_FAIL; goto error; diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index 2cad0b2ab..7bc713a35 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -49,17 +49,24 @@ int kernel_add_channel_context(struct ltt_kernel_channel *chan, DBG("Adding context to channel %s", chan->channel->name); ret = kernctl_add_context(chan->fd, &ctx->ctx); if (ret < 0) { - if (errno != EEXIST) { - PERROR("add context ioctl"); - } else { + switch (errno) { + case ENOSYS: + /* Exists but not available for this kernel */ + ret = LTTNG_ERR_KERN_CONTEXT_UNAVAILABLE; + goto error; + case EEXIST: /* If EEXIST, we just ignore the error */ ret = 0; + goto end; + default: + PERROR("add context ioctl"); + ret = LTTNG_ERR_KERN_CONTEXT_FAIL; + goto error; } - goto error; } +end: cds_list_add_tail(&ctx->list, &chan->ctx_list); - return 0; error: diff --git a/src/bin/lttng-sessiond/save.c b/src/bin/lttng-sessiond/save.c index 1a98515fa..489446d63 100644 --- a/src/bin/lttng-sessiond/save.c +++ b/src/bin/lttng-sessiond/save.c @@ -232,6 +232,18 @@ const char *get_kernel_context_type_string( case LTTNG_KERNEL_CONTEXT_HOSTNAME: context_type_string = config_event_context_hostname; break; + case LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE: + context_type_string = config_event_context_interruptible; + break; + case LTTNG_KERNEL_CONTEXT_PREEMPTIBLE: + context_type_string = config_event_context_preemptible; + break; + case LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE: + context_type_string = config_event_context_need_reschedule; + break; + case LTTNG_KERNEL_CONTEXT_MIGRATABLE: + context_type_string = config_event_context_migratable; + break; default: context_type_string = NULL; } diff --git a/src/bin/lttng/commands/add_context.c b/src/bin/lttng/commands/add_context.c index a802df0c1..a6d73a0a7 100644 --- a/src/bin/lttng/commands/add_context.c +++ b/src/bin/lttng/commands/add_context.c @@ -75,6 +75,10 @@ enum context_type { CONTEXT_PERF_CPU_COUNTER = 13, CONTEXT_PERF_THREAD_COUNTER = 14, CONTEXT_APP_CONTEXT = 15, + CONTEXT_INTERRUPTIBLE = 16, + CONTEXT_PREEMPTIBLE = 17, + CONTEXT_NEED_RESCHEDULE = 18, + CONTEXT_MIGRATABLE = 19, }; /* @@ -225,6 +229,10 @@ const struct ctx_opts { { "vppid", CONTEXT_VPPID }, { "hostname", CONTEXT_HOSTNAME }, { "ip", CONTEXT_IP }, + { "interruptible", CONTEXT_INTERRUPTIBLE }, + { "preemptible", CONTEXT_PREEMPTIBLE }, + { "need_reschedule", CONTEXT_NEED_RESCHEDULE }, + { "migratable", CONTEXT_MIGRATABLE }, /* Perf options */ diff --git a/src/common/config/config-session-abi.h b/src/common/config/config-session-abi.h index df77c63a5..66d9cca73 100644 --- a/src/common/config/config-session-abi.h +++ b/src/common/config/config-session-abi.h @@ -123,5 +123,9 @@ extern const char * const config_event_context_hostname; extern const char * const config_event_context_ip; extern const char * const config_event_context_perf_thread_counter; extern const char * const config_event_context_app; +extern const char * const config_event_context_interruptible; +extern const char * const config_event_context_preemptible; +extern const char * const config_event_context_need_reschedule; +extern const char * const config_event_context_migratable; #endif /* CONFIG_SESSION_INTERNAL_H */ diff --git a/src/common/config/session-config.c b/src/common/config/session-config.c index d89249879..8a0a95157 100644 --- a/src/common/config/session-config.c +++ b/src/common/config/session-config.c @@ -172,7 +172,10 @@ const char * const config_event_context_hostname = "HOSTNAME"; const char * const config_event_context_ip = "IP"; const char * const config_event_context_perf_thread_counter = "PERF_THREAD_COUNTER"; const char * const config_event_context_app = "APP"; - +const char * const config_event_context_interruptible = "INTERRUPTIBLE"; +const char * const config_event_context_preemptible = "PREEMPTIBLE"; +const char * const config_event_context_need_reschedule = "NEED_RESCHEDULE"; +const char * const config_event_context_migratable = "MIGRATABLE"; struct consumer_output { int enabled; @@ -987,6 +990,18 @@ int get_context_type(xmlChar *context_type) } else if (!strcmp((char *) context_type, config_event_context_ip)) { ret = LTTNG_EVENT_CONTEXT_IP; + } else if (!strcmp((char *) context_type, + config_event_context_interruptible)) { + ret = LTTNG_EVENT_CONTEXT_INTERRUPTIBLE; + } else if (!strcmp((char *) context_type, + config_event_context_preemptible)) { + ret = LTTNG_EVENT_CONTEXT_PREEMPTIBLE; + } else if (!strcmp((char *) context_type, + config_event_context_need_reschedule)) { + ret = LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE; + } else if (!strcmp((char *) context_type, + config_event_context_migratable)) { + ret = LTTNG_EVENT_CONTEXT_MIGRATABLE; } else { goto error; } diff --git a/src/common/error.c b/src/common/error.c index 9232894ff..f7e11e163 100644 --- a/src/common/error.c +++ b/src/common/error.c @@ -173,6 +173,7 @@ static const char *error_string_array[] = { [ ERROR_INDEX(LTTNG_ERR_SESSION_NOT_STARTED) ] = "Session not started", [ ERROR_INDEX(LTTNG_ERR_LIVE_SESSION) ] = "Live sessions are not supported", [ ERROR_INDEX(LTTNG_ERR_PER_PID_SESSION) ] = "Per-PID tracing sessions are not supported", + [ ERROR_INDEX(LTTNG_ERR_KERN_CONTEXT_UNAVAILABLE) ] = "Context unavailable on this kernel", /* Last element */ [ ERROR_INDEX(LTTNG_ERR_NR) ] = "Unknown error code" diff --git a/src/common/lttng-kernel.h b/src/common/lttng-kernel.h index 9dd8df7a5..78d5fc449 100644 --- a/src/common/lttng-kernel.h +++ b/src/common/lttng-kernel.h @@ -54,6 +54,10 @@ enum lttng_kernel_context_type { LTTNG_KERNEL_CONTEXT_VPPID = 9, LTTNG_KERNEL_CONTEXT_HOSTNAME = 10, LTTNG_KERNEL_CONTEXT_CPU_ID = 11, + LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE = 12, + LTTNG_KERNEL_CONTEXT_PREEMPTIBLE = 13, + LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE = 14, + LTTNG_KERNEL_CONTEXT_MIGRATABLE = 15, }; /* Perf counter attributes */