Fix: change order of _cds_lfht_new_with_alloc parameters The "flavor" parameter should come before the "alloc" parameter to match the order of cds_lfht_new_with_flavor_alloc() parameters. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: Ia704a0fd9cb90af966464e25e6202fed1a952eed
Add support for custom memory allocators for rculfhash The current implementation of rculfhash relies on calloc() to allocate memory for its buckets. This can in some cases lead to latency spikes when accessing the hash table, which can be avoided by using an optimized custom memory allocator. However, there is currently no way of replacing the default allocator with a custom one. This commit allows custom allocators to be used during the table initialization. The default behavior of the hash table remains unaffected, by using the stdlib calloc() and free(), if no custom allocator is given. Signed-off-by: Xenofon Foukas <fon1989@gmail.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: Id9a405e5dc42e5564ff8623394c86056a4d1ff48
ppc.h: use mftb on ppc Older versions of GNU as do not support mftbl. The issue affects Darwin PowerPC, as well as some older versions of NetBSD and Linux. Since mftb is equivalent and universally understood, just use that. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: I098b70fa8bb077143d2d658835586b6b059b879f
rcutorture: Check histogram of ages Ensure that the histogram of ages for all threads are valid after a stress test. Change-Id: Iadc46f47fe8835ac0e2d8967b6a16a83335a9541 Signed-off-by: Olivier Dion <odion@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
docs: Add links to project resources Indicate that Gerrit (https://review.lttng.org) is the principal place where patches are submitted and reviewed, rather than the mailing list. Based on feedback received on the mailing list: https://lists.lttng.org/pipermail/lttng-dev/2023-November/030670.html Change-Id: I19f1459045355c57a1f9932a3b540807ba3d4a1c Signed-off-by: Kienan Stewart <kstewart@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix -Walloc-size GCC 14 introduces a new -Walloc-size included in -Wextra which gives: ``` urcu-call-rcu-impl.h:912:20: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion' with size '16' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] urcu-call-rcu-impl.h:927:22: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion_work' with size '24' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] urcu-call-rcu-impl.h:912:20: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion' with size '16' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] urcu-call-rcu-impl.h:927:22: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion_work' with size '24' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] urcu-call-rcu-impl.h:912:20: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion' with size '16' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] urcu-call-rcu-impl.h:927:22: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion_work' with size '24' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] urcu-call-rcu-impl.h:912:20: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion' with size '16' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] urcu-call-rcu-impl.h:927:22: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion_work' with size '24' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] urcu-call-rcu-impl.h:912:20: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion' with size '16' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] urcu-call-rcu-impl.h:927:22: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion_work' with size '24' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] workqueue.c:401:20: warning: allocation of insufficient size '1' for type 'struct urcu_workqueue_completion' with size '16' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] workqueue.c:432:14: warning: allocation of insufficient size '1' for type 'struct urcu_workqueue_completion_work' with size '24' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] urcu-call-rcu-impl.h:912:20: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion' with size '16' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] urcu-call-rcu-impl.h:927:22: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion_work' with size '24' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] qsbr.c:49:14: warning: allocation of insufficient size ‘1’ for type ‘struct mynode’ with size ‘40’ [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] mb.c:50:14: warning: allocation of insufficient size ‘1’ for type ‘struct mynode’ with size ‘40’ [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] membarrier.c:50:14: warning: allocation of insufficient size ‘1’ for type ‘struct mynode’ with size ‘40’ [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] signal.c:49:14: warning: allocation of insufficient size ‘1’ for type ‘struct mynode’ with size ‘40’ [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] bp.c:49:14: warning: allocation of insufficient size ‘1’ for type ‘struct mynode’ with size ‘40’ [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]] ``` The calloc prototype is: ``` void *calloc(size_t nmemb, size_t size); ``` So, just swap the number of members and size arguments to match the prototype, as we're initialising 1 struct of size `sizeof(struct ...)`. GCC then sees we're not doing anything wrong. Signed-off-by: Sam James <sam@gentoo.org> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: Id84ce5cf9a1b97bfa942597aa188ef6e27e7c10d
cleanup: use an enum for the error states of nr_cpus_mask Using an enum with labels for error states instead of literal values will make the code easier to read and understand. Change-Id: I4558e17ccb45ab40515bb516af840b2852ee8fc3 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
fix: add missing SPDX licensing tags Change-Id: If7016a3c83211e88c102f8b395dc290859af4789 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
urcu/uatomic/riscv: Mark RISC-V as broken Implementations of some atomic operations of GCC for RISC-V are insufficient for sequential consistency. For this reason Userspace RCU is currently marked as `broken' for RISC-V with GCC. However, it is still possible to use other toolchains. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104831 for details. For now, we mark every version of GCC as unsupported. Distribution package maintainers will have to cherry-pick the relevant patches in GCC then remove the #error in Userspace RCU if they want to support it. As for us, we will incrementally add specific versions of GCC that have fixed the issue whenever new stable releases are made from the GCC project. Change-Id: I2cd7c8f12068628b845a096e03f5f8100eacbe43 Signed-off-by: Olivier Dion <odion@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: urcu-bp: misaligned reader accesses This is a port from a fix in LTTng-UST's embedded urcu (d1a0fad8). The original message follows: Running the LTTng-tools tests (test_valid_filter, for example) under address sanitizer results in the following warning: /usr/include/lttng/urcu/static/urcu-ust.h:155:6: runtime error: member access within misaligned address 0x7fc45db3a020 for type 'struct lttng_ust_urcu_reader', which requires 128 byte alignment 0x7fc45db3a020: note: pointer points here c4 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ While the node member of lttng_ust_urcu_reader has an "aligned" attribute of CAA_CACHE_LINE_SIZE, the compiler can't ensure the alignment of members for dynamically allocated instances. The `data` pointer is changed from char* to struct lttng_ust_urcu_reader*, allowing the compiler to enforce the expected alignment constraints. Since `data` was addressed in bytes, the code using this field is adapted to use element counts. As the chunks are only used to allocate reader instances (and not other types), it makes the code a bit easier to read. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: I89ea1c32ca3c5c45621b562ab68f47a8428d3574
rculfhash: Only pass integral types to atomic builtins Clang expects the pointers passed to atomic builtins to be integral. Fix this by casting nodes address to uintptr_t *. Change-Id: Ifb8833c493df849a542a22f0bb2baeeb85be0297 Signed-off-by: Olivier Dion <odion@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
LoongArch: Document that byte and short atomics are implemented with LL/SC Based on the LoongArch Reference Manual: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html Section 2.2.7 "Atomic Memory Access Instructions" only lists atomic operations for 32-bit and 64-bit integers. As detailed in Section 2.2.7.1, LL/SC instructions operating on 32-bit and 64-bit integers are also available. Those are used by the compiler to support atomics on byte and short types. This means atomics on 32-bit and 64-bit types have stronger forward progress guarantees than those operating on 8-bit and 16-bit types. Link: https://github.com/urcu/userspace-rcu/pull/11#issuecomment-1706528796 Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: I01569b718f7300a46d984c34065c0bbfbd2f7cc6
Add LoongArch support This commit completes LoongArch support. LoongArch supports byte and short atomic operations, and defines UATOMIC_HAS_ATOMIC_BYTE and UATOMIC_HAS_ATOMIC_SHORT. Signed-off-by: Wang Jing <wangjing@loongson.cn> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: I335e654939bfc90994275f2a4fad550c95f3eba4
Tests: Add test for byte/short atomics on addresses which are not word-aligned Add a unit test to catch architectures which do not allow byte and short atomic operations on addresses which are not word aligned. If an architecture supports byte and short atomic operations, it should be valid to issue those operations on variables which are not word-aligned, otherwise the architecture should not define UATOMIC_HAS_ATOMIC_BYTE nor UATOMIC_HAS_ATOMIC_SHORT. This should help identify architectures which mistakenly define UATOMIC_HAS_ATOMIC_BYTE and UATOMIC_HAS_ATOMIC_SHORT. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: I13d2f3be41749b018b39499106938b3746c419c1
Complete removal of urcu-signal flavor This commit completes removal of the urcu-signal flavor. Users can migrate to liburcu-memb with a kernel implementing the membarrier(2) system call to have similar read-side performance without requiring use of a reserved signal, and with improved grace period performance. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: I75b9171e705b9b2ef4c8eeabe6164e5587816fb4
doc/examples: Remove urcu-signal example Remove the urcu-signal example from documentation. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: I6497855e63f39420cb1ffa44e07c2cbf5d39c791
tests/common: Remove urcu-signal common test files In preparation for deprecation of the urcu-signal flavor, remove the urcu-signal common test files. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: I1c4216a86cd4a4bde0ae81e44764e1d66e1d006f
tests/benchmark: Remove urcu-signal benchmark tests In preparation for deprecation of the urcu-signal flavor, remove the urcu-signal benchmark tests. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: I6824862353b8a14a244d2a882cf8a8cef2f48739
tests/regression: Remove urcu-signal regression tests In preparation for deprecation of the urcu-signal flavor, remove the urcu-signal regression tests. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: Ib452e758642d8777f9dc51535176487508692456