Contexts for RT debugging
authorJulien Desfossez <jdesfossez@efficios.com>
Mon, 7 Mar 2016 20:20:25 +0000 (15:20 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 16 Mar 2016 16:52:29 +0000 (12:52 -0400)
Enables the interruptible, preemptible, need_reschedule and migratable
kernel contexts.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/lttng/event.h
include/lttng/lttng-error.h
src/bin/lttng-sessiond/context.c
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/save.c
src/bin/lttng/commands/add_context.c
src/common/config/config-session-abi.h
src/common/config/session-config.c
src/common/error.c
src/common/lttng-kernel.h

index b2e4b7d89751be6aa948dabab37bd6a336ae415d..16b4d4f59437c4a982e4e6bae307d314cf341415 100644 (file)
@@ -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 {
index b55d9478c5f25958786d3f224c4feff82e532ce1..c96322351d76ceba8b9fbb6567cd8d40d1bf0b14 100644 (file)
@@ -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 */
index 9a5738799192a7a26de2cab6e04b361477ac6bd7..9c3a394edbcb7e8e37bb379ebbdbea2e1f915876 100644 (file)
@@ -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;
index 2cad0b2ab44b8bdd8ece486521e62f6654677e4d..7bc713a35be7935250a0f96a63c480419c840706 100644 (file)
@@ -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:
index 1a98515fa0c73f0272c82b346aa102ff5f5117f8..489446d6311dc4d8048f5f525cf91fcab1e7eaa9 100644 (file)
@@ -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;
        }
index a802df0c11fb669c4bc4218ebf1776f022e31b8e..a6d73a0a7adb6e015c3c9dc8ef08b3eab5dc119d 100644 (file)
@@ -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 */
 
index df77c63a5bf6d1884071dcb12b78242aae86bb2e..66d9cca73d4405084c264f215ed4b5247d411ca5 100644 (file)
@@ -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 */
index d89249879aece2dc99ea2b138dfcc3784154f097..8a0a95157f4a8a28955f2a1938090c9216e567eb 100644 (file)
@@ -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;
        }
index 9232894ff1c6ba6fca06fd92cff7dca12d40ed60..f7e11e163fbdd9eabe76badf662faa7bee7d2321 100644 (file)
@@ -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"
index 9dd8df7a50fcfc9e8495e412ec016702d532b252..78d5fc449ced3d3aae92e6feb1e35a3335d78509 100644 (file)
@@ -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 */
This page took 0.042943 seconds and 4 git commands to generate.