goto counter_error;
}
- event_notifier_group->error_counter = counter;
event_notifier_group->error_counter_len = counter_len;
+ /*
+ * store-release to publish error counter matches load-acquire
+ * in record_error. Ensures the counter is created and the
+ * error_counter_len is set before they are used.
+ */
+ smp_store_release(&event_notifier_group->error_counter, counter);
counter->file = counter_file;
counter->owner = event_notifier_group->file;
{
struct lttng_event_notifier_group *event_notifier_group = event_notifier->group;
+ struct lttng_counter *error_counter;
size_t dimension_index[1];
int ret;
+ /*
+ * smp_load_acquire paired with smp_store_release orders
+ * creation of the error counter and setting error_counter_len
+ * before the error_counter is used.
+ */
+ error_counter = smp_load_acquire(&event_notifier_group->error_counter);
/* This group may not have an error counter attached to it. */
- if (!event_notifier_group->error_counter)
+ if (!error_counter)
return;
dimension_index[0] = event_notifier->error_counter_index;
- ret = event_notifier_group->error_counter->ops->counter_add(
- event_notifier_group->error_counter->counter,
+ ret = error_counter->ops->counter_add(error_counter->counter,
dimension_index, 1);
if (ret)
WARN_ON_ONCE(1);
if (event_notifier_group->error_counter) {
struct lttng_counter *error_counter = event_notifier_group->error_counter;
+
error_counter->ops->counter_destroy(error_counter->counter);
module_put(error_counter->transport->owner);
lttng_kvfree(error_counter);
void *filter, enum lttng_kernel_instrumentation itype)
{
struct lttng_event_notifier *event_notifier;
+ struct lttng_counter *error_counter;
const char *event_name;
struct hlist_head *head;
int ret;
/*
* Clear the error counter bucket. The sessiond keeps track of which
- * bucket is currently in use. We trust it.
+ * bucket is currently in use. We trust it. The session lock
+ * synchronizes against concurrent creation of the error
+ * counter.
*/
- if (event_notifier_group->error_counter) {
+ error_counter = event_notifier_group->error_counter;
+ if (error_counter) {
size_t dimension_index[1];
/*
}
dimension_index[0] = event_notifier->error_counter_index;
- ret = event_notifier_group->error_counter->ops->counter_clear(
- event_notifier_group->error_counter->counter,
- dimension_index);
+ ret = error_counter->ops->counter_clear(error_counter->counter, dimension_index);
if (ret) {
printk(KERN_INFO "LTTng: event_notifier: Unable to clear error counter bucket %llu\n",
event_notifier->error_counter_index);