#include <common/common.hpp>
#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/urcu.hpp>
#include <stdbool.h>
* syscall hashtable used to track duplicate between 32 and 64 bit arch.
*
* This empty the hash table and destroys it after. After this, the pointer is
- * unsuable. RCU read side lock MUST be acquired before calling this.
+ * unsuable. RCU read side lock MUST NOT be acquired before calling this.
*/
static void destroy_syscall_ht(struct lttng_ht *ht)
{
struct lttng_ht_iter iter;
struct syscall *ksyscall;
- ASSERT_RCU_READ_LOCKED();
-
DBG3("Destroying syscall hash table.");
if (!ht) {
return;
}
- cds_lfht_for_each_entry (ht->ht, &iter.iter, ksyscall, node.node) {
- int ret;
+ {
+ lttng::urcu::read_lock_guard read_lock;
+
+ cds_lfht_for_each_entry (ht->ht, &iter.iter, ksyscall, node.node) {
+ int ret;
- ret = lttng_ht_del(ht, &iter);
- LTTNG_ASSERT(!ret);
- free(ksyscall);
+ ret = lttng_ht_del(ht, &iter);
+ LTTNG_ASSERT(!ret);
+ free(ksyscall);
+ }
}
+
lttng_ht_destroy(ht);
}
/*
* Lookup a syscall in the given hash table by name.
*
+ * RCU read lock MUST be acquired by the callers of this function.
+ *
* Return syscall object if found or else NULL.
*/
static struct syscall *lookup_syscall(struct lttng_ht *ht, const char *name)
DBG("Syscall table listing.");
- rcu_read_lock();
-
/*
* Allocate at least the number of total syscall we have even if some of
* them might not be valid. The count below will make sure to return the
}
for (i = 0; i < syscall_table_nb_entry; i++) {
- struct syscall *ksyscall;
-
/* Skip empty syscalls. */
if (*syscall_table[i].name == '\0') {
continue;
}
- ksyscall = lookup_syscall(syscalls_ht, syscall_table[i].name);
- if (ksyscall) {
- update_event_syscall_bitness(events, i, ksyscall->index);
- continue;
+ {
+ lttng::urcu::read_lock_guard read_lock;
+ struct syscall *ksyscall;
+
+ ksyscall = lookup_syscall(syscalls_ht, syscall_table[i].name);
+ if (ksyscall) {
+ update_event_syscall_bitness(events, i, ksyscall->index);
+ continue;
+ }
}
ret = add_syscall_to_ht(syscalls_ht, i, index);
destroy_syscall_ht(syscalls_ht);
*_events = events;
- rcu_read_unlock();
return index;
error:
destroy_syscall_ht(syscalls_ht);
free(events);
- rcu_read_unlock();
return ret;
}