X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fevent-notifier-error-accounting.hpp;fp=src%2Fbin%2Flttng-sessiond%2Fevent-notifier-error-accounting.hpp;h=89466bd441605bf9b1336e289b92ac10b2105843;hp=0000000000000000000000000000000000000000;hb=c9e313bc594f40a86eed237dce222c0fc99c957f;hpb=4878de5c7deb512bbdac4fdfc498907efa06fb7c diff --git a/src/bin/lttng-sessiond/event-notifier-error-accounting.hpp b/src/bin/lttng-sessiond/event-notifier-error-accounting.hpp new file mode 100644 index 000000000..89466bd44 --- /dev/null +++ b/src/bin/lttng-sessiond/event-notifier-error-accounting.hpp @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2020 Francis Deslauriers + * + * SPDX-License-Identifier: GPL-2.0-only + * + */ + +#ifndef _EVENT_NOTIFIER_ERROR_ACCOUNTING_H +#define _EVENT_NOTIFIER_ERROR_ACCOUNTING_H + +#include + +#include + +#include "ust-app.hpp" + +enum event_notifier_error_accounting_status { + EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK, + EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_ERR, + EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOT_FOUND, + EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOMEM, + EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NO_INDEX_AVAILABLE, + EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_APP_DEAD, + EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_UNSUPPORTED, +}; + +/* + * 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 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 */ + +static inline +enum event_notifier_error_accounting_status +event_notifier_error_accounting_register_app( + struct ust_app *app __attribute__((unused))) +{ + return EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK; +} + +static inline +enum event_notifier_error_accounting_status +event_notifier_error_accounting_unregister_app( + struct ust_app *app __attribute__((unused))) +{ + return EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK; +} +#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, + uint64_t *error_counter_index); + +enum event_notifier_error_accounting_status +event_notifier_error_accounting_get_count( + const struct lttng_trigger *trigger, + uint64_t *count); + +void event_notifier_error_accounting_unregister_event_notifier( + const struct lttng_trigger *trigger); + +void event_notifier_error_accounting_fini(void); + +#endif /* _EVENT_NOTIFIER_ERROR_ACCOUNTING_H */