projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
.clang-tidy: remove modernize-concat-nested-namespaces
[lttng-tools.git]
/
src
/
bin
/
lttng-sessiond
/
event-notifier-error-accounting.cpp
diff --git
a/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp
b/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp
index 93ecca853af7a4ecdf76f841f499d7a9072273a1..7fa54bc93080b54c361306ca3405b580f8b58f07 100644
(file)
--- a/
src/bin/lttng-sessiond/event-notifier-error-accounting.cpp
+++ b/
src/bin/lttng-sessiond/event-notifier-error-accounting.cpp
@@
-14,6
+14,7
@@
#include <common/index-allocator.hpp>
#include <common/kernel-ctl/kernel-ctl.hpp>
#include <common/shm.hpp>
#include <common/index-allocator.hpp>
#include <common/kernel-ctl/kernel-ctl.hpp>
#include <common/shm.hpp>
+#include <common/urcu.hpp>
#include <lttng/trigger/trigger-internal.hpp>
#include <lttng/trigger/trigger-internal.hpp>
@@
-154,10
+155,9
@@
static void ust_error_accounting_entry_release(struct urcu_ref *entry_ref)
struct ust_error_accounting_entry *entry =
lttng::utils::container_of(entry_ref, &ust_error_accounting_entry::ref);
struct ust_error_accounting_entry *entry =
lttng::utils::container_of(entry_ref, &ust_error_accounting_entry::ref);
-
rcu_read_lock()
;
+
lttng::urcu::read_lock_guard read_lock
;
cds_lfht_del(error_counter_uid_ht->ht, &entry->node.node);
call_rcu(&entry->rcu_head, free_ust_error_accounting_entry);
cds_lfht_del(error_counter_uid_ht->ht, &entry->node.node);
call_rcu(&entry->rcu_head, free_ust_error_accounting_entry);
- rcu_read_unlock();
}
static void ust_error_accounting_entry_put(struct ust_error_accounting_entry *entry)
}
static void ust_error_accounting_entry_put(struct ust_error_accounting_entry *entry)
@@
-172,37
+172,41
@@
static void ust_error_accounting_entry_put(struct ust_error_accounting_entry *en
/*
* Put one reference to every UID entries.
*/
/*
* Put one reference to every UID entries.
*/
-static void put_ref_all_ust_error_accounting_entry(
void
)
+static void put_ref_all_ust_error_accounting_entry()
{
struct lttng_ht_iter iter;
struct ust_error_accounting_entry *uid_entry;
ASSERT_LOCKED(the_event_notifier_counter.lock);
{
struct lttng_ht_iter iter;
struct ust_error_accounting_entry *uid_entry;
ASSERT_LOCKED(the_event_notifier_counter.lock);
- rcu_read_lock();
- cds_lfht_for_each_entry (error_counter_uid_ht->ht, &iter.iter, uid_entry, node.node) {
- ust_error_accounting_entry_put(uid_entry);
- }
+ {
+ lttng::urcu::read_lock_guard read_lock;
- rcu_read_unlock();
+ cds_lfht_for_each_entry (
+ error_counter_uid_ht->ht, &iter.iter, uid_entry, node.node) {
+ ust_error_accounting_entry_put(uid_entry);
+ }
+ }
}
/*
* Get one reference to every UID entries.
*/
}
/*
* Get one reference to every UID entries.
*/
-static void get_ref_all_ust_error_accounting_entry(
void
)
+static void get_ref_all_ust_error_accounting_entry()
{
struct lttng_ht_iter iter;
struct ust_error_accounting_entry *uid_entry;
ASSERT_LOCKED(the_event_notifier_counter.lock);
{
struct lttng_ht_iter iter;
struct ust_error_accounting_entry *uid_entry;
ASSERT_LOCKED(the_event_notifier_counter.lock);
- rcu_read_lock();
- cds_lfht_for_each_entry (error_counter_uid_ht->ht, &iter.iter, uid_entry, node.node) {
- ust_error_accounting_entry_get(uid_entry);
- }
+ {
+ lttng::urcu::read_lock_guard read_lock;
- rcu_read_unlock();
+ cds_lfht_for_each_entry (
+ error_counter_uid_ht->ht, &iter.iter, uid_entry, node.node) {
+ ust_error_accounting_entry_get(uid_entry);
+ }
+ }
}
#endif /* HAVE_LIBLTTNG_UST_CTL */
}
#endif /* HAVE_LIBLTTNG_UST_CTL */
@@
-235,7
+239,7
@@
init_error_accounting_state(struct error_accounting_state *state, uint64_t index
error_indices_ht:
lttng_index_allocator_destroy(state->index_allocator);
error_indices_ht:
lttng_index_allocator_destroy(state->index_allocator);
- state->index_allocator =
NULL
;
+ state->index_allocator =
nullptr
;
end:
return status;
}
end:
return status;
}
@@
-300,8
+304,8
@@
static enum event_notifier_error_accounting_status get_error_counter_index_for_t
struct lttng_ht_iter iter;
const struct index_ht_entry *index_entry;
enum event_notifier_error_accounting_status status;
struct lttng_ht_iter iter;
const struct index_ht_entry *index_entry;
enum event_notifier_error_accounting_status status;
+ lttng::urcu::read_lock_guard read_guard;
- rcu_read_lock();
lttng_ht_lookup(state->indices_ht, &tracer_token, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
if (node) {
lttng_ht_lookup(state->indices_ht, &tracer_token, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
if (node) {
@@
-312,7
+316,6
@@
static enum event_notifier_error_accounting_status get_error_counter_index_for_t
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOT_FOUND;
}
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOT_FOUND;
}
- rcu_read_unlock();
return status;
}
return status;
}
@@
-331,8
+334,8
@@
static struct ust_error_accounting_entry *ust_error_accounting_entry_find(struct
lttng_ht_lookup(uid_ht, &key, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
lttng_ht_lookup(uid_ht, &key, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
- if (node ==
NULL
) {
- entry =
NULL
;
+ if (node ==
nullptr
) {
+ entry =
nullptr
;
} else {
bool got_ref;
} else {
bool got_ref;
@@
-340,7
+343,7
@@
static struct ust_error_accounting_entry *ust_error_accounting_entry_find(struct
got_ref = ust_error_accounting_entry_get(entry);
if (!got_ref) {
got_ref = ust_error_accounting_entry_get(entry);
if (!got_ref) {
- entry =
NULL
;
+ entry =
nullptr
;
}
}
}
}
@@
-354,10
+357,10
@@
static struct ust_error_accounting_entry *ust_error_accounting_entry_find(struct
static struct ust_error_accounting_entry *
ust_error_accounting_entry_create(const struct ust_app *app)
{
static struct ust_error_accounting_entry *
ust_error_accounting_entry_create(const struct ust_app *app)
{
- int i, ret, *cpu_counter_fds =
NULL
;
+ int i, ret, *cpu_counter_fds =
nullptr
;
struct lttng_ust_ctl_daemon_counter *daemon_counter;
struct lttng_ust_abi_object_data *counter, **cpu_counters;
struct lttng_ust_ctl_daemon_counter *daemon_counter;
struct lttng_ust_abi_object_data *counter, **cpu_counters;
- struct ust_error_accounting_entry *entry =
NULL
;
+ struct ust_error_accounting_entry *entry =
nullptr
;
lttng_ust_ctl_counter_dimension dimension = {};
dimension.size = ust_state.number_indices;
lttng_ust_ctl_counter_dimension dimension = {};
dimension.size = ust_state.number_indices;
@@
-508,7
+511,7
@@
error_counter_cpus_alloc:
error_counter_cpu_fds_alloc:
free(entry);
error:
error_counter_cpu_fds_alloc:
free(entry);
error:
- entry =
NULL
;
+ entry =
nullptr
;
end:
free(cpu_counter_fds);
return entry;
end:
free(cpu_counter_fds);
return entry;
@@
-591,6
+594,7
@@
event_notifier_error_accounting_register_app(struct ust_app *app)
struct ust_error_accounting_entry *entry;
enum event_notifier_error_accounting_status status;
struct lttng_ust_abi_object_data **cpu_counters;
struct ust_error_accounting_entry *entry;
enum event_notifier_error_accounting_status status;
struct lttng_ust_abi_object_data **cpu_counters;
+ lttng::urcu::read_lock_guard read_lock;
if (!ust_app_supports_counters(app)) {
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_UNSUPPORTED;
if (!ust_app_supports_counters(app)) {
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_UNSUPPORTED;
@@
-601,9
+605,8
@@
event_notifier_error_accounting_register_app(struct ust_app *app)
* Check if we already have a error counter for the user id of this
* app. If not, create one.
*/
* Check if we already have a error counter for the user id of this
* app. If not, create one.
*/
- rcu_read_lock();
entry = ust_error_accounting_entry_find(error_counter_uid_ht, app);
entry = ust_error_accounting_entry_find(error_counter_uid_ht, app);
- if (entry ==
NULL
) {
+ if (entry ==
nullptr
) {
/*
* Take the event notifier counter lock before creating the new
* entry to ensure that no event notifier is registered between
/*
* Take the event notifier counter lock before creating the new
* entry to ensure that no event notifier is registered between
@@
-668,7
+671,7
@@
event_notifier_error_accounting_register_app(struct ust_app *app)
}
for (i = 0; i < entry->nr_counter_cpu_fds; i++) {
}
for (i = 0; i < entry->nr_counter_cpu_fds; i++) {
- struct lttng_ust_abi_object_data *new_counter_cpu =
NULL
;
+ struct lttng_ust_abi_object_data *new_counter_cpu =
nullptr
;
ret = lttng_ust_ctl_duplicate_ust_object_data(&new_counter_cpu,
entry->cpu_counters[i]);
ret = lttng_ust_ctl_duplicate_ust_object_data(&new_counter_cpu,
entry->cpu_counters[i]);
@@
-700,11
+703,11
@@
event_notifier_error_accounting_register_app(struct ust_app *app)
}
app->event_notifier_group.counter = new_counter;
}
app->event_notifier_group.counter = new_counter;
- new_counter =
NULL
;
+ new_counter =
nullptr
;
app->event_notifier_group.nr_counter_cpu = entry->nr_counter_cpu_fds;
app->event_notifier_group.counter_cpu = cpu_counters;
app->event_notifier_group.nr_counter_cpu = entry->nr_counter_cpu_fds;
app->event_notifier_group.counter_cpu = cpu_counters;
- cpu_counters =
NULL
;
- goto end
_unlock
;
+ cpu_counters =
nullptr
;
+ goto end;
error_send_cpu_counter_data:
error_duplicate_cpu_counter:
error_send_cpu_counter_data:
error_duplicate_cpu_counter:
@@
-731,9
+734,7
@@
error_send_counter_data:
error_duplicate_counter:
ust_error_accounting_entry_put(entry);
error_creating_entry:
error_duplicate_counter:
ust_error_accounting_entry_put(entry);
error_creating_entry:
- app->event_notifier_group.counter = NULL;
-end_unlock:
- rcu_read_unlock();
+ app->event_notifier_group.counter = nullptr;
end:
return status;
}
end:
return status;
}
@@
-745,7
+746,7
@@
event_notifier_error_accounting_unregister_app(struct ust_app *app)
struct ust_error_accounting_entry *entry;
int i;
struct ust_error_accounting_entry *entry;
int i;
-
rcu_read_lock()
;
+
lttng::urcu::read_lock_guard read_lock
;
/* If an error occurred during app registration no entry was created. */
if (!app->event_notifier_group.counter) {
/* If an error occurred during app registration no entry was created. */
if (!app->event_notifier_group.counter) {
@@
-754,7
+755,7
@@
event_notifier_error_accounting_unregister_app(struct ust_app *app)
}
entry = ust_error_accounting_entry_find(error_counter_uid_ht, app);
}
entry = ust_error_accounting_entry_find(error_counter_uid_ht, app);
- if (entry ==
NULL
) {
+ if (entry ==
nullptr
) {
ERR("Failed to find event notitifier error accounting entry on application teardown: pid = %d, application name = '%s'",
app->pid,
app->name);
ERR("Failed to find event notitifier error accounting entry on application teardown: pid = %d, application name = '%s'",
app->pid,
app->name);
@@
-781,7
+782,6
@@
event_notifier_error_accounting_unregister_app(struct ust_app *app)
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
end:
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
end:
- rcu_read_unlock();
return status;
}
return status;
}
@@
-797,7
+797,7
@@
event_notifier_error_accounting_ust_get_count(const struct lttng_trigger *trigge
uid_t trigger_owner_uid;
const char *trigger_name;
uid_t trigger_owner_uid;
const char *trigger_name;
-
rcu_read_lock()
;
+
lttng::urcu::read_lock_guard read_lock
;
get_trigger_info_for_log(trigger, &trigger_name, &trigger_owner_uid);
get_trigger_info_for_log(trigger, &trigger_name, &trigger_owner_uid);
@@
-857,7
+857,6
@@
event_notifier_error_accounting_ust_get_count(const struct lttng_trigger *trigge
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
end:
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
end:
- rcu_read_unlock();
return status;
}
return status;
}
@@
-871,7
+870,8
@@
event_notifier_error_accounting_ust_clear(const struct lttng_trigger *trigger)
size_t dimension_index;
const uint64_t tracer_token = lttng_trigger_get_tracer_token(trigger);
size_t dimension_index;
const uint64_t tracer_token = lttng_trigger_get_tracer_token(trigger);
- rcu_read_lock();
+ lttng::urcu::read_lock_guard read_lock;
+
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;
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;
@@
-915,7
+915,6
@@
event_notifier_error_accounting_ust_clear(const struct lttng_trigger *trigger)
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
end:
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
end:
- rcu_read_unlock();
return status;
}
#endif /* HAVE_LIBLTTNG_UST_CTL */
return status;
}
#endif /* HAVE_LIBLTTNG_UST_CTL */
@@
-1042,7
+1041,7
@@
static enum event_notifier_error_accounting_status create_error_counter_index_fo
}
index_entry = zmalloc<index_ht_entry>();
}
index_entry = zmalloc<index_ht_entry>();
- if (index_entry ==
NULL
) {
+ if (index_entry ==
nullptr
) {
PERROR("Failed to allocate event notifier error counter hash table entry");
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOMEM;
goto end;
PERROR("Failed to allocate event notifier error counter hash table entry");
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOMEM;
goto end;
@@
-1262,6
+1261,8
@@
void event_notifier_error_accounting_unregister_event_notifier(const struct lttn
enum event_notifier_error_accounting_status status;
struct error_accounting_state *state;
enum event_notifier_error_accounting_status status;
struct error_accounting_state *state;
+ lttng::urcu::read_lock_guard read_lock;
+
status = event_notifier_error_accounting_clear(trigger);
if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
/* Trigger details already logged by callee on error. */
status = event_notifier_error_accounting_clear(trigger);
if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
/* Trigger details already logged by callee on error. */
@@
-1270,8
+1271,6
@@
void event_notifier_error_accounting_unregister_event_notifier(const struct lttn
goto end;
}
goto end;
}
- rcu_read_lock();
-
switch (lttng_trigger_get_underlying_domain_type_restriction(trigger)) {
case LTTNG_DOMAIN_KERNEL:
state = &kernel_state;
switch (lttng_trigger_get_underlying_domain_type_restriction(trigger)) {
case LTTNG_DOMAIN_KERNEL:
state = &kernel_state;
@@
-1330,12
+1329,11
@@
void event_notifier_error_accounting_unregister_event_notifier(const struct lttn
LTTNG_ASSERT(!del_ret);
call_rcu(&index_entry->rcu_head, free_index_ht_entry);
}
LTTNG_ASSERT(!del_ret);
call_rcu(&index_entry->rcu_head, free_index_ht_entry);
}
-
end:
end:
- r
cu_read_unlock()
;
+ r
eturn
;
}
}
-void event_notifier_error_accounting_fini(
void
)
+void event_notifier_error_accounting_fini()
{
if (kernel_error_accounting_entry.error_counter_fd) {
const int ret = close(kernel_error_accounting_entry.error_counter_fd);
{
if (kernel_error_accounting_entry.error_counter_fd) {
const int ret = close(kernel_error_accounting_entry.error_counter_fd);
This page took
0.028234 seconds
and
4
git commands to generate.