X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Flttng-syscall.cpp;h=821bbaa34f80b6e1c6d572192909c0ec0257aab2;hb=56047f5a23df5c2c583a102b8015bbec5a7da9f1;hp=3f09090cb37a6821fe61e6a1de68e3a049c46467;hpb=28ab034a2c3582d07d3423d2d746731f87d3969f;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/lttng-syscall.cpp b/src/bin/lttng-sessiond/lttng-syscall.cpp index 3f09090cb..821bbaa34 100644 --- a/src/bin/lttng-sessiond/lttng-syscall.cpp +++ b/src/bin/lttng-sessiond/lttng-syscall.cpp @@ -13,6 +13,7 @@ #include #include +#include #include @@ -85,7 +86,7 @@ int syscall_init_table(int tracer_fd) /* Overflow, stop everything, something went really wrong. */ ERR("Syscall listing memory size overflow. Stopping"); free(syscall_table); - syscall_table = NULL; + syscall_table = nullptr; ret = -EINVAL; goto error; } @@ -110,7 +111,7 @@ int syscall_init_table(int tracer_fd) syscall_table[index].name, name, sizeof(syscall_table[index].name))) { ret = -EINVAL; free(syscall_table); - syscall_table = NULL; + syscall_table = nullptr; goto error; } /* @@ -150,28 +151,31 @@ error_ioctl: * 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); } @@ -197,13 +201,15 @@ static int init_syscall_ht(struct lttng_ht **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) { struct lttng_ht_node_str *node; struct lttng_ht_iter iter; - struct syscall *ksyscall = NULL; + struct syscall *ksyscall = nullptr; LTTNG_ASSERT(ht); LTTNG_ASSERT(name); @@ -277,14 +283,12 @@ ssize_t syscall_table_list(struct lttng_event **_events) ssize_t ret; struct lttng_event *events; /* Hash table used to filter duplicate out. */ - struct lttng_ht *syscalls_ht = NULL; + struct lttng_ht *syscalls_ht = nullptr; LTTNG_ASSERT(_events); 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 @@ -303,17 +307,20 @@ ssize_t syscall_table_list(struct lttng_event **_events) } 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); @@ -332,12 +339,10 @@ ssize_t syscall_table_list(struct lttng_event **_events) 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; }