Fix: split UST per UID/PID default values
authorDavid Goulet <dgoulet@efficios.com>
Tue, 7 May 2013 15:54:41 +0000 (11:54 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 7 May 2013 19:41:12 +0000 (15:41 -0400)
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 <mathieu.desnoyers@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
doc/man/lttng.1
src/bin/lttng-sessiond/channel.c
src/bin/lttng-sessiond/channel.h
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/trace-ust.c
src/bin/lttng-sessiond/ust-app.c
src/bin/lttng/commands/enable_channels.c
src/common/defaults.c
src/common/defaults.h
src/lib/lttng-ctl/lttng-ctl.c
tests/unit/test_ust_data.c

index 37c206398deeb1771813ca7592d8cafff7f27863..afa8eb85371b40c55d2d0aa175b3976a853c985e 100644 (file)
@@ -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:
 
index ff2db69db7389976c0c1dd3bd891cf5fbc969620..8f835fd8b6276385dd9bc068dca7a92b0202233e 100644 (file)
@@ -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;
index 7fbbb4c154fbc4a3da25f5884022dd75e86f704a..15cabea743f2e8e7b0c46427834c8134740b53ef 100644 (file)
@@ -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);
index 5d2cba1d467befbde02cfcc44183304303259421..528665a141680d70d94bb979f5c76583bf454790 100644 (file)
@@ -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;
index 7592d774177a43abb8782424084c711e371bcc5c..8fb685c8d2ab62d4123997fef2be46510e448ebf 100644 (file)
@@ -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;
index e36238182d8f04e078d440dce4d3bee94b9c5360..5710226fc4504cb609eefa0b31ac4c989e15276a 100644 (file)
@@ -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 {
index 4816d62c68263a4a26a245fabc9764c17365424e..caada7deb038efd75a6e953ab730dd1826e47566 100644 (file)
@@ -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");
 }
 
index ccdbaf499f0719641538ae71c415c9536aa7b9cb..d74a42b0aa786cc95ba55f3e219db249bd004444 100644 (file)
@@ -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);
 }
index fb6a975ddabe8fb3e231fc49f5d8754855cfa775..66bb972fd7b219ead8c6ed14e192e33f3448e708 100644 (file)
 
 /* 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
 
 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 */
index 3787e292e34a5fd7b4fbf018a3f6a68decb90c6b..a7328ebfd8fa4e35d2f067d6affc01e832e6f13b 100644 (file)
@@ -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;
index a79e2eb58129f643dd8880420577601dd8f73e5b..c79dbf6f4001a0a20a0a3ba0c3b479d7b9053e96 100644 (file)
@@ -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");
 
This page took 0.051375 seconds and 4 git commands to generate.