From: David Goulet Date: Tue, 7 May 2013 15:54:41 +0000 (-0400) Subject: Fix: split UST per UID/PID default values X-Git-Tag: v2.2.0-rc2~1 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=0a9c649428b2ea8d4e743aebc12585eeb58fcf64;p=lttng-tools.git Fix: split UST per UID/PID default values The default per UID subbuffer size are changed from 4096 bytes to 131072 bytes (128k). The rest have the same values as before. Some DEFAULT_CHANNEL_* macros are prefixed with an underscore making sure they are not used elsewhere in the code base and only domain specific values are used. Fixes #524 Acked-by: Mathieu Desnoyers Signed-off-by: David Goulet --- diff --git a/doc/man/lttng.1 b/doc/man/lttng.1 index 37c206398..afa8eb853 100644 --- a/doc/man/lttng.1 +++ b/doc/man/lttng.1 @@ -327,17 +327,21 @@ same type. \-\-overwrite Flight recorder mode : overwrites events when subbuffers are full \-\-subbuf-size SIZE - Subbuffer size in bytes {+k,+M,+G} (default: 4096, kernel default: 262144) + Subbuffer size in bytes {+k,+M,+G} + (default UST uid: 131072, UST pid: 4096, kernel: 262144, metadata: 4096) Rounded up to the next power of 2. \-\-num-subbuf NUM - Number of subbuffers (default: 4) + Number of subbuffers. (default UST uid: 4, UST pid: 4, kernel: 4, metadata: 2) Rounded up to the next power of 2. \-\-switch-timer USEC - Switch subbuffer timer interval in µsec (default: 0) + Switch subbuffer timer interval in µsec. + (default UST uid: 0, UST pid: 0, kernel: 0, metadata: 0) \-\-read-timer USEC - Read timer interval in µsec (UST default: 0, kernel default: 200000) + Read timer interval in µsec. + (default UST uid: 0, UST pid: 0, kernel: 200000, metadata: 0) \-\-output TYPE Channel output type. Possible values: mmap, splice + (default UST uid: mmap, UST pid: mmap, kernel: splice, metadata: mmap) \-\-buffers-uid Use per UID buffer (\-u only). Buffers are shared between applications that have the same UID. @@ -347,9 +351,10 @@ same type. Use shared buffer for the whole system (\-k only) \-C, \-\-tracefile-size SIZE Maximum size of each tracefile within a stream (in bytes). + 0 means unlimited. (default: 0) \-W, \-\-tracefile-count COUNT Used in conjunction with \-C option, this will limit the number - of files created to the specified count. + of files created to the specified count. 0 means unlimited. (default: 0) .B EXAMPLES: diff --git a/src/bin/lttng-sessiond/channel.c b/src/bin/lttng-sessiond/channel.c index ff2db69db..8f835fd8b 100644 --- a/src/bin/lttng-sessiond/channel.c +++ b/src/bin/lttng-sessiond/channel.c @@ -33,7 +33,8 @@ /* * Return allocated channel attributes. */ -struct lttng_channel *channel_new_default_attr(int dom) +struct lttng_channel *channel_new_default_attr(int dom, + enum lttng_buffer_type type) { struct lttng_channel *chan; @@ -49,10 +50,14 @@ struct lttng_channel *channel_new_default_attr(int dom) goto error; } + /* Same for all domains. */ chan->attr.overwrite = DEFAULT_CHANNEL_OVERWRITE; + chan->attr.tracefile_size = DEFAULT_CHANNEL_TRACEFILE_SIZE; + chan->attr.tracefile_count = DEFAULT_CHANNEL_TRACEFILE_COUNT; switch (dom) { case LTTNG_DOMAIN_KERNEL: + assert(type == LTTNG_BUFFER_GLOBAL); chan->attr.subbuf_size = default_get_kernel_channel_subbuf_size(); chan->attr.num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM; @@ -61,16 +66,27 @@ struct lttng_channel *channel_new_default_attr(int dom) chan->attr.read_timer_interval = DEFAULT_KERNEL_CHANNEL_READ_TIMER; break; case LTTNG_DOMAIN_UST: -#if 0 - case LTTNG_DOMAIN_UST_PID: - case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN: - case LTTNG_DOMAIN_UST_EXEC_NAME: -#endif - chan->attr.subbuf_size = default_get_ust_channel_subbuf_size(); - chan->attr.num_subbuf = DEFAULT_UST_CHANNEL_SUBBUF_NUM; - chan->attr.output = DEFAULT_UST_CHANNEL_OUTPUT; - chan->attr.switch_timer_interval = DEFAULT_UST_CHANNEL_SWITCH_TIMER; - chan->attr.read_timer_interval = DEFAULT_UST_CHANNEL_READ_TIMER; + switch (type) { + case LTTNG_BUFFER_PER_UID: + chan->attr.subbuf_size = default_get_ust_uid_channel_subbuf_size(); + chan->attr.num_subbuf = DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM; + chan->attr.output = DEFAULT_UST_UID_CHANNEL_OUTPUT; + chan->attr.switch_timer_interval = + DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER; + chan->attr.read_timer_interval = + DEFAULT_UST_UID_CHANNEL_READ_TIMER; + break; + case LTTNG_BUFFER_PER_PID: + default: + chan->attr.subbuf_size = default_get_ust_pid_channel_subbuf_size(); + chan->attr.num_subbuf = DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM; + chan->attr.output = DEFAULT_UST_PID_CHANNEL_OUTPUT; + chan->attr.switch_timer_interval = + DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER; + chan->attr.read_timer_interval = + DEFAULT_UST_PID_CHANNEL_READ_TIMER; + break; + } break; default: goto error; /* Not implemented */ @@ -158,7 +174,8 @@ int channel_kernel_create(struct ltt_kernel_session *ksession, /* Creating channel attributes if needed */ if (attr == NULL) { - defattr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL); + defattr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL, + LTTNG_BUFFER_GLOBAL); if (defattr == NULL) { ret = LTTNG_ERR_FATAL; goto error; @@ -237,7 +254,7 @@ int channel_ust_create(struct ltt_ust_session *usess, /* Creating channel attributes if needed */ if (attr == NULL) { - defattr = channel_new_default_attr(LTTNG_DOMAIN_UST); + defattr = channel_new_default_attr(LTTNG_DOMAIN_UST, type); if (defattr == NULL) { ret = LTTNG_ERR_FATAL; goto error; @@ -245,11 +262,6 @@ int channel_ust_create(struct ltt_ust_session *usess, attr = defattr; } - if (attr->attr.subbuf_size < DEFAULT_UST_CHANNEL_SUBBUF_SIZE) { - ret = LTTNG_ERR_INVALID; - goto error; - } - /* * Validate UST buffer size and number of buffers: must both be power of 2 * and nonzero. We validate right here for UST, because applications will @@ -285,7 +297,18 @@ int channel_ust_create(struct ltt_ust_session *usess, /* Validate buffer type. */ switch (type) { case LTTNG_BUFFER_PER_PID: + if (attr->attr.subbuf_size < + default_get_ust_pid_channel_subbuf_size()) { + ret = LTTNG_ERR_INVALID; + goto error; + } + break; case LTTNG_BUFFER_PER_UID: + if (attr->attr.subbuf_size < + default_get_ust_uid_channel_subbuf_size()) { + ret = LTTNG_ERR_INVALID; + goto error; + } break; default: ret = LTTNG_ERR_BUFFER_NOT_SUPPORTED; diff --git a/src/bin/lttng-sessiond/channel.h b/src/bin/lttng-sessiond/channel.h index 7fbbb4c15..15cabea74 100644 --- a/src/bin/lttng-sessiond/channel.h +++ b/src/bin/lttng-sessiond/channel.h @@ -30,7 +30,8 @@ int channel_kernel_enable(struct ltt_kernel_session *ksession, int channel_kernel_create(struct ltt_kernel_session *ksession, struct lttng_channel *chan, int kernel_pipe); -struct lttng_channel *channel_new_default_attr(int domain); +struct lttng_channel *channel_new_default_attr(int domain, + enum lttng_buffer_type type); int channel_ust_create(struct ltt_ust_session *usess, struct lttng_channel *attr, enum lttng_buffer_type type); diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 5d2cba1d4..528665a14 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -1106,7 +1106,7 @@ int cmd_add_context(struct ltt_session *session, int domain, if (chan_count == 0) { struct lttng_channel *attr; /* Create default channel */ - attr = channel_new_default_attr(domain); + attr = channel_new_default_attr(domain, usess->buffer_type); if (attr == NULL) { ret = LTTNG_ERR_FATAL; goto error; @@ -1166,7 +1166,8 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain, kchan = trace_kernel_get_channel_by_name(channel_name, session->kernel_session); if (kchan == NULL) { - attr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL); + attr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL, + LTTNG_BUFFER_GLOBAL); if (attr == NULL) { ret = LTTNG_ERR_FATAL; goto error; @@ -1216,7 +1217,8 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain, channel_name); if (uchan == NULL) { /* Create default channel */ - attr = channel_new_default_attr(LTTNG_DOMAIN_UST); + attr = channel_new_default_attr(LTTNG_DOMAIN_UST, + usess->buffer_type); if (attr == NULL) { ret = LTTNG_ERR_FATAL; goto error; @@ -1286,7 +1288,8 @@ int cmd_enable_event_all(struct ltt_session *session, session->kernel_session); if (kchan == NULL) { /* Create default channel */ - attr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL); + attr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL, + LTTNG_BUFFER_GLOBAL); if (attr == NULL) { ret = LTTNG_ERR_FATAL; goto error; @@ -1350,7 +1353,8 @@ int cmd_enable_event_all(struct ltt_session *session, channel_name); if (uchan == NULL) { /* Create default channel */ - attr = channel_new_default_attr(LTTNG_DOMAIN_UST); + attr = channel_new_default_attr(LTTNG_DOMAIN_UST, + usess->buffer_type); if (attr == NULL) { ret = LTTNG_ERR_FATAL; goto error; diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 7592d7741..8fb685c8d 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -384,8 +384,8 @@ struct ltt_ust_metadata *trace_ust_create_metadata(char *path) lum->attr.overwrite = DEFAULT_CHANNEL_OVERWRITE; lum->attr.subbuf_size = default_get_metadata_subbuf_size(); lum->attr.num_subbuf = DEFAULT_METADATA_SUBBUF_NUM; - lum->attr.switch_timer_interval = DEFAULT_UST_CHANNEL_SWITCH_TIMER; - lum->attr.read_timer_interval = DEFAULT_UST_CHANNEL_READ_TIMER; + lum->attr.switch_timer_interval = DEFAULT_METADATA_SWITCH_TIMER; + lum->attr.read_timer_interval = DEFAULT_METADATA_READ_TIMER; lum->attr.output = LTTNG_UST_MMAP; lum->handle = -1; diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index e36238182..5710226fc 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -2527,8 +2527,8 @@ static int create_ust_app_metadata(struct ust_app_session *ua_sess, metadata->attr.overwrite = DEFAULT_CHANNEL_OVERWRITE; metadata->attr.subbuf_size = default_get_metadata_subbuf_size(); metadata->attr.num_subbuf = DEFAULT_METADATA_SUBBUF_NUM; - metadata->attr.switch_timer_interval = DEFAULT_UST_CHANNEL_SWITCH_TIMER; - metadata->attr.read_timer_interval = DEFAULT_UST_CHANNEL_READ_TIMER; + metadata->attr.switch_timer_interval = DEFAULT_METADATA_SWITCH_TIMER; + metadata->attr.read_timer_interval = DEFAULT_METADATA_READ_TIMER; metadata->attr.output = LTTNG_UST_MMAP; metadata->attr.type = LTTNG_UST_CHAN_METADATA; } else { diff --git a/src/bin/lttng/commands/enable_channels.c b/src/bin/lttng/commands/enable_channels.c index 4816d62c6..caada7deb 100644 --- a/src/bin/lttng/commands/enable_channels.c +++ b/src/bin/lttng/commands/enable_channels.c @@ -104,28 +104,42 @@ static void usage(FILE *ofp) fprintf(ofp, " --overwrite Flight recorder mode%s\n", DEFAULT_CHANNEL_OVERWRITE ? " (default)" : ""); fprintf(ofp, " --subbuf-size SIZE Subbuffer size in bytes {+k,+M,+G}\n"); - fprintf(ofp, " (default: %zu, kernel default: %zu)\n", - default_get_channel_subbuf_size(), - default_get_kernel_channel_subbuf_size()); + fprintf(ofp, " (default UST uid: %zu, UST pid: %zu, kernel: %zu, metadata: %zu)\n", + default_get_ust_uid_channel_subbuf_size(), + default_get_ust_pid_channel_subbuf_size(), + default_get_kernel_channel_subbuf_size(), + default_get_metadata_subbuf_size()); fprintf(ofp, " Rounded up to the next power of 2.\n"); fprintf(ofp, " --num-subbuf NUM Number of subbufers\n"); - fprintf(ofp, " (default: %u)\n", - DEFAULT_CHANNEL_SUBBUF_NUM); + fprintf(ofp, " (default UST uid: %u, UST pid: %u, kernel: %u, metadata: %u)\n", + DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM, DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM, + DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM, DEFAULT_METADATA_SUBBUF_NUM); fprintf(ofp, " Rounded up to the next power of 2.\n"); - fprintf(ofp, " --switch-timer USEC Switch timer interval in usec (default: %u)\n", - DEFAULT_CHANNEL_SWITCH_TIMER); - fprintf(ofp, " --read-timer USEC Read timer interval in usec (UST default: %u, kernel default: %u)\n", - DEFAULT_UST_CHANNEL_READ_TIMER, DEFAULT_KERNEL_CHANNEL_READ_TIMER); + fprintf(ofp, " --switch-timer USEC Switch timer interval in usec\n"); + fprintf(ofp, " (default UST uid: %u, UST pid: %u, kernel: %u, metadata: %u)\n", + DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER, DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER, + DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER, DEFAULT_METADATA_SWITCH_TIMER); + fprintf(ofp, " --read-timer USEC Read timer interval in usec.\n"); + fprintf(ofp, " (default UST uid: %u, UST pid: %u, kernel: %u, metadata: %u)\n", + DEFAULT_UST_UID_CHANNEL_READ_TIMER, DEFAULT_UST_UID_CHANNEL_READ_TIMER, + DEFAULT_KERNEL_CHANNEL_READ_TIMER, DEFAULT_METADATA_READ_TIMER); fprintf(ofp, " --output TYPE Channel output type (Values: %s, %s)\n", output_mmap, output_splice); + fprintf(ofp, " (default UST uid: %s, UST pid: %s, kernel: %s, metadata: %s)\n", + DEFAULT_UST_UID_CHANNEL_OUTPUT == LTTNG_EVENT_MMAP ? output_mmap : output_splice, + DEFAULT_UST_PID_CHANNEL_OUTPUT == LTTNG_EVENT_MMAP ? output_mmap : output_splice, + DEFAULT_KERNEL_CHANNEL_OUTPUT == LTTNG_EVENT_MMAP ? output_mmap : output_splice, + DEFAULT_METADATA_OUTPUT == LTTNG_EVENT_MMAP ? output_mmap : output_splice); fprintf(ofp, " --buffers-uid Use per UID buffer (-u only)\n"); fprintf(ofp, " --buffers-pid Use per PID buffer (-u only)\n"); fprintf(ofp, " --buffers-global Use shared buffer for the whole system (-k only)\n"); fprintf(ofp, " -C, --tracefile-size SIZE\n"); - fprintf(ofp, " Maximum size of each tracefile within a stream (in bytes).\n"); + fprintf(ofp, " Maximum size of each tracefile within a stream (in bytes). 0 means unlimited.\n"); + fprintf(ofp, " (default: %u)\n", DEFAULT_CHANNEL_TRACEFILE_SIZE); fprintf(ofp, " -W, --tracefile-count COUNT\n"); fprintf(ofp, " Used in conjunction with -C option, this will limit the number\n"); - fprintf(ofp, " of files created to the specified count.\n"); + fprintf(ofp, " of files created to the specified count. 0 means unlimited.\n"); + fprintf(ofp, " (default: %u)\n", DEFAULT_CHANNEL_TRACEFILE_COUNT); fprintf(ofp, "\n"); } diff --git a/src/common/defaults.c b/src/common/defaults.c index ccdbaf499..d74a42b0a 100644 --- a/src/common/defaults.c +++ b/src/common/defaults.c @@ -24,7 +24,8 @@ size_t default_channel_subbuf_size; size_t default_metadata_subbuf_size; size_t default_kernel_channel_subbuf_size; -size_t default_ust_channel_subbuf_size; +size_t default_ust_pid_channel_subbuf_size; +size_t default_ust_uid_channel_subbuf_size; static void __attribute__((constructor)) init_defaults(void) { @@ -39,11 +40,13 @@ static void __attribute__((constructor)) init_defaults(void) } default_channel_subbuf_size = - max(DEFAULT_CHANNEL_SUBBUF_SIZE, page_size); + max(_DEFAULT_CHANNEL_SUBBUF_SIZE, page_size); default_metadata_subbuf_size = max(DEFAULT_METADATA_SUBBUF_SIZE, page_size); default_kernel_channel_subbuf_size = max(DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE, page_size); - default_ust_channel_subbuf_size = - max(DEFAULT_UST_CHANNEL_SUBBUF_SIZE, page_size); + default_ust_pid_channel_subbuf_size = + max(DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE, page_size); + default_ust_uid_channel_subbuf_size = + max(DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE, page_size); } diff --git a/src/common/defaults.h b/src/common/defaults.h index fb6a975dd..66bb972fd 100644 --- a/src/common/defaults.h +++ b/src/common/defaults.h @@ -112,55 +112,57 @@ /* Default channel attributes */ #define DEFAULT_CHANNEL_NAME "channel0" -#define DEFAULT_CHANNEL_OVERWRITE 0 /* usec */ -/* 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 4 -#define DEFAULT_CHANNEL_SWITCH_TIMER 0 /* usec */ -#define DEFAULT_CHANNEL_READ_TIMER 200000 /* usec */ -#define DEFAULT_CHANNEL_OUTPUT LTTNG_EVENT_MMAP - +#define DEFAULT_CHANNEL_OVERWRITE 0 +#define DEFAULT_CHANNEL_TRACEFILE_SIZE 0 +#define DEFAULT_CHANNEL_TRACEFILE_COUNT 0 + +/* Must always be a power of 2 */ +#define _DEFAULT_CHANNEL_SUBBUF_SIZE 4096 /* bytes */ +/* Must always be a power of 2 */ +#define _DEFAULT_CHANNEL_SUBBUF_NUM 4 +#define _DEFAULT_CHANNEL_SWITCH_TIMER 0 /* usec */ +#define _DEFAULT_CHANNEL_READ_TIMER 200000 /* usec */ +#define _DEFAULT_CHANNEL_OUTPUT LTTNG_EVENT_MMAP + +/* Metadata channel defaults. */ #define DEFAULT_METADATA_SUBBUF_SIZE 4096 #define DEFAULT_METADATA_SUBBUF_NUM 2 #define DEFAULT_METADATA_CACHE_SIZE 4096 +#define DEFAULT_METADATA_SWITCH_TIMER _DEFAULT_CHANNEL_SWITCH_TIMER +#define DEFAULT_METADATA_READ_TIMER 0 +#define DEFAULT_METADATA_OUTPUT _DEFAULT_CHANNEL_OUTPUT /* Kernel has different defaults */ /* DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE must always be a power of 2 */ -#define DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE 262144 /* bytes */ +#define DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE 262144 /* bytes */ /* * DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM must always be a power of 2. * Update help manually if override. */ -#define DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM DEFAULT_CHANNEL_SUBBUF_NUM +#define DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM _DEFAULT_CHANNEL_SUBBUF_NUM /* See lttng-kernel.h enum lttng_kernel_output for channel output */ -#define DEFAULT_KERNEL_CHANNEL_OUTPUT LTTNG_EVENT_SPLICE -/* By default, unlimited tracefile size */ -#define DEFAULT_KERNEL_CHANNEL_TRACEFILE_SIZE 0 -/* By default, unlimited tracefile count */ -#define DEFAULT_KERNEL_CHANNEL_TRACEFILE_COUNT 0 - -#define DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER \ - DEFAULT_CHANNEL_SWITCH_TIMER -#define DEFAULT_KERNEL_CHANNEL_READ_TIMER 200000 /* usec */ +#define DEFAULT_KERNEL_CHANNEL_OUTPUT LTTNG_EVENT_SPLICE +#define DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER _DEFAULT_CHANNEL_SWITCH_TIMER +#define DEFAULT_KERNEL_CHANNEL_READ_TIMER _DEFAULT_CHANNEL_READ_TIMER /* User space defaults */ /* Must be a power of 2 */ -#define DEFAULT_UST_CHANNEL_SUBBUF_SIZE 4096 /* bytes */ +#define DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE _DEFAULT_CHANNEL_SUBBUF_SIZE +#define DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE 131072 /* bytes */ /* Must be a power of 2. Update help manuall if override. */ -#define DEFAULT_UST_CHANNEL_SUBBUF_NUM DEFAULT_CHANNEL_SUBBUF_NUM +#define DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM _DEFAULT_CHANNEL_SUBBUF_NUM +#define DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM _DEFAULT_CHANNEL_SUBBUF_NUM /* See lttng-ust.h enum lttng_ust_output */ -#define DEFAULT_UST_CHANNEL_OUTPUT LTTNG_EVENT_MMAP -/* By default, unlimited tracefile size */ -#define DEFAULT_UST_CHANNEL_TRACEFILE_SIZE 0 -/* By default, unlimited tracefile count */ -#define DEFAULT_UST_CHANNEL_TRACEFILE_COUNT 0 +#define DEFAULT_UST_PID_CHANNEL_OUTPUT _DEFAULT_CHANNEL_OUTPUT +#define DEFAULT_UST_UID_CHANNEL_OUTPUT _DEFAULT_CHANNEL_OUTPUT +/* Timers in usec. */ +#define DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER _DEFAULT_CHANNEL_SWITCH_TIMER +#define DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER _DEFAULT_CHANNEL_SWITCH_TIMER -#define DEFAULT_UST_CHANNEL_SWITCH_TIMER \ - DEFAULT_CHANNEL_SWITCH_TIMER -#define DEFAULT_UST_CHANNEL_READ_TIMER 0 /* usec */ +#define DEFAULT_UST_PID_CHANNEL_READ_TIMER 0 /* usec */ +#define DEFAULT_UST_UID_CHANNEL_READ_TIMER 0 /* usec */ /* * Default timeout value for the sem_timedwait() call. Blocking forever is not @@ -202,10 +204,10 @@ extern size_t default_channel_subbuf_size; extern size_t default_metadata_subbuf_size; -extern size_t default_ust_channel_subbuf_size; +extern size_t default_ust_pid_channel_subbuf_size; +extern size_t default_ust_uid_channel_subbuf_size; extern size_t default_kernel_channel_subbuf_size; - /* * Returns the default subbuf size. * @@ -243,15 +245,27 @@ size_t default_get_kernel_channel_subbuf_size(void) } /* - * Returns the default subbuf size for the UST domain. + * Returns the default subbuf size for the UST domain per PID. + * + * This function depends on a value that is set at constructor time, so it is + * unsafe to call it from another constructor. + */ +static inline +size_t default_get_ust_pid_channel_subbuf_size(void) +{ + return default_ust_pid_channel_subbuf_size; +} + +/* + * Returns the default subbuf size for the UST domain per UID. * * This function depends on a value that is set at constructor time, so it is * unsafe to call it from another constructor. */ static inline -size_t default_get_ust_channel_subbuf_size(void) +size_t default_get_ust_uid_channel_subbuf_size(void) { - return default_ust_channel_subbuf_size; + return default_ust_uid_channel_subbuf_size; } #endif /* _DEFAULTS_H */ diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 3787e292e..a7328ebfd 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -1386,29 +1386,37 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain, memset(attr, 0, sizeof(struct lttng_channel_attr)); + /* Same for all domains. */ + attr->overwrite = DEFAULT_CHANNEL_OVERWRITE; + attr->tracefile_size = DEFAULT_CHANNEL_TRACEFILE_SIZE; + attr->tracefile_count = DEFAULT_CHANNEL_TRACEFILE_COUNT; + switch (domain->type) { case LTTNG_DOMAIN_KERNEL: - attr->overwrite = DEFAULT_CHANNEL_OVERWRITE; attr->switch_timer_interval = DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER; attr->read_timer_interval = DEFAULT_KERNEL_CHANNEL_READ_TIMER; - attr->subbuf_size = default_get_kernel_channel_subbuf_size(); attr->num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM; attr->output = DEFAULT_KERNEL_CHANNEL_OUTPUT; - attr->tracefile_size = DEFAULT_KERNEL_CHANNEL_TRACEFILE_SIZE; - attr->tracefile_count = DEFAULT_KERNEL_CHANNEL_TRACEFILE_COUNT; break; case LTTNG_DOMAIN_UST: - attr->overwrite = DEFAULT_CHANNEL_OVERWRITE; - attr->switch_timer_interval = DEFAULT_UST_CHANNEL_SWITCH_TIMER; - attr->read_timer_interval = DEFAULT_UST_CHANNEL_READ_TIMER; - - attr->subbuf_size = default_get_ust_channel_subbuf_size(); - attr->num_subbuf = DEFAULT_UST_CHANNEL_SUBBUF_NUM; - attr->output = DEFAULT_UST_CHANNEL_OUTPUT; - attr->tracefile_size = DEFAULT_UST_CHANNEL_TRACEFILE_SIZE; - attr->tracefile_count = DEFAULT_UST_CHANNEL_TRACEFILE_COUNT; - break; + switch (domain->buf_type) { + case LTTNG_BUFFER_PER_UID: + attr->subbuf_size = default_get_ust_uid_channel_subbuf_size(); + attr->num_subbuf = DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM; + attr->output = DEFAULT_UST_UID_CHANNEL_OUTPUT; + attr->switch_timer_interval = DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER; + attr->read_timer_interval = DEFAULT_UST_UID_CHANNEL_READ_TIMER; + break; + case LTTNG_BUFFER_PER_PID: + default: + attr->subbuf_size = default_get_ust_pid_channel_subbuf_size(); + attr->num_subbuf = DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM; + attr->output = DEFAULT_UST_PID_CHANNEL_OUTPUT; + attr->switch_timer_interval = DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER; + attr->read_timer_interval = DEFAULT_UST_PID_CHANNEL_READ_TIMER; + break; + } default: /* Default behavior: leave set to 0. */ break; diff --git a/tests/unit/test_ust_data.c b/tests/unit/test_ust_data.c index a79e2eb58..c79dbf6f4 100644 --- a/tests/unit/test_ust_data.c +++ b/tests/unit/test_ust_data.c @@ -111,9 +111,9 @@ static void test_create_ust_metadata(void) metadata->attr.num_subbuf == DEFAULT_METADATA_SUBBUF_NUM && metadata->attr.switch_timer_interval - == DEFAULT_UST_CHANNEL_SWITCH_TIMER && + == DEFAULT_METADATA_SWITCH_TIMER && metadata->attr.read_timer_interval - == DEFAULT_UST_CHANNEL_READ_TIMER && + == DEFAULT_METADATA_READ_TIMER && metadata->attr.output == LTTNG_UST_MMAP, "Validate UST session metadata");