sessiond: split event notifier error counter CLI options
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Mon, 12 Apr 2021 15:39:08 +0000 (11:39 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 22 Apr 2021 01:22:18 +0000 (21:22 -0400)
With this commit, users can specify the size of event notifier error
counting buffers for each domain independently using the following new
lttng-sessiond options:
  --event-notifier-error-buffer-size-kernel=
  --event-notifier-error-buffer-size-userspace=

The index allocation is now also per-domain meaning that index
allocation in the kernel domain doesn't affect available indices in the
userspace domain and reversely.

Small changes:
- Add manual page description of the new options,
- Rename `struct error_account_entry` to
  `struct ust_error_accounting_entry`.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4758d32c00cb432be377fd67eaffa11b193bad74

doc/man/lttng-sessiond.8.txt
src/bin/lttng-sessiond/event-notifier-error-accounting.c
src/bin/lttng-sessiond/event-notifier-error-accounting.h
src/bin/lttng-sessiond/main.c
src/bin/lttng-sessiond/sessiond-config.c
src/bin/lttng-sessiond/sessiond-config.h
tests/regression/tools/notification/test_notification_notifier_discarded_count

index 1e587e4996b14fba73da404b9ebca83c665e2926..c35ccdccf34136733f7cd79044d1a20ef8f3da13 100644 (file)
@@ -25,6 +25,8 @@ SYNOPSIS
                [option:--ustconsumerd64-cmd-sock='PATH']
                [option:--consumerd32-path='PATH'] [option:--consumerd32-libdir='PATH']
                [option:--consumerd64-path='PATH'] [option:--consumerd64-libdir='PATH']
+               [option:--event-notifier-error-buffer-size-kernel='SIZE']
+               [option:--event-notifier-error-buffer-size-userspace='SIZE']
                [option:--quiet | [option:-v | option:-vv | option:-vvv] [option:--verbose-consumer]]
 
 
@@ -123,6 +125,13 @@ session daemon is ready to accept commands. When building a third party
 tool on liblttng-ctl, this option can be very handy to synchronize the
 control tool and the session daemon.
 
+option:--event-notifier-error-buffer-size-kernel='SIZE'::
+    Set the size of the kernel event notifier error counter buffers to 'SIZE.
+
+option:--event-notifier-error-buffer-size-userspace='SIZE'::
+    Set the size of the userspace event notifier error counter buffers to
+    'SIZE.
+
 
 Linux kernel tracing
 ~~~~~~~~~~~~~~~~~~~~
index aee82742a80ba9412f641632081fae402b3159b3..9bc433312ad5209ceacc8c21de73637ada425322 100644 (file)
@@ -31,7 +31,8 @@ struct index_ht_entry {
        struct rcu_head rcu_head;
 };
 
-struct error_account_entry {
+struct ust_error_accounting_entry {
+       uid_t uid;
        struct lttng_ht_node_u64 node;
        struct rcu_head rcu_head;
        struct ustctl_daemon_counter *daemon_counter;
@@ -47,20 +48,24 @@ struct error_account_entry {
        int nr_counter_cpu_fds;
 };
 
-struct kernel_error_account_entry {
+struct kernel_error_accounting_entry {
        int kernel_event_notifier_error_counter_fd;
 };
 
-static struct kernel_error_account_entry kernel_error_accountant;
-
-/* Hashtable mapping event notifier token to index_ht_entry. */
-static struct lttng_ht *error_counter_indexes_ht;
+static struct kernel_error_accounting_entry kernel_error_accountant;
 
 /* Hashtable mapping uid to error_account_entry. */
 static struct lttng_ht *error_counter_uid_ht;
 
-static uint64_t error_counter_size;
-static struct lttng_index_allocator *index_allocator;
+struct error_accounting_state {
+       struct lttng_index_allocator *index_allocator;
+       /* Hashtable mapping event notifier token to index_ht_entry. */
+       struct lttng_ht *indices_ht;
+       uint64_t number_indices;
+};
+
+static struct error_accounting_state ust_state;
+static struct error_accounting_state kernel_state;
 
 static inline void get_trigger_info_for_log(const struct lttng_trigger *trigger,
                const char **trigger_name,
@@ -106,24 +111,73 @@ const char *error_accounting_status_str(
        }
 }
 
+static
 enum event_notifier_error_accounting_status
-event_notifier_error_accounting_init(uint64_t nb_bucket)
+init_error_accounting_state(struct error_accounting_state *state,
+               uint64_t index_count)
 {
        enum event_notifier_error_accounting_status status;
 
-       index_allocator = lttng_index_allocator_create(nb_bucket);
-       if (!index_allocator) {
-               ERR("Failed to allocate event notifier error counter index");
+       assert(state);
+
+       state->number_indices = index_count;
+
+       state->index_allocator = lttng_index_allocator_create(index_count);
+       if (!state->index_allocator) {
+               ERR("Failed to allocate event notifier error counter index allocator");
                status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOMEM;
-               goto error_index_allocator;
+               goto end;
        }
 
-       error_counter_indexes_ht = lttng_ht_new(
-                       ERROR_COUNTER_INDEX_HT_INITIAL_SIZE, LTTNG_HT_TYPE_U64);
-       if (!error_counter_indexes_ht) {
+       state->indices_ht = lttng_ht_new(ERROR_COUNTER_INDEX_HT_INITIAL_SIZE,
+                       LTTNG_HT_TYPE_U64);
+       if (!state->indices_ht) {
                ERR("Failed to allocate error counter indices hash table");
                status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOMEM;
-               goto error_index_allocator;
+               goto error_indices_ht;
+       }
+
+       status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
+       goto end;
+
+error_indices_ht:
+       lttng_index_allocator_destroy(state->index_allocator);
+       state->index_allocator = NULL;
+end:
+       return status;
+}
+
+static
+void fini_error_accounting_state(struct error_accounting_state *state)
+{
+       assert(state);
+
+       /*
+        * Will assert if some error counter indices were not released (an
+        * internal error).
+        */
+       lttng_ht_destroy(state->indices_ht);
+       lttng_index_allocator_destroy(state->index_allocator);
+}
+
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_init(uint64_t buffer_size_kernel,
+               uint64_t buffer_size_ust)
+{
+       enum event_notifier_error_accounting_status status;
+
+       status = init_error_accounting_state(&kernel_state, buffer_size_kernel);
+       if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
+               ERR("Failed to initialize kernel event notifier accounting state: status = %s",
+                               error_accounting_status_str(status));
+               goto end;
+       }
+
+       status = init_error_accounting_state(&ust_state, buffer_size_ust);
+       if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
+               ERR("Failed to initialize UST event notifier accounting state: status = %s",
+                               error_accounting_status_str(status));
+               goto error_ust_state;
        }
 
        error_counter_uid_ht = lttng_ht_new(
@@ -131,20 +185,24 @@ event_notifier_error_accounting_init(uint64_t nb_bucket)
        if (!error_counter_uid_ht) {
                ERR("Failed to allocate UID to error counter accountant hash table");
                status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOMEM;
-               goto error_index_allocator;
+               goto error_uid_ht;
        }
 
-       error_counter_size = nb_bucket;
-
        status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
+       goto end;
 
-error_index_allocator:
+error_uid_ht:
+       fini_error_accounting_state(&ust_state);
+error_ust_state:
+       fini_error_accounting_state(&kernel_state);
+end:
        return status;
 }
 
 static
 enum event_notifier_error_accounting_status get_error_counter_index_for_token(
-               uint64_t tracer_token, uint64_t *error_counter_index)
+               struct error_accounting_state *state, uint64_t tracer_token,
+               uint64_t *error_counter_index)
 {
        struct lttng_ht_node_u64 *node;
        struct lttng_ht_iter iter;
@@ -152,7 +210,7 @@ enum event_notifier_error_accounting_status get_error_counter_index_for_token(
        enum event_notifier_error_accounting_status status;
 
        rcu_read_lock();
-       lttng_ht_lookup(error_counter_indexes_ht, &tracer_token, &iter);
+       lttng_ht_lookup(state->indices_ht, &tracer_token, &iter);
        node = lttng_ht_iter_get_node_u64(&iter);
        if (node) {
                index_entry = caa_container_of(
@@ -169,9 +227,9 @@ enum event_notifier_error_accounting_status get_error_counter_index_for_token(
 
 #ifdef HAVE_LIBLTTNG_UST_CTL
 static
-struct error_account_entry *get_uid_accounting_entry(const struct ust_app *app)
+struct ust_error_accounting_entry *get_uid_accounting_entry(const struct ust_app *app)
 {
-       struct error_account_entry *entry;
+       struct ust_error_accounting_entry *entry;
        struct lttng_ht_node_u64 *node;
        struct lttng_ht_iter iter;
        uint64_t key = app->uid;
@@ -181,34 +239,36 @@ struct error_account_entry *get_uid_accounting_entry(const struct ust_app *app)
        if(node == NULL) {
                entry = NULL;
        } else {
-               entry = caa_container_of(node, struct error_account_entry, node);
+               entry = caa_container_of(node, struct ust_error_accounting_entry, node);
        }
 
        return entry;
 }
 
 static
-struct error_account_entry *create_uid_accounting_entry(
+struct ust_error_accounting_entry *create_uid_accounting_entry(
                const struct ust_app *app)
 {
        int i, ret;
        struct ustctl_daemon_counter *daemon_counter;
        struct lttng_ust_abi_object_data *counter, **cpu_counters;
        int *cpu_counter_fds = NULL;
-       struct error_account_entry *entry = NULL;
+       struct ust_error_accounting_entry *entry = NULL;
        const struct ustctl_counter_dimension dimension = {
-               .size = error_counter_size,
+               .size = ust_state.number_indices,
                .has_underflow = false,
                .has_overflow = false,
        };
 
-       entry = zmalloc(sizeof(struct error_account_entry));
+       entry = zmalloc(sizeof(struct ust_error_accounting_entry));
        if (!entry) {
                PERROR("Failed to allocate event notifier error acounting entry")
                goto error;
        }
 
+       entry->uid = app->uid;
        entry->nr_counter_cpu_fds = ustctl_get_nr_cpu_per_counter();
+
        cpu_counter_fds = zmalloc(entry->nr_counter_cpu_fds * sizeof(*cpu_counter_fds));
        if (!cpu_counter_fds) {
                PERROR("Failed to allocate event notifier error counter file descriptors array: application uid = %d, application name = '%s', pid = %d, allocation size = %zu",
@@ -401,7 +461,7 @@ event_notifier_error_accounting_register_app(struct ust_app *app)
        int ret;
        uint64_t i;
        struct lttng_ust_abi_object_data *new_counter;
-       struct error_account_entry *entry;
+       struct ust_error_accounting_entry *entry;
        enum event_notifier_error_accounting_status status;
        struct lttng_ust_abi_object_data **cpu_counters;
 
@@ -512,7 +572,7 @@ enum event_notifier_error_accounting_status
 event_notifier_error_accounting_unregister_app(struct ust_app *app)
 {
        enum event_notifier_error_accounting_status status;
-       struct error_account_entry *entry;
+       struct ust_error_accounting_entry *entry;
        int i;
 
        rcu_read_lock();
@@ -547,29 +607,30 @@ event_notifier_error_accounting_ust_get_count(
                const struct lttng_trigger *trigger, uint64_t *count)
 {
        struct lttng_ht_iter iter;
-       struct error_account_entry *uid_entry;
+       struct ust_error_accounting_entry *uid_entry;
        uint64_t error_counter_index, global_sum = 0;
        enum event_notifier_error_accounting_status status;
        size_t dimension_indexes[1];
        const uint64_t tracer_token = lttng_trigger_get_tracer_token(trigger);
+       uid_t trigger_owner_uid;
+       const char *trigger_name;
 
-       /*
-        * Go over all error counters (ignoring uid) as a trigger (and trigger
-        * errors) can be generated from any applications that this session
-        * daemon is managing.
-        */
 
        rcu_read_lock();
 
+       get_trigger_info_for_log(trigger, &trigger_name, &trigger_owner_uid);
+
+       /*
+        * At the moment, the error counter index is domain wide. This means
+        * that if UID 1000 registers a event notifier and is allocated index 0
+        * in it's error counter, index zero will be unused in error counter of
+        * all other users.
+        */
        status = get_error_counter_index_for_token(
+                       &ust_state,
                        tracer_token,
                        &error_counter_index);
        if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
-               uid_t trigger_owner_uid;
-               const char *trigger_name;
-
-               get_trigger_info_for_log(trigger, &trigger_name,
-                                        &trigger_owner_uid);
 
                ERR("Failed to retrieve index for tracer token: token = %" PRIu64 ", trigger name = '%s', trigger owner uid = %d, status = %s",
                                tracer_token, trigger_name,
@@ -580,6 +641,13 @@ event_notifier_error_accounting_ust_get_count(
 
        dimension_indexes[0] = error_counter_index;
 
+       /*
+        * Iterate over all the UID entries.
+        * We aggregate the value of all uid entries regardless of if the uid
+        * matches the trigger's uid because a user that is allowed to register
+        * a trigger to a given sessiond is also allowed to create an event
+        * notifier on all apps that this sessiond is aware of.
+        */
        cds_lfht_for_each_entry(error_counter_uid_ht->ht, &iter.iter,
                        uid_entry, node.node) {
                int ret;
@@ -590,12 +658,6 @@ event_notifier_error_accounting_ust_get_count(
                                dimension_indexes, &local_value, &overflow,
                                &underflow);
                if (ret || local_value < 0) {
-                       uid_t trigger_owner_uid;
-                       const char *trigger_name;
-
-                       get_trigger_info_for_log(trigger, &trigger_name,
-                                       &trigger_owner_uid);
-
                        if (ret) {
                                ERR("Failed to aggregate event notifier error counter values of trigger: trigger name = '%s', trigger owner uid = %d",
                                                trigger_name,
@@ -615,7 +677,6 @@ event_notifier_error_accounting_ust_get_count(
 
                /* Cast is safe as negative values are checked-for above. */
                global_sum += (uint64_t) local_value;
-
        }
 
        *count = global_sum;
@@ -631,7 +692,7 @@ enum event_notifier_error_accounting_status event_notifier_error_accounting_ust_
                const struct lttng_trigger *trigger)
 {
        struct lttng_ht_iter iter;
-       struct error_account_entry *uid_entry;
+       struct ust_error_accounting_entry *uid_entry;
        uint64_t error_counter_index;
        enum event_notifier_error_accounting_status status;
        size_t dimension_index;
@@ -645,6 +706,7 @@ enum event_notifier_error_accounting_status event_notifier_error_accounting_ust_
 
        rcu_read_lock();
        status = get_error_counter_index_for_token(
+                       &ust_state,
                        tracer_token,
                        &error_counter_index);
        if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
@@ -700,6 +762,7 @@ event_notifier_error_accounting_kernel_clear(
        struct lttng_kernel_counter_clear counter_clear = {};
 
        status = get_error_counter_index_for_token(
+                       &kernel_state,
                        lttng_trigger_get_tracer_token(trigger),
                        &error_counter_index);
        if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
@@ -752,7 +815,7 @@ event_notifier_error_accounting_register_kernel(
                                LTTNG_KERNEL_COUNTER_BITNESS_64,
                .global_sum_step = 0,
                .number_dimensions = 1,
-               .dimensions[0].size = error_counter_size,
+               .dimensions[0].size = kernel_state.number_indices,
                .dimensions[0].has_underflow = false,
                .dimensions[0].has_overflow = false,
        };
@@ -790,22 +853,25 @@ error:
 
 static
 enum event_notifier_error_accounting_status create_error_counter_index_for_token(
-               uint64_t tracer_token, uint64_t *error_counter_index)
+               struct error_accounting_state *state, uint64_t tracer_token,
+               uint64_t *error_counter_index)
 {
        struct index_ht_entry *index_entry;
        enum lttng_index_allocator_status index_alloc_status;
        uint64_t local_error_counter_index;
        enum event_notifier_error_accounting_status status;
 
+       assert(state);
+
        /* Allocate a new index for that counter. */
-       index_alloc_status = lttng_index_allocator_alloc(index_allocator,
+       index_alloc_status = lttng_index_allocator_alloc(state->index_allocator,
                        &local_error_counter_index);
        switch (index_alloc_status) {
        case LTTNG_INDEX_ALLOCATOR_STATUS_EMPTY:
                DBG("No indices left in the configured event notifier error counter: "
                                "number-of-indices = %"PRIu64,
                                lttng_index_allocator_get_index_count(
-                                       index_allocator));
+                                       state->index_allocator));
                status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NO_INDEX_AVAILABLE;
                goto end;
        case LTTNG_INDEX_ALLOCATOR_STATUS_OK:
@@ -824,7 +890,7 @@ enum event_notifier_error_accounting_status create_error_counter_index_for_token
 
        index_entry->error_counter_index = local_error_counter_index;
        lttng_ht_node_init_u64(&index_entry->node, tracer_token);
-       lttng_ht_add_unique_u64(error_counter_indexes_ht, &index_entry->node);
+       lttng_ht_add_unique_u64(state->indices_ht, &index_entry->node);
 
        DBG("Allocated error counter index for tracer token: tracer token = %" PRIu64 ", index = %" PRIu64,
                        tracer_token, local_error_counter_index);
@@ -841,12 +907,24 @@ event_notifier_error_accounting_register_event_notifier(
 {
        enum event_notifier_error_accounting_status status;
        uint64_t local_error_counter_index;
+       struct error_accounting_state *state;
+
+       switch (lttng_trigger_get_underlying_domain_type_restriction(trigger)) {
+       case LTTNG_DOMAIN_KERNEL:
+               state = &kernel_state;
+               break;
+       case LTTNG_DOMAIN_UST:
+               state = &ust_state;
+               break;
+       default:
+               abort();
+       }
 
        /*
         * Check if this event notifier already has a error counter index
         * assigned.
         */
-       status = get_error_counter_index_for_token(
+       status = get_error_counter_index_for_token(state,
                        lttng_trigger_get_tracer_token(trigger),
                        &local_error_counter_index);
        switch (status) {
@@ -862,7 +940,7 @@ event_notifier_error_accounting_register_event_notifier(
                                trigger_name, trigger_owner_uid,
                                lttng_trigger_get_tracer_token(trigger));
 
-               status = create_error_counter_index_for_token(
+               status = create_error_counter_index_for_token(state,
                                lttng_trigger_get_tracer_token(trigger),
                                &local_error_counter_index);
                if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
@@ -896,7 +974,9 @@ event_notifier_error_accounting_kernel_get_count(
        int ret;
 
        status = get_error_counter_index_for_token(
-                       lttng_trigger_get_tracer_token(trigger), &error_counter_index);
+                       &kernel_state,
+                       lttng_trigger_get_tracer_token(trigger),
+                       &error_counter_index);
        if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
                ERR("Error getting index for token: status=%s",
                                error_accounting_status_str(status));
@@ -951,7 +1031,8 @@ event_notifier_error_accounting_get_count(
                                trigger, count);
        case LTTNG_DOMAIN_UST:
 #ifdef HAVE_LIBLTTNG_UST_CTL
-               return event_notifier_error_accounting_ust_get_count(trigger, count);
+               return event_notifier_error_accounting_ust_get_count(trigger,
+                               count);
 #else
                return EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
 #endif /* HAVE_LIBLTTNG_UST_CTL */
@@ -993,6 +1074,7 @@ void event_notifier_error_accounting_unregister_event_notifier(
        struct lttng_ht_node_u64 *node;
        const uint64_t tracer_token = lttng_trigger_get_tracer_token(trigger);
        enum event_notifier_error_accounting_status status;
+       struct error_accounting_state *state;
 
        status = event_notifier_error_accounting_clear(trigger);
        if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
@@ -1001,8 +1083,19 @@ void event_notifier_error_accounting_unregister_event_notifier(
                                error_accounting_status_str(status));
        }
 
+       switch (lttng_trigger_get_underlying_domain_type_restriction(trigger)) {
+       case LTTNG_DOMAIN_KERNEL:
+               state = &kernel_state;
+               break;
+       case LTTNG_DOMAIN_UST:
+               state = &ust_state;
+               break;
+       default:
+               abort();
+       }
+
        rcu_read_lock();
-       lttng_ht_lookup(error_counter_indexes_ht, &tracer_token, &iter);
+       lttng_ht_lookup(state->indices_ht, &tracer_token, &iter);
        node = lttng_ht_iter_get_node_u64(&iter);
        if (node) {
                int del_ret;
@@ -1011,7 +1104,7 @@ void event_notifier_error_accounting_unregister_event_notifier(
                enum lttng_index_allocator_status index_alloc_status;
 
                index_alloc_status = lttng_index_allocator_release(
-                               index_allocator,
+                               state->index_allocator,
                                index_entry->error_counter_index);
                if (index_alloc_status != LTTNG_INDEX_ALLOCATOR_STATUS_OK) {
                        uid_t trigger_owner_uid;
@@ -1026,7 +1119,7 @@ void event_notifier_error_accounting_unregister_event_notifier(
                        /* Don't exit, perform the rest of the clean-up. */
                }
 
-               del_ret = lttng_ht_del(error_counter_indexes_ht, &iter);
+               del_ret = lttng_ht_del(state->indices_ht, &iter);
                assert(!del_ret);
                call_rcu(&index_entry->rcu_head, free_index_ht_entry);
        }
@@ -1038,7 +1131,7 @@ void event_notifier_error_accounting_unregister_event_notifier(
 static void free_error_account_entry(struct rcu_head *head)
 {
        int i;
-       struct error_account_entry *entry =
+       struct ust_error_accounting_entry *entry =
                        caa_container_of(head, typeof(*entry), rcu_head);
 
        for (i = 0; i < entry->nr_counter_cpu_fds; i++) {
@@ -1063,9 +1156,7 @@ static void free_error_account_entry(struct rcu_head *head) {}
 void event_notifier_error_accounting_fini(void)
 {
        struct lttng_ht_iter iter;
-       struct error_account_entry *uid_entry;
-
-       lttng_index_allocator_destroy(index_allocator);
+       struct ust_error_accounting_entry *uid_entry;
 
        if (kernel_error_accountant.kernel_event_notifier_error_counter_fd) {
                const int ret = close(kernel_error_accountant.kernel_event_notifier_error_counter_fd);
@@ -1087,11 +1178,9 @@ void event_notifier_error_accounting_fini(void)
                call_rcu(&uid_entry->rcu_head, free_error_account_entry);
        }
        rcu_read_unlock();
+
        lttng_ht_destroy(error_counter_uid_ht);
 
-       /*
-        * Will assert if some error counter indices were not released (an
-        * internal error).
-        */
-       lttng_ht_destroy(error_counter_indexes_ht);
+       fini_error_accounting_state(&kernel_state);
+       fini_error_accounting_state(&ust_state);
 }
index 889efffa3c3316d1619b14380540f0a3d824e243..d42fff650d8cd5aeaeb7582b65e18910b6c4eaf0 100644 (file)
@@ -23,17 +23,36 @@ enum event_notifier_error_accounting_status {
        EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_APP_DEAD,
 };
 
+/*
+ * Initialize the event notifier error accounting system.
+ * `buffer_size_kernel` and `buffer_size_ust` represent the number of buckets
+ * to be allocated for each domain.
+ */
 enum event_notifier_error_accounting_status
-event_notifier_error_accounting_init(uint64_t nb_bucket);
+event_notifier_error_accounting_init(uint64_t buffer_size_kernel,
+               uint64_t buffer_size_ust);
 
+/*
+ * Register the kernel event notifier group.
+ * This allocates the counter object on the kernel side.
+ */
 enum event_notifier_error_accounting_status
 event_notifier_error_accounting_register_kernel(
                int kernel_event_notifier_group_fd);
 
 #ifdef HAVE_LIBLTTNG_UST_CTL
+
+/*
+ * Register a UST application.
+ *
+ * This reuses (or creates) the counter object of the app UID.
+ */
 enum event_notifier_error_accounting_status
 event_notifier_error_accounting_register_app(struct ust_app *app);
 
+/*
+ * Unregister a UST application.
+ */
 enum event_notifier_error_accounting_status
 event_notifier_error_accounting_unregister_app(struct ust_app *app);
 #else /* HAVE_LIBLTTNG_UST_CTL */
@@ -52,6 +71,9 @@ event_notifier_error_accounting_unregister_app(struct ust_app *app)
 }
 #endif /* HAVE_LIBLTTNG_UST_CTL */
 
+/*
+ * Allocates, reserves and returns the error counter index for that trigger.
+ */
 enum event_notifier_error_accounting_status
 event_notifier_error_accounting_register_event_notifier(
                const struct lttng_trigger *trigger,
index bca33a4f8a0f669d6e4f278ce15a9c65c444478d..05566d5f86fdb6494e8069bdafc7c03cbc05733a 100644 (file)
@@ -85,6 +85,13 @@ NULL
 ;
 
 #define EVENT_NOTIFIER_ERROR_COUNTER_NUMBER_OF_BUCKET_MAX 65535
+#define EVENT_NOTIFIER_ERROR_BUFFER_SIZE_BASE_OPTION_STR \
+               "event-notifier-error-buffer-size"
+#define EVENT_NOTIFIER_ERROR_BUFFER_SIZE_KERNEL_OPTION_STR \
+               EVENT_NOTIFIER_ERROR_BUFFER_SIZE_BASE_OPTION_STR "-kernel"
+#define EVENT_NOTIFIER_ERROR_BUFFER_SIZE_USERSPACE_OPTION_STR \
+               EVENT_NOTIFIER_ERROR_BUFFER_SIZE_BASE_OPTION_STR "-userspace"
+
 
 const char *progname;
 static int lockfile_fd = -1;
@@ -123,7 +130,8 @@ static const struct option long_options[] = {
        { "load", required_argument, 0, 'l' },
        { "kmod-probes", required_argument, 0, '\0' },
        { "extra-kmod-probes", required_argument, 0, '\0' },
-       { "event-notifier-error-number-of-bucket", required_argument, 0, '\0' },
+       { EVENT_NOTIFIER_ERROR_BUFFER_SIZE_KERNEL_OPTION_STR, required_argument, 0, '\0' },
+       { EVENT_NOTIFIER_ERROR_BUFFER_SIZE_USERSPACE_OPTION_STR, required_argument, 0, '\0' },
        { NULL, 0, 0, 0 }
 };
 
@@ -713,22 +721,43 @@ static int set_option(int opt, const char *arg, const char *optname)
                                ret = -ENOMEM;
                        }
                }
-       } else if (string_match(optname, "event-notifier-error-number-of-bucket")) {
+       } else if (string_match(optname, EVENT_NOTIFIER_ERROR_BUFFER_SIZE_KERNEL_OPTION_STR)) {
                unsigned long v;
 
                errno = 0;
                v = strtoul(arg, NULL, 0);
                if (errno != 0 || !isdigit(arg[0])) {
-                       ERR("Wrong value in --event-notifier-error-number-of-bucket parameter: %s", arg);
+                       ERR("Wrong value in --%s parameter: %s",
+                                       EVENT_NOTIFIER_ERROR_BUFFER_SIZE_KERNEL_OPTION_STR, arg);
                        return -1;
                }
                if (v == 0 || v >= EVENT_NOTIFIER_ERROR_COUNTER_NUMBER_OF_BUCKET_MAX) {
-                       ERR("Value out of range for --event-notifier-error-number-of-bucket parameter: %s", arg);
+                       ERR("Value out of range for --%s parameter: %s",
+                                       EVENT_NOTIFIER_ERROR_BUFFER_SIZE_KERNEL_OPTION_STR, arg);
                        return -1;
                }
-               the_config.event_notifier_error_counter_bucket = (int) v;
-               DBG3("Number of event notifier error counter set to non default: %i",
-                               the_config.event_notifier_error_counter_bucket);
+               the_config.event_notifier_buffer_size_kernel = (int) v;
+               DBG3("Number of event notifier error buffer kernel size to non default: %i",
+                               the_config.event_notifier_buffer_size_kernel);
+               goto end;
+       } else if (string_match(optname, EVENT_NOTIFIER_ERROR_BUFFER_SIZE_USERSPACE_OPTION_STR)) {
+               unsigned long v;
+
+               errno = 0;
+               v = strtoul(arg, NULL, 0);
+               if (errno != 0 || !isdigit(arg[0])) {
+                       ERR("Wrong value in --%s parameter: %s",
+                                       EVENT_NOTIFIER_ERROR_BUFFER_SIZE_USERSPACE_OPTION_STR, arg);
+                       return -1;
+               }
+               if (v == 0 || v >= EVENT_NOTIFIER_ERROR_COUNTER_NUMBER_OF_BUCKET_MAX) {
+                       ERR("Value out of range for --%s parameter: %s",
+                                       EVENT_NOTIFIER_ERROR_BUFFER_SIZE_USERSPACE_OPTION_STR, arg);
+                       return -1;
+               }
+               the_config.event_notifier_buffer_size_userspace = (int) v;
+               DBG3("Number of event notifier error buffer userspace size to non default: %i",
+                               the_config.event_notifier_buffer_size_userspace);
                goto end;
        } else if (string_match(optname, "config") || opt == 'f') {
                /* This is handled in set_options() thus silent skip. */
@@ -1399,6 +1428,7 @@ int main(int argc, char **argv)
        struct lttng_thread *client_thread = NULL;
        struct lttng_thread *notification_thread = NULL;
        struct lttng_thread *register_apps_thread = NULL;
+       enum event_notifier_error_accounting_status event_notifier_error_accounting_status;
 
        logger_set_thread_name("Main", false);
        init_kernel_workarounds();
@@ -1627,7 +1657,14 @@ int main(int argc, char **argv)
                goto stop_threads;
        }
 
-       event_notifier_error_accounting_init(the_config.event_notifier_error_counter_bucket);
+       event_notifier_error_accounting_status = event_notifier_error_accounting_init(
+                       the_config.event_notifier_buffer_size_kernel,
+                       the_config.event_notifier_buffer_size_userspace);
+       if (event_notifier_error_accounting_status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
+               ERR("Failed to initialize event notifier error accounting system");
+               retval = -1;
+               goto stop_threads;
+       }
 
        /*
         * Initialize agent app hash table. We allocate the hash table here
index f8dba15e7c4c3f7fa158b35bb09d67fd695db8f8..bf7b26cb484ffea047e8ef69001960ebe93f7fbf 100644 (file)
@@ -24,7 +24,8 @@ struct sessiond_config sessiond_config_build_defaults = {
        .verbose_consumer =                     0,
 
        .agent_tcp_port =                       { .begin = DEFAULT_AGENT_TCP_PORT_RANGE_BEGIN, .end = DEFAULT_AGENT_TCP_PORT_RANGE_END },
-       .event_notifier_error_counter_bucket =  DEFAULT_EVENT_NOTIFIER_ERROR_COUNT_MAP_SIZE,
+       .event_notifier_buffer_size_kernel =    DEFAULT_EVENT_NOTIFIER_ERROR_COUNT_MAP_SIZE,
+       .event_notifier_buffer_size_userspace = DEFAULT_EVENT_NOTIFIER_ERROR_COUNT_MAP_SIZE,
        .app_socket_timeout =                   DEFAULT_APP_SOCKET_RW_TIMEOUT,
 
        .no_kernel =                            false,
index 9369f4cc037de9265bed98f6e94eb9643230338e..a24a831f0f55899ef0c48db3238d88b293854549 100644 (file)
@@ -30,7 +30,8 @@ struct sessiond_config {
        /* Agent TCP port range for registration. Used by the agent thread. */
        struct config_int_range agent_tcp_port;
 
-       int event_notifier_error_counter_bucket;
+       int event_notifier_buffer_size_kernel;
+       int event_notifier_buffer_size_userspace;
        /* Socket timeout for receiving and sending (in seconds). */
        int app_socket_timeout;
 
index 36fc5c3392e06fdbb48a61ccd01a163d54073bf6..b0fce8aa8d59f722a469d6d08cb6fd6c7ffdd374 100755 (executable)
@@ -120,7 +120,7 @@ function test_kernel_notifier_discarded_count
 
 function test_kernel_notifier_discarded_count_max_bucket
 {
-       start_lttng_sessiond "" "--event-notifier-error-number-of-bucket=3"
+       start_lttng_sessiond "" "--event-notifier-error-buffer-size-kernel=3"
 
        diag "Kernel event notifer error counter bucket limit"
        for i in $(seq 3); do
@@ -239,7 +239,7 @@ function test_ust_notifier_discarded_count
 }
 function test_ust_notifier_discarded_count_max_bucket
 {
-       start_lttng_sessiond "" "--event-notifier-error-number-of-bucket=3"
+       start_lttng_sessiond "" "--event-notifier-error-buffer-size-userspace=3"
 
        diag "UST event notifer error counter bucket limit"
        for i in $(seq 3); do
This page took 0.056077 seconds and 4 git commands to generate.