From: Mathieu Desnoyers Date: Thu, 30 Jun 2011 15:18:23 +0000 (-0400) Subject: default channel selection cleanup X-Git-Tag: v2.0-pre1~62 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=7d452e122923ade6f4dc7a6e21bef105851d79e3;p=lttng-tools.git default channel selection cleanup Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng-share.h b/include/lttng-share.h index cd971c355..f75ad773d 100644 --- a/include/lttng-share.h +++ b/include/lttng-share.h @@ -30,13 +30,17 @@ typedef __s64 s64; #define LTTNG_RUNDIR "/var/run/lttng" /* Default channel attributes */ -#define DEFAULT_CHANNEL_NAME "channel0" -#define DEFAULT_CHANNEL_OVERWRITE 0 -#define DEFAULT_CHANNEL_SUBBUF_SIZE 4096 /* bytes */ -#define DEFAULT_CHANNEL_SUBBUF_NUM 8 /* Must always be a power of 2 */ -#define DEFAULT_CHANNEL_SWITCH_TIMER 0 /* usec */ -#define DEFAULT_CHANNEL_READ_TIMER 200 /* usec */ -#define DEFAULT_CHANNEL_OUTPUT 0 /* splice, mmap (0: SPLICE, 1: MMAP, see lttng.h) */ +#define DEFAULT_CHANNEL_NAME "channel0" +#define DEFAULT_CHANNEL_OVERWRITE 0 +/* DEFAULT_CHANNEL_SUBBUF_SIZE must always be a power of 2 */ +#define DEFAULT_CHANNEL_SUBBUF_SIZE 4096 /* bytes */ +/* DEFAULT_CHANNEL_SUBBUF_NUM must always be a power of 2 */ +#define DEFAULT_CHANNEL_SUBBUF_NUM 8 +#define DEFAULT_CHANNEL_SWITCH_TIMER 0 /* usec */ +#define DEFAULT_CHANNEL_READ_TIMER 200 /* usec */ +/* See lttng.h enum lttng_kernel_output for channel output */ +#define DEFAULT_KERNEL_CHANNEL_OUTPUT LTTNG_KERNEL_SPLICE +#define DEFAULT_UST_CHANNEL_OUTPUT LTTNG_UST_MMAP /* * lttng user-space instrumentation type diff --git a/kconsumerd/kconsumerd.c b/kconsumerd/kconsumerd.c index c816d0dec..c51e4adff 100644 --- a/kconsumerd/kconsumerd.c +++ b/kconsumerd/kconsumerd.c @@ -469,7 +469,8 @@ static int read_subbuffer(struct ltt_kconsumerd_fd *kconsumerd_fd) goto end; } - if (DEFAULT_CHANNEL_OUTPUT == LTTNG_KERNEL_SPLICE) { + switch (DEFAULT_KERNEL_CHANNEL_OUTPUT) { + case LTTNG_KERNEL_SPLICE: /* read the whole subbuffer */ err = kernctl_get_padded_subbuf_size(infd, &len); if (err != 0) { @@ -487,7 +488,8 @@ static int read_subbuffer(struct ltt_kconsumerd_fd *kconsumerd_fd) */ ERR("Error splicing to tracefile"); } - } else if (DEFAULT_CHANNEL_OUTPUT == LTTNG_KERNEL_MMAP) { + break; + case LTTNG_KERNEL_MMAP: /* read the used subbuffer size */ err = kernctl_get_subbuf_size(infd, &len); if (err != 0) { @@ -505,10 +507,10 @@ static int read_subbuffer(struct ltt_kconsumerd_fd *kconsumerd_fd) */ ERR("Error writing to tracefile"); } - } else { + break; + default: ERR("Unknown output method"); ret = -1; - goto end; } err = kernctl_put_next_subbuf(infd); diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index 92e41b1c6..2fcd923a1 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -720,7 +720,7 @@ static struct lttng_channel *init_default_channel(void) chan->attr.num_subbuf = DEFAULT_CHANNEL_SUBBUF_NUM; chan->attr.switch_timer_interval = DEFAULT_CHANNEL_SWITCH_TIMER; chan->attr.read_timer_interval = DEFAULT_CHANNEL_READ_TIMER; - chan->attr.output = DEFAULT_CHANNEL_OUTPUT; + chan->attr.output = DEFAULT_KERNEL_CHANNEL_OUTPUT; error: return chan; diff --git a/ltt-sessiond/trace.c b/ltt-sessiond/trace.c index 8b7be9215..297d04f29 100644 --- a/ltt-sessiond/trace.c +++ b/ltt-sessiond/trace.c @@ -236,7 +236,7 @@ struct ltt_kernel_metadata *trace_create_kernel_metadata(void) chan->attr.num_subbuf = DEFAULT_CHANNEL_SUBBUF_NUM; chan->attr.switch_timer_interval = DEFAULT_CHANNEL_SWITCH_TIMER; chan->attr.read_timer_interval = DEFAULT_CHANNEL_READ_TIMER; - chan->attr.output = DEFAULT_CHANNEL_OUTPUT; + chan->attr.output = DEFAULT_KERNEL_CHANNEL_OUTPUT; /* Init metadata */ lkm->fd = 0; diff --git a/lttng/commands/add_channel.c b/lttng/commands/add_channel.c index 0cc8e4baa..0fb0e2593 100644 --- a/lttng/commands/add_channel.c +++ b/lttng/commands/add_channel.c @@ -144,7 +144,7 @@ static void init_channel_config(void) chan.attr.num_subbuf = DEFAULT_CHANNEL_SUBBUF_NUM; chan.attr.switch_timer_interval = DEFAULT_CHANNEL_SWITCH_TIMER; chan.attr.read_timer_interval = DEFAULT_CHANNEL_READ_TIMER; - chan.attr.output = DEFAULT_CHANNEL_OUTPUT; + chan.attr.output = DEFAULT_KERNEL_CHANNEL_OUTPUT; } /*