From 8361c6ccfe5b5bf971505ea6fe76e9dfb05e0413 Mon Sep 17 00:00:00 2001 From: christos Date: Fri, 17 Jan 2025 16:00:46 +0000 Subject: [PATCH] Import userspace-rcu-0.15.0 from https://liburcu.org/ needed by bind-9.20.4. This is a userspace implentation of the read/copy/update synchronization mechanism described in https://docs.kernel.org/RCU/whatisRCU.html. --- external/lgpl2/userspace-rcu/dist/.gitreview | 11 + external/lgpl2/userspace-rcu/dist/ChangeLog | 1053 ++++++++ .../lgpl2/userspace-rcu/dist/CodingStyle.md | 16 + external/lgpl2/userspace-rcu/dist/LICENSE.md | 64 + .../dist/LICENSES/Autoconf-exception-2.0.txt | 5 + .../dist/LICENSES/BSD-2-Clause.txt | 9 + .../userspace-rcu/dist/LICENSES/CC-BY-4.0.txt | 156 ++ .../userspace-rcu/dist/LICENSES/CC0-1.0.txt | 121 + .../userspace-rcu/dist/LICENSES/FSFAP.txt | 1 + .../dist/LICENSES/GPL-2.0-only.txt | 117 + .../dist/LICENSES/GPL-2.0-or-later.txt | 117 + .../dist/LICENSES/GPL-3.0-or-later.txt | 232 ++ .../dist/LICENSES/LGPL-2.1-only.txt | 175 ++ .../dist/LICENSES/LGPL-2.1-or-later.txt | 175 ++ .../LicenseRef-Autoconf-exception-macro.txt | 12 + .../dist/LICENSES/LicenseRef-Boehm-GC.txt | 12 + .../lgpl2/userspace-rcu/dist/LICENSES/MIT.txt | 9 + external/lgpl2/userspace-rcu/dist/Makefile.am | 37 + external/lgpl2/userspace-rcu/dist/README.md | 493 ++++ external/lgpl2/userspace-rcu/dist/bootstrap | 12 + .../lgpl2/userspace-rcu/dist/configure.ac | 413 +++ .../lgpl2/userspace-rcu/dist/doc/Makefile.am | 10 + .../lgpl2/userspace-rcu/dist/doc/cds-api.md | 90 + .../dist/doc/examples/Makefile.am | 155 ++ .../doc/examples/Makefile.examples.template | 26 + .../dist/doc/examples/dist-files/Makefile | 26 + .../dist/doc/examples/hlist/Makefile | 18 + .../hlist/Makefile.cds_hlist_add_head_rcu | 14 + .../examples/hlist/Makefile.cds_hlist_del_rcu | 14 + .../Makefile.cds_hlist_for_each_entry_rcu | 14 + .../hlist/Makefile.cds_hlist_for_each_rcu | 14 + .../examples/hlist/cds_hlist_add_head_rcu.c | 57 + .../doc/examples/hlist/cds_hlist_del_rcu.c | 83 + .../hlist/cds_hlist_for_each_entry_rcu.c | 77 + .../examples/hlist/cds_hlist_for_each_rcu.c | 84 + .../dist/doc/examples/lfstack/Makefile | 16 + .../lfstack/Makefile.cds_lfs_pop_all_blocking | 14 + .../lfstack/Makefile.cds_lfs_pop_blocking | 14 + .../examples/lfstack/Makefile.cds_lfs_push | 14 + .../lfstack/cds_lfs_pop_all_blocking.c | 73 + .../examples/lfstack/cds_lfs_pop_blocking.c | 69 + .../dist/doc/examples/lfstack/cds_lfs_push.c | 66 + .../dist/doc/examples/list/Makefile | 22 + .../examples/list/Makefile.cds_list_add_rcu | 14 + .../list/Makefile.cds_list_add_tail_rcu | 14 + .../examples/list/Makefile.cds_list_del_rcu | 14 + .../list/Makefile.cds_list_for_each_entry_rcu | 14 + .../list/Makefile.cds_list_for_each_rcu | 14 + .../list/Makefile.cds_list_replace_rcu | 14 + .../dist/doc/examples/list/cds_list_add_rcu.c | 57 + .../doc/examples/list/cds_list_add_tail_rcu.c | 57 + .../dist/doc/examples/list/cds_list_del_rcu.c | 83 + .../list/cds_list_for_each_entry_rcu.c | 77 + .../doc/examples/list/cds_list_for_each_rcu.c | 83 + .../doc/examples/list/cds_list_replace_rcu.c | 87 + .../dist/doc/examples/rculfhash/Makefile | 24 + .../examples/rculfhash/Makefile.cds_lfht_add | 15 + .../rculfhash/Makefile.cds_lfht_add_replace | 15 + .../rculfhash/Makefile.cds_lfht_add_unique | 15 + .../examples/rculfhash/Makefile.cds_lfht_del | 15 + .../rculfhash/Makefile.cds_lfht_destroy | 15 + ...Makefile.cds_lfht_for_each_entry_duplicate | 15 + .../rculfhash/Makefile.cds_lfht_lookup | 15 + .../doc/examples/rculfhash/cds_lfht_add.c | 99 + .../examples/rculfhash/cds_lfht_add_replace.c | 140 + .../examples/rculfhash/cds_lfht_add_unique.c | 137 + .../doc/examples/rculfhash/cds_lfht_del.c | 161 ++ .../doc/examples/rculfhash/cds_lfht_destroy.c | 142 + .../cds_lfht_for_each_entry_duplicate.c | 136 + .../doc/examples/rculfhash/cds_lfht_lookup.c | 140 + .../dist/doc/examples/rculfhash/jhash.h | 251 ++ .../dist/doc/examples/rculfqueue/Makefile | 14 + .../rculfqueue/Makefile.cds_lfq_dequeue | 14 + .../rculfqueue/Makefile.cds_lfq_enqueue | 14 + .../doc/examples/rculfqueue/cds_lfq_dequeue.c | 108 + .../doc/examples/rculfqueue/cds_lfq_enqueue.c | 66 + .../dist/doc/examples/urcu-flavors/Makefile | 18 + .../doc/examples/urcu-flavors/Makefile.bp | 14 + .../doc/examples/urcu-flavors/Makefile.mb | 14 + .../examples/urcu-flavors/Makefile.membarrier | 14 + .../doc/examples/urcu-flavors/Makefile.qsbr | 14 + .../dist/doc/examples/urcu-flavors/bp.c | 101 + .../dist/doc/examples/urcu-flavors/mb.c | 126 + .../doc/examples/urcu-flavors/membarrier.c | 126 + .../dist/doc/examples/urcu-flavors/qsbr.c | 135 + .../dist/doc/examples/wfcqueue/Makefile | 16 + .../wfcqueue/Makefile.cds_wfcq_dequeue | 14 + .../wfcqueue/Makefile.cds_wfcq_enqueue | 14 + .../wfcqueue/Makefile.cds_wfcq_splice | 14 + .../doc/examples/wfcqueue/cds_wfcq_dequeue.c | 73 + .../doc/examples/wfcqueue/cds_wfcq_enqueue.c | 66 + .../doc/examples/wfcqueue/cds_wfcq_splice.c | 103 + .../dist/doc/examples/wfstack/Makefile | 16 + .../doc/examples/wfstack/Makefile.cds_wfs_pop | 14 + .../wfstack/Makefile.cds_wfs_pop_all_blocking | 14 + .../examples/wfstack/Makefile.cds_wfs_push | 14 + .../dist/doc/examples/wfstack/cds_wfs_pop.c | 69 + .../wfstack/cds_wfs_pop_all_blocking.c | 73 + .../dist/doc/examples/wfstack/cds_wfs_push.c | 66 + .../lgpl2/userspace-rcu/dist/doc/rcu-api.md | 273 ++ .../userspace-rcu/dist/doc/solaris-build.md | 75 + .../userspace-rcu/dist/doc/uatomic-api.md | 131 + .../userspace-rcu/dist/extras/Makefile.am | 6 + .../x86_64-pc-linux-gnu/liburcu-bp.so.6.xml | 900 +++++++ .../x86_64-pc-linux-gnu/liburcu-cds.so.6.xml | 1493 +++++++++++ .../liburcu-common.so.6.xml | 910 +++++++ .../x86_64-pc-linux-gnu/liburcu-mb.so.6.xml | 851 ++++++ .../x86_64-pc-linux-gnu/liburcu-qsbr.so.6.xml | 872 ++++++ .../liburcu-signal.so.6.xml | 858 ++++++ .../0.10/x86_64-pc-linux-gnu/liburcu.so.6.xml | 855 ++++++ .../x86_64-pc-linux-gnu/liburcu-bp.so.6.xml | 978 +++++++ .../x86_64-pc-linux-gnu/liburcu-cds.so.6.xml | 1480 +++++++++++ .../liburcu-common.so.6.xml | 910 +++++++ .../x86_64-pc-linux-gnu/liburcu-mb.so.6.xml | 919 +++++++ .../x86_64-pc-linux-gnu/liburcu-memb.so.6.xml | 925 +++++++ .../x86_64-pc-linux-gnu/liburcu-qsbr.so.6.xml | 946 +++++++ .../liburcu-signal.so.6.xml | 928 +++++++ .../0.11/x86_64-pc-linux-gnu/liburcu.so.6.xml | 925 +++++++ .../x86_64-pc-linux-gnu/liburcu-bp.so.6.xml | 985 +++++++ .../x86_64-pc-linux-gnu/liburcu-cds.so.6.xml | 1484 +++++++++++ .../liburcu-common.so.6.xml | 910 +++++++ .../x86_64-pc-linux-gnu/liburcu-mb.so.6.xml | 919 +++++++ .../x86_64-pc-linux-gnu/liburcu-memb.so.6.xml | 925 +++++++ .../x86_64-pc-linux-gnu/liburcu-qsbr.so.6.xml | 946 +++++++ .../liburcu-signal.so.6.xml | 928 +++++++ .../0.12/x86_64-pc-linux-gnu/liburcu.so.6.xml | 925 +++++++ .../x86_64-pc-linux-gnu/liburcu-bp.so.8.xml | 907 +++++++ .../x86_64-pc-linux-gnu/liburcu-cds.so.8.xml | 1484 +++++++++++ .../liburcu-common.so.8.xml | 910 +++++++ .../x86_64-pc-linux-gnu/liburcu-mb.so.8.xml | 851 ++++++ .../x86_64-pc-linux-gnu/liburcu-memb.so.8.xml | 855 ++++++ .../x86_64-pc-linux-gnu/liburcu-qsbr.so.8.xml | 872 ++++++ .../liburcu-signal.so.8.xml | 858 ++++++ .../0.13/x86_64-pc-linux-gnu/liburcu.so.8.xml | 855 ++++++ .../x86_64-pc-linux-gnu/liburcu-bp.so.8.xml | 907 +++++++ .../x86_64-pc-linux-gnu/liburcu-cds.so.8.xml | 1493 +++++++++++ .../liburcu-common.so.8.xml | 910 +++++++ .../x86_64-pc-linux-gnu/liburcu-mb.so.8.xml | 851 ++++++ .../x86_64-pc-linux-gnu/liburcu-memb.so.8.xml | 855 ++++++ .../x86_64-pc-linux-gnu/liburcu-qsbr.so.8.xml | 872 ++++++ .../liburcu-signal.so.8.xml | 858 ++++++ .../0.14/x86_64-pc-linux-gnu/liburcu.so.8.xml | 855 ++++++ .../x86_64-pc-linux-gnu/liburcu-bp.so.4.xml | 841 ++++++ .../x86_64-pc-linux-gnu/liburcu-cds.so.4.xml | 1187 +++++++++ .../liburcu-common.so.4.xml | 906 +++++++ .../x86_64-pc-linux-gnu/liburcu-mb.so.4.xml | 792 ++++++ .../x86_64-pc-linux-gnu/liburcu-qsbr.so.4.xml | 813 ++++++ .../liburcu-signal.so.4.xml | 799 ++++++ .../0.9/x86_64-pc-linux-gnu/liburcu.so.4.xml | 796 ++++++ .../userspace-rcu/dist/extras/abi/README.md | 24 + .../userspace-rcu/dist/extras/abi/dump_abi.sh | 33 + .../userspace-rcu/dist/include/Makefile.am | 110 + .../userspace-rcu/dist/include/urcu-bp.h | 6 + .../dist/include/urcu-call-rcu.h | 5 + .../userspace-rcu/dist/include/urcu-defer.h | 5 + .../userspace-rcu/dist/include/urcu-flavor.h | 5 + .../userspace-rcu/dist/include/urcu-pointer.h | 5 + .../userspace-rcu/dist/include/urcu-qsbr.h | 6 + .../lgpl2/userspace-rcu/dist/include/urcu.h | 6 + .../dist/include/urcu/annotate.h | 163 ++ .../userspace-rcu/dist/include/urcu/arch.h | 171 ++ .../dist/include/urcu/arch/aarch64.h | 58 + .../dist/include/urcu/arch/alpha.h | 38 + .../dist/include/urcu/arch/arm.h | 85 + .../dist/include/urcu/arch/gcc.h | 30 + .../dist/include/urcu/arch/generic.h | 248 ++ .../dist/include/urcu/arch/hppa.h | 48 + .../dist/include/urcu/arch/ia64.h | 38 + .../dist/include/urcu/arch/loongarch.h | 37 + .../dist/include/urcu/arch/m68k.h | 37 + .../dist/include/urcu/arch/mips.h | 33 + .../dist/include/urcu/arch/nios2.h | 28 + .../dist/include/urcu/arch/ppc.h | 136 + .../dist/include/urcu/arch/riscv.h | 37 + .../dist/include/urcu/arch/s390.h | 56 + .../dist/include/urcu/arch/sparc64.h | 50 + .../dist/include/urcu/arch/tile.h | 39 + .../dist/include/urcu/arch/x86.h | 113 + .../userspace-rcu/dist/include/urcu/assert.h | 42 + .../dist/include/urcu/call-rcu.h | 85 + .../userspace-rcu/dist/include/urcu/cds.h | 24 + .../dist/include/urcu/compiler.h | 250 ++ .../dist/include/urcu/config.h.in | 37 + .../userspace-rcu/dist/include/urcu/debug.h | 20 + .../userspace-rcu/dist/include/urcu/defer.h | 51 + .../userspace-rcu/dist/include/urcu/flavor.h | 80 + .../userspace-rcu/dist/include/urcu/futex.h | 242 ++ .../userspace-rcu/dist/include/urcu/hlist.h | 110 + .../userspace-rcu/dist/include/urcu/lfstack.h | 323 +++ .../userspace-rcu/dist/include/urcu/list.h | 188 ++ .../dist/include/urcu/map/clear.h | 67 + .../dist/include/urcu/map/urcu-bp.h | 136 + .../dist/include/urcu/map/urcu-mb.h | 128 + .../dist/include/urcu/map/urcu-memb.h | 130 + .../dist/include/urcu/map/urcu-qsbr.h | 129 + .../dist/include/urcu/map/urcu.h | 24 + .../userspace-rcu/dist/include/urcu/pointer.h | 115 + .../dist/include/urcu/rcuhlist.h | 68 + .../dist/include/urcu/rculfhash.h | 630 +++++ .../dist/include/urcu/rculfqueue.h | 76 + .../dist/include/urcu/rculfstack.h | 86 + .../userspace-rcu/dist/include/urcu/rculist.h | 78 + .../userspace-rcu/dist/include/urcu/ref.h | 96 + .../dist/include/urcu/static/lfstack.h | 319 +++ .../dist/include/urcu/static/pointer.h | 257 ++ .../dist/include/urcu/static/rculfqueue.h | 219 ++ .../dist/include/urcu/static/rculfstack.h | 118 + .../dist/include/urcu/static/urcu-bp.h | 203 ++ .../dist/include/urcu/static/urcu-common.h | 118 + .../dist/include/urcu/static/urcu-mb.h | 139 + .../dist/include/urcu/static/urcu-memb.h | 175 ++ .../dist/include/urcu/static/urcu-qsbr.h | 220 ++ .../dist/include/urcu/static/urcu.h | 31 + .../dist/include/urcu/static/wfcqueue.h | 675 +++++ .../dist/include/urcu/static/wfqueue.h | 158 ++ .../dist/include/urcu/static/wfstack.h | 452 ++++ .../dist/include/urcu/syscall-compat.h | 26 + .../userspace-rcu/dist/include/urcu/system.h | 71 + .../dist/include/urcu/tls-compat.h | 151 ++ .../userspace-rcu/dist/include/urcu/uatomic.h | 104 + .../dist/include/urcu/uatomic/aarch64.h | 33 + .../dist/include/urcu/uatomic/alpha.h | 16 + .../dist/include/urcu/uatomic/api.h | 71 + .../dist/include/urcu/uatomic/arm.h | 86 + .../include/urcu/uatomic/builtins-generic.h | 127 + .../dist/include/urcu/uatomic/builtins.h | 67 + .../dist/include/urcu/uatomic/gcc.h | 38 + .../dist/include/urcu/uatomic/generic.h | 716 +++++ .../dist/include/urcu/uatomic/hppa.h | 14 + .../dist/include/urcu/uatomic/ia64.h | 33 + .../dist/include/urcu/uatomic/loongarch.h | 33 + .../dist/include/urcu/uatomic/m68k.h | 28 + .../dist/include/urcu/uatomic/mips.h | 16 + .../dist/include/urcu/uatomic/nios2.h | 16 + .../dist/include/urcu/uatomic/ppc.h | 230 ++ .../dist/include/urcu/uatomic/riscv.h | 47 + .../dist/include/urcu/uatomic/s390.h | 155 ++ .../dist/include/urcu/uatomic/sparc64.h | 74 + .../dist/include/urcu/uatomic/tile.h | 33 + .../dist/include/urcu/uatomic/x86.h | 771 ++++++ .../dist/include/urcu/uatomic_arch.h | 6 + .../userspace-rcu/dist/include/urcu/urcu-bp.h | 191 ++ .../dist/include/urcu/urcu-futex.h | 6 + .../userspace-rcu/dist/include/urcu/urcu-mb.h | 125 + .../dist/include/urcu/urcu-memb.h | 125 + .../dist/include/urcu/urcu-poll.h | 16 + .../dist/include/urcu/urcu-qsbr.h | 143 + .../userspace-rcu/dist/include/urcu/urcu.h | 32 + .../dist/include/urcu/urcu_ref.h | 6 + .../dist/include/urcu/wfcqueue.h | 653 +++++ .../userspace-rcu/dist/include/urcu/wfqueue.h | 110 + .../userspace-rcu/dist/include/urcu/wfstack.h | 436 +++ .../userspace-rcu/dist/lgpl-relicensing.md | 37 + .../dist/m4/ae_cc_atomic_builtins.m4 | 52 + .../dist/m4/ae_config_feature.m4 | 231 ++ .../lgpl2/userspace-rcu/dist/m4/ae_pprint.m4 | 210 ++ .../dist/m4/ax_append_compile_flags.m4 | 47 + .../userspace-rcu/dist/m4/ax_append_flag.m4 | 51 + .../dist/m4/ax_c___attribute__.m4 | 67 + .../dist/m4/ax_check_compile_flag.m4 | 54 + .../dist/m4/ax_cxx_compile_stdcxx.m4 | 1019 +++++++ .../lgpl2/userspace-rcu/dist/m4/ax_pthread.m4 | 523 ++++ .../dist/m4/ax_require_defined.m4 | 38 + .../dist/scripts/urcu-api-list.sh | 221 ++ .../lgpl2/userspace-rcu/dist/src/Makefile.am | 61 + .../userspace-rcu/dist/src/compat-getcpu.h | 33 + .../lgpl2/userspace-rcu/dist/src/compat-smp.h | 275 ++ .../userspace-rcu/dist/src/compat_arch.c | 294 +++ .../userspace-rcu/dist/src/compat_futex.c | 140 + .../lgpl2/userspace-rcu/dist/src/lfstack.c | 77 + .../userspace-rcu/dist/src/liburcu-bp.pc.in | 15 + .../userspace-rcu/dist/src/liburcu-cds.pc.in | 15 + .../userspace-rcu/dist/src/liburcu-mb.pc.in | 15 + .../userspace-rcu/dist/src/liburcu-memb.pc.in | 15 + .../userspace-rcu/dist/src/liburcu-qsbr.pc.in | 15 + .../userspace-rcu/dist/src/liburcu.pc.in | 15 + .../dist/src/rculfhash-internal.h | 178 ++ .../dist/src/rculfhash-mm-chunk.c | 84 + .../dist/src/rculfhash-mm-mmap.c | 201 ++ .../dist/src/rculfhash-mm-order.c | 77 + .../lgpl2/userspace-rcu/dist/src/rculfhash.c | 2340 +++++++++++++++++ .../lgpl2/userspace-rcu/dist/src/rculfqueue.c | 45 + .../lgpl2/userspace-rcu/dist/src/rculfstack.c | 42 + .../lgpl2/userspace-rcu/dist/src/urcu-bp.c | 774 ++++++ .../dist/src/urcu-call-rcu-impl.h | 1112 ++++++++ .../userspace-rcu/dist/src/urcu-defer-impl.h | 476 ++++ .../lgpl2/userspace-rcu/dist/src/urcu-die.h | 23 + .../userspace-rcu/dist/src/urcu-pointer.c | 39 + .../userspace-rcu/dist/src/urcu-poll-impl.h | 86 + .../lgpl2/userspace-rcu/dist/src/urcu-qsbr.c | 519 ++++ .../lgpl2/userspace-rcu/dist/src/urcu-utils.h | 31 + .../lgpl2/userspace-rcu/dist/src/urcu-wait.h | 204 ++ external/lgpl2/userspace-rcu/dist/src/urcu.c | 559 ++++ .../lgpl2/userspace-rcu/dist/src/wfcqueue.c | 170 ++ .../lgpl2/userspace-rcu/dist/src/wfqueue.c | 48 + .../lgpl2/userspace-rcu/dist/src/wfstack.c | 115 + .../lgpl2/userspace-rcu/dist/src/workqueue.c | 483 ++++ .../lgpl2/userspace-rcu/dist/src/workqueue.h | 90 + .../userspace-rcu/dist/tests/Makefile.am | 23 + .../dist/tests/benchmark/Makefile.am | 235 ++ .../dist/tests/benchmark/common-states.c | 5 + .../dist/tests/benchmark/common-states.h | 55 + .../tests/benchmark/hashtable_1_seconds.tap | 18 + .../tests/benchmark/hashtable_30_seconds.tap | 18 + .../tests/benchmark/hashtable_3_seconds.tap | 18 + .../dist/tests/benchmark/run-urcu-tests.sh | 159 ++ .../dist/tests/benchmark/runhash.sh | 170 ++ .../dist/tests/benchmark/runpaul-phase1.sh | 48 + .../dist/tests/benchmark/runpaul-phase2.sh | 51 + .../dist/tests/benchmark/runpaul-phase3.sh | 54 + .../dist/tests/benchmark/runpaul-phase4.sh | 44 + .../dist/tests/benchmark/runpaul-phase5.sh | 15 + .../dist/tests/benchmark/runpaul-phase6.sh | 11 + .../dist/tests/benchmark/runpaul-phase7.sh | 45 + .../dist/tests/benchmark/runtests-batch.sh | 36 + .../dist/tests/benchmark/runtests.sh | 38 + .../dist/tests/benchmark/subphase4.sh | 105 + .../tests/benchmark/test_cycles_per_loop.c | 30 + .../dist/tests/benchmark/test_looplen.c | 59 + .../dist/tests/benchmark/test_mutex.c | 325 +++ .../dist/tests/benchmark/test_perthreadlock.c | 358 +++ .../benchmark/test_perthreadlock_timing.c | 204 ++ .../dist/tests/benchmark/test_rwlock.c | 358 +++ .../dist/tests/benchmark/test_rwlock_timing.c | 208 ++ .../dist/tests/benchmark/test_urcu.c | 334 +++ .../dist/tests/benchmark/test_urcu_assign.c | 394 +++ .../dist/tests/benchmark/test_urcu_bp.c | 331 +++ .../dist/tests/benchmark/test_urcu_defer.c | 356 +++ .../dist/tests/benchmark/test_urcu_gc.c | 404 +++ .../dist/tests/benchmark/test_urcu_hash.c | 757 ++++++ .../dist/tests/benchmark/test_urcu_hash.h | 363 +++ .../dist/tests/benchmark/test_urcu_hash_rw.c | 265 ++ .../tests/benchmark/test_urcu_hash_unique.c | 258 ++ .../dist/tests/benchmark/test_urcu_lfq.c | 415 +++ .../dist/tests/benchmark/test_urcu_lfs.c | 498 ++++ .../dist/tests/benchmark/test_urcu_lfs_rcu.c | 414 +++ .../dist/tests/benchmark/test_urcu_qsbr.c | 340 +++ .../dist/tests/benchmark/test_urcu_qsbr_gc.c | 404 +++ .../tests/benchmark/test_urcu_qsbr_timing.c | 215 ++ .../dist/tests/benchmark/test_urcu_timing.c | 215 ++ .../dist/tests/benchmark/test_urcu_wfcq.c | 560 ++++ .../dist/tests/benchmark/test_urcu_wfq.c | 381 +++ .../dist/tests/benchmark/test_urcu_wfs.c | 544 ++++ .../dist/tests/benchmark/urcu_1_seconds.tap | 18 + .../dist/tests/benchmark/urcu_30_seconds.tap | 18 + .../dist/tests/benchmark/urcu_3_seconds.tap | 18 + .../dist/tests/common/Makefile.am | 14 + .../userspace-rcu/dist/tests/common/api.h | 277 ++ .../dist/tests/common/compat-rand.h | 49 + .../dist/tests/common/debug-yield.c | 17 + .../dist/tests/common/debug-yield.h | 83 + .../dist/tests/common/thread-id.h | 79 + .../dist/tests/regression/Makefile.am | 281 ++ .../dist/tests/regression/rcutorture.h | 679 +++++ .../test_rcutorture_urcu_bp_perf_global.tap | 18 + ...est_rcutorture_urcu_bp_perf_global_cxx.tap | 18 + .../test_rcutorture_urcu_bp_perf_percpu.tap | 18 + ...est_rcutorture_urcu_bp_perf_percpu_cxx.tap | 18 + ...test_rcutorture_urcu_bp_perf_perthread.tap | 18 + ..._rcutorture_urcu_bp_perf_perthread_cxx.tap | 18 + .../test_rcutorture_urcu_bp_rperf_global.tap | 18 + ...st_rcutorture_urcu_bp_rperf_global_cxx.tap | 18 + .../test_rcutorture_urcu_bp_rperf_percpu.tap | 18 + ...st_rcutorture_urcu_bp_rperf_percpu_cxx.tap | 18 + ...est_rcutorture_urcu_bp_rperf_perthread.tap | 18 + ...rcutorture_urcu_bp_rperf_perthread_cxx.tap | 18 + .../test_rcutorture_urcu_bp_stress_global.tap | 18 + ...t_rcutorture_urcu_bp_stress_global_cxx.tap | 18 + .../test_rcutorture_urcu_bp_stress_percpu.tap | 18 + ...t_rcutorture_urcu_bp_stress_percpu_cxx.tap | 18 + ...st_rcutorture_urcu_bp_stress_perthread.tap | 18 + ...cutorture_urcu_bp_stress_perthread_cxx.tap | 18 + .../test_rcutorture_urcu_bp_uperf_global.tap | 18 + ...st_rcutorture_urcu_bp_uperf_global_cxx.tap | 18 + .../test_rcutorture_urcu_bp_uperf_percpu.tap | 18 + ...st_rcutorture_urcu_bp_uperf_percpu_cxx.tap | 18 + ...est_rcutorture_urcu_bp_uperf_perthread.tap | 18 + ...rcutorture_urcu_bp_uperf_perthread_cxx.tap | 18 + .../test_rcutorture_urcu_mb_perf_global.tap | 18 + ...est_rcutorture_urcu_mb_perf_global_cxx.tap | 18 + .../test_rcutorture_urcu_mb_perf_percpu.tap | 18 + ...est_rcutorture_urcu_mb_perf_percpu_cxx.tap | 18 + ...test_rcutorture_urcu_mb_perf_perthread.tap | 18 + ..._rcutorture_urcu_mb_perf_perthread_cxx.tap | 18 + .../test_rcutorture_urcu_mb_rperf_global.tap | 18 + ...st_rcutorture_urcu_mb_rperf_global_cxx.tap | 18 + .../test_rcutorture_urcu_mb_rperf_percpu.tap | 18 + ...st_rcutorture_urcu_mb_rperf_percpu_cxx.tap | 18 + ...est_rcutorture_urcu_mb_rperf_perthread.tap | 18 + ...rcutorture_urcu_mb_rperf_perthread_cxx.tap | 18 + .../test_rcutorture_urcu_mb_stress_global.tap | 18 + ...t_rcutorture_urcu_mb_stress_global_cxx.tap | 18 + .../test_rcutorture_urcu_mb_stress_percpu.tap | 18 + ...t_rcutorture_urcu_mb_stress_percpu_cxx.tap | 18 + ...st_rcutorture_urcu_mb_stress_perthread.tap | 18 + ...cutorture_urcu_mb_stress_perthread_cxx.tap | 18 + .../test_rcutorture_urcu_mb_uperf_global.tap | 18 + ...st_rcutorture_urcu_mb_uperf_global_cxx.tap | 18 + .../test_rcutorture_urcu_mb_uperf_percpu.tap | 18 + ...st_rcutorture_urcu_mb_uperf_percpu_cxx.tap | 18 + ...est_rcutorture_urcu_mb_uperf_perthread.tap | 18 + ...rcutorture_urcu_mb_uperf_perthread_cxx.tap | 18 + ...rcutorture_urcu_membarrier_perf_global.tap | 18 + ...orture_urcu_membarrier_perf_global_cxx.tap | 18 + ...rcutorture_urcu_membarrier_perf_percpu.tap | 18 + ...orture_urcu_membarrier_perf_percpu_cxx.tap | 18 + ...torture_urcu_membarrier_perf_perthread.tap | 18 + ...ure_urcu_membarrier_perf_perthread_cxx.tap | 18 + ...cutorture_urcu_membarrier_rperf_global.tap | 18 + ...rture_urcu_membarrier_rperf_global_cxx.tap | 18 + ...cutorture_urcu_membarrier_rperf_percpu.tap | 18 + ...rture_urcu_membarrier_rperf_percpu_cxx.tap | 18 + ...orture_urcu_membarrier_rperf_perthread.tap | 18 + ...re_urcu_membarrier_rperf_perthread_cxx.tap | 18 + ...utorture_urcu_membarrier_stress_global.tap | 18 + ...ture_urcu_membarrier_stress_global_cxx.tap | 18 + ...utorture_urcu_membarrier_stress_percpu.tap | 18 + ...ture_urcu_membarrier_stress_percpu_cxx.tap | 18 + ...rture_urcu_membarrier_stress_perthread.tap | 18 + ...e_urcu_membarrier_stress_perthread_cxx.tap | 18 + ...cutorture_urcu_membarrier_uperf_global.tap | 18 + ...rture_urcu_membarrier_uperf_global_cxx.tap | 18 + ...cutorture_urcu_membarrier_uperf_percpu.tap | 18 + ...rture_urcu_membarrier_uperf_percpu_cxx.tap | 18 + ...orture_urcu_membarrier_uperf_perthread.tap | 18 + ...re_urcu_membarrier_uperf_perthread_cxx.tap | 18 + .../test_rcutorture_urcu_qsbr_perf_global.tap | 18 + ...t_rcutorture_urcu_qsbr_perf_global_cxx.tap | 18 + .../test_rcutorture_urcu_qsbr_perf_percpu.tap | 18 + ...t_rcutorture_urcu_qsbr_perf_percpu_cxx.tap | 18 + ...st_rcutorture_urcu_qsbr_perf_perthread.tap | 18 + ...cutorture_urcu_qsbr_perf_perthread_cxx.tap | 18 + ...test_rcutorture_urcu_qsbr_rperf_global.tap | 18 + ..._rcutorture_urcu_qsbr_rperf_global_cxx.tap | 18 + ...test_rcutorture_urcu_qsbr_rperf_percpu.tap | 18 + ..._rcutorture_urcu_qsbr_rperf_percpu_cxx.tap | 18 + ...t_rcutorture_urcu_qsbr_rperf_perthread.tap | 18 + ...utorture_urcu_qsbr_rperf_perthread_cxx.tap | 18 + ...est_rcutorture_urcu_qsbr_stress_global.tap | 18 + ...rcutorture_urcu_qsbr_stress_global_cxx.tap | 18 + ...est_rcutorture_urcu_qsbr_stress_percpu.tap | 18 + ...rcutorture_urcu_qsbr_stress_percpu_cxx.tap | 18 + ..._rcutorture_urcu_qsbr_stress_perthread.tap | 18 + ...torture_urcu_qsbr_stress_perthread_cxx.tap | 18 + ...test_rcutorture_urcu_qsbr_uperf_global.tap | 18 + ..._rcutorture_urcu_qsbr_uperf_global_cxx.tap | 18 + ...test_rcutorture_urcu_qsbr_uperf_percpu.tap | 18 + ..._rcutorture_urcu_qsbr_uperf_percpu_cxx.tap | 18 + ...t_rcutorture_urcu_qsbr_uperf_perthread.tap | 18 + ...utorture_urcu_qsbr_uperf_perthread_cxx.tap | 18 + .../dist/tests/regression/test_urcu_fork.c | 200 ++ .../tests/regression/test_urcu_fork_cxx.cpp | 5 + .../dist/tests/regression/urcutorture.c | 30 + .../dist/tests/regression/urcutorture_cxx.cpp | 5 + .../userspace-rcu/dist/tests/unit/Makefile.am | 178 ++ .../dist/tests/unit/get_cpu_mask_from_sysfs.c | 40 + .../unit/get_cpu_mask_from_sysfs_cxx.cpp | 5 + .../tests/unit/get_max_cpuid_from_sysfs.c | 39 + .../unit/get_max_cpuid_from_sysfs_cxx.cpp | 5 + .../userspace-rcu/dist/tests/unit/test_arch.c | 34 + .../dist/tests/unit/test_arch_cxx.cpp | 5 + .../dist/tests/unit/test_build.c | 135 + .../dist/tests/unit/test_build_cxx.cpp | 5 + .../tests/unit/test_get_cpu_mask_from_sysfs | 58 + .../unit/test_get_cpu_mask_from_sysfs_cxx | 58 + .../tests/unit/test_get_max_cpuid_from_mask.c | 88 + .../unit/test_get_max_cpuid_from_mask_cxx.cpp | 5 + .../tests/unit/test_get_max_cpuid_from_sysfs | 96 + .../unit/test_get_max_cpuid_from_sysfs_cxx | 96 + .../unit/test_get_possible_cpus_array_len.c | 30 + .../test_get_possible_cpus_array_len_cxx.cpp | 5 + .../dist/tests/unit/test_lfstack.c | 78 + .../dist/tests/unit/test_uatomic.c | 116 + .../dist/tests/unit/test_uatomic_cxx.cpp | 5 + .../tests/unit/test_urcu_multiflavor-bp.c | 24 + .../unit/test_urcu_multiflavor-bp_cxx.cpp | 5 + .../tests/unit/test_urcu_multiflavor-mb.c | 25 + .../unit/test_urcu_multiflavor-mb_cxx.cpp | 5 + .../tests/unit/test_urcu_multiflavor-memb.c | 24 + .../unit/test_urcu_multiflavor-memb_cxx.cpp | 5 + .../tests/unit/test_urcu_multiflavor-qsbr.c | 24 + .../unit/test_urcu_multiflavor-qsbr_cxx.cpp | 5 + .../dist/tests/unit/test_urcu_multiflavor.c | 25 + .../dist/tests/unit/test_urcu_multiflavor.h | 14 + .../tests/unit/test_urcu_multiflavor_cxx.cpp | 5 + .../unit/test_urcu_multiflavor_single_unit.c | 71 + .../test_urcu_multiflavor_single_unit_cxx.cpp | 5 + .../dist/tests/unit/test_wfcqueue.c | 107 + .../dist/tests/unit/test_wfqueue.c | 79 + .../dist/tests/unit/test_wfstack.c | 78 + .../userspace-rcu/dist/tests/unit/urcu-asm.c | 25 + .../dist/tests/unit/urcu-asm_cxx.cpp | 5 + .../dist/tests/utils/Makefile.am | 13 + .../userspace-rcu/dist/tests/utils/env.sh.in | 35 + .../dist/tests/utils/tap-driver.sh | 643 +++++ .../userspace-rcu/dist/tests/utils/tap.c | 491 ++++ .../userspace-rcu/dist/tests/utils/tap.h | 70 + .../userspace-rcu/dist/tests/utils/tap.sh | 445 ++++ .../userspace-rcu/dist/tests/utils/utils.sh | 112 + 499 files changed, 93031 insertions(+) create mode 100644 external/lgpl2/userspace-rcu/dist/.gitreview create mode 100644 external/lgpl2/userspace-rcu/dist/ChangeLog create mode 100644 external/lgpl2/userspace-rcu/dist/CodingStyle.md create mode 100644 external/lgpl2/userspace-rcu/dist/LICENSE.md create mode 100644 external/lgpl2/userspace-rcu/dist/LICENSES/Autoconf-exception-2.0.txt create mode 100644 external/lgpl2/userspace-rcu/dist/LICENSES/BSD-2-Clause.txt create mode 100644 external/lgpl2/userspace-rcu/dist/LICENSES/CC-BY-4.0.txt create mode 100644 external/lgpl2/userspace-rcu/dist/LICENSES/CC0-1.0.txt create mode 100644 external/lgpl2/userspace-rcu/dist/LICENSES/FSFAP.txt create mode 100644 external/lgpl2/userspace-rcu/dist/LICENSES/GPL-2.0-only.txt create mode 100644 external/lgpl2/userspace-rcu/dist/LICENSES/GPL-2.0-or-later.txt create mode 100644 external/lgpl2/userspace-rcu/dist/LICENSES/GPL-3.0-or-later.txt create mode 100644 external/lgpl2/userspace-rcu/dist/LICENSES/LGPL-2.1-only.txt create mode 100644 external/lgpl2/userspace-rcu/dist/LICENSES/LGPL-2.1-or-later.txt create mode 100644 external/lgpl2/userspace-rcu/dist/LICENSES/LicenseRef-Autoconf-exception-macro.txt create mode 100644 external/lgpl2/userspace-rcu/dist/LICENSES/LicenseRef-Boehm-GC.txt create mode 100644 external/lgpl2/userspace-rcu/dist/LICENSES/MIT.txt create mode 100644 external/lgpl2/userspace-rcu/dist/Makefile.am create mode 100644 external/lgpl2/userspace-rcu/dist/README.md create mode 100755 external/lgpl2/userspace-rcu/dist/bootstrap create mode 100644 external/lgpl2/userspace-rcu/dist/configure.ac create mode 100644 external/lgpl2/userspace-rcu/dist/doc/Makefile.am create mode 100644 external/lgpl2/userspace-rcu/dist/doc/cds-api.md create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/Makefile.am create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/Makefile.examples.template create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/dist-files/Makefile create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile.cds_hlist_add_head_rcu create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile.cds_hlist_del_rcu create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile.cds_hlist_for_each_entry_rcu create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile.cds_hlist_for_each_rcu create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/hlist/cds_hlist_add_head_rcu.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/hlist/cds_hlist_del_rcu.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/hlist/cds_hlist_for_each_entry_rcu.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/hlist/cds_hlist_for_each_rcu.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/Makefile create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/Makefile.cds_lfs_pop_all_blocking create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/Makefile.cds_lfs_pop_blocking create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/Makefile.cds_lfs_push create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/cds_lfs_pop_all_blocking.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/cds_lfs_pop_blocking.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/cds_lfs_push.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_add_rcu create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_add_tail_rcu create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_del_rcu create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_for_each_entry_rcu create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_for_each_rcu create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_replace_rcu create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_add_rcu.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_add_tail_rcu.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_del_rcu.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_for_each_entry_rcu.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_for_each_rcu.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_replace_rcu.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_add create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_add_replace create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_add_unique create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_del create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_destroy create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_for_each_entry_duplicate create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_lookup create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_add.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_add_replace.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_add_unique.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_del.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_destroy.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_for_each_entry_duplicate.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_lookup.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/jhash.h create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/Makefile create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/Makefile.cds_lfq_dequeue create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/Makefile.cds_lfq_enqueue create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/cds_lfq_dequeue.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/cds_lfq_enqueue.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile.bp create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile.mb create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile.membarrier create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile.qsbr create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/bp.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/mb.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/membarrier.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/qsbr.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/Makefile create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/Makefile.cds_wfcq_dequeue create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/Makefile.cds_wfcq_enqueue create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/Makefile.cds_wfcq_splice create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/cds_wfcq_dequeue.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/cds_wfcq_enqueue.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/cds_wfcq_splice.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/Makefile create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/Makefile.cds_wfs_pop create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/Makefile.cds_wfs_pop_all_blocking create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/Makefile.cds_wfs_push create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/cds_wfs_pop.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/cds_wfs_pop_all_blocking.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/cds_wfs_push.c create mode 100644 external/lgpl2/userspace-rcu/dist/doc/rcu-api.md create mode 100644 external/lgpl2/userspace-rcu/dist/doc/solaris-build.md create mode 100644 external/lgpl2/userspace-rcu/dist/doc/uatomic-api.md create mode 100644 external/lgpl2/userspace-rcu/dist/extras/Makefile.am create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-bp.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-cds.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-common.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-mb.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-qsbr.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-signal.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-bp.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-cds.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-common.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-mb.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-memb.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-qsbr.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-signal.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-bp.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-cds.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-common.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-mb.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-memb.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-qsbr.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-signal.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu.so.6.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-bp.so.8.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-cds.so.8.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-common.so.8.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-mb.so.8.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-memb.so.8.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-qsbr.so.8.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-signal.so.8.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu.so.8.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-bp.so.8.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-cds.so.8.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-common.so.8.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-mb.so.8.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-memb.so.8.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-qsbr.so.8.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-signal.so.8.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu.so.8.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-bp.so.4.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-cds.so.4.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-common.so.4.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-mb.so.4.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-qsbr.so.4.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-signal.so.4.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu.so.4.xml create mode 100644 external/lgpl2/userspace-rcu/dist/extras/abi/README.md create mode 100755 external/lgpl2/userspace-rcu/dist/extras/abi/dump_abi.sh create mode 100644 external/lgpl2/userspace-rcu/dist/include/Makefile.am create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu-bp.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu-call-rcu.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu-defer.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu-flavor.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu-pointer.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu-qsbr.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/annotate.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch/aarch64.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch/alpha.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch/arm.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch/gcc.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch/generic.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch/hppa.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch/ia64.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch/loongarch.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch/m68k.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch/mips.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch/nios2.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch/ppc.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch/riscv.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch/s390.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch/sparc64.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch/tile.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/arch/x86.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/assert.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/call-rcu.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/cds.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/compiler.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/config.h.in create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/debug.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/defer.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/flavor.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/futex.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/hlist.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/lfstack.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/list.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/map/clear.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu-bp.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu-mb.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu-memb.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu-qsbr.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/pointer.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/rcuhlist.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/rculfhash.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/rculfqueue.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/rculfstack.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/rculist.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/ref.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/static/lfstack.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/static/pointer.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/static/rculfqueue.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/static/rculfstack.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-bp.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-common.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-mb.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-memb.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-qsbr.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/static/wfcqueue.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/static/wfqueue.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/static/wfstack.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/syscall-compat.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/system.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/tls-compat.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/aarch64.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/alpha.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/api.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/arm.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/builtins-generic.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/builtins.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/gcc.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/generic.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/hppa.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/ia64.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/loongarch.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/m68k.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/mips.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/nios2.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/ppc.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/riscv.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/s390.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/sparc64.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/tile.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/x86.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/uatomic_arch.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/urcu-bp.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/urcu-futex.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/urcu-mb.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/urcu-memb.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/urcu-poll.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/urcu-qsbr.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/urcu.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/urcu_ref.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/wfcqueue.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/wfqueue.h create mode 100644 external/lgpl2/userspace-rcu/dist/include/urcu/wfstack.h create mode 100644 external/lgpl2/userspace-rcu/dist/lgpl-relicensing.md create mode 100644 external/lgpl2/userspace-rcu/dist/m4/ae_cc_atomic_builtins.m4 create mode 100644 external/lgpl2/userspace-rcu/dist/m4/ae_config_feature.m4 create mode 100644 external/lgpl2/userspace-rcu/dist/m4/ae_pprint.m4 create mode 100644 external/lgpl2/userspace-rcu/dist/m4/ax_append_compile_flags.m4 create mode 100644 external/lgpl2/userspace-rcu/dist/m4/ax_append_flag.m4 create mode 100644 external/lgpl2/userspace-rcu/dist/m4/ax_c___attribute__.m4 create mode 100644 external/lgpl2/userspace-rcu/dist/m4/ax_check_compile_flag.m4 create mode 100644 external/lgpl2/userspace-rcu/dist/m4/ax_cxx_compile_stdcxx.m4 create mode 100644 external/lgpl2/userspace-rcu/dist/m4/ax_pthread.m4 create mode 100644 external/lgpl2/userspace-rcu/dist/m4/ax_require_defined.m4 create mode 100755 external/lgpl2/userspace-rcu/dist/scripts/urcu-api-list.sh create mode 100644 external/lgpl2/userspace-rcu/dist/src/Makefile.am create mode 100644 external/lgpl2/userspace-rcu/dist/src/compat-getcpu.h create mode 100644 external/lgpl2/userspace-rcu/dist/src/compat-smp.h create mode 100644 external/lgpl2/userspace-rcu/dist/src/compat_arch.c create mode 100644 external/lgpl2/userspace-rcu/dist/src/compat_futex.c create mode 100644 external/lgpl2/userspace-rcu/dist/src/lfstack.c create mode 100644 external/lgpl2/userspace-rcu/dist/src/liburcu-bp.pc.in create mode 100644 external/lgpl2/userspace-rcu/dist/src/liburcu-cds.pc.in create mode 100644 external/lgpl2/userspace-rcu/dist/src/liburcu-mb.pc.in create mode 100644 external/lgpl2/userspace-rcu/dist/src/liburcu-memb.pc.in create mode 100644 external/lgpl2/userspace-rcu/dist/src/liburcu-qsbr.pc.in create mode 100644 external/lgpl2/userspace-rcu/dist/src/liburcu.pc.in create mode 100644 external/lgpl2/userspace-rcu/dist/src/rculfhash-internal.h create mode 100644 external/lgpl2/userspace-rcu/dist/src/rculfhash-mm-chunk.c create mode 100644 external/lgpl2/userspace-rcu/dist/src/rculfhash-mm-mmap.c create mode 100644 external/lgpl2/userspace-rcu/dist/src/rculfhash-mm-order.c create mode 100644 external/lgpl2/userspace-rcu/dist/src/rculfhash.c create mode 100644 external/lgpl2/userspace-rcu/dist/src/rculfqueue.c create mode 100644 external/lgpl2/userspace-rcu/dist/src/rculfstack.c create mode 100644 external/lgpl2/userspace-rcu/dist/src/urcu-bp.c create mode 100644 external/lgpl2/userspace-rcu/dist/src/urcu-call-rcu-impl.h create mode 100644 external/lgpl2/userspace-rcu/dist/src/urcu-defer-impl.h create mode 100644 external/lgpl2/userspace-rcu/dist/src/urcu-die.h create mode 100644 external/lgpl2/userspace-rcu/dist/src/urcu-pointer.c create mode 100644 external/lgpl2/userspace-rcu/dist/src/urcu-poll-impl.h create mode 100644 external/lgpl2/userspace-rcu/dist/src/urcu-qsbr.c create mode 100644 external/lgpl2/userspace-rcu/dist/src/urcu-utils.h create mode 100644 external/lgpl2/userspace-rcu/dist/src/urcu-wait.h create mode 100644 external/lgpl2/userspace-rcu/dist/src/urcu.c create mode 100644 external/lgpl2/userspace-rcu/dist/src/wfcqueue.c create mode 100644 external/lgpl2/userspace-rcu/dist/src/wfqueue.c create mode 100644 external/lgpl2/userspace-rcu/dist/src/wfstack.c create mode 100644 external/lgpl2/userspace-rcu/dist/src/workqueue.c create mode 100644 external/lgpl2/userspace-rcu/dist/src/workqueue.h create mode 100644 external/lgpl2/userspace-rcu/dist/tests/Makefile.am create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/Makefile.am create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/common-states.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/common-states.h create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/hashtable_1_seconds.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/hashtable_30_seconds.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/hashtable_3_seconds.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/run-urcu-tests.sh create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/runhash.sh create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase1.sh create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase2.sh create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase3.sh create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase4.sh create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase5.sh create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase6.sh create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase7.sh create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/runtests-batch.sh create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/runtests.sh create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/subphase4.sh create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_cycles_per_loop.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_looplen.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_mutex.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_perthreadlock.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_perthreadlock_timing.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_rwlock.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_rwlock_timing.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_assign.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_bp.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_defer.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_gc.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_hash.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_hash.h create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_hash_rw.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_hash_unique.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_lfq.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_lfs.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_lfs_rcu.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_qsbr.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_qsbr_gc.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_qsbr_timing.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_timing.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_wfcq.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_wfq.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_wfs.c create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/urcu_1_seconds.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/urcu_30_seconds.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/benchmark/urcu_3_seconds.tap create mode 100644 external/lgpl2/userspace-rcu/dist/tests/common/Makefile.am create mode 100644 external/lgpl2/userspace-rcu/dist/tests/common/api.h create mode 100644 external/lgpl2/userspace-rcu/dist/tests/common/compat-rand.h create mode 100644 external/lgpl2/userspace-rcu/dist/tests/common/debug-yield.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/common/debug-yield.h create mode 100644 external/lgpl2/userspace-rcu/dist/tests/common/thread-id.h create mode 100644 external/lgpl2/userspace-rcu/dist/tests/regression/Makefile.am create mode 100644 external/lgpl2/userspace-rcu/dist/tests/regression/rcutorture.h create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_global.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_global_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_percpu.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_percpu_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_perthread.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_perthread_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_global.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_global_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_percpu.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_percpu_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_perthread.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_perthread_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_global.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_global_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_percpu.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_percpu_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_perthread.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_perthread_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_global.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_global_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_percpu.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_percpu_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_perthread.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_perthread_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_global.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_global_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_percpu.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_percpu_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_perthread.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_perthread_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_global.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_global_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_percpu.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_percpu_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_perthread.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_perthread_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_global.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_global_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_percpu.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_percpu_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_perthread.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_perthread_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_global.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_global_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_percpu.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_percpu_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_perthread.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_perthread_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_global.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_global_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_percpu.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_percpu_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_perthread.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_perthread_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_global.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_global_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_percpu.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_percpu_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_perthread.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_perthread_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_global.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_global_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_percpu.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_percpu_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_perthread.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_perthread_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_global.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_global_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_percpu.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_percpu_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_perthread.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_perthread_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_global.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_global_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_percpu.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_percpu_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_perthread.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_perthread_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_global.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_global_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_percpu.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_percpu_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_perthread.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_perthread_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_global.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_global_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_percpu.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_percpu_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_perthread.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_perthread_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_global.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_global_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_percpu.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_percpu_cxx.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_perthread.tap create mode 100755 external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_perthread_cxx.tap create mode 100644 external/lgpl2/userspace-rcu/dist/tests/regression/test_urcu_fork.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/regression/test_urcu_fork_cxx.cpp create mode 100644 external/lgpl2/userspace-rcu/dist/tests/regression/urcutorture.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/regression/urcutorture_cxx.cpp create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/Makefile.am create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/get_cpu_mask_from_sysfs.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/get_cpu_mask_from_sysfs_cxx.cpp create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/get_max_cpuid_from_sysfs.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/get_max_cpuid_from_sysfs_cxx.cpp create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_arch.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_arch_cxx.cpp create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_build.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_build_cxx.cpp create mode 100755 external/lgpl2/userspace-rcu/dist/tests/unit/test_get_cpu_mask_from_sysfs create mode 100755 external/lgpl2/userspace-rcu/dist/tests/unit/test_get_cpu_mask_from_sysfs_cxx create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_get_max_cpuid_from_mask.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_get_max_cpuid_from_mask_cxx.cpp create mode 100755 external/lgpl2/userspace-rcu/dist/tests/unit/test_get_max_cpuid_from_sysfs create mode 100755 external/lgpl2/userspace-rcu/dist/tests/unit/test_get_max_cpuid_from_sysfs_cxx create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_get_possible_cpus_array_len.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_get_possible_cpus_array_len_cxx.cpp create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_lfstack.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_uatomic.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_uatomic_cxx.cpp create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-bp.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-bp_cxx.cpp create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-mb.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-mb_cxx.cpp create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-memb.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-memb_cxx.cpp create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-qsbr.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-qsbr_cxx.cpp create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor.h create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor_cxx.cpp create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor_single_unit.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor_single_unit_cxx.cpp create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_wfcqueue.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_wfqueue.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/test_wfstack.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/urcu-asm.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/unit/urcu-asm_cxx.cpp create mode 100644 external/lgpl2/userspace-rcu/dist/tests/utils/Makefile.am create mode 100644 external/lgpl2/userspace-rcu/dist/tests/utils/env.sh.in create mode 100755 external/lgpl2/userspace-rcu/dist/tests/utils/tap-driver.sh create mode 100644 external/lgpl2/userspace-rcu/dist/tests/utils/tap.c create mode 100644 external/lgpl2/userspace-rcu/dist/tests/utils/tap.h create mode 100755 external/lgpl2/userspace-rcu/dist/tests/utils/tap.sh create mode 100755 external/lgpl2/userspace-rcu/dist/tests/utils/utils.sh diff --git a/external/lgpl2/userspace-rcu/dist/.gitreview b/external/lgpl2/userspace-rcu/dist/.gitreview new file mode 100644 index 0000000000000..c197662b927e4 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/.gitreview @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: 2020 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +[gerrit] +host=review.lttng.org +port=29418 +project=userspace-rcu.git +defaultbranch=master +defaultremote=review +defaultrebase=0 diff --git a/external/lgpl2/userspace-rcu/dist/ChangeLog b/external/lgpl2/userspace-rcu/dist/ChangeLog new file mode 100644 index 0000000000000..2f8326919508b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/ChangeLog @@ -0,0 +1,1053 @@ +# SPDX-FileCopyrightText: 2011-2024 Mathieu Desnoyers +# +# SPDX-License-Identifier: CC-BY-4.0 + +2024-12-20 Userspace RCU 0.15.0 + * Fix compilation errors + * Document cmm_cast_volatile + * Honor URCU_DEREFERENCE_USE_VOLATILE + * arm: Use atomic builtins for xchg if supported + * Introduce _CMM_TOOLCHAIN_SUPPORT_C11_MM + * Seperate uatomic and uatomic_mo + * uatomic: Fix header guard comment + * Fix: missing typename in URCU_FORCE_CAST + * Allow building with GCC >= 13.3 on RISC-V + * pointer.h: Fix the rcu_cmpxchg_pointer documentation + * rculfhash: make cds_lfht_iter_get_node argument const + * lfstack: make cds_lfs_empty argument const + * wfcqueue: make cds_wfcq_empty arguments const + * wfstack: make cds_wfs_empty argument const + * cds_list: make cds_list_replace @old argument const + * cds_list: make cds_list_empty const + * Adjust shell script to allow Bash in other locations + * futex.h: Indent preprocessor directives + * futex.h: Use urcu_posix_assert to validate unused values + * Use futex on OpenBSD + * fix: handle EINTR correctly in get_cpu_mask_from_sysfs + * Relicense src/compat-smp.h to MIT + * uatomic/x86: Remove redundant memory barriers + * cleanup: move rand_r compat code to tests + * ppc: Document cache line size choice + * Fix: change order of _cds_lfht_new_with_alloc parameters + * Add support for custom memory allocators for rculfhash + * ppc.h: use mftb on ppc + * rcutorture: Check histogram of ages + * docs: Add links to project resources + * Fix: allow clang to build liburcu on RISC-V + * Fix -Walloc-size + * cleanup: use an enum for the error states of nr_cpus_mask + * fix: add missing SPDX licensing tags + * urcu/uatomic/riscv: Mark RISC-V as broken + * Fix: urcu-bp: misaligned reader accesses + * rculfhash: Only pass integral types to atomic builtins + * LoongArch: Document that byte and short atomics are implemented with LL/SC + * Add LoongArch support + * Tests: Add test for byte/short atomics on addresses which are not word-aligned + * Complete removal of urcu-signal flavor + * doc/examples: Remove urcu-signal example + * tests/common: Remove urcu-signal common test files + * tests/benchmark: Remove urcu-signal benchmark tests + * tests/regression: Remove urcu-signal regression tests + * tests/unit: Remove urcu-signal unit tests + * Fix: Add missing cmm_smp_mb() in deprecated urcu-signal + * urcu/uatomic.h: Improve verbosity of static assert error messages + * urcu/compiler: Add urcu_static_assert + * Phase 1 of deprecating liburcu-signal + * uatomic/generic: Fix redundant declaration warning + * tests: Add tests for checking race conditions + * Add cmm_emit_legacy_smp_mb() + * urcu/annotate: Add CMM annotation + * tests/unit/test_build: Quiet unused return value + * benchmark: Use uatomic for accessing global states + * tests: Use uatomic for accessing global states + * urcu-wait: Fix wait state load/store + * Add CMM memory model + * urcu/arch/generic: Use atomic builtins if configured + * urcu/compiler: Use atomic builtins if configured + * configure: Add --enable-compiler-atomic-builtins option + * Fix: tests/rcutorture: Put thread offline on busy-wait + * tests/regression/rcutorture: Use urcu-wait + * tests/rcutorture: Factor out thread registration + * tests/regression/rcutorture: Add wait state + * urcu-wait: Initialize node in URCU_WAIT_NODE_INIT + * Complete REUSE support + * extras/abi: license data files under CC-1.0 + * examples: use SPDX identifiers + * tests: use SPDX identifiers + * src: use SPDX identifiers + * Public headers: use SPDX identifiers + * Build system: use SPDX identifiers + * Fix: urcu-wait: add missing futex.h include + * doc: update GCC baseline to 4.8 + * doc: update FreeBSD tested version + * doc: Remove Solaris from tested platforms + * Revert "compiler.h: Introduce caa_unqual_scalar_typeof" + * rculfhash: Use caa_container_of_check_null in cds_lfht_entry + * compiler.h: Introduce caa_container_of_check_null + * compiler.h: Introduce caa_unqual_scalar_typeof + * Avoid calling caa_container_of on NULL pointer in cds_lfht macros + * Fix: revise urcu_read_lock_update() comment + * Fix: uatomic powerpc comment about lwsync + * fix: aarch64: allow RHEL7 gcc 4.8.5-11 + * aarch64: Implement caa_cpu_relax as yield instruction + * fix: warning 'noreturn' function does return on ppc + * Fix: use __noreturn__ for C11-compatibility + * Adjust shell scripts to allow Bash in other locations + * Add support for OpenBSD + * Bump version to 0.15.0-pre + +2023-02-14 Userspace RCU 0.14.0 + * Fix: urcu-bp: only teardown call-rcu worker in destructor + * Fix: rculfhash: urcu_die() takes positive error value + * Fix: call_rcu: teardown default call_rcu worker on application exit + * Fix: join worker thread in call_rcu_data_free + * Docs: clarify grace period polling API + * Document grace period polling in rcu-api.md + * Implement poll rcu stress test in rcutorture + * urcu-memb,mb,signal: Implement grace period polling + * Fix: auto-resize hash table destroy deadlock + * Fix building on MSYS2 + * rculfhash: Include rculfhash-internal.h from local directory + * Remove "Darwin" from "should also work on list" + * Merge branch 'adah1972-improve-md' + * Add semicolons at the end of function prototypes + * Wrap a file name in backticks + * Wrap command-line options in backticks + * Fix a wrong format + * Wrap URLs in angle brackets + * Fix Markdown issues + * Fix: Always check pthread_create for failures + * Disable signals in URCU background threads + * Fix: futex.h: include headers outside extern C + * Fix: add missing unused attribute to _rcu_dereference + * Fix: change method used by _rcu_dereference to strip type constness + * Fix: remove type constness in URCU_FORCE_CAST's C++ version + * Move extern "C" down in include/urcu/urcu-bp.h + * fix: ifdef linux specific cpu count compat + * Add unit tests for possible_cpus_array_len + * fix: sysconf(_SC_NPROCESSORS_CONF) can be less than max cpu id + * Fix: revise obsolete command in README.md + * Fix: workqueue: remove unused variable "ret" + * Fix: urcu-qsbr: futex wait: handle spurious futex wakeups + * Fix: urcu: futex wait: handle spurious futex wakeups + * Fix: urcu-wait: futex wait: handle spurious futex wakeups + * Fix: defer_rcu: futex wait: handle spurious futex wakeups + * Fix: call_rcu: futex wait: handle spurious futex wakeups + * Fix: workqueue: futex wait: handle spurious futex wakeups + * Fix: Use %lu rather than %ld to print count + * Update ABI definition files + * Bump version current and age + * alpha: allocate membarrier system call number + * Bump version to 0.14.0-pre + * Improved test framework + * rculfhash: introduce cds_lfht_node_init_deleted + * Fix: changelog: v0.13.0 was released in 2021 + * cleanup: i386 arch detection + * fix: properly detect 'cmpxchg' on x86-32 + * fix: use urcu-tls compat with c++ compiler + * Fix typo + * fix: remove autoconf features default value in help message + * fix: add missing pkgconfig file for memb flavour lib + * Cleanup: Tests: Remove useless pre-C99 compatibility code from tap.h + * Document C99 and C++11 requirement in README.md + * Always use '__thread' for Thread local storage except on MSVC + * Fix: powerpc32: transparent unions alter calling convention + * fix: don't use C++ thread_local on MacOs + * wfcqueue API: implement overloaded wrappers with templates + * wfcqueue: combine C++ API cds_wfcq_head_cast with overloading + * wfstack C++ API: implement overloaded wrappers with templates + * lfstack C++ API: implement overloaded wrappers with templates + * wfstack: combine C++ API cds_wfs_stack_cast with overloading + * lfstack: combine C++ API cds_lfs_stack_cast with overloading + * fix: test_build tap plan + * Test C++ build of list head init + * Fix order of initializers in CDS_LIST_HEAD_INIT + * unit tests: test wfcqueue, wfstack, lfstack empty check functions in C++ + * wfcqueue: implement C++ API based on function overloading + * wfstack: implement C++ API based on function overloading + * lfstack: implement C++ API based on function overloading + * Fix tap.h: remove extra semicolon in pass/fail macros + * Add C++ build tests + * Build and run regression and unit tests as C++ programs + * Add --enable-Werror configure switch + * Add `urcu_posix_assert()` as `assert()` replacement + * Rename `urcu_assert()` to `urcu_assert_debug()` + * cleanup: spelling fixes in comments + * Make temporary variable in _rcu_dereference non-const + * (tls-ie2) Fix: x86 and s390: uatomic __hp() macro C++ support + * Fix: x86 and s390: uatomic __hp() macro clang support + * Fix: x86 and s390 uatomic: __hp() macro warning with gcc 11 + +2021-06-03 Userspace RCU 0.13.0 + * Document known ABI issue in README.md + * Add serialized ABI definition files + * bump SONAME major to 8 + * Remove all SONAME(6) ABI aliases + * .gitignore: list ignored Makefiles + * tests: Add a simple compile test for caa_get_cycles + * fix: clock_gettime on macOs + * Fix: rculist header: use parenthesis around macro parameters + * Fix: rcuhlist header: use parenthesis around macro parameters + * Fix: hlist header: use parenthesis around macro parameters + * Fix: list.h: use parenthesis around macro parameters, caa_container_of() + * Fix: hlist iteration relies on undefined behavior + * Fix: use __atomic_load() rather than atomic load explicit + * Fix: use atomic load memory_order_consume for rcu_dereference on C11/C++11 + * fix: we used weak symbols not weak aliases + * fix: include 'sys/endian.h' on FreeBSD + * fix: warnings on non-Linux platforms + * fix: HAVE_SCHED_SETAFFINITY is not defined + * configure: enable extended compiler warnings + * cleanup: explicitly mark unused parameters (-Wunused-parameter) + * fix: shadowed local variable (-Wshadow) + * cleanup: all functions have declarations (-Wmissing-prototypes) + * Import libtap from babeltrace + * cleanup: add 'noreturn' attribute to '_uatomic_link_error' + * fix: add missing 'S' to AC_CHECK_PROGS + * README.md: Document supported Glibc version + * README: cleanup stale MacOS information + * Bump version to 0.13.0-pre + * configure: standardise include path + * Remove glibc < 2.4 compat code for sched_setaffinity + * configure: regroup automake conditionals + * Introduce AE_FEATURE to manage configure features + * configure: regroup library checks + * configure: regroup and expand C header and program checks + * configure: regroup and expand C compiler checks + * configure: host specific config + * tests: Move tap-driver.sh out of the autotools aux directory + * configure: Set autotools baseline + * configure: centralize version information + * fix: exclude clang from GCC version blacklists + * aarch64: blacklist gcc prior to 5.1 + * Fix: configure: support Autoconf 2.70 + * Don't force a target and optimization level on ARMv7 + * Use DMB only on ARMv7 + * Blacklist GCC 4.4.0, 4.4.1 and 4.4.2 on ARM + * Cleanup: Move ARM specific code to urcu/arch/arm.h + * fix: bump tests thread limit to 4096 + * fix: reorder x86 arch detection + * fix: typo in futex syscall define check + * Compile time futex syscall detection + * Static arch and uatomic headers + * Add git-review config + * cleanup: Improve wording of CONFIG_RCU_DEBUG description + * fix: explicitly include urcu/config.h in files using CONFIG_RCU_ defines + * Fix typo in README.md + * fix: add -lurcu-common to pkg-config libs for each flavor + * call_rcu: Fix race between rcu_barrier() and call_rcu_data_free() + * Cleanup: tls-compat.h: add parentheses around expression (coding style) + * Fix: tls-compat.h exposes compiler-dependent public configuration + * Fix: tap array subscript has type char warning + +2020-04-09 Userspace RCU 0.12.0 + * tls-compat.h: introduce DEFINE_URCU_TLS_INIT + * Use _umtx_op for futex on FreeBSD + * Add FreeBSD, DragonFly to syscall-compat.h + * urcu-bp: perform thread registration on urcu_bp_register_thread + * Require automake >= 1.12 + * cds_lfht_is_node_deleted parameter can be marked const + * Fix: provide errno as argument to urcu_die() + * Fix: rculfhash worker needs to unblock to SIGRCU + * Cleanup: test_perthreadlock_timing: handle pthread mutex errors + * Fix: SONAME bump to 6.1.0 + * Cleanup: remove unused variable from configure.ac check + * Fix: urcu/futex.h: users of struct timespec should include time.h + +2019-05-06 Userspace RCU 0.11.0 + * Bump library version to 6:0:1 + * Cleanup: update code layout to fix old gcc warning + * Fix: typo CPPLAGS in examples Makefile + * Harmonize pprint macro across projects + * Check for TLS support after CC detection + * Update macros from the autotools archive + * tap-driver.sh: flush stdout after each test result + * Update dead link in lgpl-relicensing.txt + * Add multiflavor compat identifiers + * Cleanup: missing sign compare fixes + * Cleanup: enable signed/unsigned compare compiler warning + * Cleanup: compiler warning on 32-bit architectures + * config.h.in: rename CONFIG_RCU_MULTIFLAVOR to CONFIG_RCU_HAVE_MULTIFLAVOR + * rculfhash: implement iterator debugging config option + * Fix: examples silent rules on Solaris + * Add missing fall through annotations + * Fix: symbol aliases with TLS compat + * Port: no symbols aliases on MacOS + * Add -Wextra to CFLAGS + * Add silent mode to examples Makefiles + * doc: update examples to API changes + * test multiflavor single compile unit + * Update README following API changes + * Use new header locations for includes from urcu code + * Update call-rcu.h and defer.h comments and include guards + * rculfqueue.h: do not include urcu-call-rcu.h + * rculfhash: support use with multiple flavors per compile unit + * rculfhash: do not include urcu-call-rcu.h from public API + * Refactor liburcu to support many flavors per compile unit + * Fix: only wait if work queue is empty in real-time mode + * Fix: don't wait after completion of a work queue job batch + * Fix: don't wait after completion of job batch if work queue is empty + * Fix: workqueue: struct urcu_work vs rcu_head mixup + * Cleanup: workqueue: update comments referring to call-rcu + * Fix: mixup between URCU_WORKQUEUE_RT and URCU_CALL_RCU_RT + * test_rwlock: Add per-thread count to verbose output + * Add *.exe to gitignore for Cygwin + * Fix: pthread_rwlock initialization on Cygwin + * Fix: compat_futex_noasync on Cygwin + * wfcqueue: allow defining CDS_WFCQ_WAIT_SLEEP to override `poll' + * Update documentation for call_rcu before/after fork + * Add support for the RISC-V architecture + * Tests: Add tap-driver.sh for automake < 1.12 + * Tests: Replace prove by autotools tap runner + * liburcu-bp: Use membarrier private expedited when available + * liburcu: Use membarrier private expedited when available + * rculfhash: improve error handling of mmap backend + * Fix: don't use overlapping mmap mappings on Cygwin + * Tests fix: errors in shell scripts + * Revert "Use initial-exec tls model" + * Use initial-exec tls model + * Fix: don't use membarrier SHARED syscall command in liburcu-bp + * Tests fix: add missing Cygwin thread id + * Fix: assignment from incompatible pointer type warnings + * Tests fix: unused variable warnings + * Fix: add missing m68k headers to dist + * Bump version to 0.11-pre + +2017-06-12 Userspace RCU 0.10.0 + * Bump library soname due to urcu flavor structure change + * Cleanup: use mutex_lock() wrapper in rculfhash + * Use workqueue in rculfhash + * Implement urcu workqueues internal API + * Add support for m68k architecture + * Set -Wall globally in AM_CFLAGS + * Fix: remove double use of PTHREAD_CFLAGS + * Re-add PTHREAD_CFLAGS to global CFLAGS + * Fix: Don't override user variables within the build system + * Add report at the end of configure + * uatomic-api docs: use the third-person singular + * Add --enable-rcu-debug to configure + * ARM32: use dmb ish (inner shareable domain) for smp barriers + * Cleanup: remove cmm_wmb() from rcu_xchg_pointer and rcu_cmpxchg_pointer + * Fix: uatomic arm32: add missing release barrier before uatomic_xchg + * Tests: Add verbose support to test script + * Fix: add missing CONFIG_RCU_FORCE_SYS_MEMBARRIER to urcu/config.h.in + * Allow forcing the use of sys membarrier + * Fix: rcutorture: work-around signal issue on mac os x + * Fix: rcutorture should register thread using call_rcu + * Fix: add missing backslash in Makefile.am + * Fix: Do not use wildcards in include/Makefile.am + * Bump version to 0.10-pre + * Fix: check for rand_r() in compat-rand.h + * Fix: Move rand-compat to private src dir + * Fix: remove AC_FUNC_MALLOC from configure.ac + * Cleanup: Re-organise source dir + * Cleanup: remove leftover manual pthread detection + * Fix: update ax_pthread macro to handle newer clang + * Update library current version due to adding destroy API + * Fix: Use pthread_self to get threadid on OSX + * Fix: examples: use destroy API for queues/stacks + * Update library age due to new stack/queue destroy API + * Fix: tests: invoke destroy APIs for queues/stacks + * Fix: add missing destroy functions to queues/stack APIs + * Fix: add missing __cds_wfcq_init for LGPL API + * Fix: memory leak on hash table destroy + * Fix: Add failover for platforms without nproc + * Fix: use clock_get_time for caa_get_cycles fallback on MacOSX + * Fix: syscall-compat.h MacOSX support + * Fix: Add solaris-build.md to dist + * rculfhash: Documentation: clarify need for grace period before "re-using" + * Port: build shared libraries in Cygwin + * Port: fix compatibility header for Cygwin + * Add GNU Hurd support to syscall-compat.h + * Add support for aarch64_be + * Fix: urcu-bp: re-initialize list head on library exit + * bootstrap: Standardize on autoreconf -vi + * Harmonize bootstrap script across projects + * Fix: examples make distcheck failure + * wfcqueue: add C++ compatibility API + * Fix: CDS_WFCQ_WOULDBLOCK typing for c++ + * Fix: configure.ac: check for possibly required libs for clock_gettime + * Support for NIOS2 architecture + * urcu_ref_get_safe: introduce new API + * Fix: handle reference count overflow + * Fix: compat_futex should work-around futex signal-restart kernel bug + * Support for Xeon-Phi with newer MPSS + * sparc64: allocate membarrier system call number + * hppa: allocate membarrier system call number + * Fix build on non-Linux Debian ports + * Fix: urcu-signal: smp_mb_master() needs registry lock + * Fix: rculfhash only needs to include urcu-pointers.h + * Fix: out-of-tree benchmark/regtest + * Fix: add missing regtest and benchmark files to dist tarball + * Fix: add missing run.sh to benchmark makefile + +2015-10-16 Userspace RCU 0.9.0 + * Bump soname major to 4 + * Cleanup: remove trailing tab + * Fix: Use proper macro to detect stdbool.h + * Configure: Add missing checks + * Port: Add Solaris build instructions + * Fix: regtest outputs valid TAP protocol + * Port: Detect nproc bin name in benchmark scripts + * Port: Add Solaris getcpu support + * Port: Fixes to build system for portability + * Port: Add Solaris support to tests/common/thread-id.h + * Port: Add Solaris support to urcu/syscall-compat.h + * Port: replace bzero() by memset() + * Port: make bootstrap script work on most shell + * tests: rcutorture: use parameters rather than random + * Fix: only define membarrier system call on Linux + * Refactor tests + * Fix: cast caa_cycles_t to unsigned long long + * caa_get_cycles: caa_ prefix for type, use CLOCK_MONOTONIC + * Cleanup: remove trailing whitespaces at EOL + * Cleanup: move generic caa_get_cycles to arch/generic.h + * tile: allocate membarrier system call number + * ia64: allocate membarrier system call number + * aarch64: allocate membarrier system call number + * powerpc64le: use "ppc" architecture + * arm: allocate membarrier system call number + * s390: allocate membarrier system call number + * ppc: allocate membarrier system call number + * lfstack: relax constraints on node re-use + * Fix: format string signedness + * Cleanup: tests: Branch condition evaluates to a garbage value + * Fix: test: unchecked return value + * Fix: test: side-effect in assertion + * x86: allocate membarrier system call number + * urcu-bp: use sys_membarrier when available + * Cleanup: urcu: remove unused membarrier "group" parameter + * urcu/ref.h: implement urcu_ref_get_unless_zero() + * Fix: compat_futex: uninitialized ret variable + * Fix: compat_futex_noasync: don't override return value + * Fix: dynamic fallback to compat futex on sys_futex ENOSYS + * Detect RCU read-side overflows + * Detect RCU read-side underflows + * Introduce urcu_assert and registration check + * Fix: volatile in assert() + * Update following changes to sys_membarrier ABI + * uatomic: Specify complete types for atomic function calls + * Cleanup: remove unused return value warning from tests + * Fix: handle sys_futex() FUTEX_WAIT interrupted by signal + * Fix: compat_futex.c: *uaddr should be read as volatile + * Cleanup: cast poll delay return value to void + * tests: Convert unit tests to TAP + * Fix: make benchmark test run in oot build + * Fix: call_rcu_thread() affinity failure + * Cleanup: cast poll delay return value to void + * Cleanup: cast poll delay return value to void + * Cleanup: cast poll delay return value to void + * Cleanup: cast poll delay return value to void + * Cleanup: cast poll() return value to void for delays + * urcu: fix deprecation warning with new glibc + * urcu: add cds_list_for_each_entry_safe_from macro + * Fix: deadlock when thread join is issued in read-side C.S. + * Fix: rename RCU_DEBUG to DEBUG_RCU in urcu-qsbr.h + * Cleanup some c99 pedantic warnings + * Mark braced-groups within expressions with __extension__ + * Fix: compat_futex_noasync race condition + * tests: Use stderr redirection for time output + * Fix: use space after rpath for OS X ld + * Fix: move transparent union attribute after union declaration for clang + * Configure: add check for used type + * Configure: add missing check of headers + * Configure: add missing check for funcs: memset, strerror + * Fix: documentation: urcu-pointer.h: s/rcu_dereference_pointer/rcu_dereference/ + * urcu-bp/urcu-qsbr: remove unneeded DEBUG_YIELD code + * Fix: call rcu should call internal RCU API + * Fix: silence gcc -Wextra warning + * compiler: use __GNUC__ instead of the undefined __GNUC_MAJOR__ + * Fix: lfstack reversed empty/non-empty return value + * lfstack: fix: add missing __cds_lfs_init + * wfstack: add missing union parameters + * Fix: preserve example files' timestamps when copying + * wfstack: implement mutex-free wfstack with transparent union + * wfcqueue: Implement mutex-free wfcqueue head with transparent union + * lfstack: Implement mutex-free stack head with transparent union (v2) + * rculfhash: remove duplicated code + * rculfhash: handle pthread_create failures + * rculfhash: fall back to single-threaded resize on calloc failure + * x86: drop extra semi-colon in caa_cpu_relax + * Cleanup: tests: cast console write return value as void + * Modernize doc using Markdown + * Fix: update automake following README to README.md change + * Modernize README using Markdown + * Fix: incorrect parenthesis in cds_hlist_for_each_entry_safe_2 + * Fix: Use after free in rcu_barrier() + * Fix: rcu_barrier(): uninitialized futex field + * call_rcu threads should clear their PAUSED flag when they unpause + * test_urcu_fork: test many fork, with 3 children deep + * Update list of supported architectures in README + * Add support for hppa/PA-RISC architecture + * Use autoconf AM_MAINTAINER_MODE + * Use gcc atomics on aarch64/powerpc64le + * Fix: move wait loop increment before first conditional block + * Fix: high cpu usage in synchronize_rcu with long RCU read-side C.S. + * Fix: out of tree build: doc/examples + * Fix: out of tree build tests/common + * tests/unit: use lib rather than source + * automake: Rename INCLUDES to AM_CPPFLAGS (new name) + * tests regressions: use lib rather than recompile from source + * tests: use common lib rather than recompile compat sources + * urcu tests: use lib rather than compile from source + * urcu mb tests: use lib rather than recompile from source + * urcu signal tests: use library rather than recompile source + * tests: move yield debug to common test library + * tests urcu bp: use lib rather than recompile source + * test_urcu_defer: link on urcu lib rather than recompile source + * tests/benchmark: use urcu qsbr lib rather than recompile from source + * Pass the CC variable to the example Makefiles + * Fix: urcu-bp interaction with threads vs constructors/destructors + * x86 barrier for Xeon Phi: use rsp on x86-64 + * Set RCU_HAVE_FENCE to false on Intel Xeon Phi + * Fix undefined NULL pointer arithmetic in hlist + * Cleanup: Check for pthread in Libc + * Cleanup: Android: Do not redefine gettid + * Fix undefined NULL pointer arithmetic + * Android: implement rand_r() + * Android: do not redefine gettid on Android + * Android: add a compat layer for 'syscall.h' + * Android: do not link pthread on Android + * Android: configure.ac Android check + * Blacklist ARM gcc 4.8.0, 4.8.1, 4.8.2 + * rculfhash: document max_nr_buckets = 0 + * Library major version number (soname) increment to 3 + * Fix: tls-compat multi-lib conflict + * Use cross compiler for doc examples + * Add lttng-dev mailing list to readme + * wfcqueue: remove misleading comment + * gcc warning fixes: -Wsign-compare and -Wextra + * Fix: urcu-qsbr: reversed logic on RCU_DEBUG + * Fix: urcu-bp segfault in glibc pthread_kill() + * Fix urcu-bp: don't move registry + * Fix: compat futex duplicated lock and completion + * Fix: i386 compat code duplicated mutex instances + * Fix: urcu-bp: Bulletproof RCU arena resize bug + * Fix: test_mutex.c uninitialized mutex + +2013-09-06 Userspace RCU 0.8.0 + * Fix: hash table growth (for small tables) should be limited + * Fix: doc/examples cross-build + * Introduce URCU_INLINE_SMALL_FUNCTIONS + * Add missing tests/common/Makefile.am + * README: document make check/regtest/bench + * tests: split in check, regtest and bench targets + * Cleanup: doc/examples makefile + * Fix: doc/examples VPATH build + * doc/examples: Move the LIBS after the OBJECTS in the Makefile + * Document build work-around on MacOS X + * Fix tests: use of uninitialized variables + * test_urcu_hash*: initialize TLS seeds + * doc/examples: cds_lfht_for_each_entry_duplicate + * doc/examples: cds_lfht_lookup + * doc/examples: cds_lfht_destroy + * doc/examples: cds_lfht_add_replace + * doc/examples: cds_lfht_add_unique + * doc/examples: cds_lfht_add/cds_lfht_del + * doc/examples: add rculfqueue example + * doc/examples: add synchronize_rcu() + * doc/examples: add bp flavor + * doc/examples: add dist toplevel makefile + * doc/examples: add membarrier flavor + * doc/examples: document call_rcu() + * doc/examples: update qsbr example + * urcu signal: remove assertion on exit + * doc/examples: signal flavor + * doc/examples: add mb flavor + * doc/examples: update qsbr + * doc/examples: introduce urcu-flavors examples directory + * doc/examples: enhance rcu-flavor-qsbr example + * doc/examples: rename qsbr-minimal to rcu-flavor-qsbr + * doc/examples: automake stop on error + * doc/examples: hlist + * hlist/rcuhlist update + * doc/examples: fix typo in list example + * rcuhlist: make pointer stores atomic + * hlist, rcuhlist: cleanup coding style + * doc/examples: lfstack + * doc/examples: update cds_wfs_pop_all_blocking + * doc/examples: cds_wfs_pop_all_blocking + * doc/examples: cds_wfs_pop + * doc/examples: add missing Makefile + * doc/examples: cds_wfs_push + * doc/wfcqueue: cds_wfcq_splice + * doc/examples: add cds_wfcq_dequeue + * doc/examples: wfcq needs to link against urcu-common + * doc/examples: update queue comment + * doc/examples: fix make clean + * gitignore: add qsbr-minimal + * doc/examples: cds_wfcq_enqueue + * doc/examples: Move LIBS to each makefile + * doc/examples: cds_list_for_each_rcu + * doc/examples: cds_list_for_each_entry_rcu + * doc/examples: cds_list_replace_rcu + * doc/examples: cds_list_add_tail_rcu + * doc/examples: cds_list_del_rcu + * doc/examples: cds_list_add_rcu + * rculist: ensure atomic updates of next pointers + * rculist: implement cds_list_add_tail_rcu + * rculist.h and list.h style cleanup + * example makefile: add missing cd .. + * Update gitignore + * Fix: examples Makefile on FreeBSD + * hash table test: don't redefine CACHE_LINE_SIZE + * tests: use thread-id.h wrapper + * Implement thread-id.h wrapper + * tests: add missing unsigned long casts to pthread_self() + * Fix: don't build examples in static builds + * Add QSBR minimal example + * compiler.h: implement CAA_ARRAY_SIZE() + * document rcu barrier + * rcu barrier: handle OOM die urcu_die + * Implement rcu_barrier() + * rculfhash: document destroy context limitations + * Add MIPS to README + * Update README + * Update README testing info about FreeBSD + * test: fix api.h missing if brackets + * tests: fix incorrect counter + * Fix: membarrier fallback symbol conflict + * Fix: Use a filled signal mask to disable all signals + * urcu-bp: introduce struct urcu_gp + * Fix: struct urcu_gp broke multiflavor + * Cleanup test usage printout + * wfstack tests: use pop "last" state info + * wfstack: return whether pop is popping the last element + * wfcqueue tests: use dequeue empty state + * wfcqueue: return whether dequeue is dequeuing last element + * urcu: avoid false sharing for rcu_gp_ctr + * urcu: make the code of urcu-qsbr as normal urcu + * rculfhash: detect if resize/destroy are called within RCU read-side C.S. + * Documentation: rculfhash: cds_lfht_resize not within read-side C.S. + * fix: rculfhash don't change qsbr online state + * Add rcu_read_ongoing() API to each urcu flavor + * Add "sparc" host cpu to configure.ac + * futex: include syscall.h instead of sys/syscall.h + * Add tab to output in order to allow easy nesting of tables. + * Remove urcu-api-list.sh from dist tarball + * Add urcu-api-list.sh script + * list: implement cds_list_for_each_safe() + * Fix: tests/api.h use cpuset.h + * Fix hurd-i386: move cpuset tests outside of sched_setaffinity conditional + * Fix tests: finer-grained use of CPU_SET, CPU_ZERO and cpu_set_t + * Test for CPU_SET + * Fix build on architectures with HAVE_SCHED_GETCPU but without HAVE_SYSCONF + * README: document that Clang 3.0 (based on LLVM 3.0) is supported + * clang: silence "unused expression result" warning + * rculfhash: add assertions on node alignment + * Spelling cleanups within comments and documentation + * Fix configure checks for Tile + * uatomic: style fix + * doc/cds-api.txt: expand documentation + * README: document each API file + * README: reorganize + * Add compilation support for the TileGX architecture + * wfstack: add nonblocking to _LGPL_SOURCE API + * Discourage use of pthread_atfork() for call_rcu handlers + * Fix call_rcu fork handling + * test: fork handling + * rculfhash: add cds_lfht_replace to the write operations in the comments + * urcu: fix comments for cds_list_for_each_prev() + * documentation: fix rcu-api.txt duplicates + * test wfcq: remove unneeded urcu.h include + * test wfs: remove unneeded urcu.h include + * urcu: declare test_urcu_multiflavor functions + * urcu: remove the wrong comma + * wfstack: implement nonblocking pop and next + * wfcqueue: document first/next return values + * wfstack: update comments about cds_wfs_empty/first being wait-free + * wfstack API: rename cds_wfs_first_blocking to cds_wfs_first + * wfstack test: test if number of push to empty vs pop_all match + * wfstack: document first/next return values + * test wfstack: enforce external mutex if needed by default + * test wfcqueue: enforce external mutex if needed by default + * urcu-mb/signal/membarrier: batch concurrent synchronize_rcu() + * urcu-wait: move queue management code into urcu-wait.h + * urcu-wait: move wait code into separate file + * urcu-qsbr: batch concurrent synchronize_rcu() + * tests: use standard malloc/free for synchronize_rcu() + * urcu-bp: move quiescent threads to separate list + * urcu-mb/signal/membarrier: move quiescent threads to separate list + * urcu-qsbr: move offline threads to separate list + * urcu-bp: improve 2-phase wait scheme + * urcu-mb/signal/membarrier: improve 2-phase wait scheme + * urcu-qsbr: improve 2-phase wait scheme + * wfcqueue: implement mutex-free splice + * wfcqueue: document empty criterion + * urcu-call-rcu: use wait-free splice return value + * test wfcqueue: add tests for queue state return value + * wfcqueue: enqueue and splice return queue state + * Fix: wfcqueue nonblocking dequeue + * wfcqueue: Fix lock and unlock functions + * runtests: Make path of time binary configurable + * urcu-qsbr: skip Q.S. reporting if already reported + * Fix TLS detection: test with linker, add --disable-compiler-tls + * Cleanup: cast pthread_self() return value to unsigned long + * Fallback mechanism not working on platform where TLS is unsupported + * Revert "Fix: cross-build: configure.ac should use --target, not --host" + * Fix: cross-build: configure.ac should use --target, not --host + * test_urcu_wfcq: add splice and nosync tests + * test_urcu_wfs: cleanup + * test_urcu_lfs: cleanup + * Fix static linking: add missing static for _defer_rcu + * tests: report error value for make check + * Add multiflavor test program + * Fix static linking: fix symbol name namespaces + * Fix static linking: add missing static to thr_defer + * Fix static linking: add missing static + * deprecation: fix build with gcc < 4.5 + * wfstack.c: update copyright notice + * Update wfstack copyright notice + * Comment fix: update associated LGPL header name + * Update cds-api.txt following API deprecations + * Deprecate wfqueue + * Deprecate rculfstack + * wfcqueue: introduce nonblocking API + * lfstack: test pop_all and pop + * lfstack: implement empty, pop_all and iterators, document API + * lfstack: implement test + * lfstack: implement lock-free stack + * wfstack: implement pop_all and iteration tests + * wfstack: implement cds_wfs_pop_all and iterators, document API + * rculfhash test: fix trivial memleak and return node leak and errors + * rculfhash: add missing extern + * Cleanup: fix cppcheck errors + * wfcqueue: remove ancient comment + * test_urcu_lfq: remove rcu_defer_register_thread() from test_urcu_lfq + * test_urcu_lfq: test for the proper pointer + * test_urcu_lfs: remove rcu_defer_register_thread() from test_urcu_lfs + * test_urcu_lfs: test for the proper pointer + * wfcqueue: clarify locking usage + * Document APIs in README + * Test cleanup: replace "l" parameter by "loops" + * Add wfcqueue header to cds.h + * Fix: urcu-bp, urcu, urcu-qsbr should include wfcqueue + * Fix: call_rcu list corruption on teardown (documentation) + * call_rcu: remove head field alignement, explain wfcqueue motivation + * wfcqueue: update credits in patch documentation + * wfcqueue documentation: hint at for_each iterators + * Fix urcu-call-rcu-impl.h: false-sharing + * call_rcu: use wfcqueue, eliminate false-sharing + * wfcqueue test + * wfcqueue: implement concurrency-efficient queue + * Ensure that read-side functions meet 10-line LGPL criterion + * tls-compat.h: document sigaltstack(2) limitation + * urcu: add notice to URCU_TLS() for it is not strictly async-signal-safe + * Document sigaltstack(2) limitation + * Documentation: update LICENSE file + +2012-08-27 Userspace RCU 0.7.4 + * rculfhash API documentation: document destroy RCU read-lock constraint + * Fix: rculfhash should be offline while waiting for resize to complete + * Add missing entry to gitignore + * urcu: move busy-wait code and name it ___cds_wfq_node_sync_next() + * urcu: fix compat_futex_noasync() + * urcu: add hint to DEFINE_URCU_TLS() for compound types + * Fix: CAA_BUILD_BUG_ON should refer to CAA_BUILD_BUG_ON_ZERO + * Add MIPS support + * Compatibility: remove bash-ismsm from test scripts + * Fix inappropriate lib behavior: don't call exit() + * Fix: re-enable compatibility with autoconf < 2.64 + * Fix c99 compatibility: use __asm__ and __volatile__ in public headers + * Fix c99 compatibility: use __typeof__ instead of typeof in public headers + * warning fix: tests urcutorture for NetBSD 5 + +2012-06-01 Userspace RCU 0.7.3 + * Fix tests: make dist lib dependency + * Update README for OS supported, tests dependency + * Add CodingStyle to tarball + * Add coding style document + * Test fix: test_perthreadlock uninitialized mutex + * tests: support FreeBSD short "time" args + * freebsd 8.2 fix: define MAP_ANONYMOUS for compatibility + +2012-05-24 Userspace RCU 0.7.2 + * Fix library compatibility + +2012-05-24 Userspace RCU 0.7.1 + * fix: uatomic_set return value compile fix for non-x86 arch. + +2012-05-21 Userspace RCU 0.7.0 + * Cleanup: header comments coding style + * Document uatomic operations + * Update return value of "set" operations + * Fix mremap wrapper for NetBSD 5 + * Use urcu/tls-compat.h + * Implement urcu/tls-compat.h + * Add TLS detection m4 macro + * document concurrent data structures + * documentation: refer to rcu-api.txt + * Move API.txt to doc/rcu-api.txt, install in system doc/ + * rculfhash: document implied memory barriers + * rculfhash: Ensure future-proof memory barrier semantic consistency + * API cleanup: use "uatomic_*" in cmm_smp_mb__ API + * uatomic: add memory barrier API for and/or/add/sub/inc/sub + * rculfhash: add runhash.sh test script + * rculfhash tests: add missing check + * rculfhash: fix: race between replace and del operations + * rculfhash: replace unneeded rcu_dereference by CMM_LOAD_SHARED + * rculfhash: use do {} while (0) for dbg_printf() + * rculfhash: cleanup typo + * rculfhash: update API comments + * rculfhash: update comments in implementation + * rculfhash tests: add long hash chains tests + * rculfhash tests: add uniqueness test + * rculfhash test: print test name + * rculfhash: stress requirement in documentation + * rculfhash: fix typo + * rculfhash tests: use array of callbacks to modularize + * rculfhash tests: modularize tests + * rculfhash: document ordering guarantees + * rculfhash: document linearizability guarantees + * rculfhash: update removal comment + * Add missing files to .gitignore + * Fix out-of-tree build + * rculfhash: check malloc NULL pointer + * Fix uatomic sign cast + * Remove unused jhash.h file + * Fix: use known license text, fix incorrect FSF address + * Fix: add missing sched.h include in rculfhash.c + * Allow tests to run on architectures without per-cpu call_rcu support + * Hash table test: FreeBSD compatibility fix + * tests: define _GNU_SOURCE instead of __USE_GNU + * RCU lock-free hash table: implement cds_lfht_is_node_deleted() + * Define _GNU_SOURCE to access CPU_ZERO() macro in uClibc + * Install ChangeLog and README into system's doc + * Fix AC_LANG_SOURCE usage: only takes one parameter + * Fix autoconf futex check + * configure.ac: Use AC_LANG_SOURCE for if else macros + * Refresh autoconf files + * Update gitignore + * rculfhash: add comment about hash seed randomness within test program + * readme: state correct GCC dependency for ARM + * rculfhash: remove an invocation of bit_reverse_ulong() when adding + * rculfhash: remove unneeded conversion + * rculfhash: remove unneeded clear_flag() + * cds_lfht_replace: add checks for old/new node hash/value match + * rculfhash: use node instead of iter argument for deletion + * rculfhash: number of logically removed nodes should not appear in API + * Document that flags could be represented on 2 bits + * Add missing REMOVAL_OWNER_FLAG comment to cds_lfht_node comment + * _cds_lfht_del is not used for buckets anymore, remove parameter + * rculfhash: Relax atomicity guarantees required by removal operation + * remove unneeded "return;" + * simplify the deletion for bucket node + * Remove unneeded code + * Cleanup DEFINE_RCU_FLAVOR() + * Add cds_lfht_ prefix to fls_ulong, get_count_order_ulong, get_count_order_u32 + * Merge RCU Lock-Free Resizable Hash Table + +2011-12-12 Userspace RCU 0.6.7 + * Add compat file for test urcu wfs + * Add missing compat file for wfq test + * hlist.h: Add missing stddef.h include for NULL + * call_rcu: Add missing call_rcu_before_fork and + call_rcu_after_fork_parent declarations + * Describe autotools/libtool/automake version dependency + * Remove m4_ifdef for AC_PROG_LIBTOOL (deprecated) + * Support older autotools + * Apply autoupdate to configure.ac + * Fix build for amd64 environment (for FreeBSD 8.2) + * Add missing rcu_dereference_sym_bp + * Install test scripts in the dist tarball + +2011-11-03 Userspace RCU 0.6.6 + * qsbr vs call_rcu : remove exit assertion + * Rename likely/unlikely to caa_likely/caa_unlikely + * Reinsert missing test_urcu_*.c files (missing in rename) + * rename test_qsbr to test_urcu_qsbr + * urcu-pointer: fix rcu_set_pointer unset return value + * Enhance API.txt documentation, add to Makefile as EXTRA_DIST + +2011-09-29 Userspace RCU 0.6.5 + * call_rcu: Document call_rcu requirements + * call_rcu: fix error handling of malloc error + * urcu call_rcu: Use RCU read-side protection for per-cpu call_rcu data + * urcu,call_rcu: Cleanup call_rcu_data pointers before use in child + * urcu,call_rcu: avoid create call_rcu_data for child when unneed + * urcu,defer_rcu: Make defer_rcu encoding more compact for marker + * urcu_defer: Use cancellation flag instead of pthread_cancel() + * urcu,call_rcu: protects call_rcu_data_list when remove node + * Create default call rcu data upon per-cpu call-rcu teardown + * powerpc: use __NO_LWSYNC__ check to use appropriate lwsync/sync opcode + * cmm: provide lightweight smp_rmb/smp_wmb on PPC + * atomic: provide seq_cst semantics on powerpc + * avoid leaking crdp for failed path + * Return -EEXIST when the old cpu call_rcu_data has not been removed + * protect writing to per_cpu_call_rcu_data[*] + * wake up default call_rcu thread after we move the leftover callbacks + * avoid memory leak in call_rcu_data_free() + * urcu call_rcu: fix use after free() + * use get_cpu_call_rcu_data() for get_call_rcu_data() + * init maxcpus before use + * call_rcu implementation: add missing static + * Document QSBR interaction with mutexes + * urcu-pointer: implement URCU_FORCE_CAST for C++ compatibility of urcu-pointer.h + * urcu-qsbr: use rcu_thread_offline/rcu_thread_online instead of inlining them + * Pair all_cpu call_rcu create with free + * QSBR: add missing wakeups in synchronize_rcu code + * cmm: do not generate code for smp_rmb/smp_wmb on x86_64 + * cmm: let per-arch files provide cmm_smp_* barriers + * Optimize caa_get_cycles() for PowerPC64 + * lfq/lfs tests: use call_rcu + * list: Add cds_list_first_entry + * rculfstack/queue: define _LGPL_SOURCE around static header include + * Add __rcu annotation (unimplemented) + * Fix incorrect fsf address in header files + * wfstack: push returns prior stack emptiness state + * Make lf stack push return if the stack was empty + * Document caa_container_of + * urcu-bp: do not call munmap for NULL registry at exit + * urcu libraries can directly use the _LGPL_SOURCE wfqueue + * rculfstack: document "push" + * Add runall.sh to tarball + * Fix build order of liburcu-cds-common + * Fix missing check for SYS_membarrier in map header + * urcu-qsbr: avoid useless futex wakeups and burning CPU for long grace periods + * api: reimplement BUILD_BUG_ON in compiler.h + * test api cleanup: remove unused primitives + * put thread offline while waiting for the init flag + * urcu: move private definitions to .c file + * urcu-bp: move private definitions to .c file + * urcu-qsbr: move private definitions to .c file + * rcutorture: fix rcutorture-qsbr + * wfqueue: fix type-incorrect assignment + * Fix tests Makefile EXTRA_DIST to use api.h + * Fix choice of default flavour in urcu/map/urcu.h + * api: remove list/hlist + * api: remove arch-specific files + * api: make api_gcc.h a superset of the other headers + * tests api: remove atomics + * put thread offline while waiting for the init flag + * urcu: move private definitions to .c file + * urcu-bp: move private definitions to .c file + * urcu-qsbr: move private definitions to .c file + * rcutorture: fix rcutorture-qsbr + * wfqueue: fix type-incorrect assignment + * Use caa_ prefix for min() and max() + +2011-07-21 Userspace RCU 0.6.4 + * uatomic: Fix ARM build errors in uatomic. + * urcu tests: hold mutex across use of custom allocator. + * Portability fixes to support FreeBSD 8.2. + +2011-06-27 Userspace RCU 0.6.3 + * uatomic: Fix i386 compatibility build errors in uatomic. + +2011-06-13 Userspace RCU 0.6.2 + * Fix build on powerpc. + +2011-06-13 Userspace RCU 0.6.1 + * Add missing headers into release tarball: + urcu-call-rcu-impl.h and urcu-defer-impl.h + +2011-06-10 Userspace RCU 0.6.0 + * Added call_rcu() support, graciously contributed by Paul E. McKenney. + * Added urcu/cds.h and merged all "Concurrent Data Containers" (CDS) + into a single .so: liburcu-cds.so to have a single header/shared + object holding all concurrency-aware data containers. It provides + support for RCU lists, queues and stacks at the moment. + * liburcu 0.6.0 now allows linking a single application with multiple + flavors of RCU. This required a library API change which is + incompatible with older 0.5.x liburcu. The .so version number + is therefore bumped from 0 to 1 (e.g. liburcu.so.1). + * Added "atfork" handling API, documented in README. Only useful for + processes using fork() without following exec(). + * Renaming the following files, keeping the old files (producing a + compiler warning): + urcu/uatomic_arch.h -> urcu/uatomic.h + urcu/urcu-futex.h -> urcu/futex.h + urcu/urcu_ref.h -> urcu/ref.h + +2011-03-04 Userspace RCU 0.5.4 + * urcu-bp: Update fork() handling + + Introduce + + extern void rcu_bp_before_fork(void); + extern void rcu_bp_after_fork_parent(void); + extern void rcu_bp_after_fork_child(void); + + to handle fork gracefully. These disable signals and hold + the registry mutex across forks. (this flavor of the liburcu + library ("bp" for "bulletproof") is mainly used by UST, the + user-space tracer). + +2011-03-03 Userspace RCU 0.5.3 + * Add support for older ARM single-CPU architecturess (pre-ARMv7) + (thanks to Jason Wessel from WindRiver). + * Fix ARMv7 cmm_rmb/cmm_wmb primitives (use a dmb barrier). + * Remove leftover list_t type from urcu/list.h (namespace cleanup). + * urcu_defer: handle malloc error value. + * Update README file to describe urcu interaction with fork() when not + * followed + by an exec() system call. + +2010-11-18 Userspace RCU 0.5.2 + * Fix renaming error introduced in 0.5.0. + +2010-11-18 Userspace RCU 0.5.1 + * Fix renaming error introduced in 0.5.0. (incomplete fix) + +2010-11-18 Userspace RCU 0.5.0 + * Version 0.5.0 changes the API presented by memory model, + architecture abstraction and data structure primitives in + headers. The prefixes are, respectively: + - cmm_ : Concurrent Memory Model + - caa_ : Concurrent Architecture Abstraction + - cds_ : Concurrent Data Structures + +2010-03-04 Userspace RCU 0.4.2 + * Add generic uatomic ops support. + * Bugfix in urcu-bp. (rare garbage collection bug occurring in + multithreaded environment). Only affects urcu-bp users (UST). + +2010-02-12 Userspace RCU 0.4.1 + * s390: compilation fix. + +2010-01-30 Userspace RCU 0.4.0 + * API change: SIGURCU -> SIGRCU + * API changes: standardize on rcu_ prefix. + * API change: urcu_init -> rcu_init. + * urcu/config.h options renamed to CONFIG_RCU_HAVE_FENCE, + CONFIG_RCU_HAVE_FUTEX, CONFIG_RCU_SMP, CONFIG_RCU_COMPAT_ARCH. + ((moving from URCU -> RCU). + * library names changes: liburcu becomes the "default" version, using + sys_membarrier() when available, and using liburcu-mb as a + fallback. + * The signal-based liburcu is renamed from liburcu to + liburcu-signal. People previously using the signal-based + "liburcu" will automatically be moved to the "default" liburcu + version. + +2009-11-16 Userspace RCU 0.3.1 + * Add support for sparcv9 32-bit build. + * Update build system to use --host instead of --target. + +2009-11-03 Userspace RCU 0.3.0 + * API change for the "deferred work" interface. + +2009-10-14 Userspace RCU 0.2.3 + * Move to autotools. + * Automated architecture detection, with i386 fallback. + * Detect if NR_futex is on the system, fallback on portable + alternatives. + * Add configure mode for UP-only systems. + +2009-10-02 Userspace RCU 0.2.2 + * Phases out rcu_publish_content() api. + * Adds type checking to urcu-pointer.h pointer exchange primitives. + +2009-10-02 Userspace RCU 0.2.1 + * small header dependency fix for rculist.h. + * new "liburcu-bp.so" : "Bulletproof RCU", made especially for + the UST userspace tracer. It's a library that sacrifices a bit + of read-side performance for automatically monitoring thread + creation/removal. See README for details. + +2009-10-01 Userspace RCU 0.2 + * Clarify usage of rcu_cmpxchg_pointer, rcu_xchg_pointer, + rcu_set_pointer. + +2009-09-29 Userspace RCU 0.1 + * Initial release. diff --git a/external/lgpl2/userspace-rcu/dist/CodingStyle.md b/external/lgpl2/userspace-rcu/dist/CodingStyle.md new file mode 100644 index 0000000000000..d2ad79acf1d4c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/CodingStyle.md @@ -0,0 +1,16 @@ + + +# Userspace RCU Coding Style + +The coding style used for this project follows the Linux kernel +guide lines. Please refer to: + +- Linux kernel Documentation/CodingStyle document for details, +- Linux kernel scripts/checkpatch.pl for a script which verify the patch + coding style. + +Mathieu Desnoyers, May 30, 2012 diff --git a/external/lgpl2/userspace-rcu/dist/LICENSE.md b/external/lgpl2/userspace-rcu/dist/LICENSE.md new file mode 100644 index 0000000000000..6a5d2046c77bd --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/LICENSE.md @@ -0,0 +1,64 @@ +# Userspace RCU library licensing + +This project is compliant with the [REUSE](https://reuse.software/spec/) +specification, each file contains [SPDX](https://spdx.org/specifications) tags, +the full licenses can be found in the `LICENSES/` directory. + + +## Library code + +The library part is distributed under `LGPL-2.1-or-later`. See +`LICENSES/LGPL-2.1-or-later.txt` for license details. Refer to the individual +file headers for details. + +LGPL-compatible source code can statically use the library header using : + +```` +#define _LGPL_SOURCE +#include +```` + +Dynamic-only linking with the LGPL library is used if `_LGPL_SOURCE` is not +defined. It permits relinking with newer versions of the library, which is +required by the LGPL license. + +See `lgpl-relicensing.md` for details. + + +## Headers + +Most headers are also distributed under `LGPL-2.1-or-later`, some include code +from `atomic_ops` and are distributed under `Boehm-GC` and some others are +distributed under `MIT`. Refer to the individual file headers for details. + +xchg() primitive has been rewritten from scratch starting from `atomic_ops 1.2` +which has a MIT-style license that is intended to allow use in both free and +proprietary software: + +```` +http://www.hpl.hp.com/research/linux/atomic_ops/LICENSING.txt +http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/ +```` + + +## Tests + +Library test code is distributed under the `GPL-2.0-only` license. See +`LICENSES/GPL-2.0-only.txt` for license details. See headers of individual +files under `tests/` for details. + + +## Documentation + +The documentation is distributed under the `CC-BY-4.0` license. + + +## Build system + +Build system related files are mostly distributed under the `MIT` license. See +headers of individual files for details. + + +## Generated data files + +Generated data files are distributed under the `CC-1.0` license. diff --git a/external/lgpl2/userspace-rcu/dist/LICENSES/Autoconf-exception-2.0.txt b/external/lgpl2/userspace-rcu/dist/LICENSES/Autoconf-exception-2.0.txt new file mode 100644 index 0000000000000..00cddeba4d280 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/LICENSES/Autoconf-exception-2.0.txt @@ -0,0 +1,5 @@ +As a special exception, the Free Software Foundation gives unlimited permission to copy, distribute and modify the configure scripts that are the output of Autoconf. You need not follow the terms of the GNU General Public License when using or distributing such scripts, even though portions of the text of Autoconf appear in them. The GNU General Public License (GPL) does govern all other use of the material that constitutes the Autoconf program. + +Certain portions of the Autoconf source text are designed to be copied (in certain cases, depending on the input) into the output of Autoconf. We call these the "data" portions. The rest of the Autoconf source text consists of comments plus executable code that decides which of the data portions to output in any given case. We call these comments and executable code the "non-data" portions. Autoconf never copies any of the non-data portions into its output. + +This special exception to the GPL applies to versions of Autoconf released by the Free Software Foundation. When you make and distribute a modified version of Autoconf, you may extend this special exception to the GPL to apply to your modified version as well, *unless* your modified version has the potential to copy into its output some of the text that was the non-data portion of the version that you started with. (In other words, unless your change moves or copies text from the non-data portions to the data portions.) If your modification has such potential, you must delete any notice of this special exception to the GPL from your modified version. diff --git a/external/lgpl2/userspace-rcu/dist/LICENSES/BSD-2-Clause.txt b/external/lgpl2/userspace-rcu/dist/LICENSES/BSD-2-Clause.txt new file mode 100644 index 0000000000000..5f662b354cd40 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/LICENSES/BSD-2-Clause.txt @@ -0,0 +1,9 @@ +Copyright (c) + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/external/lgpl2/userspace-rcu/dist/LICENSES/CC-BY-4.0.txt b/external/lgpl2/userspace-rcu/dist/LICENSES/CC-BY-4.0.txt new file mode 100644 index 0000000000000..13ca539f377dc --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/LICENSES/CC-BY-4.0.txt @@ -0,0 +1,156 @@ +Creative Commons Attribution 4.0 International + + Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. + +Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors. + +Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public. + +Creative Commons Attribution 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. + +Section 1 – Definitions. + + a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. + + c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. + + d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. + + e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. + + f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. + + g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. + + h. Licensor means the individual(s) or entity(ies) granting rights under this Public License. + + i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. + + j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. + + k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. + +Section 2 – Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: + + A. reproduce and Share the Licensed Material, in whole or in part; and + + B. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. + + 3. Term. The term of this Public License is specified in Section 6(a). + + 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. + + 5. Downstream recipients. + + A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. + + B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. + + 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). + +b. Other rights. + + 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this Public License. + + 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties. + +Section 3 – License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified form), You must: + + A. retain the following if it is supplied by the Licensor with the Licensed Material: + + i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of warranties; + + v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; + + B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and + + C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. + + 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. + + 4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License. + +Section 4 – Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database; + + b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and + + c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. +For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. + +Section 5 – Disclaimer of Warranties and Limitation of Liability. + + a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. + + b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. + + c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. + +Section 6 – Term and Termination. + + a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or + + 2. upon express reinstatement by the Licensor. + + c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. + + d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. + + e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. + +Section 7 – Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. + +Section 8 – Interpretation. + + a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. + + c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. + + d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. + +Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/external/lgpl2/userspace-rcu/dist/LICENSES/CC0-1.0.txt b/external/lgpl2/userspace-rcu/dist/LICENSES/CC0-1.0.txt new file mode 100644 index 0000000000000..0e259d42c9967 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/LICENSES/CC0-1.0.txt @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/external/lgpl2/userspace-rcu/dist/LICENSES/FSFAP.txt b/external/lgpl2/userspace-rcu/dist/LICENSES/FSFAP.txt new file mode 100644 index 0000000000000..32bc8a88986de --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/LICENSES/FSFAP.txt @@ -0,0 +1 @@ +Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty. diff --git a/external/lgpl2/userspace-rcu/dist/LICENSES/GPL-2.0-only.txt b/external/lgpl2/userspace-rcu/dist/LICENSES/GPL-2.0-only.txt new file mode 100644 index 0000000000000..17cb286430a4d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/LICENSES/GPL-2.0-only.txt @@ -0,0 +1,117 @@ +GNU GENERAL PUBLIC LICENSE +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + + c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + one line to give the program's name and an idea of what it does. Copyright (C) yyyy name of author + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. + +signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice diff --git a/external/lgpl2/userspace-rcu/dist/LICENSES/GPL-2.0-or-later.txt b/external/lgpl2/userspace-rcu/dist/LICENSES/GPL-2.0-or-later.txt new file mode 100644 index 0000000000000..17cb286430a4d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/LICENSES/GPL-2.0-or-later.txt @@ -0,0 +1,117 @@ +GNU GENERAL PUBLIC LICENSE +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + + c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + one line to give the program's name and an idea of what it does. Copyright (C) yyyy name of author + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. + +signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice diff --git a/external/lgpl2/userspace-rcu/dist/LICENSES/GPL-3.0-or-later.txt b/external/lgpl2/userspace-rcu/dist/LICENSES/GPL-3.0-or-later.txt new file mode 100644 index 0000000000000..f6cdd22a6c1fb --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/LICENSES/GPL-3.0-or-later.txt @@ -0,0 +1,232 @@ +GNU GENERAL PUBLIC LICENSE +Version 3, 29 June 2007 + +Copyright © 2007 Free Software Foundation, Inc. + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The GNU General Public License is a free, copyleft license for software and other kinds of works. + +The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. + +Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. + +Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS + +0. Definitions. + +“This License” refers to version 3 of the GNU General Public License. + +“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. + +“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations. + +To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work. + +A “covered work” means either the unmodified Program or a work based on the Program. + +To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. + +To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. + +1. Source Code. +The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work. + +A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. + +The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. + +The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same work. + +2. Basic Permissions. +All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. + +3. Protecting Users' Legal Rights From Anti-Circumvention Law. +No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. + +When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. + +4. Conveying Verbatim Copies. +You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. + +5. Conveying Modified Source Versions. +You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”. + + c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. + +A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. + +6. Conveying Non-Source Forms. +You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: + + a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. + + d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. + +A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. + +“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. + +If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). + +The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. + +7. Additional Terms. +“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or authors of the material; or + + e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. + +All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. + +8. Termination. +You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). + +However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. + +Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. + +9. Acceptance Not Required for Having Copies. +You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. + +10. Automatic Licensing of Downstream Recipients. +Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. + +An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. + +11. Patents. +A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”. + +A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. + +In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. + +A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. + +12. No Surrender of Others' Freedom. +If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. + +13. Use with the GNU Affero General Public License. +Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. + +14. Revised Versions of this License. +The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. + +Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. + +15. Disclaimer of Warranty. +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. Limitation of Liability. +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +17. Interpretation of Sections 15 and 16. +If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + +If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”. + +You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . + +The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . diff --git a/external/lgpl2/userspace-rcu/dist/LICENSES/LGPL-2.1-only.txt b/external/lgpl2/userspace-rcu/dist/LICENSES/LGPL-2.1-only.txt new file mode 100644 index 0000000000000..c9aa53018e760 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/LICENSES/LGPL-2.1-only.txt @@ -0,0 +1,175 @@ +GNU LESSER GENERAL PUBLIC LICENSE + +Version 2.1, February 1999 + +Copyright (C) 1991, 1999 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. + +This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. + +When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. + +To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. + +For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. + +We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. + +To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. + +Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. + +Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. + +When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. + +We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. + +For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. + +In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. + +Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. + +The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". + +A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. + +The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) + +"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. + +1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. + +(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. + +Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. + +This option is useful when you wish to copy part of the code of the Library into a program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. + +If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. + +5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. + +However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. + +When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. + +If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. + +6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. + +You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: + + a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. + + e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. + +For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. + + b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. + +8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. + +10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. + +11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. + +14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Libraries + +If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). + +To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + one line to give the library's name and an idea of what it does. + Copyright (C) year name of author + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in +the library `Frob' (a library for tweaking knobs) written +by James Random Hacker. + +signature of Ty Coon, 1 April 1990 +Ty Coon, President of Vice +That's all there is to it! diff --git a/external/lgpl2/userspace-rcu/dist/LICENSES/LGPL-2.1-or-later.txt b/external/lgpl2/userspace-rcu/dist/LICENSES/LGPL-2.1-or-later.txt new file mode 100644 index 0000000000000..c9aa53018e760 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/LICENSES/LGPL-2.1-or-later.txt @@ -0,0 +1,175 @@ +GNU LESSER GENERAL PUBLIC LICENSE + +Version 2.1, February 1999 + +Copyright (C) 1991, 1999 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. + +This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. + +When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. + +To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. + +For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. + +We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. + +To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. + +Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. + +Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. + +When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. + +We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. + +For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. + +In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. + +Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. + +The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". + +A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. + +The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) + +"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. + +1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. + +(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. + +Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. + +This option is useful when you wish to copy part of the code of the Library into a program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. + +If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. + +5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. + +However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. + +When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. + +If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. + +6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. + +You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: + + a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. + + e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. + +For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. + + b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. + +8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. + +10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. + +11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. + +14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Libraries + +If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). + +To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + one line to give the library's name and an idea of what it does. + Copyright (C) year name of author + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in +the library `Frob' (a library for tweaking knobs) written +by James Random Hacker. + +signature of Ty Coon, 1 April 1990 +Ty Coon, President of Vice +That's all there is to it! diff --git a/external/lgpl2/userspace-rcu/dist/LICENSES/LicenseRef-Autoconf-exception-macro.txt b/external/lgpl2/userspace-rcu/dist/LICENSES/LicenseRef-Autoconf-exception-macro.txt new file mode 100644 index 0000000000000..8b5b4677f3eb0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/LICENSES/LicenseRef-Autoconf-exception-macro.txt @@ -0,0 +1,12 @@ +As a special exception, the respective Autoconf Macro's copyright owner +gives unlimited permission to copy, distribute and modify the configure +scripts that are the output of Autoconf when processing the Macro. You +need not follow the terms of the GNU General Public License when using +or distributing such scripts, even though portions of the text of the +Macro appear in them. The GNU General Public License (GPL) does govern +all other use of the material that constitutes the Autoconf Macro. + +This special exception to the GPL applies to versions of the Autoconf +Macro released by the Autoconf Archive. When you make and distribute a +modified version of the Autoconf Macro, you may extend this special +exception to the GPL to apply to your modified version as well. diff --git a/external/lgpl2/userspace-rcu/dist/LICENSES/LicenseRef-Boehm-GC.txt b/external/lgpl2/userspace-rcu/dist/LICENSES/LicenseRef-Boehm-GC.txt new file mode 100644 index 0000000000000..95427c0b59062 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/LICENSES/LicenseRef-Boehm-GC.txt @@ -0,0 +1,12 @@ +Copyright (c) ... + +THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + +Permission is hereby granted to use or copy this program +for any purpose, provided the above notices are retained on all copies. +Permission to modify the code and to distribute modified code is granted, +provided the above notices are retained, and a notice that the code was +modified is included with the above copyright notice. + +A few files have other copyright holders. diff --git a/external/lgpl2/userspace-rcu/dist/LICENSES/MIT.txt b/external/lgpl2/userspace-rcu/dist/LICENSES/MIT.txt new file mode 100644 index 0000000000000..2071b23b0e085 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/LICENSES/MIT.txt @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/external/lgpl2/userspace-rcu/dist/Makefile.am b/external/lgpl2/userspace-rcu/dist/Makefile.am new file mode 100644 index 0000000000000..539a2ca3ad34c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/Makefile.am @@ -0,0 +1,37 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +ACLOCAL_AMFLAGS=-I m4 + +SUBDIRS = include src doc tests extras + +dist_doc_DATA = \ + LICENSE.md \ + README.md + +EXTRA_DIST = \ + CodingStyle.md \ + lgpl-relicensing.md \ + LICENSES/Autoconf-exception-2.0.txt \ + LICENSES/BSD-2-Clause.txt \ + LICENSES/CC0-1.0.txt \ + LICENSES/CC-BY-4.0.txt \ + LICENSES/FSFAP.txt \ + LICENSES/GPL-2.0-only.txt \ + LICENSES/GPL-2.0-or-later.txt \ + LICENSES/LGPL-2.1-only.txt \ + LICENSES/LGPL-2.1-or-later.txt \ + LICENSES/LicenseRef-Autoconf-exception-macro.txt \ + LICENSES/LicenseRef-Boehm-GC.txt \ + LICENSES/MIT.txt + +.PHONY: short_bench long_bench regtest check-loop +short_bench: + cd tests && $(MAKE) $(AM_MAKEFLAGS) short_bench +long_bench: + cd tests && $(MAKE) $(AM_MAKEFLAGS) long_bench +regtest: + cd tests && $(MAKE) $(AM_MAKEFLAGS) regtest +check-loop: + cd tests && $(MAKE) $(AM_MAKEFLAGS) check-loop diff --git a/external/lgpl2/userspace-rcu/dist/README.md b/external/lgpl2/userspace-rcu/dist/README.md new file mode 100644 index 0000000000000..d868ac491c501 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/README.md @@ -0,0 +1,493 @@ + + +Userspace RCU Implementation +============================ + +by Mathieu Desnoyers and Paul E. McKenney + + +Building +-------- + + ./bootstrap # skip if using tarball + ./configure + make + make install + ldconfig + +Hints: + + - Forcing 32-bit build: + + CFLAGS="-m32 -g -O2" ./configure + + - Forcing 64-bit build: + + CFLAGS="-m64 -g -O2" ./configure + + - Forcing a 32-bit build with 386 backward compatibility: + + CFLAGS="-m32 -g -O2" ./configure --host=i386-pc-linux-gnu + + - Forcing a 32-bit build for Sparcv9 (typical for Sparc v9) + + CFLAGS="-m32 -Wa,-Av9a -g -O2" ./configure + + +Architectures supported +----------------------- + +Currently, the following architectures are supported: + + - x86 (i386, i486, i586, i686) + - amd64 / x86\_64 + - PowerPC 32/64 + - S390, S390x + - ARM 32/64 + - MIPS + - NIOS2 + - Alpha + - ia64 + - Sparcv9 32/64 + - Tilera + - hppa/PA-RISC + - m68k + - RISC-V + - LoongArch + +Tested on: + + - Linux all architectures + - FreeBSD 13 i386/amd64 + - Cygwin i386/amd64 + - MacOS amd64/arm64 + +Should also work on: + + - Android + - NetBSD 5 + - OpenBSD + - Solaris + +(more testing needed before claiming support for these OS). + + +Toolchain support +----------------- + +The C compiler used needs to support at least C99. The C++ compiler used needs +to support at least C++11. The oldest GCC version officialy supported and +tested is 4.8. + +Older GCC versions might still work with the following exceptions: + + - GCC 3.3 and 3.4 have a bug that prevents them from generating volatile + accesses to offsets in a TLS structure on 32-bit x86. These versions are + therefore not compatible with `liburcu` on x86 32-bit + (i386, i486, i586, i686). + The problem has been reported to the GCC community: + + - GCC 3.3 cannot match the "xchg" instruction on 32-bit x86 build. + See + - Alpha, ia64 and ARM architectures depend on GCC 4.x with atomic builtins + support. For ARM this was introduced with GCC 4.4: + . + - Linux aarch64 depends on GCC 5.1 or better because prior versions + perform unsafe access to deallocated stack. + +Clang version 3.0 (based on LLVM 3.0) is supported. + +Glibc >= 2.4 should work but the older version we test against is +currently 2.17. + + +Build system +------------ + +For developers using the Git tree: + +This source tree is based on the autotools suite from GNU to simplify +portability. Here are some things you should have on your system in order to +compile the git repository tree : + + - GNU autotools (automake >=1.12, autoconf >=2.69) + (make sure your system wide `automake` points to a recent version!) + - GNU Libtool >=2.2 + (for more information, go to ) + +If you get the tree from the repository, you will need to use the `bootstrap` +script in the root of the tree. It calls all the GNU tools needed to prepare +the tree configuration. + +Test scripts provided in the `tests/` directory of the source tree depend +on `bash` and the `seq` program. + + +API +--- + +See the relevant API documentation files in `doc/`. The APIs provided by +Userspace RCU are, by prefix: + + - `rcu_`: Read-Copy Update (see [`doc/rcu-api.md`](doc/rcu-api.md)) + - `cmm_`: Concurrent Memory Model + - `caa_`: Concurrent Architecture Abstraction + - `cds_`: Concurrent Data Structures + (see [`doc/cds-api.md`](doc/cds-api.md)) + - `uatomic_`: Userspace Atomic + (see [`doc/uatomic-api.md`](doc/uatomic-api.md)) + + +Quick start guide +----------------- + +### Usage of all urcu libraries: + + - Define `_LGPL_SOURCE` (only) if your code is LGPL or GPL compatible + before including the `urcu.h` or `urcu-qsbr.h` header. If your application + is distributed under another license, function calls will be generated + instead of inlines, so your application can link with the library. + - Linking with one of the libraries below is always necessary even for + LGPL and GPL applications. + - Define `URCU_INLINE_SMALL_FUNCTIONS` before including Userspace RCU + headers if you want Userspace RCU to inline small functions (10 + lines or less) into the application. It can be used by applications + distributed under any kind of license, and does *not* make the + application a derived work of Userspace RCU. + +Those small inlined functions are guaranteed to match the library +content as long as the library major version is unchanged. +Therefore, the application *must* be compiled with headers matching +the library major version number. Applications using +`URCU_INLINE_SMALL_FUNCTIONS` may be unable to use debugging +features of Userspace RCU without being recompiled. + +There are multiple flavors of liburcu available: + + - `memb`, + - `qsbr`, + - `mb`, + - `bp`. + +The API members start with the prefix `urcu__`, where +`` is the chosen flavor name. + + +### Usage of `liburcu-memb` + + 1. `#include ` + 2. Link the application with `-lurcu-memb` + +This is the preferred version of the library, in terms of +grace-period detection speed, read-side speed and flexibility. +Dynamically detects kernel support for `sys_membarrier()`. Falls back +on `urcu-mb` scheme if support is not present, which has slower +read-side. Use the `--disable-sys-membarrier-fallback` configure option +to disable the fall back, thus requiring `sys_membarrier()` to be +available. This gives a small speedup when `sys_membarrier()` is +supported by the kernel, and aborts in the library constructor if not +supported. + + +### Usage of `liburcu-qsbr` + + 1. `#include ` + 2. Link with `-lurcu-qsbr` + +The QSBR flavor of RCU needs to have each reader thread executing +`rcu_quiescent_state()` periodically to progress. `rcu_thread_online()` +and `rcu_thread_offline()` can be used to mark long periods for which +the threads are not active. It provides the fastest read-side at the +expense of more intrusiveness in the application code. + + +### Usage of `liburcu-mb` + + 1. `#include ` + 2. Link with `-lurcu-mb` + +This version of the urcu library uses memory barriers on the writer +and reader sides. This results in faster grace-period detection, but +results in slower reads. + + +### Usage of `liburcu-bp` + + 1. `#include ` + 2. Link with `-lurcu-bp` + +The BP library flavor stands for "bulletproof". It is specifically +designed to help tracing library to hook on applications without +requiring to modify these applications. `urcu_bp_init()`, and +`urcu_bp_unregister_thread()` all become nops, whereas calling +`urcu_bp_register_thread()` becomes optional. The state is dealt with by +the library internally at the expense of read-side and write-side +performance. + + +### Initialization + +Each thread that has reader critical sections (that uses +`urcu__read_lock()`/`urcu__read_unlock()` must first +register to the URCU library. This is done by calling +`urcu__register_thread()`. Unregistration must be performed +before exiting the thread by using `urcu__unregister_thread()`. + + +### Reading + +Reader critical sections must be protected by locating them between +calls to `urcu__read_lock()` and `urcu__read_unlock()`. +Inside that lock, `rcu_dereference()` may be called to read an RCU +protected pointer. + + +### Writing + +`rcu_assign_pointer()` and `rcu_xchg_pointer()` may be called anywhere. +After, `urcu__synchronize_rcu()` must be called. When it +returns, the old values are not in usage anymore. + +As an alternative to `urcu__synchronize_rcu()`, +it is also possible to use the urcu polling mechanism to wait for a +grace period to elapse. This can be done by using +`urcu__start_poll_synchronize_rcu()` +to start the grace period polling, and then invoke +`urcu__poll_state_synchronize_rcu()`, which returns true if +the grace period has completed, false otherwise. + + +### Usage of `liburcu-defer` + + - Follow instructions for either `liburcu-memb`, `liburcu-qsbr`, + `liburcu-mb`, or `liburcu-bp` above. + The `liburcu-defer` functionality is pulled into each of + those library modules. + - Provides `urcu__defer_rcu()` primitive to enqueue delayed + callbacks. Queued callbacks are executed in batch periodically after + a grace period. Do _not_ use `urcu__defer_rcu()` within a + read-side critical section, because it may call + `urcu__synchronize_rcu()` if the thread queue is full. This + can lead to deadlock or worse. + - Requires that `urcu__defer_barrier()` must be called in + library destructor if a library queues callbacks and is expected to + be unloaded with `dlclose()`. + +Its API is currently experimental. It may change in future library releases. + + +### Usage of `urcu-call-rcu` + + - Follow instructions for either `liburcu-memb`, `liburcu-qsbr`, + `liburcu-mb`, or `liburcu-bp` above. + The `urcu-call-rcu` functionality is pulled into each of + those library modules. + - Provides the `urcu__call_rcu()` primitive to enqueue delayed + callbacks in a manner similar to `urcu__defer_rcu()`, but + without ever delaying for a grace period. On the other hand, + `urcu__call_rcu()`'s best-case overhead is not quite as good + as that of `urcu__defer_rcu()`. + - Provides `urcu__call_rcu()` to allow asynchronous handling + of RCU grace periods. A number of additional functions are provided + to manage the helper threads used by `urcu__call_rcu()`, but + reasonable defaults are used if these additional functions are not + invoked. See [`doc/rcu-api.md`](doc/rcu-api.md) in userspace-rcu + documentation for more details. + + +### Being careful with signals + +Read-side critical sections are allowed in a signal handler, +except those setup with `sigaltstack(2)`, with `liburcu-memb` and +`liburcu-mb`. Be careful, however, to disable these signals +between thread creation and calls to `urcu__register_thread()`, +because a signal handler nesting on an unregistered thread would not be +allowed to call `urcu__read_lock()`. + +Read-side critical sections are _not_ allowed in a signal handler with +`liburcu-qsbr`, unless signals are disabled explicitly around each +`urcu_qsbr_quiescent_state()` calls, when threads are put offline and around +calls to `urcu_qsbr_synchronize_rcu()`. Even then, we do not recommend it. + + +### Interaction with mutexes + +One must be careful to do not cause deadlocks due to interaction of +`urcu__synchronize_rcu()` and RCU read-side with mutexes. If +`urcu__synchronize_rcu()` is called with a mutex held, this +mutex (or any mutex which has this mutex in its dependency chain) should +not be acquired from within a RCU read-side critical section. + +This is especially important to understand in the context of the +QSBR flavor: a registered reader thread being "online" by +default should be considered as within a RCU read-side critical +section unless explicitly put "offline". Therefore, if +`urcu_qsbr_synchronize_rcu()` is called with a mutex held, this mutex, +as well as any mutex which has this mutex in its dependency chain should +only be taken when the RCU reader thread is "offline" (this can be +performed by calling `urcu_qsbr_thread_offline()`). + + +### Interaction with `fork()` + +Special care must be taken for applications performing `fork()` without +any following `exec()`. This is caused by the fact that Linux only clones +the thread calling `fork()`, and thus never replicates any of the other +parent thread into the child process. Most `liburcu` implementations +require that all registrations (as reader, `defer_rcu` and `call_rcu` +threads) should be released before a `fork()` is performed, except for the +rather common scenario where `fork()` is immediately followed by `exec()` in +the child process. The only implementation not subject to that rule is +`liburcu-bp`, which is designed to handle `fork()` by calling +`urcu_bp_before_fork`, `urcu_bp_after_fork_parent` and +`urcu_bp_after_fork_child`. + +Applications that use `urcu__call_rcu()` and that `fork()` +without doing an immediate `exec()` must take special action. The +parent must invoke `urcu__call_rcu_before_fork()` before the +`fork()` and `urcu__call_rcu_after_fork_parent()` after the +`fork()`. The child process must invoke +`urcu__call_rcu_after_fork_child()`. Even though these three +APIs are suitable for passing to `pthread_atfork()`, use of +`pthread_atfork()` is **STRONGLY DISCOURAGED** for programs calling the +glibc memory allocator (`malloc()`, `calloc()`, `free()`, ...) within +`urcu__call_rcu` callbacks. This is due to limitations in the +way glibc memory allocator handles calls to the memory allocator from +concurrent threads while the `pthread_atfork()` handlers are executing. + +Combining e.g.: + + - call to `free()` from callbacks executed within + `urcu__call_rcu` worker threads, + - executing `urcu__call_rcu` atfork handlers within the glibc + pthread atfork mechanism, + +will sometimes trigger interesting process hangs. This usually +hangs on a memory allocator lock within glibc. + + +### Thread Local Storage (TLS) + +Userspace RCU can fall back on `pthread_getspecific()` to emulate +TLS variables on systems where it is not available. This behavior +can be forced by specifying `--disable-compiler-tls` as configure +argument. + + +### Usage of `DEBUG_RCU` & `--enable-rcu-debug` + +By default the library is configured with internal debugging +self-checks disabled. + +For always-on debugging self-checks: + + ./configure --enable-rcu-debug + +For fine grained enabling of debugging self-checks, build +userspace-rcu with `DEBUG_RCU` defined and compile dependent +applications with `DEBUG_RCU` defined when necessary. + +Warning: Enabling this feature result in a performance penalty. + + +### Usage of `DEBUG_YIELD` + +`DEBUG_YIELD` is used to add random delays in the code for testing +purposes. + + +### SMP support + +By default the library is configured to use synchronization primitives +adequate for SMP systems. On uniprocessor systems, support for SMP +systems can be disabled with: + + ./configure --disable-smp-support + +theoretically yielding slightly better performance. + + +### Usage of `--enable-cds-lfht-iter-debug` + +By default the library is configured with extra debugging checks for +lock-free hash table iterator traversal disabled. + +Building liburcu with `--enable-cds-lfht-iter-debug` and rebuilding +application to match the ABI change allows finding cases where the hash +table iterator is re-purposed to be used on a different hash table while +still being used to iterate on a hash table. + +This option alters the rculfhash ABI. Make sure to compile both library +and application with matching configuration. + +### Usage of `--enable-compiler-atomic-builtins` + +Building liburcu with `--enable-compiler-atomic-builtins` implements the uatomic +API with the compiler atomic builtins if supported. + +Make targets +------------ + +In addition to the usual `make check` target, Userspace RCU features +`make regtest`, `make short_bench` and `make long_bench` targets: + + - `make check`: short tests, meant to be run when rebuilding or + porting Userspace RCU. + - `make regtest`: long (many hours) test, meant to be run when + modifying Userspace RCU or porting it to a new architecture or + operating system. + - `make short_bench`: short benchmarks, 3 seconds per test. + - `make long_bench`: long (many hours) benchmarks, 30 seconds per test. + + +Known issues +------------ + +There is an application vs library compatibility issue between +applications built using Userspace RCU 0.10 headers linked against +Userspace RCU 0.11 or 0.12 shared objects. The problem occurs as +follows: + + - An application executable is built with `_LGPL_SOURCE` defined, includes + any of the Userspace RCU 0.10 urcu flavor headers, and is built + without the `-fpic` compiler option. + + - The Userspace RCU 0.10 library shared objects are updated to 0.11 + or 0.12 without rebuilding the application. + + - The application will hang, typically when RCU grace period + (synchronize_rcu) is invoked. + +Some possible work-arounds for this are: + + - Rebuild the application against Userspace RCU 0.11+. + + - Rebuild the application with `-fpic`. + + - Upgrade Userspace RCU to 0.13+ without installing 0.11 nor 0.12. + + +Contacts +-------- + +You can contact the maintainers on the following mailing list: +`lttng-dev@lists.lttng.org`. + +IRC channel: [#lttng](irc://irc.oftc.net/lttng) on the OFTC network + +Bug tracker: [Userspace RCU bug tracker](https://bugs.lttng.org/projects/urcu) + +Code review: [_userspace-rcu_ project](https://review.lttng.org/q/project:userspace-rcu) on LTTng Review + +Continuous integration: [Userspace RCU](https://ci.lttng.org/view/Liburcu/) on LTTng's CI + +GitHub mirror: [urcu/userspace-rcu](https://github.com/urcu/userspace-rcu) + +Patches are principally submitted and reviewed on [LTTng Review](https://review.lttng.org), +but may also be submitted to the [mailing list](mailto:lttng-dev@lists.lttng.org) +with the subject prefix `PATCH urcu` or by pull request on the +[GitHub mirror](https://github.com/urcu/userspace-rcu). diff --git a/external/lgpl2/userspace-rcu/dist/bootstrap b/external/lgpl2/userspace-rcu/dist/bootstrap new file mode 100755 index 0000000000000..47a85ff608d48 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/bootstrap @@ -0,0 +1,12 @@ +#!/bin/sh + +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +set -x +if [ ! -d "config" ]; then + mkdir config +fi + +autoreconf -vi -W all,error diff --git a/external/lgpl2/userspace-rcu/dist/configure.ac b/external/lgpl2/userspace-rcu/dist/configure.ac new file mode 100644 index 0000000000000..66be61203b71b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/configure.ac @@ -0,0 +1,413 @@ +dnl SPDX-License-Identifier: LGPL-2.1-only +dnl +dnl Copyright (C) 2021 EfficiOS, Inc. +dnl +dnl Process this file with autoconf to produce a configure script. + +# Project version information +m4_define([urcu_version_major], [0]) +m4_define([urcu_version_minor], [15]) +m4_define([urcu_version_patch], [0]) +m4_define([urcu_version_dev_stage], []) +m4_define([urcu_version], urcu_version_major[.]urcu_version_minor[.]urcu_version_patch[]urcu_version_dev_stage) + +# Library version information of "liburcu" +# Following the numbering scheme proposed by libtool for the library version +# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html +m4_define([urcu_lib_version_current], [9]) +m4_define([urcu_lib_version_revision], [0]) +m4_define([urcu_lib_version_age], [1]) +m4_define([urcu_lib_version], urcu_lib_version_current[:]urcu_lib_version_revision[:]urcu_lib_version_age) + + +## ## +## Autoconf base setup ## +## ## + +AC_PREREQ([2.69]) +AC_INIT([userspace-rcu],[urcu_version],[mathieu dot desnoyers at efficios dot com],[],[http://liburcu.org/]) + +AC_CONFIG_HEADERS([include/config.h include/urcu/config.h]) +AC_CONFIG_AUX_DIR([config]) +AC_CONFIG_MACRO_DIR([m4]) + +AC_CANONICAL_TARGET +AC_CANONICAL_HOST + + +## ## +## Automake base setup ## +## ## + +AM_INIT_AUTOMAKE([1.12 foreign dist-bzip2 no-dist-gzip nostdinc -Wall -Wno-portability -Werror]) +AM_MAINTAINER_MODE([enable]) + +# Enable silent rules by default +AM_SILENT_RULES([yes]) + + +## ## +## OS and Arch specific defaults ## +## ## + +AS_CASE([$host], + [*-cygwin* | *-msys*], [LT_NO_UNDEFINED="-no-undefined"] +) + + +## ## +## C compiler checks ## +## ## + +# Choose the C compiler +AC_PROG_CC +# AC_PROG_CC_STDC was merged in AC_PROG_CC in autoconf 2.70 +m4_version_prereq([2.70], [], [AC_PROG_CC_STDC]) + +# Make sure the C compiler supports C99 +AS_IF([test "$ac_cv_prog_cc_c99" = "no"], [AC_MSG_ERROR([The compiler does not support C99])]) + +# Enable available system extensions and LFS support +AC_USE_SYSTEM_EXTENSIONS +AC_SYS_LARGEFILE + +# Check if the selected C compiler supports atomic builtins +AE_CC_ATOMIC_BUILTINS + + +## ## +## C++ compiler checks ## +## ## + +# Require a C++11 compiler without GNU extensions (-std=c++11) +AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory]) + +# Make sure the C compiler supports __attribute__ +AX_C___ATTRIBUTE__ +AS_IF([test "x$ax_cv___attribute__" != "xyes"], + [AC_MSG_ERROR([The compiler does not support __attribute__ extensions])]) + +# Make sure we have pthread support +AX_PTHREAD([], [AC_MSG_ERROR([Could not configure pthread support])]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_INLINE +AC_C_TYPEOF +AC_TYPE_INT32_T +AC_TYPE_PID_T +AC_TYPE_SIZE_T +AC_TYPE_SSIZE_T +AC_TYPE_UINT16_T +AC_TYPE_UINT32_T +AC_TYPE_UINT64_T +AC_TYPE_UINT8_T + +# Detect warning flags supported by the C compiler and append them to +# WARN_CFLAGS. +m4_define([WARN_FLAGS_LIST], [ dnl + -Wall dnl + -Wextra dnl + -Wmissing-prototypes dnl + -Wmissing-declarations dnl + -Wnull-dereference dnl + -Wundef dnl + -Wshadow dnl + -Wjump-misses-init dnl + -Wsuggest-attribute=format dnl + -Wtautological-constant-out-of-range-compare dnl + -Wnested-externs dnl + -Wwrite-strings dnl + -Wformat=2 dnl + -Wstrict-aliasing dnl + -Wmissing-noreturn dnl + -Winit-self dnl + -Wduplicated-cond dnl + -Wduplicated-branches dnl + -Wlogical-op dnl + dnl + dnl-Wredundant-decls dnl + -Wno-null-dereference dnl +]) + +# Pass -Werror as an extra flag during the test: this is needed to make the +# -Wunknown-warning-option diagnostic fatal with clang. +AC_LANG_PUSH([C]) +AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CFLAGS], [-Werror]) +AC_LANG_POP([C]) + +AC_LANG_PUSH([C++]) +AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CXXFLAGS], [-Werror]) +AC_LANG_POP([C++]) + +AE_IF_FEATURE_ENABLED([Werror], [WARN_CFLAGS="${WARN_CFLAGS} -Werror"]) +AE_IF_FEATURE_ENABLED([Werror], [WARN_CXXFLAGS="${WARN_CXXFLAGS} -Werror"]) + + +## ## +## Header checks ## +## ## + +AC_HEADER_STDBOOL +AC_CHECK_HEADERS([ \ + limits.h \ + stddef.h \ + sys/param.h \ + sys/time.h \ +]) + + +## ## +## Programs checks ## +## ## + +AC_PROG_AWK +AC_PROG_GREP +AC_PROG_MAKE_SET +AC_CHECK_PROGS(NPROC, [nproc gnproc]) +AC_CHECK_PROGS(GETCONF, [getconf]) +AC_CHECK_PROGS(TIME, [time]) + +# Initialize and configure libtool +LT_INIT + + +## ## +## Library checks ## +## ## + +# Checks for library functions. +AC_FUNC_MMAP +AC_FUNC_FORK +AC_CHECK_FUNCS([ \ + atexit \ + getcpuid \ + gettid \ + gettimeofday \ + memeset \ + memset \ + munmap \ + rand_r \ + sched_getcpu \ + sched_setaffinity \ + strerror \ + strtoul \ + sysconf \ +]) + +# AC_FUNC_MALLOC causes problems when cross-compiling. +#AC_FUNC_MALLOC + +# Search for clock_gettime() in -lrt +AC_SEARCH_LIBS([clock_gettime], [rt], [ + AC_DEFINE([CONFIG_RCU_HAVE_CLOCK_GETTIME], [1], [clock_gettime() is detected.]) +]) + + +## ## +## Optional features selection ## +## ## + +# Allow to fallback to FIXME if the membarrier syscall is unavailable on the +# running kernel, when disabled, abort if the syscall is unavailable. Applies +# to default and bulletproof flavors. +# Enabled by default +AE_FEATURE_DEFAULT_ENABLE +AE_FEATURE([sys-membarrier-fallback], [Abort if sys-membarrier is needed but not available rather than using a fallback.]) + +# Use compiler Thread Local Storage, when disabled use pthread_getspecific() to emulate TLS. +# Enabled by default +AE_FEATURE_DEFAULT_ENABLE +AE_FEATURE([compiler-tls], [Use pthread_getspecific() to emulate Thread Local Storage (TLS) variables.]) + +# smp-support configure option +# Enabled by default +AE_FEATURE_DEFAULT_ENABLE +AE_FEATURE([smp-support], [Disable SMP support. Warning: only use this on uniprocessor systems.]) + +# RCU debugging option +# Disabled by default +AE_FEATURE_DEFAULT_DISABLE +AE_FEATURE([rcu-debug], [Enable internal debugging self-checks. Introduces a performance penalty.]) + +# rculfhash iterator debugging +# Disabled by default +AE_FEATURE_DEFAULT_DISABLE +AE_FEATURE([cds-lfht-iter-debug], [Enable extra debugging checks for lock-free hash table iterator traversal. Alters the rculfhash ABI. Make sure to compile both library and application with matching configuration.]) + +# Use compiler atomic builtins, when disabled use our legacy uatomic implementation. +# Disabled by default +AE_FEATURE_DEFAULT_DISABLE +AE_FEATURE([compiler-atomic-builtins], [Enable the use of compiler atomic builtins.]) + +# emit legacy memory barriers +# Enable by default +AE_FEATURE_DEFAULT_ENABLE +AE_FEATURE([legacy-mb], [Disable legacy memory barriers.]) + +# When given, add -Werror to WARN_CFLAGS and WARN_CXXFLAGS. +# Disabled by default +AE_FEATURE_DEFAULT_DISABLE +AE_FEATURE([Werror],[Treat compiler warnings as errors.]) + +## ## +## Set defines for optional features conditionnals in the source code ## +## ## + +AE_IF_FEATURE_DISABLED([sys-membarrier-fallback], [ + AC_DEFINE([CONFIG_RCU_FORCE_SYS_MEMBARRIER], [1], [Require the operating system to support the membarrier system call for default and bulletproof flavors.]) +]) + +AE_IF_FEATURE_ENABLED([compiler-tls], [ + AC_DEFINE([CONFIG_RCU_TLS], [1], [Use compiler provided Thread Local Storage.]) +]) + +AE_IF_FEATURE_ENABLED([smp-support], [ + AC_DEFINE([CONFIG_RCU_SMP], [1], [Enable SMP support. With SMP support enabled, uniprocessors are also supported. With SMP support disabled, UP systems work fine, but the behavior of SMP systems is undefined.]) +]) + +AE_IF_FEATURE_ENABLED([rcu-debug], [ + AC_DEFINE([CONFIG_RCU_DEBUG], [1], [Enable internal debugging self-checks. Introduces a performance penalty.]) +]) + +AE_IF_FEATURE_ENABLED([cds-lfht-iter-debug], [ + AC_DEFINE([CONFIG_CDS_LFHT_ITER_DEBUG], [1], [Enable extra debugging checks for lock-free hash table iterator traversal. Alters the rculfhash ABI. Make sure to compile both library and application with matching configuration.]) +]) + +AE_IF_FEATURE_ENABLED([compiler-atomic-builtins], [ + AC_DEFINE([CONFIG_RCU_USE_ATOMIC_BUILTINS], [1], [Use compiler atomic builtins.]) +]) + +AE_IF_FEATURE_ENABLED([legacy-mb], [ + AC_DEFINE([CONFIG_RCU_EMIT_LEGACY_MB], [1], [Emit legacy memory barriers that were documented in the APIs.]) +]) + +## ## +## Set automake variables for optional feature conditionnals in Makefile.am ## +## ## + +# Building the examples requires the shared libraries to be enabled +AM_CONDITIONAL([ENABLE_EXAMPLES], AE_IS_FEATURE_ENABLED([shared])) + + +## ## +## Check for optional features dependencies ## +## ## + + +AE_IF_FEATURE_ENABLED([compiler-atomic-builtins], [ + AS_IF([test "x$ae_cv_cc_atomic_builtins" != xyes], [ + AC_MSG_ERROR([The compiler does not support atomic builtins.]) + ]) +]) + +## ## +## Substitute variables for use in Makefile.am ## +## ## + +# Library versions for libtool +AC_SUBST([URCU_LIBRARY_VERSION], [urcu_lib_version]) + +AC_SUBST(LT_NO_UNDEFINED) + +# The order in which the include folders are searched is important. +# The top_builddir should always be searched first in the event that a build +# time generated file is included. +AM_CPPFLAGS="-I\$(top_builddir)/include -I\$(top_srcdir)/include -include config.h" +AC_SUBST(AM_CPPFLAGS) + +AM_CFLAGS="$WARN_CFLAGS $PTHREAD_CFLAGS" +AC_SUBST(AM_CFLAGS) + +AM_CXXFLAGS="$WARN_CXXFLAGS $PTHREAD_CFLAGS" +AC_SUBST(AM_CXXFLAGS) + + +## ## +## Output files generated by configure ## +## ## + +AC_CONFIG_FILES([ + Makefile + doc/Makefile + doc/examples/Makefile + extras/Makefile + include/Makefile + src/Makefile + tests/Makefile + tests/common/Makefile + tests/unit/Makefile + tests/benchmark/Makefile + tests/regression/Makefile + tests/utils/Makefile + src/liburcu.pc + src/liburcu-bp.pc + src/liburcu-cds.pc + src/liburcu-qsbr.pc + src/liburcu-mb.pc + src/liburcu-memb.pc +]) + +AC_CONFIG_FILES([tests/utils/env.sh],[chmod +x tests/utils/env.sh]) + + +AC_OUTPUT + +# +# Mini-report on what will be built. +# + +AE_PPRINT_INIT +AE_PPRINT_SET_INDENT(1) +AE_PPRINT_SET_TS(38) + +AS_ECHO +AS_ECHO("${AE_PPRINT_COLOR_BLDBLU}Userspace-RCU $PACKAGE_VERSION${AE_PPRINT_COLOR_RST}") +AS_ECHO + +AE_PPRINT_SUBTITLE([Features]) + +AE_PPRINT_PROP_STRING([Target architecture], $host_cpu) + +# SMP support enabled/disabled +AE_IS_FEATURE_ENABLED([smp-support]) && value=1 || value=0 +AE_PPRINT_PROP_BOOL([SMP support], $value) + +# TLS +AE_IS_FEATURE_ENABLED([compiler-tls]) && value="compiler TLS" || value="pthread_getspecific()" +AE_PPRINT_PROP_STRING([Thread Local Storage (TLS)], [$value]) + +# clock_gettime() available +test "x$ac_cv_search_function_clock_gettime" != "xno" && value=1 || value=0 +AE_PPRINT_PROP_BOOL([clock_gettime()], $value) + +# Require membarrier +AE_IS_FEATURE_ENABLED([sys-membarrier-fallback]) && value=0 || value=1 +AE_PPRINT_PROP_BOOL([Require membarrier], $value) + +# RCU debug enabled/disabled +AE_IS_FEATURE_ENABLED([rcu-debug]) && value=1 || value=0 +AE_PPRINT_PROP_BOOL([Internal debugging], $value) + +# rculfhash iterator debug enabled/disabled +AE_IS_FEATURE_ENABLED([cds-lfht-iter-debug]) && value=1 || value=0 +AE_PPRINT_PROP_BOOL([Lock-free HT iterator debugging], $value) + +AE_PPRINT_PROP_BOOL([Multi-flavor support], 1) + +# atomic builtins enabled/disabled +AE_IS_FEATURE_ENABLED([compiler-atomic-builtins]) && value=1 || value=0 +AE_PPRINT_PROP_BOOL([Use compiler atomic builtins], $value) + +# legacy memory barriers +AE_IS_FEATURE_ENABLED([legacy-mb]) && value=1 || value=0 +AE_PPRINT_PROP_BOOL([Emit legacy memory barriers], $value) + +report_bindir="`eval eval echo $bindir`" +report_libdir="`eval eval echo $libdir`" + +# Print the bindir and libdir this 'make install' will install into. +AS_ECHO +AE_PPRINT_SUBTITLE([Install directories]) +AE_PPRINT_PROP_STRING([Binaries], [$report_bindir]) +AE_PPRINT_PROP_STRING([Libraries], [$report_libdir]) + diff --git a/external/lgpl2/userspace-rcu/dist/doc/Makefile.am b/external/lgpl2/userspace-rcu/dist/doc/Makefile.am new file mode 100644 index 0000000000000..19a27097a0632 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/Makefile.am @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +SUBDIRS = examples + +dist_doc_DATA = rcu-api.md \ + cds-api.md \ + solaris-build.md \ + uatomic-api.md diff --git a/external/lgpl2/userspace-rcu/dist/doc/cds-api.md b/external/lgpl2/userspace-rcu/dist/doc/cds-api.md new file mode 100644 index 0000000000000..9940a366bbe9e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/cds-api.md @@ -0,0 +1,90 @@ + + +Userspace RCU Concurrent Data Structures (CDS) API +================================================== + +by Mathieu Desnoyers and Paul E. McKenney + +This document describes briefly the data structures contained with the +userspace RCU library. + + +Data structure files +-------------------- + +### `urcu/list.h` + +Doubly-linked list, which requires mutual exclusion on +updates and reads. + + +### `urcu/rculist.h` + +Doubly-linked list, which requires mutual exclusion on +updates, allows RCU read traversals. + + +### `urcu/hlist.h` + +Doubly-linked list, with single pointer list head. Requires +mutual exclusion on updates and reads. Useful for implementing hash tables. +Downside over `list.h`: lookup of tail in O(n). + + +### `urcu/rcuhlist.h` + +Doubly-linked list, with single pointer list head. +Requires mutual exclusion on updates, allows RCU read traversals. Useful +for implementing hash tables. Downside over `rculist.h`: lookup of tail in O(n). + + +### `urcu/wfstack.h` + +Stack with wait-free push and wait-free pop\_all. Both +blocking and non-blocking pop and traversal operations are provided. This +stack does _not_ specifically rely on RCU. Various synchronization techniques +can be used to deal with pop ABA. Those are detailed in the API. + + +### `urcu/wfcqueue.h` + +Concurrent queue with wait-free enqueue. Both blocking and +non-blocking dequeue, splice (move all elements from one queue +to another), and traversal operations are provided. + +This queue does _not_ specifically rely on RCU. Mutual exclusion +is used to protect dequeue, splice (from source queue) and +traversal (see API for details). + + - Note: deprecates `urcu/wfqueue.h`. + + +### `urcu/lfstack.h` + +Stack with lock-free push, lock-free pop, wait-free pop\_all, +wait-free traversal. Various synchronization techniques can be +used to deal with pop ABA. Those are detailed in the API. +This stack does _not_ specifically rely on RCU. + + - Note: deprecates `urcu/rculfstack.h`. + + +### `urcu/rculfqueue.h` + +RCU queue with lock-free enqueue, lock-free dequeue. +This queue relies on RCU for existence guarantees. + + +### `urcu/rculfhash.h` + +Lock-Free Resizable RCU Hash Table. RCU used to provide +existence guarantees. Provides scalable updates, and scalable +RCU read-side lookups and traversals. Unique and duplicate keys +are supported. Provides "uniquify add" and "replace add" +operations, along with associated read-side traversal uniqueness +guarantees. Automatic hash table resize based on number of +elements is supported. See the API for more details. diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/Makefile.am b/external/lgpl2/userspace-rcu/dist/doc/examples/Makefile.am new file mode 100644 index 0000000000000..81691692ed5a7 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/Makefile.am @@ -0,0 +1,155 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +doc_examplesdir = ${docdir}/examples + +doc_examples_urcu_flavorsdir = ${doc_examplesdir}/urcu-flavors + +dist_doc_examples_urcu_flavors_DATA = \ + urcu-flavors/Makefile \ + urcu-flavors/Makefile.qsbr \ + urcu-flavors/Makefile.mb \ + urcu-flavors/Makefile.membarrier \ + urcu-flavors/Makefile.bp \ + urcu-flavors/qsbr.c \ + urcu-flavors/mb.c \ + urcu-flavors/membarrier.c \ + urcu-flavors/bp.c + +dist_doc_examples_DATA = \ + dist-files/Makefile \ + Makefile.examples.template + +doc_examples_listdir = ${doc_examplesdir}/list + +dist_doc_examples_list_DATA = \ + list/Makefile \ + list/Makefile.cds_list_add_rcu \ + list/Makefile.cds_list_add_tail_rcu \ + list/Makefile.cds_list_del_rcu \ + list/Makefile.cds_list_for_each_rcu \ + list/Makefile.cds_list_for_each_entry_rcu \ + list/Makefile.cds_list_replace_rcu \ + list/cds_list_add_rcu.c \ + list/cds_list_add_tail_rcu.c \ + list/cds_list_del_rcu.c \ + list/cds_list_for_each_rcu.c \ + list/cds_list_for_each_entry_rcu.c \ + list/cds_list_replace_rcu.c + +doc_examples_hlistdir = ${doc_examplesdir}/hlist + +dist_doc_examples_hlist_DATA = \ + hlist/Makefile \ + hlist/Makefile.cds_hlist_add_head_rcu \ + hlist/Makefile.cds_hlist_del_rcu \ + hlist/Makefile.cds_hlist_for_each_rcu \ + hlist/Makefile.cds_hlist_for_each_entry_rcu \ + hlist/cds_hlist_add_head_rcu.c \ + hlist/cds_hlist_del_rcu.c \ + hlist/cds_hlist_for_each_rcu.c \ + hlist/cds_hlist_for_each_entry_rcu.c + +doc_examples_wfcqueuedir = ${doc_examplesdir}/wfcqueue + +dist_doc_examples_wfcqueue_DATA = \ + wfcqueue/Makefile \ + wfcqueue/Makefile.cds_wfcq_enqueue \ + wfcqueue/Makefile.cds_wfcq_dequeue \ + wfcqueue/Makefile.cds_wfcq_splice \ + wfcqueue/cds_wfcq_enqueue.c \ + wfcqueue/cds_wfcq_dequeue.c \ + wfcqueue/cds_wfcq_splice.c + +doc_examples_wfstackdir = ${doc_examplesdir}/wfstack + +dist_doc_examples_wfstack_DATA = \ + wfstack/Makefile \ + wfstack/Makefile.cds_wfs_push \ + wfstack/Makefile.cds_wfs_pop \ + wfstack/Makefile.cds_wfs_pop_all_blocking \ + wfstack/cds_wfs_push.c \ + wfstack/cds_wfs_pop.c \ + wfstack/cds_wfs_pop_all_blocking.c + +doc_examples_lfstackdir = ${doc_examplesdir}/lfstack + +dist_doc_examples_lfstack_DATA = \ + lfstack/Makefile \ + lfstack/Makefile.cds_lfs_push \ + lfstack/Makefile.cds_lfs_pop_blocking \ + lfstack/Makefile.cds_lfs_pop_all_blocking \ + lfstack/cds_lfs_push.c \ + lfstack/cds_lfs_pop_blocking.c \ + lfstack/cds_lfs_pop_all_blocking.c + +doc_examples_rculfqueuedir = ${doc_examplesdir}/rculfqueue + +dist_doc_examples_rculfqueue_DATA = \ + rculfqueue/Makefile \ + rculfqueue/Makefile.cds_lfq_enqueue \ + rculfqueue/Makefile.cds_lfq_dequeue \ + rculfqueue/cds_lfq_enqueue.c \ + rculfqueue/cds_lfq_dequeue.c + +doc_examples_rculfhashdir = ${doc_examplesdir}/rculfhash + +dist_doc_examples_rculfhash_DATA = \ + rculfhash/Makefile \ + rculfhash/jhash.h \ + rculfhash/Makefile.cds_lfht_add \ + rculfhash/Makefile.cds_lfht_add_unique \ + rculfhash/Makefile.cds_lfht_add_replace \ + rculfhash/Makefile.cds_lfht_del \ + rculfhash/Makefile.cds_lfht_destroy \ + rculfhash/Makefile.cds_lfht_lookup \ + rculfhash/Makefile.cds_lfht_for_each_entry_duplicate \ + rculfhash/cds_lfht_add.c \ + rculfhash/cds_lfht_add_unique.c \ + rculfhash/cds_lfht_add_replace.c \ + rculfhash/cds_lfht_del.c \ + rculfhash/cds_lfht_destroy.c \ + rculfhash/cds_lfht_lookup.c \ + rculfhash/cds_lfht_for_each_entry_duplicate.c + +# Building the examples requires the shared libraries to be enabled +if ENABLE_EXAMPLES + +SUBDIRS_PROXY = hlist list urcu-flavors wfcqueue rculfqueue \ + wfstack lfstack rculfhash + +# Copies are for VPATH build support. +all-local: + $(AM_V_at)if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + cp -pfR $(srcdir)/dist-files $(builddir); \ + chmod -R u+w $(builddir)/dist-files; \ + cp -pf $(srcdir)/Makefile.examples.template $(builddir); \ + chmod u+w $(builddir)/Makefile.examples.template; \ + for subdir in $(SUBDIRS_PROXY); do \ + cp -pfR $(srcdir)/$$subdir $(builddir); \ + chmod -R u+w $(builddir)/$$subdir; \ + done; \ + fi; \ + if [ x"$(shell echo "$(top_srcdir)" | $(GREP) "^/" | wc -l)" = x"1" ]; then \ + rel_src_subdir=""; \ + else \ + rel_src_subdir="../"; \ + fi; \ + if [ x"$(shell echo "$(top_builddir)" | $(GREP) "^/" | wc -l)" = x"1" ]; then \ + rel_build_subdir=""; \ + else \ + rel_build_subdir="../"; \ + fi; \ + $(MAKE) -f dist-files/Makefile CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" AM_CPPFLAGS="$(AM_CPPFLAGS) -I"$${rel_src_subdir}/$(top_srcdir)/include/" -I"$${rel_src_subdir}/$(top_srcdir)/src/" -I"$${rel_build_subdir}$(top_builddir)/include/" -I"$${rel_build_subdir}$(top_builddir)/include/src/"" CFLAGS="$(CFLAGS)" AM_CFLAGS="$(AM_CFLAGS)" LDFLAGS="$(LDFLAGS)" AM_LDFLAGS="$(AM_LDFLAGS) -L../../../src/.libs/ -Wl,-rpath "$(PWD)/../../src/.libs/"" AM_V_P="$(AM_V_P)" AM_V_at="$(AM_V_at)" $(AM_MAKEFLAGS) all; + +clean-local: + $(AM_V_at)$(MAKE) -f dist-files/Makefile $(AM_MAKEFLAGS) clean; \ + if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + for subdir in $(SUBDIRS_PROXY); do \ + rm -rf $(builddir)/$$subdir; \ + done; \ + rm -f $(builddir)/Makefile.examples.template; \ + rm -rf $(builddir)/dist-files; \ + fi; +endif diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/Makefile.examples.template b/external/lgpl2/userspace-rcu/dist/doc/examples/Makefile.examples.template new file mode 100644 index 0000000000000..21cac7b93dfd4 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/Makefile.examples.template @@ -0,0 +1,26 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +LOCAL_CFLAGS := -g -O2 -Wall +AM_V_P := : + +all: $(BINARY) + +$(BINARY): $(OBJECTS) + @verbose="$(AM_V_P)"; if [ "x$$verbose" = "x" ]; then verbose=":"; fi; \ + if $$verbose; then set -x; else echo " CCLD $@"; fi; \ + $(CC) $(LOCAL_CFLAGS) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ $(OBJECTS) $(LIBS) + +$(OBJECTS): $(SOURCES) $(DEPS) + @verbose="$(AM_V_P)"; if [ "x$$verbose" = "x" ]; then verbose=":"; fi; \ + if $$verbose; then set -x; else echo " CC $@"; fi; \ + $(CC) $(LOCAL_CFLAGS) $(AM_CFLAGS) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) \ + -c -o $@ $(SOURCES) + +.PHONY: clean +clean: + rm -f *.o $(BINARY) diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/dist-files/Makefile b/external/lgpl2/userspace-rcu/dist/doc/examples/dist-files/Makefile new file mode 100644 index 0000000000000..676d9b30d7455 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/dist-files/Makefile @@ -0,0 +1,26 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +all: + $(AM_V_at)$(MAKE) -C hlist + $(AM_V_at)$(MAKE) -C list + $(AM_V_at)$(MAKE) -C urcu-flavors + $(AM_V_at)$(MAKE) -C wfcqueue + $(AM_V_at)$(MAKE) -C rculfqueue + $(AM_V_at)$(MAKE) -C wfstack + $(AM_V_at)$(MAKE) -C lfstack + $(AM_V_at)$(MAKE) -C rculfhash + +.PHONY: clean +clean: + $(AM_V_at)$(MAKE) -C hlist clean + $(AM_V_at)$(MAKE) -C list clean + $(AM_V_at)$(MAKE) -C urcu-flavors clean + $(AM_V_at)$(MAKE) -C wfcqueue clean + $(AM_V_at)$(MAKE) -C rculfqueue clean + $(AM_V_at)$(MAKE) -C wfstack clean + $(AM_V_at)$(MAKE) -C lfstack clean + $(AM_V_at)$(MAKE) -C rculfhash clean diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile new file mode 100644 index 0000000000000..c06be16a6666e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile @@ -0,0 +1,18 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +all: + $(AM_V_at)$(MAKE) -f Makefile.cds_hlist_add_head_rcu + $(AM_V_at)$(MAKE) -f Makefile.cds_hlist_del_rcu + $(AM_V_at)$(MAKE) -f Makefile.cds_hlist_for_each_rcu + $(AM_V_at)$(MAKE) -f Makefile.cds_hlist_for_each_entry_rcu + +.PHONY: clean +clean: + $(AM_V_at)$(MAKE) -f Makefile.cds_hlist_add_head_rcu clean + $(AM_V_at)$(MAKE) -f Makefile.cds_hlist_del_rcu clean + $(AM_V_at)$(MAKE) -f Makefile.cds_hlist_for_each_rcu clean + $(AM_V_at)$(MAKE) -f Makefile.cds_hlist_for_each_entry_rcu clean diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile.cds_hlist_add_head_rcu b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile.cds_hlist_add_head_rcu new file mode 100644 index 0000000000000..1f225fd0e9aee --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile.cds_hlist_add_head_rcu @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_hlist_add_head_rcu + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile.cds_hlist_del_rcu b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile.cds_hlist_del_rcu new file mode 100644 index 0000000000000..e042ffac59f9e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile.cds_hlist_del_rcu @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_hlist_del_rcu + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile.cds_hlist_for_each_entry_rcu b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile.cds_hlist_for_each_entry_rcu new file mode 100644 index 0000000000000..86380a51efa95 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile.cds_hlist_for_each_entry_rcu @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_hlist_for_each_entry_rcu + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile.cds_hlist_for_each_rcu b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile.cds_hlist_for_each_rcu new file mode 100644 index 0000000000000..9b40d8a9601c8 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/Makefile.cds_hlist_for_each_rcu @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_hlist_for_each_rcu + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/cds_hlist_add_head_rcu.c b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/cds_hlist_add_head_rcu.c new file mode 100644 index 0000000000000..6087bae8b2d4a --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/cds_hlist_add_head_rcu.c @@ -0,0 +1,57 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to add into a non-circular linked-list safely + * against concurrent RCU traversals. + */ + +#include + +#include /* Userspace RCU flavor */ +#include /* RCU hlist */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the list. + */ +struct mynode { + int value; /* Node content */ + struct cds_hlist_node node; /* Linked-list chaining */ +}; + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + CDS_HLIST_HEAD(mylist); /* Defines an empty hlist head */ + unsigned int i; + int ret = 0; + struct mynode *node; + + /* + * Adding nodes to the linked-list. Safe against concurrent + * RCU traversals, require mutual exclusion with list updates. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + node->value = values[i]; + cds_hlist_add_head_rcu(&node->node, &mylist); + } + + /* + * Just show the list content. This is _not_ an RCU-safe + * iteration on the list. + */ + printf("mylist content:"); + cds_hlist_for_each_entry_2(node, &mylist, node) { + printf(" %d", node->value); + } + printf("\n"); +end: + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/cds_hlist_del_rcu.c b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/cds_hlist_del_rcu.c new file mode 100644 index 0000000000000..1ef229f61a9d6 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/cds_hlist_del_rcu.c @@ -0,0 +1,83 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to remove from a non-circular linked-list + * safely against concurrent RCU traversals. + */ + +#include + +#include /* Userspace RCU flavor */ +#include /* RCU hlist */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the list. + */ +struct mynode { + int value; /* Node content */ + struct cds_hlist_node node; /* Linked-list chaining */ + struct rcu_head rcu_head; /* For call_rcu() */ +}; + +static +void free_node_rcu(struct rcu_head *head) +{ + struct mynode *node = caa_container_of(head, struct mynode, rcu_head); + + free(node); +} + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + CDS_HLIST_HEAD(mylist); /* Defines an empty hlist head */ + unsigned int i; + int ret = 0; + struct mynode *node, *n; + + /* + * Adding nodes to the linked-list. Safe against concurrent + * RCU traversals, require mutual exclusion with list updates. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + node->value = values[i]; + cds_hlist_add_head_rcu(&node->node, &mylist); + } + + /* + * Removing all positive values. Safe against concurrent RCU + * traversals, require mutual exclusion with list updates. + * Notice the "safe" iteration: it is safe against removal of + * nodes as we iterate on the list. + */ + cds_hlist_for_each_entry_safe_2(node, n, &mylist, node) { + if (node->value > 0) { + cds_hlist_del_rcu(&node->node); + /* + * We can only reclaim memory after a grace + * period has passed after cds_hlist_del_rcu(). + */ + urcu_memb_call_rcu(&node->rcu_head, free_node_rcu); + } + } + + /* + * Just show the list content. This is _not_ an RCU-safe + * iteration on the list. + */ + printf("mylist content:"); + cds_hlist_for_each_entry_2(node, &mylist, node) { + printf(" %d", node->value); + } + printf("\n"); +end: + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/cds_hlist_for_each_entry_rcu.c b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/cds_hlist_for_each_entry_rcu.c new file mode 100644 index 0000000000000..bf675fd809233 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/cds_hlist_for_each_entry_rcu.c @@ -0,0 +1,77 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to do a non-circular RCU linked list + * traversal, safely against concurrent RCU updates. + */ + +#include + +#include /* Userspace RCU flavor */ +#include /* RCU hlist */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the list. + */ +struct mynode { + int value; /* Node content */ + struct cds_hlist_node node; /* Linked-list chaining */ +}; + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + CDS_HLIST_HEAD(mylist); /* Defines an empty hlist head */ + unsigned int i; + int ret = 0; + struct mynode *node; + + /* + * Each thread need using RCU read-side need to be explicitly + * registered. + */ + urcu_memb_register_thread(); + + /* + * Adding nodes to the linked-list. Safe against concurrent + * RCU traversals, require mutual exclusion with list updates. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + node->value = values[i]; + cds_hlist_add_head_rcu(&node->node, &mylist); + } + + /* + * RCU-safe iteration on the list. + */ + printf("mylist content:"); + + /* + * Surround the RCU read-side critical section with rcu_read_lock() + * and rcu_read_unlock(). + */ + urcu_memb_read_lock(); + + /* + * This traversal can be performed concurrently with RCU + * updates. + */ + cds_hlist_for_each_entry_rcu_2(node, &mylist, node) { + printf(" %d", node->value); + } + + urcu_memb_read_unlock(); + + printf("\n"); +end: + urcu_memb_unregister_thread(); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/cds_hlist_for_each_rcu.c b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/cds_hlist_for_each_rcu.c new file mode 100644 index 0000000000000..464205400c793 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/hlist/cds_hlist_for_each_rcu.c @@ -0,0 +1,84 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to do a non-circular RCU linked list + * traversal, safely against concurrent RCU updates. + * cds_hlist_for_each_rcu() iterates on struct cds_hlist_node, and thus, + * either caa_container_of() or cds_hlist_entry() are needed to access + * the container structure. + */ + +#include + +#include /* Userspace RCU flavor */ +#include /* RCU hlist */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the list. + */ +struct mynode { + int value; /* Node content */ + struct cds_hlist_node node; /* Linked-list chaining */ +}; + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + CDS_HLIST_HEAD(mylist); /* Defines an empty hlist head */ + unsigned int i; + int ret = 0; + struct cds_hlist_node *pos; + + /* + * Each thread need using RCU read-side need to be explicitly + * registered. + */ + urcu_memb_register_thread(); + + /* + * Adding nodes to the linked-list. Safe against concurrent + * RCU traversals, require mutual exclusion with list updates. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + struct mynode *node; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + node->value = values[i]; + cds_hlist_add_head_rcu(&node->node, &mylist); + } + + /* + * RCU-safe iteration on the list. + */ + printf("mylist content:"); + + /* + * Surround the RCU read-side critical section with rcu_read_lock() + * and rcu_read_unlock(). + */ + urcu_memb_read_lock(); + + /* + * This traversal can be performed concurrently with RCU + * updates. + */ + cds_hlist_for_each_rcu(pos, &mylist) { + struct mynode *node = cds_hlist_entry(pos, struct mynode, node); + + printf(" %d", node->value); + } + + urcu_memb_read_unlock(); + + printf("\n"); +end: + urcu_memb_unregister_thread(); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/Makefile b/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/Makefile new file mode 100644 index 0000000000000..189a7bd996d75 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/Makefile @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +all: + $(AM_V_at)$(MAKE) -f Makefile.cds_lfs_push + $(AM_V_at)$(MAKE) -f Makefile.cds_lfs_pop_blocking + $(AM_V_at)$(MAKE) -f Makefile.cds_lfs_pop_all_blocking + +.PHONY: clean +clean: + $(AM_V_at)$(MAKE) -f Makefile.cds_lfs_push clean + $(AM_V_at)$(MAKE) -f Makefile.cds_lfs_pop_blocking clean + $(AM_V_at)$(MAKE) -f Makefile.cds_lfs_pop_all_blocking clean diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/Makefile.cds_lfs_pop_all_blocking b/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/Makefile.cds_lfs_pop_all_blocking new file mode 100644 index 0000000000000..07a07d7bf1f01 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/Makefile.cds_lfs_pop_all_blocking @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_lfs_pop_all_blocking + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-cds + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/Makefile.cds_lfs_pop_blocking b/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/Makefile.cds_lfs_pop_blocking new file mode 100644 index 0000000000000..f5fa1c868963d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/Makefile.cds_lfs_pop_blocking @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_lfs_pop_blocking + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-cds + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/Makefile.cds_lfs_push b/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/Makefile.cds_lfs_push new file mode 100644 index 0000000000000..8908afe2e12d7 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/Makefile.cds_lfs_push @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_lfs_push + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-cds + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/cds_lfs_pop_all_blocking.c b/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/cds_lfs_pop_all_blocking.c new file mode 100644 index 0000000000000..290fe8096f9c6 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/cds_lfs_pop_all_blocking.c @@ -0,0 +1,73 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to pop all nodes from a lfstack. + */ + +#include +#include + +#include /* Lock-free stack */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the stack. + */ +struct mynode { + int value; /* Node content */ + struct cds_lfs_node node; /* Chaining in stack */ +}; + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + struct cds_lfs_stack mystack; /* Stack */ + unsigned int i; + int ret = 0; + struct cds_lfs_node *snode, *sn; + struct cds_lfs_head *shead; + + cds_lfs_init(&mystack); + + /* + * Push nodes. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + struct mynode *node; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + + cds_lfs_node_init(&node->node); + node->value = values[i]; + cds_lfs_push(&mystack, &node->node); + } + + /* + * Pop all nodes from mystack into shead. The head can the be + * used for iteration. + */ + shead = cds_lfs_pop_all_blocking(&mystack); + + /* + * Show the stack content, iterate in reverse order of push, + * from newest to oldest. Use cds_lfs_for_each_safe() so we can + * free the nodes as we iterate. + */ + printf("mystack content:"); + cds_lfs_for_each_safe(shead, snode, sn) { + struct mynode *node = + caa_container_of(snode, struct mynode, node); + printf(" %d", node->value); + free(node); + } + printf("\n"); +end: + cds_lfs_destroy(&mystack); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/cds_lfs_pop_blocking.c b/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/cds_lfs_pop_blocking.c new file mode 100644 index 0000000000000..25d6381bb582d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/cds_lfs_pop_blocking.c @@ -0,0 +1,69 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to pop nodes from a lfstack. + */ + +#include +#include + +#include /* Wait-free stack */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the stack. + */ +struct mynode { + int value; /* Node content */ + struct cds_lfs_node node; /* Chaining in stack */ +}; + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + struct cds_lfs_stack mystack; /* Stack */ + unsigned int i; + int ret = 0; + + cds_lfs_init(&mystack); + + /* + * Push nodes. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + struct mynode *node; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + + cds_lfs_node_init(&node->node); + node->value = values[i]; + cds_lfs_push(&mystack, &node->node); + } + + /* + * Pop nodes from the stack, one by one, from newest to oldest. + */ + printf("pop each mystack node:"); + for (;;) { + struct cds_lfs_node *snode; + struct mynode *node; + + snode = cds_lfs_pop_blocking(&mystack); + if (!snode) { + break; + } + node = caa_container_of(snode, struct mynode, node); + printf(" %d", node->value); + free(node); + } + printf("\n"); +end: + cds_lfs_destroy(&mystack); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/cds_lfs_push.c b/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/cds_lfs_push.c new file mode 100644 index 0000000000000..b3c5b933f0cf8 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/lfstack/cds_lfs_push.c @@ -0,0 +1,66 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to push nodes into a lfstack. + */ + +#include +#include + +#include /* Lock-free stack */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the stack. + */ +struct mynode { + int value; /* Node content */ + struct cds_lfs_node node; /* Chaining in stack */ +}; + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + struct cds_lfs_stack mystack; /* Stack */ + unsigned int i; + int ret = 0; + struct cds_lfs_node *snode; + struct cds_lfs_head *shead; + + cds_lfs_init(&mystack); + + /* + * Push nodes. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + struct mynode *node; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + + cds_lfs_node_init(&node->node); + node->value = values[i]; + cds_lfs_push(&mystack, &node->node); + } + + /* + * Show the stack content, iterate in reverse order of push, + * from newest to oldest. + */ + printf("mystack content:"); + shead = cds_lfs_pop_all_blocking(&mystack); + cds_lfs_for_each(shead, snode) { + struct mynode *node = + caa_container_of(snode, struct mynode, node); + printf(" %d", node->value); + } + printf("\n"); +end: + cds_lfs_destroy(&mystack); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile b/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile new file mode 100644 index 0000000000000..034a59315a395 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile @@ -0,0 +1,22 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +all: + $(AM_V_at)$(MAKE) -f Makefile.cds_list_add_rcu + $(AM_V_at)$(MAKE) -f Makefile.cds_list_add_tail_rcu + $(AM_V_at)$(MAKE) -f Makefile.cds_list_del_rcu + $(AM_V_at)$(MAKE) -f Makefile.cds_list_for_each_rcu + $(AM_V_at)$(MAKE) -f Makefile.cds_list_for_each_entry_rcu + $(AM_V_at)$(MAKE) -f Makefile.cds_list_replace_rcu + +.PHONY: clean +clean: + $(AM_V_at)$(MAKE) -f Makefile.cds_list_add_rcu clean + $(AM_V_at)$(MAKE) -f Makefile.cds_list_add_tail_rcu clean + $(AM_V_at)$(MAKE) -f Makefile.cds_list_del_rcu clean + $(AM_V_at)$(MAKE) -f Makefile.cds_list_for_each_rcu clean + $(AM_V_at)$(MAKE) -f Makefile.cds_list_for_each_entry_rcu clean + $(AM_V_at)$(MAKE) -f Makefile.cds_list_replace_rcu clean diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_add_rcu b/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_add_rcu new file mode 100644 index 0000000000000..91ab9039af9be --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_add_rcu @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_list_add_rcu + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_add_tail_rcu b/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_add_tail_rcu new file mode 100644 index 0000000000000..6a60c03fa79d0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_add_tail_rcu @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_list_add_tail_rcu + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_del_rcu b/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_del_rcu new file mode 100644 index 0000000000000..1509267c262c7 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_del_rcu @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_list_del_rcu + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_for_each_entry_rcu b/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_for_each_entry_rcu new file mode 100644 index 0000000000000..af0805693bad5 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_for_each_entry_rcu @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_list_for_each_entry_rcu + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_for_each_rcu b/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_for_each_rcu new file mode 100644 index 0000000000000..54bb040a12b8f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_for_each_rcu @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_list_for_each_rcu + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_replace_rcu b/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_replace_rcu new file mode 100644 index 0000000000000..a7cc56d97f283 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/list/Makefile.cds_list_replace_rcu @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_list_replace_rcu + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_add_rcu.c b/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_add_rcu.c new file mode 100644 index 0000000000000..13da5b39cf51e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_add_rcu.c @@ -0,0 +1,57 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to add into a linked-list safely against + * concurrent RCU traversals. + */ + +#include + +#include /* Userspace RCU flavor */ +#include /* RCU list */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the list. + */ +struct mynode { + int value; /* Node content */ + struct cds_list_head node; /* Linked-list chaining */ +}; + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + CDS_LIST_HEAD(mylist); /* Defines an empty list head */ + unsigned int i; + int ret = 0; + struct mynode *node; + + /* + * Adding nodes to the linked-list. Safe against concurrent + * RCU traversals, require mutual exclusion with list updates. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + node->value = values[i]; + cds_list_add_rcu(&node->node, &mylist); + } + + /* + * Just show the list content. This is _not_ an RCU-safe + * iteration on the list. + */ + printf("mylist content:"); + cds_list_for_each_entry(node, &mylist, node) { + printf(" %d", node->value); + } + printf("\n"); +end: + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_add_tail_rcu.c b/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_add_tail_rcu.c new file mode 100644 index 0000000000000..475cf6624a5ca --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_add_tail_rcu.c @@ -0,0 +1,57 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to add into tail of a linked-list safely + * against concurrent RCU traversals. + */ + +#include + +#include /* Userspace RCU flavor */ +#include /* RCU list */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the list. + */ +struct mynode { + int value; /* Node content */ + struct cds_list_head node; /* Linked-list chaining */ +}; + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + CDS_LIST_HEAD(mylist); /* Defines an empty list head */ + unsigned int i; + int ret = 0; + struct mynode *node; + + /* + * Adding nodes to the linked-list. Safe against concurrent + * RCU traversals, require mutual exclusion with list updates. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + node->value = values[i]; + cds_list_add_tail_rcu(&node->node, &mylist); + } + + /* + * Just show the list content. This is _not_ an RCU-safe + * iteration on the list. + */ + printf("mylist content:"); + cds_list_for_each_entry(node, &mylist, node) { + printf(" %d", node->value); + } + printf("\n"); +end: + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_del_rcu.c b/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_del_rcu.c new file mode 100644 index 0000000000000..b4e4c13724623 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_del_rcu.c @@ -0,0 +1,83 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to remove from a linked-list safely against + * concurrent RCU traversals. + */ + +#include + +#include /* Userspace RCU flavor */ +#include /* RCU list */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the list. + */ +struct mynode { + int value; /* Node content */ + struct cds_list_head node; /* Linked-list chaining */ + struct rcu_head rcu_head; /* For call_rcu() */ +}; + +static +void free_node_rcu(struct rcu_head *head) +{ + struct mynode *node = caa_container_of(head, struct mynode, rcu_head); + + free(node); +} + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + CDS_LIST_HEAD(mylist); /* Defines an empty list head */ + unsigned int i; + int ret = 0; + struct mynode *node, *n; + + /* + * Adding nodes to the linked-list. Safe against concurrent + * RCU traversals, require mutual exclusion with list updates. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + node->value = values[i]; + cds_list_add_rcu(&node->node, &mylist); + } + + /* + * Removing all positive values. Safe against concurrent RCU + * traversals, require mutual exclusion with list updates. + * Notice the "safe" iteration: it is safe against removal of + * nodes as we iterate on the list. + */ + cds_list_for_each_entry_safe(node, n, &mylist, node) { + if (node->value > 0) { + cds_list_del_rcu(&node->node); + /* + * We can only reclaim memory after a grace + * period has passed after cds_list_del_rcu(). + */ + urcu_memb_call_rcu(&node->rcu_head, free_node_rcu); + } + } + + /* + * Just show the list content. This is _not_ an RCU-safe + * iteration on the list. + */ + printf("mylist content:"); + cds_list_for_each_entry(node, &mylist, node) { + printf(" %d", node->value); + } + printf("\n"); +end: + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_for_each_entry_rcu.c b/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_for_each_entry_rcu.c new file mode 100644 index 0000000000000..ef9e954bf2f30 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_for_each_entry_rcu.c @@ -0,0 +1,77 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to do a RCU linked list traversal, safely + * against concurrent RCU updates. + */ + +#include + +#include /* Userspace RCU flavor */ +#include /* RCU list */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the list. + */ +struct mynode { + int value; /* Node content */ + struct cds_list_head node; /* Linked-list chaining */ +}; + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + CDS_LIST_HEAD(mylist); /* Defines an empty list head */ + unsigned int i; + int ret = 0; + struct mynode *node; + + /* + * Each thread need using RCU read-side need to be explicitly + * registered. + */ + urcu_memb_register_thread(); + + /* + * Adding nodes to the linked-list. Safe against concurrent + * RCU traversals, require mutual exclusion with list updates. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + node->value = values[i]; + cds_list_add_tail_rcu(&node->node, &mylist); + } + + /* + * RCU-safe iteration on the list. + */ + printf("mylist content:"); + + /* + * Surround the RCU read-side critical section with urcu_memb_read_lock() + * and urcu_memb_read_unlock(). + */ + urcu_memb_read_lock(); + + /* + * This traversal can be performed concurrently with RCU + * updates. + */ + cds_list_for_each_entry_rcu(node, &mylist, node) { + printf(" %d", node->value); + } + + urcu_memb_read_unlock(); + + printf("\n"); +end: + urcu_memb_unregister_thread(); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_for_each_rcu.c b/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_for_each_rcu.c new file mode 100644 index 0000000000000..044aa5efeb7b9 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_for_each_rcu.c @@ -0,0 +1,83 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to do a RCU linked list traversal, safely + * against concurrent RCU updates. cds_list_for_each_rcu() iterates on + * struct cds_list_head, and thus, either caa_container_of() or + * cds_list_entry() are needed to access the container structure. + */ + +#include + +#include /* Userspace RCU flavor */ +#include /* RCU list */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the list. + */ +struct mynode { + int value; /* Node content */ + struct cds_list_head node; /* Linked-list chaining */ +}; + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + CDS_LIST_HEAD(mylist); /* Defines an empty list head */ + unsigned int i; + int ret = 0; + struct cds_list_head *pos; + + /* + * Each thread need using RCU read-side need to be explicitly + * registered. + */ + urcu_memb_register_thread(); + + /* + * Adding nodes to the linked-list. Safe against concurrent + * RCU traversals, require mutual exclusion with list updates. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + struct mynode *node; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + node->value = values[i]; + cds_list_add_tail_rcu(&node->node, &mylist); + } + + /* + * RCU-safe iteration on the list. + */ + printf("mylist content:"); + + /* + * Surround the RCU read-side critical section with urcu_memb_read_lock() + * and urcu_memb_read_unlock(). + */ + urcu_memb_read_lock(); + + /* + * This traversal can be performed concurrently with RCU + * updates. + */ + cds_list_for_each_rcu(pos, &mylist) { + struct mynode *node = cds_list_entry(pos, struct mynode, node); + + printf(" %d", node->value); + } + + urcu_memb_read_unlock(); + + printf("\n"); +end: + urcu_memb_unregister_thread(); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_replace_rcu.c b/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_replace_rcu.c new file mode 100644 index 0000000000000..d17084b661993 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/list/cds_list_replace_rcu.c @@ -0,0 +1,87 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to replace a node within a linked-list safely + * against concurrent RCU traversals. + */ + +#include + +#include /* Userspace RCU flavor */ +#include /* RCU list */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the list. + */ +struct mynode { + int value; /* Node content */ + struct cds_list_head node; /* Linked-list chaining */ + struct rcu_head rcu_head; /* For call_rcu() */ +}; + +static +void free_node_rcu(struct rcu_head *head) +{ + struct mynode *node = caa_container_of(head, struct mynode, rcu_head); + + free(node); +} + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + CDS_LIST_HEAD(mylist); /* Defines an empty list head */ + unsigned int i; + int ret = 0; + struct mynode *node, *n; + + /* + * Adding nodes to the linked-list. Safe against concurrent + * RCU traversals, require mutual exclusion with list updates. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + node->value = values[i]; + cds_list_add_tail_rcu(&node->node, &mylist); + } + + /* + * Replacing all values by their negated value. Safe against + * concurrent RCU traversals, require mutual exclusion with list + * updates. Notice the "safe" iteration: it is safe against + * removal (and thus replacement) of nodes as we iterate on the + * list. + */ + cds_list_for_each_entry_safe(node, n, &mylist, node) { + struct mynode *new_node; + + new_node = malloc(sizeof(*node)); + if (!new_node) { + ret = -1; + goto end; + } + /* Replacement node value is negated original value. */ + new_node->value = -node->value; + cds_list_replace_rcu(&node->node, &new_node->node); + urcu_memb_call_rcu(&node->rcu_head, free_node_rcu); + } + + /* + * Just show the list content. This is _not_ an RCU-safe + * iteration on the list. + */ + printf("mylist content:"); + cds_list_for_each_entry(node, &mylist, node) { + printf(" %d", node->value); + } + printf("\n"); +end: + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile new file mode 100644 index 0000000000000..29b28f7d8bb7e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +all: + $(AM_V_at)$(MAKE) -f Makefile.cds_lfht_add + $(AM_V_at)$(MAKE) -f Makefile.cds_lfht_add_unique + $(AM_V_at)$(MAKE) -f Makefile.cds_lfht_add_replace + $(AM_V_at)$(MAKE) -f Makefile.cds_lfht_del + $(AM_V_at)$(MAKE) -f Makefile.cds_lfht_destroy + $(AM_V_at)$(MAKE) -f Makefile.cds_lfht_lookup + $(AM_V_at)$(MAKE) -f Makefile.cds_lfht_for_each_entry_duplicate + +.PHONY: clean +clean: + $(AM_V_at)$(MAKE) -f Makefile.cds_lfht_add clean + $(AM_V_at)$(MAKE) -f Makefile.cds_lfht_add_unique clean + $(AM_V_at)$(MAKE) -f Makefile.cds_lfht_add_replace clean + $(AM_V_at)$(MAKE) -f Makefile.cds_lfht_del clean + $(AM_V_at)$(MAKE) -f Makefile.cds_lfht_destroy clean + $(AM_V_at)$(MAKE) -f Makefile.cds_lfht_lookup clean + $(AM_V_at)$(MAKE) -f Makefile.cds_lfht_for_each_entry_duplicate clean diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_add b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_add new file mode 100644 index 0000000000000..45333f5579db8 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_add @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_lfht_add + +SOURCES = $(EXAMPLE_NAME).c +DEPS = jhash.h +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-cds -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_add_replace b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_add_replace new file mode 100644 index 0000000000000..6147a414fbcda --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_add_replace @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_lfht_add_replace + +SOURCES = $(EXAMPLE_NAME).c +DEPS = jhash.h +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-cds -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_add_unique b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_add_unique new file mode 100644 index 0000000000000..a1772d32efce9 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_add_unique @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_lfht_add_unique + +SOURCES = $(EXAMPLE_NAME).c +DEPS = jhash.h +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-cds -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_del b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_del new file mode 100644 index 0000000000000..982b0f7887895 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_del @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_lfht_del + +SOURCES = $(EXAMPLE_NAME).c +DEPS = jhash.h +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-cds -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_destroy b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_destroy new file mode 100644 index 0000000000000..deda37af1d085 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_destroy @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_lfht_destroy + +SOURCES = $(EXAMPLE_NAME).c +DEPS = jhash.h +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-cds -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_for_each_entry_duplicate b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_for_each_entry_duplicate new file mode 100644 index 0000000000000..fd5d38dfa1bc0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_for_each_entry_duplicate @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_lfht_for_each_entry_duplicate + +SOURCES = $(EXAMPLE_NAME).c +DEPS = jhash.h +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-cds -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_lookup b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_lookup new file mode 100644 index 0000000000000..8330c9ca22198 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/Makefile.cds_lfht_lookup @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_lfht_lookup + +SOURCES = $(EXAMPLE_NAME).c +DEPS = jhash.h +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-cds -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_add.c b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_add.c new file mode 100644 index 0000000000000..927e38d99c24d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_add.c @@ -0,0 +1,99 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to add nodes (allowing duplicate keys) into a + * RCU lock-free hash table. + * This hash table requires using a RCU scheme. + */ + +#include +#include +#include + +#include /* RCU flavor */ +#include /* RCU Lock-free hash table */ +#include /* For CAA_ARRAY_SIZE */ +#include "jhash.h" /* Example hash function */ + +/* + * Nodes populated into the hash table. + */ +struct mynode { + int value; /* Node content */ + struct cds_lfht_node node; /* Chaining in hash table */ +}; + +int main(void) +{ + int values[] = { -5, 42, 42, 36, 24, }; /* 42 is duplicated */ + struct cds_lfht *ht; /* Hash table */ + unsigned int i; + int ret = 0; + uint32_t seed; + struct cds_lfht_iter iter; /* For iteration on hash table */ + struct mynode *node; + + /* + * Each thread need using RCU read-side need to be explicitly + * registered. + */ + urcu_memb_register_thread(); + + /* Use time as seed for hash table hashing. */ + seed = (uint32_t) time(NULL); + + /* + * Allocate hash table. + */ + ht = cds_lfht_new_flavor(1, 1, 0, + CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, + &urcu_memb_flavor, NULL); + if (!ht) { + printf("Error allocating hash table\n"); + ret = -1; + goto end; + } + + /* + * Add nodes to hash table. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + unsigned long hash; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + + cds_lfht_node_init(&node->node); + node->value = values[i]; + hash = jhash(&values[i], sizeof(values[i]), seed); + + /* + * cds_lfht_add() needs to be called from RCU read-side + * critical section. + */ + urcu_memb_read_lock(); + cds_lfht_add(ht, hash, &node->node); + urcu_memb_read_unlock(); + } + + /* + * Iterate over each hash table node. Those will appear in + * random order, depending on the hash seed. Iteration needs to + * be performed within RCU read-side critical section. + */ + printf("hash table content (random order):"); + urcu_memb_read_lock(); + cds_lfht_for_each_entry(ht, &iter, node, node) { + printf(" %d", node->value); + } + urcu_memb_read_unlock(); + printf("\n"); +end: + urcu_memb_unregister_thread(); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_add_replace.c b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_add_replace.c new file mode 100644 index 0000000000000..ecab5708c6cff --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_add_replace.c @@ -0,0 +1,140 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to add nodes into a RCU lock-free hash table + * with cds_lfht_add_replace(), which replaces existing nodes with the + * same key if found. + * We use a "seqnum" field to show which node is staying in the hash + * table. This hash table requires using a RCU scheme. + */ + +#include +#include +#include + +#include /* RCU flavor */ +#include /* RCU Lock-free hash table */ +#include /* For CAA_ARRAY_SIZE */ +#include "jhash.h" /* Example hash function */ + +/* + * Nodes populated into the hash table. + */ +struct mynode { + int value; /* Node content */ + int seqnum; /* Our node sequence number */ + struct cds_lfht_node node; /* Chaining in hash table */ + struct rcu_head rcu_head; /* For call_rcu() */ +}; + +static +int match(struct cds_lfht_node *ht_node, const void *_key) +{ + struct mynode *node = + caa_container_of(ht_node, struct mynode, node); + const int *key = _key; + + return *key == node->value; +} + +static +void free_node(struct rcu_head *head) +{ + struct mynode *node = caa_container_of(head, struct mynode, rcu_head); + + free(node); +} + +int main(void) +{ + int values[] = { -5, 42, 42, 36, 24, }; /* 42 is duplicated */ + struct cds_lfht *ht; /* Hash table */ + unsigned int i; + int ret = 0, seqnum = 0; + uint32_t seed; + struct cds_lfht_iter iter; /* For iteration on hash table */ + struct cds_lfht_node *ht_node; + struct mynode *node; + + /* + * Each thread need using RCU read-side need to be explicitly + * registered. + */ + urcu_memb_register_thread(); + + /* Use time as seed for hash table hashing. */ + seed = (uint32_t) time(NULL); + + /* + * Allocate hash table. + */ + ht = cds_lfht_new_flavor(1, 1, 0, + CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, + &urcu_memb_flavor, NULL); + if (!ht) { + printf("Error allocating hash table\n"); + ret = -1; + goto end; + } + + /* + * Add nodes to hash table. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + unsigned long hash; + int value; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + + cds_lfht_node_init(&node->node); + value = values[i]; + node->value = value; + node->seqnum = seqnum++; + hash = jhash(&value, sizeof(value), seed); + + /* + * cds_lfht_add() needs to be called from RCU read-side + * critical section. + */ + urcu_memb_read_lock(); + ht_node = cds_lfht_add_replace(ht, hash, match, &value, + &node->node); + if (ht_node) { + struct mynode *ret_node = + caa_container_of(ht_node, struct mynode, node); + + printf("Replaced node (key: %d, seqnum: %d) by (key: %d, seqnum: %d)\n", + ret_node->value, ret_node->seqnum, + node->value, node->seqnum); + urcu_memb_call_rcu(&ret_node->rcu_head, free_node); + } else { + printf("Add (key: %d, seqnum: %d)\n", + node->value, node->seqnum); + } + urcu_memb_read_unlock(); + } + + /* + * Iterate over each hash table node. Those will appear in + * random order, depending on the hash seed. Iteration needs to + * be performed within RCU read-side critical section. + */ + printf("hash table content (random order):"); + urcu_memb_read_lock(); + cds_lfht_for_each_entry(ht, &iter, node, node) { + printf(" (key: %d, seqnum: %d)", + node->value, node->seqnum); + } + urcu_memb_read_unlock(); + printf("\n"); + +end: + urcu_memb_unregister_thread(); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_add_unique.c b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_add_unique.c new file mode 100644 index 0000000000000..326e19b135f24 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_add_unique.c @@ -0,0 +1,137 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to add unique nodes into a RCU lock-free hash + * table. We use a "seqnum" field to show which node is staying in the + * hash table. This hash table requires using a RCU scheme. + */ + +#include +#include +#include + +#include /* RCU flavor */ +#include /* RCU Lock-free hash table */ +#include /* For CAA_ARRAY_SIZE */ +#include "jhash.h" /* Example hash function */ + +/* + * Nodes populated into the hash table. + */ +struct mynode { + int value; /* Node content */ + int seqnum; /* Our node sequence number */ + struct cds_lfht_node node; /* Chaining in hash table */ +}; + +static +int match(struct cds_lfht_node *ht_node, const void *_key) +{ + struct mynode *node = + caa_container_of(ht_node, struct mynode, node); + const int *key = _key; + + return *key == node->value; +} + +int main(void) +{ + int values[] = { -5, 42, 42, 36, 24, }; /* 42 is duplicated */ + struct cds_lfht *ht; /* Hash table */ + unsigned int i; + int ret = 0, seqnum = 0; + uint32_t seed; + struct cds_lfht_iter iter; /* For iteration on hash table */ + struct cds_lfht_node *ht_node; + struct mynode *node; + + /* + * Each thread need using RCU read-side need to be explicitly + * registered. + */ + urcu_memb_register_thread(); + + /* Use time as seed for hash table hashing. */ + seed = (uint32_t) time(NULL); + + /* + * Allocate hash table. + */ + ht = cds_lfht_new_flavor(1, 1, 0, + CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, + &urcu_memb_flavor, NULL); + if (!ht) { + printf("Error allocating hash table\n"); + ret = -1; + goto end; + } + + /* + * Add nodes to hash table. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + unsigned long hash; + int value; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + + cds_lfht_node_init(&node->node); + value = values[i]; + node->value = value; + node->seqnum = seqnum++; + hash = jhash(&value, sizeof(value), seed); + + /* + * cds_lfht_add() needs to be called from RCU read-side + * critical section. + */ + urcu_memb_read_lock(); + ht_node = cds_lfht_add_unique(ht, hash, match, &value, + &node->node); + /* + * cds_lfht_add_unique() returns the added node if not + * already present, else returns the node matching the + * key. + */ + if (ht_node != &node->node) { + /* + * We found a match. Therefore, to ensure we + * don't add duplicates, cds_lfht_add_unique() + * acted as a RCU lookup, returning the found + * match. It did not add the new node to the + * hash table, so we can free it on the spot. + */ + printf("Not adding duplicate (key: %d, seqnum: %d)\n", + node->value, node->seqnum); + free(node); + } else { + printf("Add (key: %d, seqnum: %d)\n", + node->value, node->seqnum); + } + urcu_memb_read_unlock(); + } + + /* + * Iterate over each hash table node. Those will appear in + * random order, depending on the hash seed. Iteration needs to + * be performed within RCU read-side critical section. + */ + printf("hash table content (random order):"); + urcu_memb_read_lock(); + cds_lfht_for_each_entry(ht, &iter, node, node) { + printf(" (key: %d, seqnum: %d)", + node->value, node->seqnum); + } + urcu_memb_read_unlock(); + printf("\n"); + +end: + urcu_memb_unregister_thread(); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_del.c b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_del.c new file mode 100644 index 0000000000000..4eb3486e5833d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_del.c @@ -0,0 +1,161 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to remove nodes from a RCU lock-free hash table. + * This hash table requires using a RCU scheme. + */ + +#include +#include +#include + +#include /* RCU flavor */ +#include /* RCU Lock-free hash table */ +#include /* For CAA_ARRAY_SIZE */ +#include "jhash.h" /* Example hash function */ + +/* + * Nodes populated into the hash table. + */ +struct mynode { + int value; /* Node content */ + struct cds_lfht_node node; /* Chaining in hash table */ + struct rcu_head rcu_head; /* For call_rcu() */ +}; + +static +int match(struct cds_lfht_node *ht_node, const void *_key) +{ + struct mynode *node = + caa_container_of(ht_node, struct mynode, node); + const int *key = _key; + + return *key == node->value; +} + +static +void free_node(struct rcu_head *head) +{ + struct mynode *node = caa_container_of(head, struct mynode, rcu_head); + + free(node); +} + +int main(void) +{ + int values[] = { -5, 42, 42, 36, 24, }; /* 42 is duplicated */ + int remove_values[] = { 42, 36, 24, 123, }; + struct cds_lfht *ht; /* Hash table */ + unsigned int i; + int ret = 0; + uint32_t seed; + struct cds_lfht_iter iter; /* For iteration on hash table */ + struct cds_lfht_node *ht_node; + struct mynode *node; + + /* + * Each thread need using RCU read-side need to be explicitly + * registered. + */ + urcu_memb_register_thread(); + + /* Use time as seed for hash table hashing. */ + seed = (uint32_t) time(NULL); + + /* + * Allocate hash table. + */ + ht = cds_lfht_new_flavor(1, 1, 0, + CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, + &urcu_memb_flavor, NULL); + if (!ht) { + printf("Error allocating hash table\n"); + ret = -1; + goto end; + } + + /* + * Add nodes to hash table. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + unsigned long hash; + int value; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + + cds_lfht_node_init(&node->node); + value = values[i]; + node->value = value; + hash = jhash(&value, sizeof(value), seed); + + /* + * cds_lfht_add() needs to be called from RCU read-side + * critical section. + */ + urcu_memb_read_lock(); + cds_lfht_add(ht, hash, &node->node); + urcu_memb_read_unlock(); + } + + /* + * Iterate over each hash table node. Those will appear in + * random order, depending on the hash seed. Iteration needs to + * be performed within RCU read-side critical section. + */ + printf("hash table content (random order):"); + urcu_memb_read_lock(); + cds_lfht_for_each_entry(ht, &iter, node, node) { + printf(" %d", node->value); + } + urcu_memb_read_unlock(); + printf("\n"); + + /* + * Remove one node for each key, if such a node is present. + */ + printf("removing keys (single key, not duplicates):"); + for (i = 0; i < CAA_ARRAY_SIZE(remove_values); i++) { + unsigned long hash; + int value; + + value = remove_values[i]; + hash = jhash(&value, sizeof(value), seed); + printf(" %d", value); + urcu_memb_read_lock(); + cds_lfht_lookup(ht, hash, match, &value, &iter); + ht_node = cds_lfht_iter_get_node(&iter); + if (ht_node) { + ret = cds_lfht_del(ht, ht_node); + if (ret) { + printf(" (concurrently deleted)"); + } else { + struct mynode *del_node = + caa_container_of(ht_node, + struct mynode, node); + urcu_memb_call_rcu(&del_node->rcu_head, free_node); + } + } else { + printf(" (not found)"); + } + urcu_memb_read_unlock(); + } + printf("\n"); + + printf("hash table content (random order):"); + urcu_memb_read_lock(); + cds_lfht_for_each_entry(ht, &iter, node, node) { + printf(" %d", node->value); + } + urcu_memb_read_unlock(); + printf("\n"); + +end: + urcu_memb_unregister_thread(); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_destroy.c b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_destroy.c new file mode 100644 index 0000000000000..f0c8219f9194c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_destroy.c @@ -0,0 +1,142 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to use cds_lfht_destroy() to clear memory used + * by a a RCU lock-free hash table. This hash table requires using a + * RCU scheme. + */ + +#include +#include +#include + +#include /* RCU flavor */ +#include /* RCU Lock-free hash table */ +#include /* For CAA_ARRAY_SIZE */ +#include "jhash.h" /* Example hash function */ + +/* + * Nodes populated into the hash table. + */ +struct mynode { + int value; /* Node content */ + struct cds_lfht_node node; /* Chaining in hash table */ + struct rcu_head rcu_head; /* For call_rcu() */ +}; + +static +void free_node(struct rcu_head *head) +{ + struct mynode *node = caa_container_of(head, struct mynode, rcu_head); + + free(node); +} + +int main(void) +{ + int values[] = { -5, 42, 42, 36, 24, }; /* 42 is duplicated */ + struct cds_lfht *ht; /* Hash table */ + unsigned int i; + int ret = 0; + uint32_t seed; + struct cds_lfht_iter iter; /* For iteration on hash table */ + struct cds_lfht_node *ht_node; + struct mynode *node; + + /* + * Each thread need using RCU read-side need to be explicitly + * registered. + */ + urcu_memb_register_thread(); + + /* Use time as seed for hash table hashing. */ + seed = (uint32_t) time(NULL); + + /* + * Allocate hash table. + */ + ht = cds_lfht_new_flavor(1, 1, 0, + CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, + &urcu_memb_flavor, NULL); + if (!ht) { + printf("Error allocating hash table\n"); + ret = -1; + goto end; + } + + /* + * Add nodes to hash table. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + unsigned long hash; + int value; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + + cds_lfht_node_init(&node->node); + value = values[i]; + node->value = value; + hash = jhash(&value, sizeof(value), seed); + + /* + * cds_lfht_add() needs to be called from RCU read-side + * critical section. + */ + urcu_memb_read_lock(); + cds_lfht_add(ht, hash, &node->node); + urcu_memb_read_unlock(); + } + + /* + * Iterate over each hash table node. Those will appear in + * random order, depending on the hash seed. Iteration needs to + * be performed within RCU read-side critical section. + */ + printf("hash table content (random order):"); + urcu_memb_read_lock(); + cds_lfht_for_each_entry(ht, &iter, node, node) { + printf(" %d", node->value); + } + urcu_memb_read_unlock(); + printf("\n"); + + + /* + * Make sure all hash table nodes are removed before destroying. + */ + printf("removing all nodes:"); + urcu_memb_read_lock(); + cds_lfht_for_each_entry(ht, &iter, node, node) { + ht_node = cds_lfht_iter_get_node(&iter); + ret = cds_lfht_del(ht, ht_node); + printf(" %d", node->value); + if (ret) { + printf(" (concurrently deleted)"); + } else { + urcu_memb_call_rcu(&node->rcu_head, free_node); + } + } + urcu_memb_read_unlock(); + printf("\n"); + + /* + * cds_lfht_destroy() must be called from a very specific + * context: it needs to be called from a registered RCU reader + * thread. However, this thread should _not_ be within a RCU + * read-side critical section. Also, it should _not_ be called + * from a call_rcu thread. + */ + ret = cds_lfht_destroy(ht, NULL); + if (ret) { + printf("Destroying hash table failed\n"); + } +end: + urcu_memb_unregister_thread(); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_for_each_entry_duplicate.c b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_for_each_entry_duplicate.c new file mode 100644 index 0000000000000..14f39e1f8ba32 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_for_each_entry_duplicate.c @@ -0,0 +1,136 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to iterate on duplicate keys within a RCU + * lock-free hash table. This hash table requires using a RCU scheme. + */ + +#include +#include +#include + +#include /* RCU flavor */ +#include /* RCU Lock-free hash table */ +#include /* For CAA_ARRAY_SIZE */ +#include "jhash.h" /* Example hash function */ + +/* + * Nodes populated into the hash table. + */ +struct mynode { + int value; /* Node content */ + int seqnum; /* Our node sequence number */ + struct cds_lfht_node node; /* Chaining in hash table */ +}; + +static +int match(struct cds_lfht_node *ht_node, const void *_key) +{ + struct mynode *node = + caa_container_of(ht_node, struct mynode, node); + const int *key = _key; + + return *key == node->value; +} + +int main(void) +{ + int values[] = { -5, 42, 42, 36, 24, }; /* 42 is duplicated */ + int lookup_values[] = { 42, 200, 36, }; + struct cds_lfht *ht; /* Hash table */ + unsigned int i; + int ret = 0, seqnum = 0; + uint32_t seed; + struct cds_lfht_iter iter; /* For iteration on hash table */ + struct mynode *node; + + /* + * Each thread need using RCU read-side need to be explicitly + * registered. + */ + urcu_memb_register_thread(); + + /* Use time as seed for hash table hashing. */ + seed = (uint32_t) time(NULL); + + /* + * Allocate hash table. + */ + ht = cds_lfht_new_flavor(1, 1, 0, + CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, + &urcu_memb_flavor, NULL); + if (!ht) { + printf("Error allocating hash table\n"); + ret = -1; + goto end; + } + + /* + * Add nodes to hash table. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + unsigned long hash; + int value; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + + cds_lfht_node_init(&node->node); + value = values[i]; + node->value = value; + node->seqnum = seqnum++; + hash = jhash(&value, sizeof(value), seed); + + /* + * cds_lfht_add() needs to be called from RCU read-side + * critical section. + */ + urcu_memb_read_lock(); + cds_lfht_add(ht, hash, &node->node); + printf("Add (key: %d, seqnum: %d)\n", + node->value, node->seqnum); + urcu_memb_read_unlock(); + } + + /* + * Iterate over each hash table node. Those will appear in + * random order, depending on the hash seed. Iteration needs to + * be performed within RCU read-side critical section. + */ + printf("hash table content (random order):"); + urcu_memb_read_lock(); + cds_lfht_for_each_entry(ht, &iter, node, node) { + printf(" (key: %d, seqnum: %d)", + node->value, node->seqnum); + } + urcu_memb_read_unlock(); + printf("\n"); + + /* + * Lookup queries. Note that which node (seqnum) within + * duplicates will be found by lookup is random. + */ + printf("Lookups, with iteration on duplicates:\n"); + for (i = 0; i < CAA_ARRAY_SIZE(lookup_values); i++) { + int value = lookup_values[i]; + unsigned long hash = jhash(&value, sizeof(value), seed); + + printf("lookup key: %d\n", value); + urcu_memb_read_lock(); + cds_lfht_for_each_entry_duplicate(ht, hash, match, + &value, &iter, node, node) { + printf(" (key %d, seqnum %d) found\n", + node->value, node->seqnum); + } + urcu_memb_read_unlock(); + } + +end: + urcu_memb_unregister_thread(); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_lookup.c b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_lookup.c new file mode 100644 index 0000000000000..6b06095df1631 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/cds_lfht_lookup.c @@ -0,0 +1,140 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to lookup keys within a RCU lock-free hash + * table. This hash table requires using a RCU scheme. + */ + +#include +#include +#include + +#include /* RCU flavor */ +#include /* RCU Lock-free hash table */ +#include /* For CAA_ARRAY_SIZE */ +#include "jhash.h" /* Example hash function */ + +/* + * Nodes populated into the hash table. + */ +struct mynode { + int value; /* Node content */ + int seqnum; /* Our node sequence number */ + struct cds_lfht_node node; /* Chaining in hash table */ +}; + +static +int match(struct cds_lfht_node *ht_node, const void *_key) +{ + struct mynode *node = + caa_container_of(ht_node, struct mynode, node); + const int *key = _key; + + return *key == node->value; +} + +int main(void) +{ + int values[] = { -5, 42, 42, 36, 24, }; /* 42 is duplicated */ + int lookup_values[] = { 42, 200, 36, }; + struct cds_lfht *ht; /* Hash table */ + unsigned int i; + int ret = 0, seqnum = 0; + uint32_t seed; + struct cds_lfht_iter iter; /* For iteration on hash table */ + struct cds_lfht_node *ht_node; + struct mynode *node; + + /* + * Each thread need using RCU read-side need to be explicitly + * registered. + */ + urcu_memb_register_thread(); + + /* Use time as seed for hash table hashing. */ + seed = (uint32_t) time(NULL); + + /* + * Allocate hash table. + */ + ht = cds_lfht_new_flavor(1, 1, 0, + CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, + &urcu_memb_flavor, NULL); + if (!ht) { + printf("Error allocating hash table\n"); + ret = -1; + goto end; + } + + /* + * Add nodes to hash table. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + unsigned long hash; + int value; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + + cds_lfht_node_init(&node->node); + value = values[i]; + node->value = value; + node->seqnum = seqnum++; + hash = jhash(&value, sizeof(value), seed); + + /* + * cds_lfht_add() needs to be called from RCU read-side + * critical section. + */ + urcu_memb_read_lock(); + cds_lfht_add(ht, hash, &node->node); + printf("Add (key: %d, seqnum: %d)\n", + node->value, node->seqnum); + urcu_memb_read_unlock(); + } + + /* + * Iterate over each hash table node. Those will appear in + * random order, depending on the hash seed. Iteration needs to + * be performed within RCU read-side critical section. + */ + printf("hash table content (random order):"); + urcu_memb_read_lock(); + cds_lfht_for_each_entry(ht, &iter, node, node) { + printf(" (key: %d, seqnum: %d)", + node->value, node->seqnum); + } + urcu_memb_read_unlock(); + printf("\n"); + + /* + * Lookup queries. Note that which node (seqnum) within + * duplicates will be found by lookup is random. + */ + printf("Lookups:\n"); + for (i = 0; i < CAA_ARRAY_SIZE(lookup_values); i++) { + int value = lookup_values[i]; + unsigned long hash = jhash(&value, sizeof(value), seed); + + urcu_memb_read_lock(); + cds_lfht_lookup(ht, hash, match, &value, &iter); + ht_node = cds_lfht_iter_get_node(&iter); + if (!ht_node) { + printf("Key %d not found\n", value); + } else { + node = caa_container_of(ht_node, struct mynode, node); + printf("(key %d, seqnum %d) found\n", + node->value, node->seqnum); + } + urcu_memb_read_unlock(); + } + +end: + urcu_memb_unregister_thread(); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/jhash.h b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/jhash.h new file mode 100644 index 0000000000000..23812ce246d6c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfhash/jhash.h @@ -0,0 +1,251 @@ +// SPDX-FileCopyrightText: 2009-2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +#ifndef _JHASH_H +#define _JHASH_H + +#if defined(__FreeBSD__) +#include +#endif + +/* + * Example hash function. + */ + +/* + * Hash function + * Source: http://burtleburtle.net/bob/c/lookup3.c + * Originally Public Domain + */ + +#define rot(x, k) (((x) << (k)) | ((x) >> (32 - (k)))) + +#define mix(a, b, c) \ +do { \ + a -= c; a ^= rot(c, 4); c += b; \ + b -= a; b ^= rot(a, 6); a += c; \ + c -= b; c ^= rot(b, 8); b += a; \ + a -= c; a ^= rot(c, 16); c += b; \ + b -= a; b ^= rot(a, 19); a += c; \ + c -= b; c ^= rot(b, 4); b += a; \ +} while (0) + +#define final(a, b, c) \ +{ \ + c ^= b; c -= rot(b, 14); \ + a ^= c; a -= rot(c, 11); \ + b ^= a; b -= rot(a, 25); \ + c ^= b; c -= rot(b, 16); \ + a ^= c; a -= rot(c, 4); \ + b ^= a; b -= rot(a, 14); \ + c ^= b; c -= rot(b, 24); \ +} + +#if (BYTE_ORDER == LITTLE_ENDIAN) +#define HASH_LITTLE_ENDIAN 1 +#else +#define HASH_LITTLE_ENDIAN 0 +#endif + +/* + * + * hashlittle() -- hash a variable-length key into a 32-bit value + * k : the key (the unaligned variable-length array of bytes) + * length : the length of the key, counting by bytes + * initval : can be any 4-byte value + * Returns a 32-bit value. Every bit of the key affects every bit of + * the return value. Two keys differing by one or two bits will have + * totally different hash values. + * + * The best hash table sizes are powers of 2. There is no need to do + * mod a prime (mod is sooo slow!). If you need less than 32 bits, + * use a bitmask. For example, if you need only 10 bits, do + * h = (h & hashmask(10)); + * In which case, the hash table should have hashsize(10) elements. + * + * If you are hashing n strings (uint8_t **)k, do it like this: + * for (i = 0, h = 0; i < n; ++i) h = hashlittle(k[i], len[i], h); + * + * By Bob Jenkins, 2006. bob_jenkins@burtleburtle.net. You may use this + * code any way you wish, private, educational, or commercial. It's free. + * + * Use for hash table lookup, or anything where one collision in 2^^32 is + * acceptable. Do NOT use for cryptographic purposes. + */ +static +uint32_t hashlittle(const void *key, size_t length, uint32_t initval) +{ + uint32_t a, b, c; /* internal state */ + union { + const void *ptr; + size_t i; + } u; + + /* Set up the internal state */ + a = b = c = 0xdeadbeef + ((uint32_t)length) + initval; + + u.ptr = key; + if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) { + const uint32_t *k = (const uint32_t *) key; /* read 32-bit chunks */ + + /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */ + while (length > 12) { + a += k[0]; + b += k[1]; + c += k[2]; + mix(a, b, c); + length -= 12; + k += 3; + } + + /*----------------------------- handle the last (probably partial) block */ + /* + * "k[2]&0xffffff" actually reads beyond the end of the string, but + * then masks off the part it's not allowed to read. Because the + * string is aligned, the masked-off tail is in the same word as the + * rest of the string. Every machine with memory protection I've seen + * does it on word boundaries, so is OK with this. But VALGRIND will + * still catch it and complain. The masking trick does make the hash + * noticeably faster for short strings (like English words). + */ +#ifndef VALGRIND + + switch (length) { + case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; + case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break; + case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break; + case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break; + case 8 : b+=k[1]; a+=k[0]; break; + case 7 : b+=k[1]&0xffffff; a+=k[0]; break; + case 6 : b+=k[1]&0xffff; a+=k[0]; break; + case 5 : b+=k[1]&0xff; a+=k[0]; break; + case 4 : a+=k[0]; break; + case 3 : a+=k[0]&0xffffff; break; + case 2 : a+=k[0]&0xffff; break; + case 1 : a+=k[0]&0xff; break; + case 0 : return c; /* zero length strings require no mixing */ + } + +#else /* make valgrind happy */ + { + const uint8_t *k8; + + k8 = (const uint8_t *) k; + switch (length) { + case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; + case 11: c+=((uint32_t) k8[10])<<16; /* fall through */ + case 10: c+=((uint32_t) k8[9])<<8; /* fall through */ + case 9 : c+=k8[8]; /* fall through */ + case 8 : b+=k[1]; a+=k[0]; break; + case 7 : b+=((uint32_t) k8[6])<<16; /* fall through */ + case 6 : b+=((uint32_t) k8[5])<<8; /* fall through */ + case 5 : b+=k8[4]; /* fall through */ + case 4 : a+=k[0]; break; + case 3 : a+=((uint32_t) k8[2])<<16; /* fall through */ + case 2 : a+=((uint32_t) k8[1])<<8; /* fall through */ + case 1 : a+=k8[0]; break; + case 0 : return c; + } + } +#endif /* !valgrind */ + + } else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) { + const uint16_t *k = (const uint16_t *) key; /* read 16-bit chunks */ + const uint8_t *k8; + + /*--------------- all but last block: aligned reads and different mixing */ + while (length > 12) + { + a += k[0] + (((uint32_t) k[1])<<16); + b += k[2] + (((uint32_t) k[3])<<16); + c += k[4] + (((uint32_t) k[5])<<16); + mix(a, b, c); + length -= 12; + k += 6; + } + + /*----------------------------- handle the last (probably partial) block */ + k8 = (const uint8_t *) k; + switch(length) + { + case 12: c+=k[4]+(((uint32_t) k[5])<<16); + b+=k[2]+(((uint32_t) k[3])<<16); + a+=k[0]+(((uint32_t) k[1])<<16); + break; + case 11: c+=((uint32_t) k8[10])<<16; /* fall through */ + case 10: c+=k[4]; + b+=k[2]+(((uint32_t) k[3])<<16); + a+=k[0]+(((uint32_t) k[1])<<16); + break; + case 9 : c+=k8[8]; /* fall through */ + case 8 : b+=k[2]+(((uint32_t) k[3])<<16); + a+=k[0]+(((uint32_t) k[1])<<16); + break; + case 7 : b+=((uint32_t) k8[6])<<16; /* fall through */ + case 6 : b+=k[2]; + a+=k[0]+(((uint32_t) k[1])<<16); + break; + case 5 : b+=k8[4]; /* fall through */ + case 4 : a+=k[0]+(((uint32_t) k[1])<<16); + break; + case 3 : a+=((uint32_t) k8[2])<<16; /* fall through */ + case 2 : a+=k[0]; + break; + case 1 : a+=k8[0]; + break; + case 0 : return c; /* zero length requires no mixing */ + } + + } else { /* need to read the key one byte at a time */ + const uint8_t *k = (const uint8_t *)key; + + /*--------------- all but the last block: affect some 32 bits of (a, b, c) */ + while (length > 12) { + a += k[0]; + a += ((uint32_t) k[1])<<8; + a += ((uint32_t) k[2])<<16; + a += ((uint32_t) k[3])<<24; + b += k[4]; + b += ((uint32_t) k[5])<<8; + b += ((uint32_t) k[6])<<16; + b += ((uint32_t) k[7])<<24; + c += k[8]; + c += ((uint32_t) k[9])<<8; + c += ((uint32_t) k[10])<<16; + c += ((uint32_t) k[11])<<24; + mix(a,b,c); + length -= 12; + k += 12; + } + + /*-------------------------------- last block: affect all 32 bits of (c) */ + switch (length) { /* all the case statements fall through */ + case 12: c+=((uint32_t) k[11])<<24; /* fall through */ + case 11: c+=((uint32_t) k[10])<<16; /* fall through */ + case 10: c+=((uint32_t) k[9])<<8; /* fall through */ + case 9 : c+=k[8]; /* fall through */ + case 8 : b+=((uint32_t) k[7])<<24; /* fall through */ + case 7 : b+=((uint32_t) k[6])<<16; /* fall through */ + case 6 : b+=((uint32_t) k[5])<<8; /* fall through */ + case 5 : b+=k[4]; /* fall through */ + case 4 : a+=((uint32_t) k[3])<<24; /* fall through */ + case 3 : a+=((uint32_t) k[2])<<16; /* fall through */ + case 2 : a+=((uint32_t) k[1])<<8; /* fall through */ + case 1 : a+=k[0]; + break; + case 0 : return c; + } + } + + final(a, b, c); + return c; +} + +static inline +uint32_t jhash(const void *key, size_t length, uint32_t seed) +{ + return hashlittle(key, length, seed); +} + +#endif /* _JHASH_H */ diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/Makefile b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/Makefile new file mode 100644 index 0000000000000..445a3ad978329 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/Makefile @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +all: + $(AM_V_at)$(MAKE) -f Makefile.cds_lfq_enqueue + $(AM_V_at)$(MAKE) -f Makefile.cds_lfq_dequeue + +.PHONY: clean +clean: + $(AM_V_at)$(MAKE) -f Makefile.cds_lfq_enqueue clean + $(AM_V_at)$(MAKE) -f Makefile.cds_lfq_dequeue clean diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/Makefile.cds_lfq_dequeue b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/Makefile.cds_lfq_dequeue new file mode 100644 index 0000000000000..e893b5b8818e0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/Makefile.cds_lfq_dequeue @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_lfq_dequeue + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-cds -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/Makefile.cds_lfq_enqueue b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/Makefile.cds_lfq_enqueue new file mode 100644 index 0000000000000..c84c5c4b6c9df --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/Makefile.cds_lfq_enqueue @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_lfq_enqueue + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-cds -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/cds_lfq_dequeue.c b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/cds_lfq_dequeue.c new file mode 100644 index 0000000000000..67d766a6c6a16 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/cds_lfq_dequeue.c @@ -0,0 +1,108 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to dequeue nodes from a RCU lock-free queue. + * This queue requires using a RCU scheme. + */ + +#include +#include + +#include /* RCU flavor */ +#include /* RCU Lock-free queue */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the queue. + */ +struct mynode { + int value; /* Node content */ + struct cds_lfq_node_rcu node; /* Chaining in queue */ + struct rcu_head rcu_head; /* For call_rcu() */ +}; + +static +void free_node(struct rcu_head *head) +{ + struct mynode *node = + caa_container_of(head, struct mynode, rcu_head); + + free(node); +} + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + struct cds_lfq_queue_rcu myqueue; /* Queue */ + unsigned int i; + int ret = 0; + + /* + * Each thread need using RCU read-side need to be explicitly + * registered. + */ + urcu_memb_register_thread(); + + cds_lfq_init_rcu(&myqueue, urcu_memb_call_rcu); + + /* + * Enqueue nodes. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + struct mynode *node; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + + cds_lfq_node_init_rcu(&node->node); + node->value = values[i]; + /* + * Both enqueue and dequeue need to be called within RCU + * read-side critical section. + */ + urcu_memb_read_lock(); + cds_lfq_enqueue_rcu(&myqueue, &node->node); + urcu_memb_read_unlock(); + } + + /* + * Dequeue each node from the queue. Those will be dequeued from + * the oldest (first enqueued) to the newest (last enqueued). + */ + printf("dequeued content:"); + for (;;) { + struct cds_lfq_node_rcu *qnode; + struct mynode *node; + + /* + * Both enqueue and dequeue need to be called within RCU + * read-side critical section. + */ + urcu_memb_read_lock(); + qnode = cds_lfq_dequeue_rcu(&myqueue); + urcu_memb_read_unlock(); + if (!qnode) { + break; /* Queue is empty. */ + } + /* Getting the container structure from the node */ + node = caa_container_of(qnode, struct mynode, node); + printf(" %d", node->value); + urcu_memb_call_rcu(&node->rcu_head, free_node); + } + printf("\n"); + /* + * Release memory used by the queue. + */ + ret = cds_lfq_destroy_rcu(&myqueue); + if (ret) { + printf("Error destroying queue (non-empty)\n"); + } +end: + urcu_memb_unregister_thread(); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/cds_lfq_enqueue.c b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/cds_lfq_enqueue.c new file mode 100644 index 0000000000000..b0ea030537723 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/rculfqueue/cds_lfq_enqueue.c @@ -0,0 +1,66 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to enqueue nodes into a RCU lock-free queue. + * This queue requires using a RCU scheme. + */ + +#include +#include + +#include /* RCU flavor */ +#include /* RCU Lock-free queue */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the queue. + */ +struct mynode { + int value; /* Node content */ + struct cds_lfq_node_rcu node; /* Chaining in queue */ +}; + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + struct cds_lfq_queue_rcu myqueue; /* Queue */ + unsigned int i; + int ret = 0; + + /* + * Each thread need using RCU read-side need to be explicitly + * registered. + */ + urcu_memb_register_thread(); + + cds_lfq_init_rcu(&myqueue, urcu_memb_call_rcu); + + /* + * Enqueue nodes. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + struct mynode *node; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + + cds_lfq_node_init_rcu(&node->node); + node->value = values[i]; + /* + * Both enqueue and dequeue need to be called within RCU + * read-side critical section. + */ + urcu_memb_read_lock(); + cds_lfq_enqueue_rcu(&myqueue, &node->node); + urcu_memb_read_unlock(); + } + +end: + urcu_memb_unregister_thread(); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile new file mode 100644 index 0000000000000..6738eafb11cf7 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile @@ -0,0 +1,18 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +all: + $(AM_V_at)$(MAKE) -f Makefile.qsbr + $(AM_V_at)$(MAKE) -f Makefile.mb + $(AM_V_at)$(MAKE) -f Makefile.membarrier + $(AM_V_at)$(MAKE) -f Makefile.bp + +.PHONY: clean +clean: + $(AM_V_at)$(MAKE) -f Makefile.qsbr clean + $(AM_V_at)$(MAKE) -f Makefile.mb clean + $(AM_V_at)$(MAKE) -f Makefile.membarrier clean + $(AM_V_at)$(MAKE) -f Makefile.bp clean diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile.bp b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile.bp new file mode 100644 index 0000000000000..b42fe4dd67932 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile.bp @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = bp + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-bp + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile.mb b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile.mb new file mode 100644 index 0000000000000..b5d9ffbd7df5b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile.mb @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = mb + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-mb + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile.membarrier b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile.membarrier new file mode 100644 index 0000000000000..64dfceb4ab6d6 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile.membarrier @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = membarrier + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile.qsbr b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile.qsbr new file mode 100644 index 0000000000000..b50ce82f2ff98 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/Makefile.qsbr @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = qsbr + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-qsbr + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/bp.c b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/bp.c new file mode 100644 index 0000000000000..d42373386633f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/bp.c @@ -0,0 +1,101 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#include +#include +#include +#include +#include + +#include /* Bulletproof RCU flavor */ +#include /* List example */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Example showing how to use the Bulletproof Userspace RCU flavor. + * + * This is a mock-up example where updates and RCU traversals are + * performed by the same thread to keep things simple on purpose. + */ + +static CDS_LIST_HEAD(mylist); + +struct mynode { + uint64_t value; + struct cds_list_head node; /* linked-list chaining */ + struct rcu_head rcu_head; /* for call_rcu() */ +}; + +static +int add_node(uint64_t v) +{ + struct mynode *node; + + node = calloc(1, sizeof(*node)); + if (!node) + return -1; + node->value = v; + cds_list_add_rcu(&node->node, &mylist); + return 0; +} + +int main(void) +{ + uint64_t values[] = { 42, 36, 24, }; + unsigned int i; + int ret; + struct mynode *node, *n; + + /* + * Notice that with the bulletproof flavor, there is no need to + * register/unregister RCU reader threads. + */ + + /* + * Adding nodes to the linked-list. Safe against concurrent + * RCU traversals, require mutual exclusion with list updates. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + ret = add_node(values[i]); + if (ret) + goto end; + } + + /* + * We need to explicitly mark RCU read-side critical sections + * with rcu_read_lock() and rcu_read_unlock(). They can be + * nested. Those are no-ops for the QSBR flavor. + */ + urcu_bp_read_lock(); + + /* + * RCU traversal of the linked list. + */ + cds_list_for_each_entry_rcu(node, &mylist, node) { + printf("Value: %" PRIu64 "\n", node->value); + } + urcu_bp_read_unlock(); + + /* + * Removing nodes from linked list. Safe against concurrent RCU + * traversals, require mutual exclusion with list updates. + */ + cds_list_for_each_entry_safe(node, n, &mylist, node) { + cds_list_del_rcu(&node->node); + + /* + * Using synchronize_rcu() directly for synchronization + * so we keep a minimal impact on the system by not + * spawning any call_rcu() thread. It is slower though, + * since there is no batching. + */ + urcu_bp_synchronize_rcu(); + free(node); + } + + sleep(1); + +end: + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/mb.c b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/mb.c new file mode 100644 index 0000000000000..7069c248fef60 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/mb.c @@ -0,0 +1,126 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#include +#include +#include +#include +#include + +#include /* Memory barrier RCU flavor */ +#include /* List example */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Example showing how to use the memory-barrier-based Userspace RCU + * flavor. + * + * This is a mock-up example where updates and RCU traversals are + * performed by the same thread to keep things simple on purpose. + */ + +static CDS_LIST_HEAD(mylist); + +struct mynode { + uint64_t value; + struct cds_list_head node; /* linked-list chaining */ + struct rcu_head rcu_head; /* for call_rcu() */ +}; + +static +int add_node(uint64_t v) +{ + struct mynode *node; + + node = calloc(1, sizeof(*node)); + if (!node) + return -1; + node->value = v; + cds_list_add_rcu(&node->node, &mylist); + return 0; +} + +static +void rcu_free_node(struct rcu_head *rh) +{ + struct mynode *node = caa_container_of(rh, struct mynode, rcu_head); + + free(node); +} + +int main(void) +{ + uint64_t values[] = { 42, 36, 24, }; + unsigned int i; + int ret; + struct mynode *node, *n; + + /* + * Each thread need using RCU read-side need to be explicitly + * registered. + */ + urcu_mb_register_thread(); + + /* + * Adding nodes to the linked-list. Safe against concurrent + * RCU traversals, require mutual exclusion with list updates. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + ret = add_node(values[i]); + if (ret) + goto end; + } + + /* + * We need to explicitly mark RCU read-side critical sections + * with rcu_read_lock() and rcu_read_unlock(). They can be + * nested. Those are no-ops for the QSBR flavor. + */ + urcu_mb_read_lock(); + + /* + * RCU traversal of the linked list. + */ + cds_list_for_each_entry_rcu(node, &mylist, node) { + printf("Value: %" PRIu64 "\n", node->value); + } + urcu_mb_read_unlock(); + + /* + * Removing nodes from linked list. Safe against concurrent RCU + * traversals, require mutual exclusion with list updates. + */ + cds_list_for_each_entry_safe(node, n, &mylist, node) { + cds_list_del_rcu(&node->node); + /* + * call_rcu() will ensure that the handler + * "rcu_free_node" is executed after a grace period. + * call_rcu() can be called from RCU read-side critical + * sections. + */ + urcu_mb_call_rcu(&node->rcu_head, rcu_free_node); + } + + /* + * We can also wait for a quiescent state by calling + * synchronize_rcu() rather than using call_rcu(). It is usually + * a slower approach than call_rcu(), because the latter can + * batch work. Moreover, call_rcu() can be called from a RCU + * read-side critical section, but synchronize_rcu() should not. + */ + urcu_mb_synchronize_rcu(); + + sleep(1); + + /* + * Waiting for previously called call_rcu handlers to complete + * before program exits, or in library destructors, is a good + * practice. + */ + urcu_mb_barrier(); + +end: + urcu_mb_unregister_thread(); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/membarrier.c b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/membarrier.c new file mode 100644 index 0000000000000..73b9bd8edd124 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/membarrier.c @@ -0,0 +1,126 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#include +#include +#include +#include +#include + +#include /* sys_membarrier() RCU flavor */ +#include /* List example */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Example showing how to use the sys_membarrier()-based Userspace RCU + * flavor. + * + * This is a mock-up example where updates and RCU traversals are + * performed by the same thread to keep things simple on purpose. + */ + +static CDS_LIST_HEAD(mylist); + +struct mynode { + uint64_t value; + struct cds_list_head node; /* linked-list chaining */ + struct rcu_head rcu_head; /* for call_rcu() */ +}; + +static +int add_node(uint64_t v) +{ + struct mynode *node; + + node = calloc(1, sizeof(*node)); + if (!node) + return -1; + node->value = v; + cds_list_add_rcu(&node->node, &mylist); + return 0; +} + +static +void rcu_free_node(struct rcu_head *rh) +{ + struct mynode *node = caa_container_of(rh, struct mynode, rcu_head); + + free(node); +} + +int main(void) +{ + uint64_t values[] = { 42, 36, 24, }; + unsigned int i; + int ret; + struct mynode *node, *n; + + /* + * Each thread need using RCU read-side need to be explicitly + * registered. + */ + urcu_memb_register_thread(); + + /* + * Adding nodes to the linked-list. Safe against concurrent + * RCU traversals, require mutual exclusion with list updates. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + ret = add_node(values[i]); + if (ret) + goto end; + } + + /* + * We need to explicitly mark RCU read-side critical sections + * with rcu_read_lock() and rcu_read_unlock(). They can be + * nested. Those are no-ops for the QSBR flavor. + */ + urcu_memb_read_lock(); + + /* + * RCU traversal of the linked list. + */ + cds_list_for_each_entry_rcu(node, &mylist, node) { + printf("Value: %" PRIu64 "\n", node->value); + } + urcu_memb_read_unlock(); + + /* + * Removing nodes from linked list. Safe against concurrent RCU + * traversals, require mutual exclusion with list updates. + */ + cds_list_for_each_entry_safe(node, n, &mylist, node) { + cds_list_del_rcu(&node->node); + /* + * call_rcu() will ensure that the handler + * "rcu_free_node" is executed after a grace period. + * call_rcu() can be called from RCU read-side critical + * sections. + */ + urcu_memb_call_rcu(&node->rcu_head, rcu_free_node); + } + + /* + * We can also wait for a quiescent state by calling + * synchronize_rcu() rather than using call_rcu(). It is usually + * a slower approach than call_rcu(), because the latter can + * batch work. Moreover, call_rcu() can be called from a RCU + * read-side critical section, but synchronize_rcu() should not. + */ + urcu_memb_synchronize_rcu(); + + sleep(1); + + /* + * Waiting for previously called call_rcu handlers to complete + * before program exits, or in library destructors, is a good + * practice. + */ + urcu_memb_barrier(); + +end: + urcu_memb_unregister_thread(); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/qsbr.c b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/qsbr.c new file mode 100644 index 0000000000000..ca00933a1a88b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/urcu-flavors/qsbr.c @@ -0,0 +1,135 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#include +#include +#include +#include +#include + +#include /* QSBR RCU flavor */ +#include /* List example */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Example showing how to use the QSBR Userspace RCU flavor. + * + * This is a mock-up example where updates and RCU traversals are + * performed by the same thread to keep things simple on purpose. + */ + +static CDS_LIST_HEAD(mylist); + +struct mynode { + uint64_t value; + struct cds_list_head node; /* linked-list chaining */ + struct rcu_head rcu_head; /* for call_rcu() */ +}; + +static +int add_node(uint64_t v) +{ + struct mynode *node; + + node = calloc(1, sizeof(*node)); + if (!node) + return -1; + node->value = v; + cds_list_add_rcu(&node->node, &mylist); + return 0; +} + +static +void rcu_free_node(struct rcu_head *rh) +{ + struct mynode *node = caa_container_of(rh, struct mynode, rcu_head); + + free(node); +} + +int main(void) +{ + uint64_t values[] = { 42, 36, 24, }; + unsigned int i; + int ret; + struct mynode *node, *n; + + /* + * Each thread need using RCU read-side need to be explicitly + * registered. + */ + urcu_qsbr_register_thread(); + + /* + * Adding nodes to the linked-list. Safe against concurrent + * RCU traversals, require mutual exclusion with list updates. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + ret = add_node(values[i]); + if (ret) + goto end; + } + + /* + * RCU traversal of the linked list. + */ + cds_list_for_each_entry_rcu(node, &mylist, node) { + printf("Value: %" PRIu64 "\n", node->value); + } + + /* + * Removing nodes from linked list. Safe against concurrent RCU + * traversals, require mutual exclusion with list updates. + */ + cds_list_for_each_entry_safe(node, n, &mylist, node) { + cds_list_del_rcu(&node->node); + /* + * call_rcu() will ensure that the handler + * "rcu_free_node" is executed after a grace period. + * call_rcu() can be called from RCU read-side critical + * sections. + */ + urcu_qsbr_call_rcu(&node->rcu_head, rcu_free_node); + } + + /* + * For QSBR flavor, we need to explicitly announce quiescent + * states. Here is how it is done. This should be performed by + * every online registered RCU threads in the program + * periodically. + */ + urcu_qsbr_quiescent_state(); + + /* + * For QSBR flavor, when a thread needs to be in a quiescent + * state for a long period of time, we use rcu_thread_offline() + * and rcu_thread_online(). + */ + urcu_qsbr_thread_offline(); + + sleep(1); + + urcu_qsbr_thread_online(); + + /* + * We can also wait for a quiescent state by calling + * synchronize_rcu() rather than using call_rcu(). It is usually + * a slower approach than call_rcu(), because the latter can + * batch work. Moreover, call_rcu() can be called from a RCU + * read-side critical section, but synchronize_rcu() ensures the + * caller thread is offline, thus acting as a quiescent state. + */ + urcu_qsbr_synchronize_rcu(); + + /* + * Waiting for previously called call_rcu handlers to complete + * before program exits, or in library destructors, is a good + * practice. + */ + urcu_qsbr_barrier(); + +end: + urcu_qsbr_unregister_thread(); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/Makefile b/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/Makefile new file mode 100644 index 0000000000000..317985d830572 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/Makefile @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +all: + $(AM_V_at)$(MAKE) -f Makefile.cds_wfcq_enqueue + $(AM_V_at)$(MAKE) -f Makefile.cds_wfcq_dequeue + $(AM_V_at)$(MAKE) -f Makefile.cds_wfcq_splice + +.PHONY: clean +clean: + $(AM_V_at)$(MAKE) -f Makefile.cds_wfcq_enqueue clean + $(AM_V_at)$(MAKE) -f Makefile.cds_wfcq_dequeue clean + $(AM_V_at)$(MAKE) -f Makefile.cds_wfcq_splice clean diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/Makefile.cds_wfcq_dequeue b/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/Makefile.cds_wfcq_dequeue new file mode 100644 index 0000000000000..bbb303ded2f34 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/Makefile.cds_wfcq_dequeue @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_wfcq_dequeue + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-common + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/Makefile.cds_wfcq_enqueue b/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/Makefile.cds_wfcq_enqueue new file mode 100644 index 0000000000000..1145756837a9c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/Makefile.cds_wfcq_enqueue @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_wfcq_enqueue + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-common + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/Makefile.cds_wfcq_splice b/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/Makefile.cds_wfcq_splice new file mode 100644 index 0000000000000..17da52abe94a7 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/Makefile.cds_wfcq_splice @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_wfcq_splice + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-common + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/cds_wfcq_dequeue.c b/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/cds_wfcq_dequeue.c new file mode 100644 index 0000000000000..01a34a5f43473 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/cds_wfcq_dequeue.c @@ -0,0 +1,73 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to dequeue nodes from a wfcqueue. + */ + +#include +#include + +#include /* Wait-free concurrent queue */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the queue. + */ +struct mynode { + int value; /* Node content */ + struct cds_wfcq_node node; /* Chaining in queue */ +}; + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + struct cds_wfcq_head myqueue_head; /* Queue head */ + struct cds_wfcq_tail myqueue_tail; /* Queue tail */ + unsigned int i; + int ret = 0; + + cds_wfcq_init(&myqueue_head, &myqueue_tail); + + /* + * Enqueue nodes. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + struct mynode *node; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + + cds_wfcq_node_init(&node->node); + node->value = values[i]; + cds_wfcq_enqueue(&myqueue_head, &myqueue_tail, + &node->node); + } + + /* + * Dequeue each node from the queue. Those will be dequeued from + * the oldest (first enqueued) to the newest (last enqueued). + */ + printf("dequeued content:"); + for (;;) { + struct cds_wfcq_node *qnode; + struct mynode *node; + + qnode = cds_wfcq_dequeue_blocking(&myqueue_head, &myqueue_tail); + if (!qnode) { + break; /* Queue is empty. */ + } + /* Getting the container structure from the node */ + node = caa_container_of(qnode, struct mynode, node); + printf(" %d", node->value); + free(node); + } + printf("\n"); +end: + cds_wfcq_destroy(&myqueue_head, &myqueue_tail); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/cds_wfcq_enqueue.c b/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/cds_wfcq_enqueue.c new file mode 100644 index 0000000000000..374ca72c9791d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/cds_wfcq_enqueue.c @@ -0,0 +1,66 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to enqueue nodes into a wfcqueue. + */ + +#include +#include + +#include /* Wait-free concurrent queue */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the queue. + */ +struct mynode { + int value; /* Node content */ + struct cds_wfcq_node node; /* Chaining in queue */ +}; + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + struct cds_wfcq_head myqueue_head; /* Queue head */ + struct cds_wfcq_tail myqueue_tail; /* Queue tail */ + unsigned int i; + int ret = 0; + struct cds_wfcq_node *qnode; + + cds_wfcq_init(&myqueue_head, &myqueue_tail); + + /* + * Enqueue nodes. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + struct mynode *node; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + + cds_wfcq_node_init(&node->node); + node->value = values[i]; + cds_wfcq_enqueue(&myqueue_head, &myqueue_tail, + &node->node); + } + + /* + * Show the queue content, iterate in the same order nodes were + * enqueued, from oldest to newest. + */ + printf("myqueue content:"); + __cds_wfcq_for_each_blocking(&myqueue_head, &myqueue_tail, qnode) { + struct mynode *node = + caa_container_of(qnode, struct mynode, node); + printf(" %d", node->value); + } + printf("\n"); +end: + cds_wfcq_destroy(&myqueue_head, &myqueue_tail); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/cds_wfcq_splice.c b/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/cds_wfcq_splice.c new file mode 100644 index 0000000000000..5e369e83291e2 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/wfcqueue/cds_wfcq_splice.c @@ -0,0 +1,103 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to splice nodes from a source wfcqueue A into + * a destination wfcqueue B. + */ + +#include +#include + +#include /* Wait-free concurrent queue */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the queue. + */ +struct mynode { + int value; /* Node content */ + struct cds_wfcq_node node; /* Chaining in queue */ +}; + +static +int enqueue_values(struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail, + int *values, + size_t nr_values) +{ + int ret = 0; + unsigned int i; + + for (i = 0; i < nr_values; i++) { + struct mynode *node; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + cds_wfcq_node_init(&node->node); + node->value = values[i]; + cds_wfcq_enqueue(head, tail, &node->node); + } +end: + return ret; +} + +static +void print_queue(struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail, + const char *qname) +{ + struct cds_wfcq_node *qnode; + + printf("%s:", qname); + __cds_wfcq_for_each_blocking(head, tail, qnode) { + struct mynode *node = + caa_container_of(qnode, struct mynode, node); + printf(" %d", node->value); + } + printf("\n"); +} + +int main(void) +{ + int values_A[] = { -5, 42, 36, 24, }; + int values_B[] = { 200, 300, 400, }; + struct cds_wfcq_head head_A; /* Queue A head */ + struct cds_wfcq_tail tail_A; /* Queue A tail */ + struct cds_wfcq_head head_B; /* Queue B head */ + struct cds_wfcq_tail tail_B; /* Queue B tail */ + int ret = 0; + + cds_wfcq_init(&head_A, &tail_A); + /* Enqueue nodes into A. */ + ret = enqueue_values(&head_A, &tail_A, values_A, + CAA_ARRAY_SIZE(values_A)); + if (ret) + goto end; + cds_wfcq_init(&head_B, &tail_B); + /* Enqueue nodes into B. */ + ret = enqueue_values(&head_B, &tail_B, values_B, + CAA_ARRAY_SIZE(values_B)); + if (ret) + goto end; + + print_queue(&head_A, &tail_A, "queue A content before splice"); + print_queue(&head_B, &tail_B, "queue B content before splice"); + + /* + * Splice nodes from A into B. + */ + printf("Splicing queue A into queue B\n"); + (void) cds_wfcq_splice_blocking(&head_B, &tail_B, + &head_A, &tail_A); + + print_queue(&head_A, &tail_A, "queue A content after splice"); + print_queue(&head_B, &tail_B, "queue B content after splice"); +end: + cds_wfcq_destroy(&head_A, &tail_A); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/Makefile b/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/Makefile new file mode 100644 index 0000000000000..a0be0dabc6a6e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/Makefile @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +all: + $(AM_V_at)$(MAKE) -f Makefile.cds_wfs_push + $(AM_V_at)$(MAKE) -f Makefile.cds_wfs_pop + $(AM_V_at)$(MAKE) -f Makefile.cds_wfs_pop_all_blocking + +.PHONY: clean +clean: + $(AM_V_at)$(MAKE) -f Makefile.cds_wfs_push clean + $(AM_V_at)$(MAKE) -f Makefile.cds_wfs_pop clean + $(AM_V_at)$(MAKE) -f Makefile.cds_wfs_pop_all_blocking clean diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/Makefile.cds_wfs_pop b/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/Makefile.cds_wfs_pop new file mode 100644 index 0000000000000..69e91ff11aa56 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/Makefile.cds_wfs_pop @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_wfs_pop + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-common + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/Makefile.cds_wfs_pop_all_blocking b/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/Makefile.cds_wfs_pop_all_blocking new file mode 100644 index 0000000000000..164c89bb629f0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/Makefile.cds_wfs_pop_all_blocking @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_wfs_pop_all_blocking + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-common + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/Makefile.cds_wfs_push b/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/Makefile.cds_wfs_push new file mode 100644 index 0000000000000..e29a35f37e7bc --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/Makefile.cds_wfs_push @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +# +# SPDX-License-Identifier: MIT + +# This makefile is purposefully kept simple to support GNU and BSD make. + +EXAMPLE_NAME = cds_wfs_push + +SOURCES = $(EXAMPLE_NAME).c +OBJECTS = $(EXAMPLE_NAME).o +BINARY = $(EXAMPLE_NAME) +LIBS = -lurcu-common + +include ../Makefile.examples.template diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/cds_wfs_pop.c b/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/cds_wfs_pop.c new file mode 100644 index 0000000000000..93809ef4b7aa4 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/cds_wfs_pop.c @@ -0,0 +1,69 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to pop nodes from a wfstack. + */ + +#include +#include + +#include /* Wait-free stack */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the stack. + */ +struct mynode { + int value; /* Node content */ + struct cds_wfs_node node; /* Chaining in stack */ +}; + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + struct cds_wfs_stack mystack; /* Stack */ + unsigned int i; + int ret = 0; + + cds_wfs_init(&mystack); + + /* + * Push nodes. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + struct mynode *node; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + + cds_wfs_node_init(&node->node); + node->value = values[i]; + cds_wfs_push(&mystack, &node->node); + } + + /* + * Pop nodes from the stack, one by one, from newest to oldest. + */ + printf("pop each mystack node:"); + for (;;) { + struct cds_wfs_node *snode; + struct mynode *node; + + snode = cds_wfs_pop_blocking(&mystack); + if (!snode) { + break; + } + node = caa_container_of(snode, struct mynode, node); + printf(" %d", node->value); + free(node); + } + printf("\n"); +end: + cds_wfs_destroy(&mystack); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/cds_wfs_pop_all_blocking.c b/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/cds_wfs_pop_all_blocking.c new file mode 100644 index 0000000000000..a9cc4ca01cabe --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/cds_wfs_pop_all_blocking.c @@ -0,0 +1,73 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to pop all nodes from a wfstack. + */ + +#include +#include + +#include /* Wait-free stack */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the stack. + */ +struct mynode { + int value; /* Node content */ + struct cds_wfs_node node; /* Chaining in stack */ +}; + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + struct cds_wfs_stack mystack; /* Stack */ + unsigned int i; + int ret = 0; + struct cds_wfs_node *snode, *sn; + struct cds_wfs_head *shead; + + cds_wfs_init(&mystack); + + /* + * Push nodes. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + struct mynode *node; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + + cds_wfs_node_init(&node->node); + node->value = values[i]; + cds_wfs_push(&mystack, &node->node); + } + + /* + * Pop all nodes from mystack into shead. The head can the be + * used for iteration. + */ + shead = cds_wfs_pop_all_blocking(&mystack); + + /* + * Show the stack content, iterate in reverse order of push, + * from newest to oldest. Use cds_wfs_for_each_blocking_safe() + * so we can free the nodes as we iterate. + */ + printf("mystack content:"); + cds_wfs_for_each_blocking_safe(shead, snode, sn) { + struct mynode *node = + caa_container_of(snode, struct mynode, node); + printf(" %d", node->value); + free(node); + } + printf("\n"); +end: + cds_wfs_destroy(&mystack); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/cds_wfs_push.c b/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/cds_wfs_push.c new file mode 100644 index 0000000000000..69eb6ca09844e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/examples/wfstack/cds_wfs_push.c @@ -0,0 +1,66 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +/* + * This example shows how to push nodes into a wfstack. + */ + +#include +#include + +#include /* Wait-free stack */ +#include /* For CAA_ARRAY_SIZE */ + +/* + * Nodes populated into the stack. + */ +struct mynode { + int value; /* Node content */ + struct cds_wfs_node node; /* Chaining in stack */ +}; + +int main(void) +{ + int values[] = { -5, 42, 36, 24, }; + struct cds_wfs_stack mystack; /* Stack */ + unsigned int i; + int ret = 0; + struct cds_wfs_node *snode; + struct cds_wfs_head *shead; + + cds_wfs_init(&mystack); + + /* + * Push nodes. + */ + for (i = 0; i < CAA_ARRAY_SIZE(values); i++) { + struct mynode *node; + + node = malloc(sizeof(*node)); + if (!node) { + ret = -1; + goto end; + } + + cds_wfs_node_init(&node->node); + node->value = values[i]; + cds_wfs_push(&mystack, &node->node); + } + + /* + * Show the stack content, iterate in reverse order of push, + * from newest to oldest. + */ + printf("mystack content:"); + shead = cds_wfs_pop_all_blocking(&mystack); + cds_wfs_for_each_blocking(shead, snode) { + struct mynode *node = + caa_container_of(snode, struct mynode, node); + printf(" %d", node->value); + } + printf("\n"); +end: + cds_wfs_destroy(&mystack); + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/doc/rcu-api.md b/external/lgpl2/userspace-rcu/dist/doc/rcu-api.md new file mode 100644 index 0000000000000..b305fcfa5bf4c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/rcu-api.md @@ -0,0 +1,273 @@ + + +Userspace RCU API +================= + +by Mathieu Desnoyers and Paul E. McKenney + + +API +--- + +```c +void rcu_init(void); +``` + +This must be called before any of the following functions +are invoked. + + +```c +void rcu_read_lock(void); +``` + +Begin an RCU read-side critical section. These critical +sections may be nested. + + +```c +void rcu_read_unlock(void); +``` + +End an RCU read-side critical section. + + +```c +void rcu_register_thread(void); +``` + +Each thread must invoke this function before its first call to +`rcu_read_lock()`. Threads that never call `rcu_read_lock()` need +not invoke this function. In addition, `rcu-bp` ("bullet proof" +RCU) does not require any thread to invoke `rcu_register_thread()`. + + +```c +void rcu_unregister_thread(void); +``` + +Each thread that invokes `rcu_register_thread()` must invoke +`rcu_unregister_thread()` before `invoking pthread_exit()` +or before returning from its top-level function. + + +```c +void synchronize_rcu(void); +``` + +Wait until every pre-existing RCU read-side critical section +has completed. Note that this primitive will not necessarily +wait for RCU read-side critical sections that have not yet +started: this is not a reader-writer lock. The duration +actually waited is called an RCU grace period. + + +```c +struct urcu_gp_poll_state start_poll_synchronize_rcu(void); +``` + +Provides a handle for checking if a new grace period has started +and completed since the handle was obtained. It returns a +`struct urcu_gp_poll_state` handle that can be used with +`poll_state_synchronize_rcu` to check, by polling, if the +associated grace period has completed. + +`start_poll_synchronize_rcu` must only be called from +registered RCU read-side threads. For the QSBR flavor, the +caller must be online. + + +```c +bool poll_state_synchronize_rcu(struct urcu_gp_poll_state state); +``` + +Checks if the grace period associated with the +`struct urcu_gp_poll_state` handle has completed. If the grace +period has completed, the function returns true. Otherwise, +it returns false. + + +```c +void call_rcu(struct rcu_head *head, + void (*func)(struct rcu_head *head)); +``` + +Registers the callback indicated by "head". This means +that `func` will be invoked after the end of a future +RCU grace period. The `rcu_head` structure referenced +by `head` will normally be a field in a larger RCU-protected +structure. A typical implementation of `func` is as +follows: + +```c +void func(struct rcu_head *head) +{ + struct foo *p = container_of(head, struct foo, rcu); + + free(p); +} +``` + +This RCU callback function can be registered as follows +given a pointer `p` to the enclosing structure: + +```c +call_rcu(&p->rcu, func); +``` + +`call_rcu` should be called from registered RCU read-side threads. +For the QSBR flavor, the caller should be online. + + +```c +void rcu_barrier(void); +``` + +Wait for all `call_rcu()` work initiated prior to `rcu_barrier()` by +_any_ thread on the system to have completed before `rcu_barrier()` +returns. `rcu_barrier()` should never be called from a `call_rcu()` +thread. This function can be used, for instance, to ensure that +all memory reclaim involving a shared object has completed +before allowing `dlclose()` of this shared object to complete. + + +```c +struct call_rcu_data *create_call_rcu_data(unsigned long flags, + int cpu_affinity); +``` + +Returns a handle that can be passed to the following +primitives. The `flags` argument can be zero, or can be +`URCU_CALL_RCU_RT` if the worker threads associated with the +new helper thread are to get real-time response. The argument +`cpu_affinity` specifies a CPU on which the `call_rcu` thread should +be affined to. It is ignored if negative. + + +```c +void call_rcu_data_free(struct call_rcu_data *crdp); +``` + +Terminates a `call_rcu()` helper thread and frees its associated +data. The caller must have ensured that this thread is no longer +in use, for example, by passing `NULL` to `set_thread_call_rcu_data()` +and `set_cpu_call_rcu_data()` as required. + + +```c +struct call_rcu_data *get_default_call_rcu_data(void); +``` + +Returns the handle for the default `call_rcu()` helper thread. +Creates it if necessary. + + +```c +struct call_rcu_data *get_cpu_call_rcu_data(int cpu); +``` + +Returns the handle for the current CPU's `call_rcu()` helper +thread, or `NULL` if the current CPU has no helper thread +currently assigned. The call to this function and use of the +returned `call_rcu_data` should be protected by RCU read-side +lock. + + +```c +struct call_rcu_data *get_thread_call_rcu_data(void); +``` + +Returns the handle for the current thread's hard-assigned +`call_rcu()` helper thread, or `NULL` if the current thread is +instead using a per-CPU or the default helper thread. + + +```c +struct call_rcu_data *get_call_rcu_data(void); +``` + +Returns the handle for the current thread's `call_rcu()` helper +thread, which is either, in increasing order of preference: +per-thread hard-assigned helper thread, per-CPU helper thread, +or default helper thread. `get_call_rcu_data` should be called +from registered RCU read-side threads. For the QSBR flavor, the +caller should be online. + + +```c +pthread_t get_call_rcu_thread(struct call_rcu_data *crdp); +``` + +Returns the helper thread's pthread identifier linked to a call +rcu helper thread data. + + +```c +void set_thread_call_rcu_data(struct call_rcu_data *crdp); +``` + +Sets the current thread's hard-assigned `call_rcu()` helper to the +handle specified by `crdp`. Note that `crdp` can be `NULL` to +disassociate this thread from its helper. Once a thread is +disassociated from its helper, further `call_rcu()` invocations +use the current CPU's helper if there is one and the default +helper otherwise. + + +```c +int set_cpu_call_rcu_data(int cpu, struct call_rcu_data *crdp); +``` + +Sets the specified CPU's `call_rcu()` helper to the handle +specified by `crdp`. Again, `crdp` can be `NULL` to disassociate +this CPU from its helper thread. Once a CPU has been +disassociated from its helper, further `call_rcu()` invocations +that would otherwise have used this CPU's helper will instead +use the default helper. + +The caller must wait for a grace-period to pass between return from +`set_cpu_call_rcu_data()` and call to `call_rcu_data_free()` passing the +previous call rcu data as argument. + + +```c +int create_all_cpu_call_rcu_data(unsigned long flags); +``` + +Creates a separate `call_rcu()` helper thread for each CPU. +After this primitive is invoked, the global default `call_rcu()` +helper thread will not be called. + +The `set_thread_call_rcu_data()`, `set_cpu_call_rcu_data()`, and +`create_all_cpu_call_rcu_data()` functions may be combined to set up +pretty much any desired association between worker and `call_rcu()` +helper threads. If a given executable calls only `call_rcu()`, +then that executable will have only the single global default +`call_rcu()` helper thread. This will suffice in most cases. + + +```c +void free_all_cpu_call_rcu_data(void); +``` + +Clean up all the per-CPU `call_rcu` threads. Should be paired with +`create_all_cpu_call_rcu_data()` to perform teardown. Note that +this function invokes `synchronize_rcu()` internally, so the +caller should be careful not to hold mutexes (or mutexes within a +dependency chain) that are also taken within a RCU read-side +critical section, or in a section where QSBR threads are online. + + +```c +void call_rcu_before_fork_parent(void); +void call_rcu_after_fork_parent(void); +void call_rcu_after_fork_child(void); +``` + +Should be used as `pthread_atfork()` handler for programs using +`call_rcu` and performing `fork()` or `clone()` without a following +`exec()`. diff --git a/external/lgpl2/userspace-rcu/dist/doc/solaris-build.md b/external/lgpl2/userspace-rcu/dist/doc/solaris-build.md new file mode 100644 index 0000000000000..1a0c68c42cad5 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/solaris-build.md @@ -0,0 +1,75 @@ + + +# Solaris support +## Solaris 10 +### Dependencies +On Solaris 10, the OpenCSW open source software distribution is required for build and runtime dependencies. The following base packages are required : + +* SUNWtoo +* SUNWbtool +* SUNWhea +* SUNWarc +* SUNWarcr +* SUNWlibmr +* SUNWlibm + +And the following OpenCSW packages are required : +* automake +* autoconf +* libtool +* bison +* flex +* gsed +* gmake +* pkgconfig +* libglib2\_dev +* gcc4core + +### Build + +Add CSW and CCS to PATH : +``` +export PATH="/opt/csw/bin:/usr/ccs/bin:$PATH" +``` + +Build with gmake : +``` +./bootstrap +CFLAGS="-D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__=1" MAKE=gmake ./configure +gmake +gmake check +gmake regtest +gmake install +``` + +## Solaris 11 +### Dependencies +On Solaris 11, the following base packages are required : +* autoconf +* automake +* gnu-make +* libtool +* gcc +* flex +* bison + +### Build +Add Perl5 to PATH : +``` +export PATH="$PATH:/usr/perl5/bin" +``` + +Build with gmake : +``` +./bootstrap +CFLAGS="-D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__=1" MAKE=gmake ./configure --prefix=$PREFIX +gmake +gmake check +gmake regtest +gmake install +``` + diff --git a/external/lgpl2/userspace-rcu/dist/doc/uatomic-api.md b/external/lgpl2/userspace-rcu/dist/doc/uatomic-api.md new file mode 100644 index 0000000000000..642170857a1e2 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/doc/uatomic-api.md @@ -0,0 +1,131 @@ + + +Userspace RCU Atomic Operations API +=================================== + +by Mathieu Desnoyers and Paul E. McKenney + +This document describes the `` API. Those are the atomic +operations provided by the Userspace RCU library. The general rule +regarding memory barriers is that only `uatomic_xchg()`, +`uatomic_cmpxchg()`, `uatomic_add_return()`, and `uatomic_sub_return()` imply +full memory barriers before and after the atomic operation. Other +primitives don't guarantee any memory barrier. + +Only atomic operations performed on integers (`int` and `long`, signed +and unsigned) are supported on all architectures. Some architectures +also support 1-byte and 2-byte atomic operations. Those respectively +have `UATOMIC_HAS_ATOMIC_BYTE` and `UATOMIC_HAS_ATOMIC_SHORT` defined when +`uatomic.h` is included. An architecture trying to perform an atomic write +to a type size not supported by the architecture will trigger an illegal +instruction. + +In the description below, `type` is a type that can be atomically +written to by the architecture. It needs to be at most word-sized, and +its alignment needs to greater or equal to its size. + + +API +--- + +```c +void uatomic_set(type *addr, type v); +``` + +Atomically write `v` into `addr`. By "atomically", we mean that no +concurrent operation that reads from addr will see partial +effects of `uatomic_set()`. + + +```c +type uatomic_read(type *addr); +``` + +Atomically read `v` from `addr`. By "atomically", we mean that +`uatomic_read()` cannot see a partial effect of any concurrent +uatomic update. + + +```c +type uatomic_cmpxchg(type *addr, type old, type new); +``` + +An atomic read-modify-write operation that performs this +sequence of operations atomically: check if `addr` contains `old`. +If true, then replace the content of `addr` by `new`. Return the +value previously contained by `addr`. This function implies a full +memory barrier before and after the atomic operation on success. +On failure, no memory order is guaranteed. + + +```c +type uatomic_xchg(type *addr, type new); +``` + +An atomic read-modify-write operation that performs this sequence +of operations atomically: replace the content of `addr` by `new`, +and return the value previously contained by `addr`. This +function implies a full memory barrier before and after the atomic +operation. + + +```c +type uatomic_add_return(type *addr, type v); +type uatomic_sub_return(type *addr, type v); +``` + +An atomic read-modify-write operation that performs this +sequence of operations atomically: increment/decrement the +content of `addr` by `v`, and return the resulting value. This +function implies a full memory barrier before and after the atomic +operation. + + +```c +void uatomic_and(type *addr, type mask); +void uatomic_or(type *addr, type mask); +``` + +Atomically write the result of bitwise "and"/"or" between the +content of `addr` and `mask` into `addr`. + +These operations do not necessarily imply memory barriers. +If memory barriers are needed, they may be provided by explicitly using +`cmm_smp_mb__before_uatomic_and()`, `cmm_smp_mb__after_uatomic_and()`, +`cmm_smp_mb__before_uatomic_or()`, and `cmm_smp_mb__after_uatomic_or()`. +These explicit barriers are no-ops on architectures in which the underlying +atomic instructions implicitly supply the needed memory barriers. + + +```c +void uatomic_add(type *addr, type v); +void uatomic_sub(type *addr, type v); +``` + +Atomically increment/decrement the content of `addr` by `v`. +These operations do not necessarily imply memory barriers. +If memory barriers are needed, they may be provided by +explicitly using `cmm_smp_mb__before_uatomic_add()`, +`cmm_smp_mb__after_uatomic_add()`, `cmm_smp_mb__before_uatomic_sub()`, and +`cmm_smp_mb__after_uatomic_sub()`. These explicit barriers are +no-ops on architectures in which the underlying atomic +instructions implicitly supply the needed memory barriers. + + +```c +void uatomic_inc(type *addr); +void uatomic_dec(type *addr); +``` + +Atomically increment/decrement the content of `addr` by 1. +These operations do not necessarily imply memory barriers. +If memory barriers are needed, they may be provided by +explicitly using `cmm_smp_mb__before_uatomic_inc()`, +`cmm_smp_mb__after_uatomic_inc()`, `cmm_smp_mb__before_uatomic_dec()`, +and `cmm_smp_mb__after_uatomic_dec()`. These explicit barriers are +no-ops on architectures in which the underlying atomic +instructions implicitly supply the needed memory barriers. diff --git a/external/lgpl2/userspace-rcu/dist/extras/Makefile.am b/external/lgpl2/userspace-rcu/dist/extras/Makefile.am new file mode 100644 index 0000000000000..514c889c1ee6a --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/Makefile.am @@ -0,0 +1,6 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +# Directories added to EXTRA_DIST will be recursively copied to the distribution. +EXTRA_DIST = $(srcdir)/abi diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-bp.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-bp.so.6.xml new file mode 100644 index 0000000000000..044f276b8c670 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-bp.so.6.xml @@ -0,0 +1,900 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-cds.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-cds.so.6.xml new file mode 100644 index 0000000000000..bcdb9db37b40c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-cds.so.6.xml @@ -0,0 +1,1493 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-common.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-common.so.6.xml new file mode 100644 index 0000000000000..e7aef91deb94b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-common.so.6.xml @@ -0,0 +1,910 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-mb.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-mb.so.6.xml new file mode 100644 index 0000000000000..3ce07d1e8a877 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-mb.so.6.xml @@ -0,0 +1,851 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-qsbr.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-qsbr.so.6.xml new file mode 100644 index 0000000000000..c1ee1962308de --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-qsbr.so.6.xml @@ -0,0 +1,872 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-signal.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-signal.so.6.xml new file mode 100644 index 0000000000000..4f9ffcc59e67a --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu-signal.so.6.xml @@ -0,0 +1,858 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu.so.6.xml new file mode 100644 index 0000000000000..566ccbf293756 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.10/x86_64-pc-linux-gnu/liburcu.so.6.xml @@ -0,0 +1,855 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-bp.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-bp.so.6.xml new file mode 100644 index 0000000000000..312bc93f99acb --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-bp.so.6.xml @@ -0,0 +1,978 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-cds.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-cds.so.6.xml new file mode 100644 index 0000000000000..a085bee96f285 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-cds.so.6.xml @@ -0,0 +1,1480 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-common.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-common.so.6.xml new file mode 100644 index 0000000000000..e7aef91deb94b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-common.so.6.xml @@ -0,0 +1,910 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-mb.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-mb.so.6.xml new file mode 100644 index 0000000000000..400eb0b8ace07 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-mb.so.6.xml @@ -0,0 +1,919 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-memb.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-memb.so.6.xml new file mode 100644 index 0000000000000..e22c57827b7a0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-memb.so.6.xml @@ -0,0 +1,925 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-qsbr.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-qsbr.so.6.xml new file mode 100644 index 0000000000000..f0b9ce60b0beb --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-qsbr.so.6.xml @@ -0,0 +1,946 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-signal.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-signal.so.6.xml new file mode 100644 index 0000000000000..feaa997d5a01f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu-signal.so.6.xml @@ -0,0 +1,928 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu.so.6.xml new file mode 100644 index 0000000000000..3d42cd2877056 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.11/x86_64-pc-linux-gnu/liburcu.so.6.xml @@ -0,0 +1,925 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-bp.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-bp.so.6.xml new file mode 100644 index 0000000000000..df3f029971ae0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-bp.so.6.xml @@ -0,0 +1,985 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-cds.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-cds.so.6.xml new file mode 100644 index 0000000000000..ccfe923f92373 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-cds.so.6.xml @@ -0,0 +1,1484 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-common.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-common.so.6.xml new file mode 100644 index 0000000000000..e7aef91deb94b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-common.so.6.xml @@ -0,0 +1,910 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-mb.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-mb.so.6.xml new file mode 100644 index 0000000000000..400eb0b8ace07 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-mb.so.6.xml @@ -0,0 +1,919 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-memb.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-memb.so.6.xml new file mode 100644 index 0000000000000..e22c57827b7a0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-memb.so.6.xml @@ -0,0 +1,925 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-qsbr.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-qsbr.so.6.xml new file mode 100644 index 0000000000000..f0b9ce60b0beb --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-qsbr.so.6.xml @@ -0,0 +1,946 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-signal.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-signal.so.6.xml new file mode 100644 index 0000000000000..feaa997d5a01f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu-signal.so.6.xml @@ -0,0 +1,928 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu.so.6.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu.so.6.xml new file mode 100644 index 0000000000000..3d42cd2877056 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.12/x86_64-pc-linux-gnu/liburcu.so.6.xml @@ -0,0 +1,925 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-bp.so.8.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-bp.so.8.xml new file mode 100644 index 0000000000000..7bc53cb78b4c0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-bp.so.8.xml @@ -0,0 +1,907 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-cds.so.8.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-cds.so.8.xml new file mode 100644 index 0000000000000..ae03526048b25 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-cds.so.8.xml @@ -0,0 +1,1484 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-common.so.8.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-common.so.8.xml new file mode 100644 index 0000000000000..33bf1df100b3d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-common.so.8.xml @@ -0,0 +1,910 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-mb.so.8.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-mb.so.8.xml new file mode 100644 index 0000000000000..5ad4e9d9d2e62 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-mb.so.8.xml @@ -0,0 +1,851 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-memb.so.8.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-memb.so.8.xml new file mode 100644 index 0000000000000..ba5db9b1ac841 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-memb.so.8.xml @@ -0,0 +1,855 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-qsbr.so.8.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-qsbr.so.8.xml new file mode 100644 index 0000000000000..0e350cc89f9ad --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-qsbr.so.8.xml @@ -0,0 +1,872 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-signal.so.8.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-signal.so.8.xml new file mode 100644 index 0000000000000..2aea31056a7bc --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-signal.so.8.xml @@ -0,0 +1,858 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu.so.8.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu.so.8.xml new file mode 100644 index 0000000000000..709f7843f830e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.13/x86_64-pc-linux-gnu/liburcu.so.8.xml @@ -0,0 +1,855 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-bp.so.8.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-bp.so.8.xml new file mode 100644 index 0000000000000..2bd8607d14ad8 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-bp.so.8.xml @@ -0,0 +1,907 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-cds.so.8.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-cds.so.8.xml new file mode 100644 index 0000000000000..b0cb83cbe558d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-cds.so.8.xml @@ -0,0 +1,1493 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-common.so.8.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-common.so.8.xml new file mode 100644 index 0000000000000..95bd3636a07a6 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-common.so.8.xml @@ -0,0 +1,910 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-mb.so.8.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-mb.so.8.xml new file mode 100644 index 0000000000000..d8e736d5213c8 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-mb.so.8.xml @@ -0,0 +1,851 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-memb.so.8.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-memb.so.8.xml new file mode 100644 index 0000000000000..7df5cada985bf --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-memb.so.8.xml @@ -0,0 +1,855 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-qsbr.so.8.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-qsbr.so.8.xml new file mode 100644 index 0000000000000..848eb7a7bb2e7 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-qsbr.so.8.xml @@ -0,0 +1,872 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-signal.so.8.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-signal.so.8.xml new file mode 100644 index 0000000000000..032143234183b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu-signal.so.8.xml @@ -0,0 +1,858 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu.so.8.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu.so.8.xml new file mode 100644 index 0000000000000..e9bfeaad3bd78 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.14/x86_64-pc-linux-gnu/liburcu.so.8.xml @@ -0,0 +1,855 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-bp.so.4.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-bp.so.4.xml new file mode 100644 index 0000000000000..0ee16cbaa6a83 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-bp.so.4.xml @@ -0,0 +1,841 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-cds.so.4.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-cds.so.4.xml new file mode 100644 index 0000000000000..58a6a9b9e8914 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-cds.so.4.xml @@ -0,0 +1,1187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-common.so.4.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-common.so.4.xml new file mode 100644 index 0000000000000..73fe288430f70 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-common.so.4.xml @@ -0,0 +1,906 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-mb.so.4.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-mb.so.4.xml new file mode 100644 index 0000000000000..e09bed297dcf0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-mb.so.4.xml @@ -0,0 +1,792 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-qsbr.so.4.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-qsbr.so.4.xml new file mode 100644 index 0000000000000..ad6c8ec65ad33 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-qsbr.so.4.xml @@ -0,0 +1,813 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-signal.so.4.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-signal.so.4.xml new file mode 100644 index 0000000000000..f61bc436adaa8 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu-signal.so.4.xml @@ -0,0 +1,799 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu.so.4.xml b/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu.so.4.xml new file mode 100644 index 0000000000000..612689bb3d98e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/0.9/x86_64-pc-linux-gnu/liburcu.so.4.xml @@ -0,0 +1,796 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/README.md b/external/lgpl2/userspace-rcu/dist/extras/abi/README.md new file mode 100644 index 0000000000000..a7242a22c788c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/README.md @@ -0,0 +1,24 @@ + + +# Userspace-RCU ABI definitions + +This directory contains the serialized ABI definitions for a typical build of +the liburcu libraries. This information is extracted using +[libabigail](https://sourceware.org/libabigail/). + +The artefacts used to generate these were built with **CFLAGS="-O0 -ggdb"** on +an Ubuntu 18.04 x86_64 system. + +You can compare the serialized ABI with a shared object to check for breaking +changes. For example, here we compare an in-tree built version of +**liburcu-memb.so** with the serialized ABI of stable-0.13 : + +```` +abidiff \ + extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-memb.so.8.xml \ + src/.libs/liburcu-memb.so +```` diff --git a/external/lgpl2/userspace-rcu/dist/extras/abi/dump_abi.sh b/external/lgpl2/userspace-rcu/dist/extras/abi/dump_abi.sh new file mode 100755 index 0000000000000..673b8391e1644 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/extras/abi/dump_abi.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: 2021 Michael Jeanson +# +# SPDX-License-Identifier: GPL-2.0-only + +set -eu + +INDIR=$1 +OUTDIR=$2 + +ARGS=( + "--annotate" # Add comments to the xml output + "--no-corpus-path" # Do not put the path in the abi-corpus +) + +# Older version of the reuse tool are a bit dumb, split the tags string to make +# it happy. +spdx="SPDX" +copyright="FileCopyrightText" +license="License-Identifier" + +for lib in "${INDIR}"/liburcu*.so.? +do + abidw "${ARGS[@]}" --out-file "${OUTDIR}/$(basename "$lib").xml" "$lib" + + # Clean the full paths + sed -i "s#$(pwd)/##g" "${OUTDIR}/$(basename "$lib").xml" + + # Add SPDX headers + sed -i "2 i " "${OUTDIR}/$(basename "$lib").xml" +done + diff --git a/external/lgpl2/userspace-rcu/dist/include/Makefile.am b/external/lgpl2/userspace-rcu/dist/include/Makefile.am new file mode 100644 index 0000000000000..9bc93b45adf7f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/Makefile.am @@ -0,0 +1,110 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +nobase_include_HEADERS = \ + urcu/annotate.h \ + urcu/arch/aarch64.h \ + urcu/arch/alpha.h \ + urcu/arch/arm.h \ + urcu/arch/gcc.h \ + urcu/arch/generic.h \ + urcu/arch.h \ + urcu/arch/hppa.h \ + urcu/arch/ia64.h \ + urcu/arch/loongarch.h \ + urcu/arch/m68k.h \ + urcu/arch/mips.h \ + urcu/arch/nios2.h \ + urcu/arch/ppc.h \ + urcu/arch/riscv.h \ + urcu/arch/s390.h \ + urcu/arch/sparc64.h \ + urcu/arch/tile.h \ + urcu/arch/x86.h \ + urcu/assert.h \ + urcu/call-rcu.h \ + urcu/cds.h \ + urcu/compiler.h \ + urcu/debug.h \ + urcu/defer.h \ + urcu/flavor.h \ + urcu/futex.h \ + urcu/hlist.h \ + urcu/lfstack.h \ + urcu/list.h \ + urcu/map/clear.h \ + urcu/map/urcu-bp.h \ + urcu/map/urcu.h \ + urcu/map/urcu-mb.h \ + urcu/map/urcu-memb.h \ + urcu/map/urcu-qsbr.h \ + urcu/pointer.h \ + urcu/rcuhlist.h \ + urcu/rculfhash.h \ + urcu/rculfqueue.h \ + urcu/rculfstack.h \ + urcu/rculist.h \ + urcu/ref.h \ + urcu/static/lfstack.h \ + urcu/static/pointer.h \ + urcu/static/rculfqueue.h \ + urcu/static/rculfstack.h \ + urcu/static/urcu-bp.h \ + urcu/static/urcu-common.h \ + urcu/static/urcu.h \ + urcu/static/urcu-mb.h \ + urcu/static/urcu-memb.h \ + urcu/static/urcu-qsbr.h \ + urcu/static/wfcqueue.h \ + urcu/static/wfqueue.h \ + urcu/static/wfstack.h \ + urcu/syscall-compat.h \ + urcu/system.h \ + urcu/tls-compat.h \ + urcu/uatomic/aarch64.h \ + urcu/uatomic/alpha.h \ + urcu/uatomic/api.h \ + urcu/uatomic_arch.h \ + urcu/uatomic/arm.h \ + urcu/uatomic/builtins.h \ + urcu/uatomic/builtins-generic.h \ + urcu/uatomic/gcc.h \ + urcu/uatomic/generic.h \ + urcu/uatomic.h \ + urcu/uatomic/hppa.h \ + urcu/uatomic/ia64.h \ + urcu/uatomic/loongarch.h \ + urcu/uatomic/m68k.h \ + urcu/uatomic/mips.h \ + urcu/uatomic/nios2.h \ + urcu/uatomic/ppc.h \ + urcu/uatomic/riscv.h \ + urcu/uatomic/s390.h \ + urcu/uatomic/sparc64.h \ + urcu/uatomic/tile.h \ + urcu/uatomic/x86.h \ + urcu/urcu-bp.h \ + urcu/urcu-futex.h \ + urcu/urcu.h \ + urcu/urcu-mb.h \ + urcu/urcu-memb.h \ + urcu/urcu-qsbr.h \ + urcu/urcu_ref.h \ + urcu/wfcqueue.h \ + urcu/wfqueue.h \ + urcu/wfstack.h \ + urcu/urcu-poll.h + +# Don't distribute generated headers +nobase_nodist_include_HEADERS = urcu/config.h + +# Non 'urcu/' prefixed compat headers +include_HEADERS = \ + urcu-qsbr.h \ + urcu-bp.h \ + urcu-call-rcu.h \ + urcu-defer.h \ + urcu-flavor.h \ + urcu.h \ + urcu-pointer.h diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu-bp.h b/external/lgpl2/userspace-rcu/dist/include/urcu-bp.h new file mode 100644 index 0000000000000..5f17e12652f2b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu-bp.h @@ -0,0 +1,6 @@ +// SPDX-FileCopyrightText: 2018 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#define URCU_API_MAP +#include diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu-call-rcu.h b/external/lgpl2/userspace-rcu/dist/include/urcu-call-rcu.h new file mode 100644 index 0000000000000..2d994e5d3ba5b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu-call-rcu.h @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2018 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#include diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu-defer.h b/external/lgpl2/userspace-rcu/dist/include/urcu-defer.h new file mode 100644 index 0000000000000..cd6bd9b54c32c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu-defer.h @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2018 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#include diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu-flavor.h b/external/lgpl2/userspace-rcu/dist/include/urcu-flavor.h new file mode 100644 index 0000000000000..dbd70eb18cd3e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu-flavor.h @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2018 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#include diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu-pointer.h b/external/lgpl2/userspace-rcu/dist/include/urcu-pointer.h new file mode 100644 index 0000000000000..2e61c4d1cc05a --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu-pointer.h @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2018 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#include diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu-qsbr.h b/external/lgpl2/userspace-rcu/dist/include/urcu-qsbr.h new file mode 100644 index 0000000000000..1a0d0a1f47fb1 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu-qsbr.h @@ -0,0 +1,6 @@ +// SPDX-FileCopyrightText: 2018 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#define URCU_API_MAP +#include diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu.h b/external/lgpl2/userspace-rcu/dist/include/urcu.h new file mode 100644 index 0000000000000..0bd5f23f78795 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu.h @@ -0,0 +1,6 @@ +// SPDX-FileCopyrightText: 2018 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#define URCU_API_MAP +#include diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/annotate.h b/external/lgpl2/userspace-rcu/dist/include/urcu/annotate.h new file mode 100644 index 0000000000000..f0955a0cbf7aa --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/annotate.h @@ -0,0 +1,163 @@ +// SPDX-FileCopyrightText: 2023 Olivier Dion +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ANNOTATE_H +#define _URCU_ANNOTATE_H + +/* + * urcu/annotate.h + * + * Userspace RCU - annotation header. + */ + +/* + * WARNING! + * + * This API is highly experimental. There is zero guarantees of stability + * between releases. + * + * You have been warned. + */ + +#include +#include + +#include + +enum cmm_annotate { + CMM_ANNOTATE_VOID, + CMM_ANNOTATE_LOAD, + CMM_ANNOTATE_STORE, + CMM_ANNOTATE_MB, +}; + +typedef enum cmm_annotate cmm_annotate_t __attribute__((unused)); + +#define cmm_annotate_define(name) \ + cmm_annotate_t name = CMM_ANNOTATE_VOID + +#ifdef CMM_SANITIZE_THREAD + +# ifdef __cplusplus +extern "C" { +# endif +extern void __tsan_acquire(void *); +extern void __tsan_release(void *); +# ifdef __cplusplus +} +# endif + +# define cmm_annotate_die(msg) \ + do { \ + fprintf(stderr, \ + "(" __FILE__ ":%s@%u) Annotation ERROR: %s\n", \ + __func__, __LINE__, msg); \ + abort(); \ + } while (0) + +/* Only used for typechecking in macros. */ +static inline cmm_annotate_t cmm_annotate_dereference(cmm_annotate_t *group) +{ + return *group; +} + +# define cmm_annotate_group_mb_acquire(group) \ + do { \ + switch (cmm_annotate_dereference(group)) { \ + case CMM_ANNOTATE_VOID: \ + break; \ + case CMM_ANNOTATE_LOAD: \ + break; \ + case CMM_ANNOTATE_STORE: \ + cmm_annotate_die("store for acquire group"); \ + break; \ + case CMM_ANNOTATE_MB: \ + cmm_annotate_die( \ + "redundant mb for acquire group" \ + ); \ + break; \ + } \ + *(group) = CMM_ANNOTATE_MB; \ + } while (0) + +# define cmm_annotate_group_mb_release(group) \ + do { \ + switch (cmm_annotate_dereference(group)) { \ + case CMM_ANNOTATE_VOID: \ + break; \ + case CMM_ANNOTATE_LOAD: \ + cmm_annotate_die("load before release group"); \ + break; \ + case CMM_ANNOTATE_STORE: \ + cmm_annotate_die( \ + "store before release group" \ + ); \ + break; \ + case CMM_ANNOTATE_MB: \ + cmm_annotate_die( \ + "redundant mb of release group" \ + ); \ + break; \ + } \ + *(group) = CMM_ANNOTATE_MB; \ + } while (0) + +# define cmm_annotate_group_mem_acquire(group, mem) \ + do { \ + __tsan_acquire((void*)(mem)); \ + switch (cmm_annotate_dereference(group)) { \ + case CMM_ANNOTATE_VOID: \ + *(group) = CMM_ANNOTATE_LOAD; \ + break; \ + case CMM_ANNOTATE_MB: \ + cmm_annotate_die( \ + "load after mb for acquire group" \ + ); \ + break; \ + default: \ + break; \ + } \ + } while (0) + +# define cmm_annotate_group_mem_release(group, mem) \ + do { \ + __tsan_release((void*)(mem)); \ + switch (cmm_annotate_dereference(group)) { \ + case CMM_ANNOTATE_MB: \ + break; \ + default: \ + cmm_annotate_die( \ + "missing mb for release group" \ + ); \ + } \ + } while (0) + +# define cmm_annotate_mem_acquire(mem) \ + __tsan_acquire((void*)(mem)) + +# define cmm_annotate_mem_release(mem) \ + __tsan_release((void*)(mem)) +#else + +# define cmm_annotate_group_mb_acquire(group) \ + (void) (group) + +# define cmm_annotate_group_mb_release(group) \ + (void) (group) + +# define cmm_annotate_group_mem_acquire(group, mem) \ + (void) (group) + +# define cmm_annotate_group_mem_release(group, mem) \ + (void) (group) + +# define cmm_annotate_mem_acquire(mem) \ + do { } while (0) + +# define cmm_annotate_mem_release(mem) \ + do { } while (0) + +#endif /* CMM_SANITIZE_THREAD */ + +#endif /* _URCU_ANNOTATE_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch.h new file mode 100644 index 0000000000000..5147d304f4623 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch.h @@ -0,0 +1,171 @@ +// SPDX-FileCopyrightText: 2020 Michael Jeanson +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_H +#define _URCU_ARCH_H + +/* + * Architecture detection using compiler defines. + * + * The following defines are used internally for architecture specific code. + * + * URCU_ARCH_X86 : All x86 variants 32 and 64 bits + * URCU_ARCH_I386 : Specific to the i386 + * URCU_ARCH_AMD64 : All 64 bits x86 variants + * URCU_ARCH_K1OM : Specific to the Xeon Phi / MIC + * + * URCU_ARCH_PPC : All PowerPC variants 32 and 64 bits + * URCU_ARCH_PPC64 : Specific to 64 bits variants + * + * URCU_ARCH_S390 : All IBM s390 / s390x variants + * + * URCU_ARCH_SPARC64 : All Sun SPARC variants + * + * URCU_ARCH_ALPHA : All DEC Alpha variants + * URCU_ARCH_IA64 : All Intel Itanium variants + * URCU_ARCH_ARM : All ARM 32 bits variants + * URCU_ARCH_ARMV7 : All ARMv7 ISA variants + * URCU_ARCH_AARCH64 : All ARM 64 bits variants + * URCU_ARCH_MIPS : All MIPS variants + * URCU_ARCH_NIOS2 : All Intel / Altera NIOS II variants + * URCU_ARCH_TILE : All Tilera TILE variants + * URCU_ARCH_HPPA : All HP PA-RISC variants + * URCU_ARCH_M68K : All Motorola 68000 variants + * URCU_ARCH_RISCV : All RISC-V variants + * URCU_ARCH_LOONGARCH : All LoongArch variants + */ + +#if (defined(__INTEL_OFFLOAD) || defined(__TARGET_ARCH_MIC) || defined(__MIC__)) + +#define URCU_ARCH_X86 1 +#define URCU_ARCH_AMD64 1 +#define URCU_ARCH_K1OM 1 +#include + +#elif (defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)) + +#define URCU_ARCH_X86 1 +#define URCU_ARCH_AMD64 1 +#include + +#elif (defined(__i386__) || defined(__i386)) + +#define URCU_ARCH_X86 1 + +/* + * URCU_ARCH_X86_NO_CAS enables a compat layer that will detect the presence of + * the cmpxchg instructions at runtime and provide a compat mode based on a + * pthread mutex when it isn't. + * + * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 was introduced in GCC 4.3 and Clang 3.3, + * building with older compilers will result in the compat layer always being + * used on x86-32. + */ +#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 +#define URCU_ARCH_X86_NO_CAS 1 +/* For backwards compat */ +#define URCU_ARCH_I386 1 +#endif + +#include + +#elif (defined(__powerpc64__) || defined(__ppc64__)) + +#define URCU_ARCH_PPC 1 +#define URCU_ARCH_PPC64 1 +#include + +#elif (defined(__powerpc__) || defined(__powerpc) || defined(__ppc__)) + +#define URCU_ARCH_PPC 1 +#include + +#elif (defined(__s390__) || defined(__s390x__) || defined(__zarch__)) + +#define URCU_ARCH_S390 1 +#include + +#elif (defined(__sparc__) || defined(__sparc) || defined(__sparc64__)) + +#define URCU_ARCH_SPARC64 1 +#include + +#elif (defined(__alpha__) || defined(__alpha)) + +#define URCU_ARCH_ALPHA 1 +#include + +#elif (defined(__ia64__) || defined(__ia64)) + +#define URCU_ARCH_IA64 1 +#include + +#elif (defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7__)) + +#define URCU_ARCH_ARMV7 1 +#define URCU_ARCH_ARM 1 +#include + +#elif (defined(__arm__) || defined(__arm)) + +#define URCU_ARCH_ARM 1 +#include + +#elif defined(__aarch64__) + +#define URCU_ARCH_AARCH64 1 +#include + +#elif (defined(__mips__) || defined(__mips)) + +#define URCU_ARCH_MIPS 1 +#include + +#elif (defined(__nios2__) || defined(__nios2)) + +#define URCU_ARCH_NIOS2 1 +#include + +#elif defined(__tilegx__) +/* + * URCU has only been tested on the TileGx architecture. For other Tile* + * architectures, please run the tests first and report the results to the + * maintainer so that proper support can be added. + */ + +#define URCU_ARCH_TILE 1 +#include + +#elif (defined(__hppa__) || defined(__HPPA__) || defined(__hppa)) + +#define URCU_ARCH_HPPA 1 +#include + +#elif defined(__m68k__) + +#define URCU_ARCH_M68K 1 +#include + +#elif defined(__riscv) + +#define URCU_ARCH_RISCV 1 +#include + +#elif defined(__loongarch__) + +#define URCU_ARCH_LOONGARCH 1 +#include + +#else +#error "Cannot build: unrecognized architecture, see ." +#endif + +#ifdef CONFIG_RCU_EMIT_LEGACY_MB +# define cmm_emit_legacy_smp_mb() cmm_smp_mb() +#else +# define cmm_emit_legacy_smp_mb() do { } while (0) +#endif + + +#endif /* _URCU_ARCH_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch/aarch64.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/aarch64.h new file mode 100644 index 0000000000000..f573306a05450 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/aarch64.h @@ -0,0 +1,58 @@ +// SPDX-FileCopyrightText: 2010 Paul E. McKenney, IBM Corporation. +// SPDX-FileCopyrightText: 2009-2015 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_AARCH64_H +#define _URCU_ARCH_AARCH64_H + +/* + * arch/aarch64.h: definitions for aarch64 architecture + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * On Linux, define the membarrier system call number if not yet available in + * the system headers. aarch64 implements asm-generic/unistd.h system call + * numbers. + */ +#if (defined(__linux__) && !defined(__NR_membarrier)) +#define __NR_membarrier 283 +#endif + +/* + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293 + * + * Backported in RHEL7 gcc 4.8.5-11 + */ +#if defined(URCU_GCC_VERSION) && defined(__GNUC_RH_RELEASE__) +# if (URCU_GCC_VERSION == 40805) && (__GNUC_RH_RELEASE__ >= 11) +# define URCU_GCC_PATCHED_63293 +# endif +#endif + +#ifdef URCU_GCC_VERSION +# if URCU_GCC_VERSION < 50100 && !defined(URCU_GCC_PATCHED_63293) +# error Your gcc version performs unsafe access to deallocated stack +# endif +#endif + +#define caa_cpu_relax() __asm__ __volatile__ ("yield" : : : "memory") + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_AARCH64_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch/alpha.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/alpha.h new file mode 100644 index 0000000000000..db7ab3eb55e32 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/alpha.h @@ -0,0 +1,38 @@ +// SPDX-FileCopyrightText: 2010 Paolo Bonzini +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_ALPHA_H +#define _URCU_ARCH_ALPHA_H + +/* + * arch_alpha.h: trivial definitions for the Alpha architecture. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define cmm_mb() __asm__ __volatile__ ("mb":::"memory") +#define cmm_wmb() __asm__ __volatile__ ("wmb":::"memory") +#define cmm_read_barrier_depends() __asm__ __volatile__ ("mb":::"memory") + +/* + * On Linux, define the membarrier system call number if not yet available in + * the system headers. + */ +#if (defined(__linux__) && !defined(__NR_membarrier)) +#define __NR_membarrier 517 +#endif + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_ALPHA_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch/arm.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/arm.h new file mode 100644 index 0000000000000..407f422a92ee7 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/arm.h @@ -0,0 +1,85 @@ +// SPDX-FileCopyrightText: 2010 Paul E. McKenney, IBM Corporation. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_ARM_H +#define _URCU_ARCH_ARM_H + +/* + * arch_arm.h: trivial definitions for the ARM architecture. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Using DMB is faster than the builtin __sync_synchronize and this instruction is + * part of the baseline ARMv7 ISA. + */ +#ifdef URCU_ARCH_ARMV7 + +/* For backwards compat. */ +#define CONFIG_RCU_ARM_HAVE_DMB 1 + +/* + * Issues full system DMB operation. + */ +#define cmm_mb() __asm__ __volatile__ ("dmb sy":::"memory") +#define cmm_rmb() __asm__ __volatile__ ("dmb sy":::"memory") +#define cmm_wmb() __asm__ __volatile__ ("dmb sy":::"memory") + +/* + * Issues DMB operation only to the inner shareable domain. + */ +#define cmm_smp_mb() __asm__ __volatile__ ("dmb ish":::"memory") +#define cmm_smp_rmb() __asm__ __volatile__ ("dmb ish":::"memory") +#define cmm_smp_wmb() __asm__ __volatile__ ("dmb ish":::"memory") + +#endif /* URCU_ARCH_ARMV7 */ + +#include +#include + +/* + * On Linux, define the membarrier system call number if not yet available in + * the system headers. + */ +#if (defined(__linux__) && !defined(__NR_membarrier)) +#define __NR_membarrier 389 +#endif + +/* + * Error out for compilers with known bugs. + */ + +/* + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58854 + */ +#ifdef URCU_GCC_VERSION +# if URCU_GCC_VERSION >= 40800 && URCU_GCC_VERSION <= 40802 +# error Your gcc version produces clobbered frame accesses +# endif +#endif + +/* + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42263 + */ +#ifdef URCU_GCC_VERSION +# if URCU_GCC_VERSION >= 40400 && URCU_GCC_VERSION <= 40402 +# error Your gcc version has a non-functional __sync_synchronize() +# endif +#endif + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_ARM_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch/gcc.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/gcc.h new file mode 100644 index 0000000000000..1987450df7c92 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/gcc.h @@ -0,0 +1,30 @@ +// SPDX-FileCopyrightText: 2010 Paul E. McKenney, IBM Corporation. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_GCC_H +#define _URCU_ARCH_GCC_H + +/* + * arch_gcc.h: trivial definitions for architectures using gcc __sync_ + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_GCC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch/generic.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/generic.h new file mode 100644 index 0000000000000..ac15a3bf7a378 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/generic.h @@ -0,0 +1,248 @@ +// SPDX-FileCopyrightText: 2010 Paolo Bonzini +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_GENERIC_H +#define _URCU_ARCH_GENERIC_H + +/* + * arch_generic.h: common definitions for multiple architectures. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef CAA_CACHE_LINE_SIZE +#define CAA_CACHE_LINE_SIZE 64 +#endif + +#if !defined(cmm_mc) && !defined(cmm_rmc) && !defined(cmm_wmc) +#define CONFIG_HAVE_MEM_COHERENCY +/* + * Architectures with cache coherency must _not_ define cmm_mc/cmm_rmc/cmm_wmc. + * + * For them, cmm_mc/cmm_rmc/cmm_wmc are implemented with a simple + * compiler barrier; in addition, we provide defaults for cmm_mb (using + * GCC builtins) as well as cmm_rmb and cmm_wmb (defaulting to cmm_mb). + */ + +#ifdef CONFIG_RCU_USE_ATOMIC_BUILTINS + +# ifdef CMM_SANITIZE_THREAD +/* + * This makes TSAN quiet about unsupported thread fence. + */ +static inline void _cmm_thread_fence_wrapper(void) +{ +# if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wpragmas" +# pragma clang diagnostic ignored "-Wunknown-warning-option" +# pragma clang diagnostic ignored "-Wtsan" +# elif defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wpragmas" +# pragma GCC diagnostic ignored "-Wtsan" +# endif + __atomic_thread_fence(__ATOMIC_SEQ_CST); +# if defined(__clang__) +# pragma clang diagnostic pop +# elif defined(__GNUC__) +# pragma GCC diagnostic pop +# endif +} +# endif /* CMM_SANITIZE_THREAD */ + +# ifndef cmm_smp_mb +# ifdef CMM_SANITIZE_THREAD +# define cmm_smp_mb() _cmm_thread_fence_wrapper() +# else +# define cmm_smp_mb() __atomic_thread_fence(__ATOMIC_SEQ_CST) +# endif /* CMM_SANITIZE_THREAD */ +# endif /* !cmm_smp_mb */ + +#endif /* CONFIG_RCU_USE_ATOMIC_BUILTINS */ + + +/* + * cmm_mb() expands to __sync_synchronize() instead of __atomic_thread_fence + * with SEQ_CST because the former "issues a full memory barrier" while the + * latter "acts as a synchronization fence between threads" which is too weak + * for what we want, for example with I/O devices. + * + * Even though sync_synchronize seems to be an alias for a sequential consistent + * atomic thread fence on every architecture on GCC and Clang, this assumption + * might be untrue in future. Therefore, the definitions above are used to + * ensure correct behavior in the future. + * + * The above defintions are quoted from the GCC manual. + */ +#ifndef cmm_mb +#define cmm_mb() __sync_synchronize() +#endif + +#ifndef cmm_rmb +#define cmm_rmb() cmm_mb() +#endif + +#ifndef cmm_wmb +#define cmm_wmb() cmm_mb() +#endif + +#define cmm_mc() cmm_barrier() +#define cmm_rmc() cmm_barrier() +#define cmm_wmc() cmm_barrier() +#else +/* + * Architectures without cache coherency need something like the following: + * + * #define cmm_mc() arch_cache_flush() + * #define cmm_rmc() arch_cache_flush_read() + * #define cmm_wmc() arch_cache_flush_write() + * + * Of these, only cmm_mc is mandatory. cmm_rmc and cmm_wmc default to + * cmm_mc. cmm_mb/cmm_rmb/cmm_wmb use these definitions by default: + * + * #define cmm_mb() cmm_mc() + * #define cmm_rmb() cmm_rmc() + * #define cmm_wmb() cmm_wmc() + */ + +#ifndef cmm_mb +#define cmm_mb() cmm_mc() +#endif + +#ifndef cmm_rmb +#define cmm_rmb() cmm_rmc() +#endif + +#ifndef cmm_wmb +#define cmm_wmb() cmm_wmc() +#endif + +#ifndef cmm_rmc +#define cmm_rmc() cmm_mc() +#endif + +#ifndef cmm_wmc +#define cmm_wmc() cmm_mc() +#endif +#endif + +/* Nop everywhere except on alpha. */ +#ifndef cmm_read_barrier_depends +#define cmm_read_barrier_depends() +#endif + +#ifdef CONFIG_RCU_SMP +#ifndef cmm_smp_mb +#define cmm_smp_mb() cmm_mb() +#endif +#ifndef cmm_smp_rmb +#define cmm_smp_rmb() cmm_rmb() +#endif +#ifndef cmm_smp_wmb +#define cmm_smp_wmb() cmm_wmb() +#endif +#ifndef cmm_smp_mc +#define cmm_smp_mc() cmm_mc() +#endif +#ifndef cmm_smp_rmc +#define cmm_smp_rmc() cmm_rmc() +#endif +#ifndef cmm_smp_wmc +#define cmm_smp_wmc() cmm_wmc() +#endif +#ifndef cmm_smp_read_barrier_depends +#define cmm_smp_read_barrier_depends() cmm_read_barrier_depends() +#endif +#else +#ifndef cmm_smp_mb +#define cmm_smp_mb() cmm_barrier() +#endif +#ifndef cmm_smp_rmb +#define cmm_smp_rmb() cmm_barrier() +#endif +#ifndef cmm_smp_wmb +#define cmm_smp_wmb() cmm_barrier() +#endif +#ifndef cmm_smp_mc +#define cmm_smp_mc() cmm_barrier() +#endif +#ifndef cmm_smp_rmc +#define cmm_smp_rmc() cmm_barrier() +#endif +#ifndef cmm_smp_wmc +#define cmm_smp_wmc() cmm_barrier() +#endif +#ifndef cmm_smp_read_barrier_depends +#define cmm_smp_read_barrier_depends() +#endif +#endif + +#ifndef caa_cpu_relax +#define caa_cpu_relax() cmm_barrier() +#endif + +#ifndef HAS_CAA_GET_CYCLES +#define HAS_CAA_GET_CYCLES + +#if defined(__APPLE__) + +#include +#include +#include +#include +#include + +typedef uint64_t caa_cycles_t; + +static inline caa_cycles_t caa_get_cycles (void) +{ + mach_timespec_t ts = { 0, 0 }; + static clock_serv_t clock_service; + + if (caa_unlikely(!clock_service)) { + if (host_get_clock_service(mach_host_self(), + SYSTEM_CLOCK, &clock_service)) + return -1ULL; + } + if (caa_unlikely(clock_get_time(clock_service, &ts))) + return -1ULL; + return ((uint64_t) ts.tv_sec * 1000000000ULL) + ts.tv_nsec; +} + +#elif defined(CONFIG_RCU_HAVE_CLOCK_GETTIME) + +#include +#include + +typedef uint64_t caa_cycles_t; + +static inline caa_cycles_t caa_get_cycles (void) +{ + struct timespec ts; + + if (caa_unlikely(clock_gettime(CLOCK_MONOTONIC, &ts))) + return -1ULL; + return ((uint64_t) ts.tv_sec * 1000000000ULL) + ts.tv_nsec; +} + +#else + +#error caa_get_cycles() not implemented for this platform. + +#endif + +#endif /* HAS_CAA_GET_CYCLES */ + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_ARCH_GENERIC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch/hppa.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/hppa.h new file mode 100644 index 0000000000000..2a2236e56c9e5 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/hppa.h @@ -0,0 +1,48 @@ +// SPDX-FileCopyrightText: 2014 Helge Deller +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_HPPA_H +#define _URCU_ARCH_HPPA_H + +/* + * arch/hppa.h: definitions for hppa architecture + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * On Linux, define the membarrier system call number if not yet available in + * the system headers. + */ +#if (defined(__linux__) && !defined(__NR_membarrier)) +#define __NR_membarrier 343 +#endif + +#define HAS_CAA_GET_CYCLES +typedef unsigned long caa_cycles_t; + +static inline caa_cycles_t caa_get_cycles(void) +{ + caa_cycles_t cycles; + + asm volatile("mfctl 16, %0" : "=r" (cycles)); + return cycles; +} + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_HPPA_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch/ia64.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/ia64.h new file mode 100644 index 0000000000000..9ed009639df2f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/ia64.h @@ -0,0 +1,38 @@ +// SPDX-FileCopyrightText: 2010 Paul E. McKenney, IBM Corporation. +// SPDX-FileCopyrightText: 2009-2015 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_IA64_H +#define _URCU_ARCH_IA64_H + +/* + * arch/ia64.h: definitions for ia64 architecture + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * On Linux, define the membarrier system call number if not yet available in + * the system headers. + */ +#if (defined(__linux__) && !defined(__NR_membarrier)) +#define __NR_membarrier 1344 +#endif + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_IA64_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch/loongarch.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/loongarch.h new file mode 100644 index 0000000000000..7e82d9aad5f0f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/loongarch.h @@ -0,0 +1,37 @@ +// SPDX-FileCopyrightText: 2021 Wang Jing +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_LOONGARCH_H +#define _URCU_ARCH_LOONGARCH_H + +/* + * arch/loongarch.h: trivial definitions for the LoongArch architecture. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * On Linux, define the membarrier system call number if not yet available in + * the system headers. + */ +#if (defined(__linux__) && !defined(__NR_membarrier)) +#define __NR_membarrier 283 +#endif + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_LOONGARCH_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch/m68k.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/m68k.h new file mode 100644 index 0000000000000..29dbfc5827438 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/m68k.h @@ -0,0 +1,37 @@ +// SPDX-FileCopyrightText: 2017 Michael Jeanson +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_M68K_H +#define _URCU_ARCH_M68K_H + +/* + * arch/m68k.h: definitions for m68k architecture + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * On Linux, define the membarrier system call number if not yet available in + * the system headers. + */ +#if (defined(__linux__) && !defined(__NR_membarrier)) +#define __NR_membarrier 374 +#endif + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_M68K_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch/mips.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/mips.h new file mode 100644 index 0000000000000..c22dee281489e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/mips.h @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: 2010 Paolo Bonzini +// SPDX-FileCopyrightText: 2012 Ralf Baechle +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_MIPS_H +#define _URCU_ARCH_MIPS_H + +/* + * arch_mips.h: trivial definitions for the MIPS architecture. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define cmm_mb() __asm__ __volatile__ ( \ + " .set mips2 \n" \ + " sync \n" \ + " .set mips0 \n" \ + :::"memory") + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_MIPS_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch/nios2.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/nios2.h new file mode 100644 index 0000000000000..4887443ad75f0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/nios2.h @@ -0,0 +1,28 @@ +// SPDX-FileCopyrightText: 2016 Marek Vasut +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_NIOS2_H +#define _URCU_ARCH_NIOS2_H + +/* + * arch_nios2.h: trivial definitions for the NIOS2 architecture. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define cmm_mb() cmm_barrier() + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_NIOS2_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch/ppc.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/ppc.h new file mode 100644 index 0000000000000..1285b6d2211f3 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/ppc.h @@ -0,0 +1,136 @@ +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_PPC_H +#define _URCU_ARCH_PPC_H + +/* + * arch_ppc.h: trivial definitions for the powerpc architecture. + */ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Most powerpc machines have 128 bytes cache lines, but to make sure + * there is no false sharing on all known Power hardware, use the + * largest known cache line size, which is the physical size of POWER5 + * L3 cache lines (256 bytes). + * + * "Each slice [of the L3] is 12-way set-associative, with 4,096 + * congruence classes of 256-byte lines managed as two 128-byte sectors + * to match the L2 line size." + * + * From: "POWER5 system microarchitecture", + * IBM Journal of Research & Development, + * vol. 49, no. 4/5, July/September 2005 + * https://www.eecg.utoronto.ca/~moshovos/ACA08/readings/power5.pdf + * + * This value is a compile-time constant, which prevents us from + * querying the processor for the cache line size at runtime. We + * therefore need to be pessimistic and assume the largest known cache + * line size. + * + * This value is exposed through public headers, so tuning it for + * specific environments is a concern for ABI compatibility between + * applications and liburcu. + */ +#define CAA_CACHE_LINE_SIZE 256 + +#ifdef __NO_LWSYNC__ +#define LWSYNC_OPCODE "sync\n" +#else +#define LWSYNC_OPCODE "lwsync\n" +#endif + +/* + * Use sync for all cmm_mb/rmb/wmb barriers because lwsync does not + * preserve ordering of cacheable vs. non-cacheable accesses, so it + * should not be used to order with respect to MMIO operations. An + * eieio+lwsync pair is also not enough for cmm_rmb, because it will + * order cacheable and non-cacheable memory operations separately---i.e. + * not the latter against the former. + */ +#define cmm_mb() __asm__ __volatile__ ("sync":::"memory") + +/* + * lwsync orders loads in cacheable memory with respect to other loads, + * and stores in cacheable memory with respect to other stores. + * Therefore, use it for barriers ordering accesses to cacheable memory + * only. + */ +#define cmm_smp_rmb() __asm__ __volatile__ (LWSYNC_OPCODE:::"memory") +#define cmm_smp_wmb() __asm__ __volatile__ (LWSYNC_OPCODE:::"memory") + +#define mftbl() \ + __extension__ \ + ({ \ + unsigned long rval; \ + __asm__ __volatile__ ("mftb %0" : "=r" (rval)); \ + rval; \ + }) + +#define mftbu() \ + __extension__ \ + ({ \ + unsigned long rval; \ + __asm__ __volatile__ ("mftbu %0" : "=r" (rval)); \ + rval; \ + }) + +#define mftb() \ + __extension__ \ + ({ \ + unsigned long long rval; \ + __asm__ __volatile__ ("mftb %0" : "=r" (rval)); \ + rval; \ + }) + +#define HAS_CAA_GET_CYCLES + +typedef uint64_t caa_cycles_t; + +#ifdef __powerpc64__ +static inline caa_cycles_t caa_get_cycles(void) +{ + return (caa_cycles_t) mftb(); +} +#else +static inline caa_cycles_t caa_get_cycles(void) +{ + unsigned long h, l; + + for (;;) { + h = mftbu(); + cmm_barrier(); + l = mftbl(); + cmm_barrier(); + if (mftbu() == h) + return (((caa_cycles_t) h) << 32) + l; + } +} +#endif + +/* + * On Linux, define the membarrier system call number if not yet available in + * the system headers. + */ +#if (defined(__linux__) && !defined(__NR_membarrier)) +#define __NR_membarrier 365 +#endif + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_PPC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch/riscv.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/riscv.h new file mode 100644 index 0000000000000..cb8173fb5773d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/riscv.h @@ -0,0 +1,37 @@ +// SPDX-FileCopyrightText: 2018 Michael Jeanson +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_RISCV_H +#define _URCU_ARCH_RISCV_H + +/* + * arch/riscv.h: definitions for the RISC-V architecture + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * On Linux, define the membarrier system call number if not yet available in + * the system headers. + */ +#if (defined(__linux__) && !defined(__NR_membarrier)) +#define __NR_membarrier 283 +#endif + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_RISCV_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch/s390.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/s390.h new file mode 100644 index 0000000000000..906d3e97f6786 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/s390.h @@ -0,0 +1,56 @@ +// SPDX-FileCopyrightText: 2009 Novell, Inc. +// +// SPDX-License-Identifier: MIT + +#ifndef _URCU_ARCH_S390_H +#define _URCU_ARCH_S390_H + +/* + * Trivial definitions for the S390 architecture based on information from the + * Principles of Operation "CPU Serialization" (5-91), "BRANCH ON CONDITION" + * (7-25) and "STORE CLOCK" (7-169). + * + * Author: Jan Blunck + */ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CAA_CACHE_LINE_SIZE 128 + +#define cmm_mb() __asm__ __volatile__("bcr 15,0" : : : "memory") + +#define HAS_CAA_GET_CYCLES + +typedef uint64_t caa_cycles_t; + +static inline caa_cycles_t caa_get_cycles (void) +{ + caa_cycles_t cycles; + + __asm__ __volatile__("stck %0" : "=m" (cycles) : : "cc", "memory" ); + + return cycles; +} + +/* + * On Linux, define the membarrier system call number if not yet available in + * the system headers. + */ +#if (defined(__linux__) && !defined(__NR_membarrier)) +#define __NR_membarrier 356 +#endif + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_S390_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch/sparc64.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/sparc64.h new file mode 100644 index 0000000000000..1fdc6a4f88f6a --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/sparc64.h @@ -0,0 +1,50 @@ +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_SPARC64_H +#define _URCU_ARCH_SPARC64_H + +/* + * arch_sparc64.h: trivial definitions for the Sparc64 architecture. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * On Linux, define the membarrier system call number if not yet available in + * the system headers. + */ +#if (defined(__linux__) && !defined(__NR_membarrier)) +#define __NR_membarrier 351 +#endif + +#define CAA_CACHE_LINE_SIZE 256 + +/* + * Inspired from the Linux kernel. Workaround Spitfire bug #51. + */ +#define membar_safe(type) \ +__asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \ + "membar " type "\n" \ + "1:\n" \ + : : : "memory") + +#define cmm_mb() membar_safe("#LoadLoad | #LoadStore | #StoreStore | #StoreLoad") +#define cmm_rmb() membar_safe("#LoadLoad") +#define cmm_wmb() membar_safe("#StoreStore") + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_SPARC64_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch/tile.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/tile.h new file mode 100644 index 0000000000000..0c5af191d790e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/tile.h @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: 2010 Paul E. McKenney, IBM Corporation. +// SPDX-FileCopyrightText: 2009-2015 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_TILE_H +#define _URCU_ARCH_TILE_H + +/* + * arch/tile.h: definitions for tile architecture + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * On Linux, define the membarrier system call number if not yet available in + * the system headers. tile implements asm-generic/unistd.h system call + * numbers. + */ +#if (defined(__linux__) && !defined(__NR_membarrier)) +#define __NR_membarrier 283 +#endif + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_TILE_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/arch/x86.h b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/x86.h new file mode 100644 index 0000000000000..dcff3a8d16c19 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/arch/x86.h @@ -0,0 +1,113 @@ +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_X86_H +#define _URCU_ARCH_X86_H + +/* + * arch_x86.h: trivial definitions for the x86 architecture. + */ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CAA_CACHE_LINE_SIZE 128 + +/* + * For now, using lock; addl compatibility mode even for i686, because the + * Pentium III is seen as a i686, but lacks mfence instruction. Only using + * fence for x86_64. + * + * k1om (__MIC__) is the name for the Intel MIC family (Xeon Phi). It is an + * x86_64 variant but lacks fence instructions. + */ +#if (defined(URCU_ARCH_AMD64) && !defined(URCU_ARCH_K1OM)) + +/* For backwards compat */ +#define CONFIG_RCU_HAVE_FENCE 1 + +#define cmm_mb() __asm__ __volatile__ ("mfence":::"memory") + +/* + * Define cmm_rmb/cmm_wmb to "strict" barriers that may be needed when + * using SSE or working with I/O areas. cmm_smp_rmb/cmm_smp_wmb are + * only compiler barriers, which is enough for general use. + */ +#define cmm_rmb() __asm__ __volatile__ ("lfence":::"memory") +#define cmm_wmb() __asm__ __volatile__ ("sfence"::: "memory") +#define cmm_smp_rmb() cmm_barrier() +#define cmm_smp_wmb() cmm_barrier() + +#else + +/* + * We leave smp_rmb/smp_wmb as full barriers for processors that do not have + * fence instructions. + * + * An empty cmm_smp_rmb() may not be enough on old PentiumPro multiprocessor + * systems, due to an erratum. The Linux kernel says that "Even distro + * kernels should think twice before enabling this", but for now let's + * be conservative and leave the full barrier on 32-bit processors. Also, + * IDT WinChip supports weak store ordering, and the kernel may enable it + * under our feet; cmm_smp_wmb() ceases to be a nop for these processors. + */ +#if (CAA_BITS_PER_LONG == 32) +#define cmm_mb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)":::"memory") +#define cmm_rmb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)":::"memory") +#define cmm_wmb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)":::"memory") +#else +#define cmm_mb() __asm__ __volatile__ ("lock; addl $0,0(%%rsp)":::"memory") +#define cmm_rmb() __asm__ __volatile__ ("lock; addl $0,0(%%rsp)":::"memory") +#define cmm_wmb() __asm__ __volatile__ ("lock; addl $0,0(%%rsp)":::"memory") +#endif +#endif + +#define caa_cpu_relax() __asm__ __volatile__ ("rep; nop" : : : "memory") + +#define HAS_CAA_GET_CYCLES + +#define rdtscll(val) \ + do { \ + unsigned int __a, __d; \ + __asm__ __volatile__ ("rdtsc" : "=a" (__a), "=d" (__d)); \ + (val) = ((unsigned long long)__a) \ + | (((unsigned long long)__d) << 32); \ + } while(0) + +typedef uint64_t caa_cycles_t; + +static inline caa_cycles_t caa_get_cycles(void) +{ + caa_cycles_t ret = 0; + + rdtscll(ret); + return ret; +} + +/* + * On Linux, define the membarrier system call number if not yet available in + * the system headers. + */ +#if (defined(__linux__) && !defined(__NR_membarrier)) +#if (CAA_BITS_PER_LONG == 32) +#define __NR_membarrier 375 +#else +#define __NR_membarrier 324 +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_X86_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/assert.h b/external/lgpl2/userspace-rcu/dist/include/urcu/assert.h new file mode 100644 index 0000000000000..3b8cdc6c44e79 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/assert.h @@ -0,0 +1,42 @@ +// SPDX-FileCopyrightText: 2021 Francis Deslauriers +// +// SPDX-License-Identifier: MIT + +#ifndef _URCU_ASSERT_H +#define _URCU_ASSERT_H + +/* + * Userspace RCU assertion facilities. + */ + +#include + +/* + * Force usage of an expression to prevent unused expression compiler warning. + */ +#define _urcu_use_expression(_expr) ((void) sizeof((void) (_expr), 0)) + +#ifdef NDEBUG +/* + * Vanilla assert() replacement. When NDEBUG is defined, the expression is + * consumed to prevent unused variable compile warnings. + */ +# define urcu_posix_assert(_cond) _urcu_use_expression(_cond) +#else +# include +# define urcu_posix_assert(_cond) assert(_cond) +#endif + +#if defined(DEBUG_RCU) || defined(CONFIG_RCU_DEBUG) + +/* + * Enables debugging/expensive assertions to be used in fast paths and only + * enabled on demand. When disabled, the expression is consumed to prevent + * unused variable compile warnings. + */ +# define urcu_assert_debug(_cond) urcu_posix_assert(_cond) +#else +# define urcu_assert_debug(_cond) _urcu_use_expression(_cond) +#endif + +#endif /* _URCU_ASSERT_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/call-rcu.h b/external/lgpl2/userspace-rcu/dist/include/urcu/call-rcu.h new file mode 100644 index 0000000000000..6b6de5c526b03 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/call-rcu.h @@ -0,0 +1,85 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_CALL_RCU_H +#define _URCU_CALL_RCU_H + +/* + * Userspace RCU header - batch memory reclamation with kernel API + * + * This header is meant to be included indirectly through a liburcu + * flavor header. + */ + +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Note that struct call_rcu_data is opaque to callers. */ + +struct call_rcu_data; + +/* Flag values. */ + +#define URCU_CALL_RCU_RT (1U << 0) +#define URCU_CALL_RCU_RUNNING (1U << 1) +#define URCU_CALL_RCU_STOP (1U << 2) +#define URCU_CALL_RCU_STOPPED (1U << 3) +#define URCU_CALL_RCU_PAUSE (1U << 4) +#define URCU_CALL_RCU_PAUSED (1U << 5) + +/* + * The rcu_head data structure is placed in the structure to be freed + * via call_rcu(). + */ + +struct rcu_head { + struct cds_wfcq_node next; + void (*func)(struct rcu_head *head); +}; + +/* + * Exported functions + * + * Important: see rcu-api.md in userspace-rcu documentation for + * call_rcu family of functions usage detail, including the surrounding + * RCU usage required when using these primitives. + */ + +void call_rcu(struct rcu_head *head, + void (*func)(struct rcu_head *head)); + +struct call_rcu_data *create_call_rcu_data(unsigned long flags, + int cpu_affinity); +void call_rcu_data_free(struct call_rcu_data *crdp); + +struct call_rcu_data *get_default_call_rcu_data(void); +struct call_rcu_data *get_cpu_call_rcu_data(int cpu); +struct call_rcu_data *get_thread_call_rcu_data(void); +struct call_rcu_data *get_call_rcu_data(void); +pthread_t get_call_rcu_thread(struct call_rcu_data *crdp); + +void set_thread_call_rcu_data(struct call_rcu_data *crdp); +int set_cpu_call_rcu_data(int cpu, struct call_rcu_data *crdp); + +int create_all_cpu_call_rcu_data(unsigned long flags); +void free_all_cpu_call_rcu_data(void); + +void call_rcu_before_fork(void); +void call_rcu_after_fork_parent(void); +void call_rcu_after_fork_child(void); + +void rcu_barrier(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_CALL_RCU_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/cds.h b/external/lgpl2/userspace-rcu/dist/include/urcu/cds.h new file mode 100644 index 0000000000000..9eae429af81ed --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/cds.h @@ -0,0 +1,24 @@ +// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_CDS_H +#define _URCU_CDS_H + +/* + * Userspace RCU library - Concurrent Data Structures + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif /* _URCU_CDS_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/compiler.h b/external/lgpl2/userspace-rcu/dist/include/urcu/compiler.h new file mode 100644 index 0000000000000..e027c130100ea --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/compiler.h @@ -0,0 +1,250 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_COMPILER_H +#define _URCU_COMPILER_H + +/* + * Compiler definitions. + */ + +#include /* for offsetof */ + +#if defined __cplusplus +# include /* for std::remove_cv */ +#endif + +#include + +#define caa_likely(x) __builtin_expect(!!(x), 1) +#define caa_unlikely(x) __builtin_expect(!!(x), 0) + +#ifdef CONFIG_RCU_USE_ATOMIC_BUILTINS +# define cmm_barrier() __atomic_signal_fence(__ATOMIC_SEQ_CST) +#else +# define cmm_barrier() __asm__ __volatile__ ("" : : : "memory") +#endif + +/* + * Instruct the compiler to perform only a single access to a variable + * (prohibits merging and refetching). The compiler is also forbidden to reorder + * successive instances of CMM_ACCESS_ONCE(), but only when the compiler is aware of + * particular ordering. Compiler ordering can be ensured, for example, by + * putting two CMM_ACCESS_ONCE() in separate C statements. + * + * This macro does absolutely -nothing- to prevent the CPU from reordering, + * merging, or refetching absolutely anything at any time. Its main intended + * use is to mediate communication between process-level code and irq/NMI + * handlers, all running on the same CPU. + */ +#define CMM_ACCESS_ONCE(x) (*(__volatile__ __typeof__(x) *)&(x)) + +/* + * If the toolchain support the C11 memory model, define the private macro + * _CMM_TOOLCHAIN_SUPPORT_C11_MM. + */ +#if ((defined (__cplusplus) && __cplusplus >= 201103L) || \ + (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)) +# define _CMM_TOOLCHAIN_SUPPORT_C11_MM +#elif defined(CONFIG_RCU_USE_ATOMIC_BUILTINS) +# error "URCU was configured to use atomic builtins, but this toolchain does not support them." +#endif + +/* Make the optimizer believe the variable can be manipulated arbitrarily. */ +#define _CMM_OPTIMIZER_HIDE_VAR(var) \ + __asm__ ("" : "+r" (var)) + +#ifndef caa_max +#define caa_max(a,b) ((a)>(b)?(a):(b)) +#endif + +#ifndef caa_min +#define caa_min(a,b) ((a)<(b)?(a):(b)) +#endif + +#if defined(__SIZEOF_LONG__) +#define CAA_BITS_PER_LONG (__SIZEOF_LONG__ * 8) +#elif defined(_LP64) +#define CAA_BITS_PER_LONG 64 +#else +#define CAA_BITS_PER_LONG 32 +#endif + +/* + * caa_container_of - Get the address of an object containing a field. + * + * @ptr: pointer to the field. + * @type: type of the object. + * @member: name of the field within the object. + */ +#define caa_container_of(ptr, type, member) \ + __extension__ \ + ({ \ + const __typeof__(((type *) NULL)->member) * __ptr = (ptr); \ + (type *)((char *)__ptr - offsetof(type, member)); \ + }) + +/* + * caa_container_of_check_null - Get the address of an object containing a field. + * + * @ptr: pointer to the field. + * @type: type of the object. + * @member: name of the field within the object. + * + * Return the address of the object containing the field. Return NULL if + * @ptr is NULL. + */ +#define caa_container_of_check_null(ptr, type, member) \ + __extension__ \ + ({ \ + const __typeof__(((type *) NULL)->member) * __ptr = (ptr); \ + (__ptr) ? (type *)((char *)__ptr - offsetof(type, member)) : NULL; \ + }) + +#define CAA_BUILD_BUG_ON_ZERO(cond) (sizeof(struct { int:-!!(cond); })) +#define CAA_BUILD_BUG_ON(cond) ((void)CAA_BUILD_BUG_ON_ZERO(cond)) + +/* + * __rcu is an annotation that documents RCU pointer accesses that need + * to be protected by a read-side critical section. Eventually, a static + * checker will be able to use this annotation to detect incorrect RCU + * usage. + */ +#define __rcu + +#ifdef __cplusplus +#define URCU_FORCE_CAST(_type, arg) (reinterpret_cast::type>(arg)) +#else +#define URCU_FORCE_CAST(type, arg) ((type) (arg)) +#endif + +#define caa_is_signed_type(type) ((type) -1 < (type) 0) + +/* + * Cast to unsigned long, sign-extending if @v is signed. + * Note: casting to a larger type or to same type size keeps the sign of + * the expression being cast (see C99 6.3.1.3). + */ +#define caa_cast_long_keep_sign(v) ((unsigned long) (v)) + +#if defined (__GNUC__) \ + && ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5) \ + || __GNUC__ >= 5) +#define CDS_DEPRECATED(msg) \ + __attribute__((deprecated(msg))) +#else +#define CDS_DEPRECATED(msg) \ + __attribute__((deprecated)) +#endif + +#define CAA_ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + +/* + * URCU_GCC_VERSION is used to blacklist specific GCC versions with known + * bugs, clang also defines these macros to an equivalent GCC version it + * claims to support, so exclude it. + */ +#if defined(__GNUC__) && !defined(__clang__) +# define URCU_GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) +#endif + +#ifdef __cplusplus +#define caa_unqual_scalar_typeof(x) \ + std::remove_cv::type>::type +#else +#define caa_scalar_type_to_expr(type) \ + unsigned type: (unsigned type)0, \ + signed type: (signed type)0 + +/* + * Use C11 _Generic to express unqualified type from expression. This removes + * volatile qualifier from expression type. + */ +#define caa_unqual_scalar_typeof(x) \ + __typeof__( \ + _Generic((x), \ + char: (char)0, \ + caa_scalar_type_to_expr(char), \ + caa_scalar_type_to_expr(short), \ + caa_scalar_type_to_expr(int), \ + caa_scalar_type_to_expr(long), \ + caa_scalar_type_to_expr(long long), \ + default: (x) \ + ) \ + ) +#endif + +/* + * Allow user to manually define CMM_SANITIZE_THREAD if their toolchain is not + * supported by this check. + */ +#ifndef CMM_SANITIZE_THREAD +# if defined(__GNUC__) && defined(__SANITIZE_THREAD__) +# define CMM_SANITIZE_THREAD +# elif defined(__clang__) && defined(__has_feature) +# if __has_feature(thread_sanitizer) +# define CMM_SANITIZE_THREAD +# endif +# endif +#endif /* !CMM_SANITIZE_THREAD */ + +/* + * Helper to add the volatile qualifier to a pointer. + * + * This is used to enforce volatile accesses even when using atomic + * builtins. Indeed, C11 atomic operations all work on volatile memory + * accesses, but this is not documented for compiler atomic builtins. + * + * This could prevent certain classes of optimization from the compiler such + * as load/store fusing. + */ +#if defined __cplusplus +template +volatile T cmm_cast_volatile(T t) +{ + return static_cast(t); +} +#else +# define cmm_cast_volatile(ptr) \ + __extension__ \ + ({ \ + (volatile __typeof__(ptr))(ptr); \ + }) +#endif + +/* + * Compile time assertion. + * - predicate: boolean expression to evaluate, + * - msg: string to print to the user on failure when `static_assert()` is + * supported, + * - c_identifier_msg: message to be included in the typedef to emulate a + * static assertion. This parameter must be a valid C identifier as it will + * be used as a typedef name. + */ +#ifdef __cplusplus +#define urcu_static_assert(predicate, msg, c_identifier_msg) \ + static_assert(predicate, msg) +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) +#define urcu_static_assert(predicate, msg, c_identifier_msg) \ + _Static_assert(predicate, msg) +#else +/* + * Evaluates the predicate and emit a compilation error on failure. + * + * If the predicate evaluates to true, this macro emits a function + * prototype with an argument type which is an array of size 0. + * + * If the predicate evaluates to false, this macro emits a function + * prototype with an argument type which is an array of negative size + * which is invalid in C and forces a compiler error. The + * c_identifier_msg parameter is used as the argument identifier so it + * is printed to the user when the error is reported. + */ +#define urcu_static_assert(predicate, msg, c_identifier_msg) \ + void urcu_static_assert_proto(char c_identifier_msg[2*!!(predicate)-1]) +#endif + +#endif /* _URCU_COMPILER_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/config.h.in b/external/lgpl2/userspace-rcu/dist/include/urcu/config.h.in new file mode 100644 index 0000000000000..473d7a2ec49a0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/config.h.in @@ -0,0 +1,37 @@ +// SPDX-FileCopyrightText: 2023 EfficiOS Inc. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* urcu/config.h.in. Manually generated for control over the contained defs. */ + +/* Enable SMP support. With SMP support enabled, uniprocessors are also + supported. With SMP support disabled, UP systems work fine, but the + behavior of SMP systems is undefined. */ +#undef CONFIG_RCU_SMP + +/* TLS provided by the compiler. */ +#undef CONFIG_RCU_TLS + +/* clock_gettime() is detected. */ +#undef CONFIG_RCU_HAVE_CLOCK_GETTIME + +/* Require the operating system to support the membarrier system call for + default and bulletproof flavors. */ +#undef CONFIG_RCU_FORCE_SYS_MEMBARRIER + +/* Enable internal debugging self-checks. + Introduces a performance penalty. */ +#undef CONFIG_RCU_DEBUG + +/* Uatomic API uses atomic builtins. */ +#undef CONFIG_RCU_USE_ATOMIC_BUILTINS + +/* Emit legacy memory barriers? */ +#undef CONFIG_RCU_EMIT_LEGACY_MB + +/* Expose multi-flavor support */ +#define CONFIG_RCU_HAVE_MULTIFLAVOR 1 + +/* Enable extra debugging checks for lock-free hash table iterator + traversal. */ +#undef CONFIG_CDS_LFHT_ITER_DEBUG diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/debug.h b/external/lgpl2/userspace-rcu/dist/include/urcu/debug.h new file mode 100644 index 0000000000000..ff89de273150c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/debug.h @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: 2015 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +#ifndef _URCU_DEBUG_H +#define _URCU_DEBUG_H + +/* + * Userspace RCU debugging facilities. + */ + +#include + +/* + * For backward compatibility reasons, this file must expose the urcu_assert() + * macro. + */ +#define urcu_assert(_cond) urcu_assert_debug(_cond) + +#endif /* _URCU_DEBUG_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/defer.h b/external/lgpl2/userspace-rcu/dist/include/urcu/defer.h new file mode 100644 index 0000000000000..db3640494a940 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/defer.h @@ -0,0 +1,51 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_DEFER_H +#define _URCU_DEFER_H + +/* + * Userspace RCU header - deferred execution + * + * This header is meant to be included indirectly through a liburcu + * flavor header. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Note: the defer_rcu() API is currently EXPERIMENTAL. It may change in the + * future. + * + * Important ! + * + * Each thread queuing memory reclamation must be registered with + * rcu_defer_register_thread(). rcu_defer_unregister_thread() should be + * called before the thread exits. + * + * *NEVER* use defer_rcu() within a RCU read-side critical section, because this + * primitive need to call synchronize_rcu() if the thread queue is full. + */ + +extern void defer_rcu(void (*fct)(void *p), void *p); + +/* + * Thread registration for reclamation. + */ +extern int rcu_defer_register_thread(void); +extern void rcu_defer_unregister_thread(void); +extern void rcu_defer_barrier(void); +extern void rcu_defer_barrier_thread(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_DEFER_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/flavor.h b/external/lgpl2/userspace-rcu/dist/include/urcu/flavor.h new file mode 100644 index 0000000000000..ce2a013a9aa14 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/flavor.h @@ -0,0 +1,80 @@ +// SPDX-FileCopyrightText: 2011 Lai Jiangshan +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_FLAVOR_H +#define _URCU_FLAVOR_H + +/* + * Userspace RCU header - rcu flavor declarations + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct rcu_head; + +struct urcu_atfork { + void (*before_fork)(void *priv); + void (*after_fork_parent)(void *priv); + void (*after_fork_child)(void *priv); + void *priv; +}; + +void urcu_register_rculfhash_atfork(struct urcu_atfork *atfork); +void urcu_unregister_rculfhash_atfork(struct urcu_atfork *atfork); + +struct rcu_flavor_struct { + void (*read_lock)(void); + void (*read_unlock)(void); + int (*read_ongoing)(void); + void (*read_quiescent_state)(void); + void (*update_call_rcu)(struct rcu_head *head, + void (*func)(struct rcu_head *head)); + void (*update_synchronize_rcu)(void); + void (*update_defer_rcu)(void (*fct)(void *p), void *p); + + void (*thread_offline)(void); + void (*thread_online)(void); + void (*register_thread)(void); + void (*unregister_thread)(void); + + void (*barrier)(void); + + void (*register_rculfhash_atfork)(struct urcu_atfork *atfork); + void (*unregister_rculfhash_atfork)(struct urcu_atfork *atfork); + + struct urcu_gp_poll_state (*update_start_poll_synchronize_rcu)(void); + bool (*update_poll_state_synchronize_rcu)(struct urcu_gp_poll_state state); +}; + +#define DEFINE_RCU_FLAVOR(x) \ +const struct rcu_flavor_struct x = { \ + .read_lock = rcu_read_lock, \ + .read_unlock = rcu_read_unlock, \ + .read_ongoing = rcu_read_ongoing, \ + .read_quiescent_state = rcu_quiescent_state, \ + .update_call_rcu = call_rcu, \ + .update_synchronize_rcu = synchronize_rcu, \ + .update_defer_rcu = defer_rcu, \ + .thread_offline = rcu_thread_offline, \ + .thread_online = rcu_thread_online, \ + .register_thread = rcu_register_thread, \ + .unregister_thread = rcu_unregister_thread,\ + .barrier = rcu_barrier, \ + .register_rculfhash_atfork = urcu_register_rculfhash_atfork, \ + .unregister_rculfhash_atfork = urcu_unregister_rculfhash_atfork,\ + .update_start_poll_synchronize_rcu = start_poll_synchronize_rcu,\ + .update_poll_state_synchronize_rcu = poll_state_synchronize_rcu,\ +} + +extern const struct rcu_flavor_struct rcu_flavor; + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_FLAVOR_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/futex.h b/external/lgpl2/userspace-rcu/dist/include/urcu/futex.h new file mode 100644 index 0000000000000..f1181ee4a6011 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/futex.h @@ -0,0 +1,242 @@ +// SPDX-FileCopyrightText: 2011-2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_FUTEX_H +#define _URCU_FUTEX_H + +/* + * Userspace RCU - sys_futex/compat_futex header. + */ + +#include +#include + +#include +#include +#include + +#if (defined(__linux__) && defined(__NR_futex)) + +/* For backwards compat */ +# define CONFIG_RCU_HAVE_FUTEX 1 + +# include +# include +# include +# include +# include + +#elif defined(__FreeBSD__) + +# include +# include + +#elif defined(__OpenBSD__) + +# include +# include + +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __OpenBSD__ +# define FUTEX_WAIT 0 +# define FUTEX_WAKE 1 +#endif + +/* + * sys_futex compatibility header. + * Use *only* *either of* futex_noasync OR futex_async on a given address. + * + * futex_noasync cannot be executed in signal handlers, but ensures that + * it will be put in a wait queue even in compatibility mode. + * + * futex_async is signal-handler safe for the wakeup. It uses polling + * on the wait-side in compatibility mode. + * + * BEWARE: sys_futex() FUTEX_WAIT may return early if interrupted + * (returns EINTR). + */ + +extern int compat_futex_noasync(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3); +extern int compat_futex_async(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3); + +#if (defined(__linux__) && defined(__NR_futex)) + +static inline int futex(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3) +{ + return syscall(__NR_futex, uaddr, op, val, timeout, uaddr2, val3); +} + +static inline int futex_noasync(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3) +{ + int ret; + + ret = futex(uaddr, op, val, timeout, uaddr2, val3); + if (caa_unlikely(ret < 0 && errno == ENOSYS)) { + /* + * The fallback on ENOSYS is the async-safe version of + * the compat futex implementation, because the + * async-safe compat implementation allows being used + * concurrently with calls to futex(). Indeed, sys_futex + * FUTEX_WAIT, on some architectures (mips and parisc), + * within a given process, spuriously return ENOSYS due + * to signal restart bugs on some kernel versions. + */ + return compat_futex_async(uaddr, op, val, timeout, + uaddr2, val3); + } + return ret; + +} + +static inline int futex_async(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3) +{ + int ret; + + ret = futex(uaddr, op, val, timeout, uaddr2, val3); + if (caa_unlikely(ret < 0 && errno == ENOSYS)) { + return compat_futex_async(uaddr, op, val, timeout, + uaddr2, val3); + } + return ret; +} + +#elif defined(__FreeBSD__) + +static inline int futex_async(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3) +{ + int umtx_op; + void *umtx_uaddr = NULL, *umtx_uaddr2 = NULL; + struct _umtx_time umtx_timeout = { + ._flags = UMTX_ABSTIME, + ._clockid = CLOCK_MONOTONIC, + }; + + /* + * Check if NULL or zero. Don't let users expect that they are + * taken into account. + */ + urcu_posix_assert(!uaddr2); + urcu_posix_assert(!val3); + + switch (op) { + case FUTEX_WAIT: + /* On FreeBSD, a "u_int" is a 32-bit integer. */ + umtx_op = UMTX_OP_WAIT_UINT; + if (timeout != NULL) { + umtx_timeout._timeout = *timeout; + umtx_uaddr = (void *) sizeof(umtx_timeout); + umtx_uaddr2 = (void *) &umtx_timeout; + } + break; + case FUTEX_WAKE: + umtx_op = UMTX_OP_WAKE; + break; + default: + errno = EINVAL; + return -1; + } + + return _umtx_op(uaddr, umtx_op, (uint32_t) val, umtx_uaddr, + umtx_uaddr2); +} + +static inline int futex_noasync(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3) +{ + return futex_async(uaddr, op, val, timeout, uaddr2, val3); +} + +#elif defined(__OpenBSD__) + +static inline int futex_noasync(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3) +{ + int ret; + + /* + * Check that val3 is zero. Don't let users expect that it is + * taken into account. + */ + urcu_posix_assert(!val3); + + ret = futex((volatile uint32_t *) uaddr, op, val, timeout, + (volatile uint32_t *) uaddr2); + if (caa_unlikely(ret < 0 && errno == ENOSYS)) { + return compat_futex_noasync(uaddr, op, val, timeout, + uaddr2, val3); + } + return ret; +} + +static inline int futex_async(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3) +{ + int ret; + + /* + * Check that val3 is zero. Don't let users expect that it is + * taken into account. + */ + urcu_posix_assert(!val3); + + ret = futex((volatile uint32_t *) uaddr, op, val, timeout, + (volatile uint32_t *) uaddr2); + if (caa_unlikely(ret < 0 && errno == ENOSYS)) { + return compat_futex_async(uaddr, op, val, timeout, + uaddr2, val3); + } + return ret; +} + +#elif defined(__CYGWIN__) + +/* + * The futex_noasync compat code uses a weak symbol to share state across + * different shared object which is not possible on Windows with the + * Portable Executable format. Use the async compat code for both cases. + */ +static inline int futex_noasync(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3) +{ + return compat_futex_async(uaddr, op, val, timeout, uaddr2, val3); +} + +static inline int futex_async(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3) +{ + return compat_futex_async(uaddr, op, val, timeout, uaddr2, val3); +} + +#else + +static inline int futex_noasync(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3) +{ + return compat_futex_noasync(uaddr, op, val, timeout, uaddr2, val3); +} + +static inline int futex_async(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3) +{ + return compat_futex_async(uaddr, op, val, timeout, uaddr2, val3); +} + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_FUTEX_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/hlist.h b/external/lgpl2/userspace-rcu/dist/include/urcu/hlist.h new file mode 100644 index 0000000000000..9a1eb21e33990 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/hlist.h @@ -0,0 +1,110 @@ +// SPDX-FileCopyrightText: 2009 Novell Inc. +// SPDX-FileCopyrightText: 2010-2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-only + +#ifndef _KCOMPAT_HLIST_H +#define _KCOMPAT_HLIST_H + +/* + * Kernel sourcecode compatible lightweight single pointer list head useful + * for implementing hash tables + * + * Author: Jan Blunck + */ + +#include +#include + +struct cds_hlist_head { + struct cds_hlist_node *next; +}; + +struct cds_hlist_node { + struct cds_hlist_node *next, *prev; +}; + +/* Initialize a new list head. */ +static inline +void CDS_INIT_HLIST_HEAD(struct cds_hlist_head *ptr) +{ + ptr->next = NULL; +} + +#define CDS_HLIST_HEAD(name) \ + struct cds_hlist_head name = { NULL } + +#define CDS_HLIST_HEAD_INIT(name) \ + { .next = NULL } + +/* Get typed element from list at a given position. */ +#define cds_hlist_entry(ptr, type, member) caa_container_of(ptr, type, member) + +/* Get typed element from list at a given position, keeping NULL pointers. */ +#define cds_hlist_entry_safe(ptr, type, member) \ + ({ \ + __typeof__(ptr) ____ret = (ptr); \ + ____ret ? cds_hlist_entry(____ret, type, member) : NULL; \ + }) + +/* Add new element at the head of the list. */ +static inline +void cds_hlist_add_head(struct cds_hlist_node *newp, + struct cds_hlist_head *head) +{ + if (head->next) + head->next->prev = newp; + newp->next = head->next; + newp->prev = (struct cds_hlist_node *) head; + head->next = newp; +} + +/* Remove element from list. */ +static inline +void cds_hlist_del(struct cds_hlist_node *elem) +{ + if (elem->next) + elem->next->prev = elem->prev; + elem->prev->next = elem->next; +} + +#define cds_hlist_for_each(pos, head) \ + for (pos = (head)->next; (pos) != NULL; pos = (pos)->next) + +#define cds_hlist_for_each_safe(pos, p, head) \ + for (pos = (head)->next; \ + ((pos) != NULL) && (p = (pos)->next, 1); \ + pos = (p)) + +/* + * cds_hlist_for_each_entry and cds_hlist_for_each_entry_safe take + * respectively 4 and 5 arguments, while the Linux kernel APIs take 3, + * and 4. We implement cds_hlist_for_each_entry_2() and + * cds_hlist_for_each_entry_safe_2() to follow the Linux kernel APIs. + */ +#define cds_hlist_for_each_entry(entry, pos, head, member) \ + for (pos = (head)->next, \ + entry = cds_hlist_entry(pos, __typeof__(*(entry)), member); \ + (pos) != NULL; \ + pos = (pos)->next, \ + entry = cds_hlist_entry(pos, __typeof__(*(entry)), member)) + +#define cds_hlist_for_each_entry_safe(entry, pos, p, head, member) \ + for (pos = (head)->next, \ + entry = cds_hlist_entry(pos, __typeof__(*(entry)), member); \ + ((pos) != NULL) && (p = (pos)->next, 1); \ + pos = (p), \ + entry = cds_hlist_entry(pos, __typeof__(*entry), member)) + +#define cds_hlist_for_each_entry_2(entry, head, member) \ + for (entry = cds_hlist_entry_safe((head)->next, __typeof__(*(entry)), member); \ + (entry) != NULL; \ + entry = cds_hlist_entry_safe((entry)->member.next, __typeof__(*(entry)), member)) + +#define cds_hlist_for_each_entry_safe_2(entry, e, head, member) \ + for (entry = cds_hlist_entry_safe((head)->next, __typeof__(*(entry)), member); \ + ((entry) != NULL) && (e = (cds_hlist_entry_safe((entry)->member.next, \ + __typeof__(*(entry)), member)), 1); \ + entry = e) + +#endif /* _KCOMPAT_HLIST_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/lfstack.h b/external/lgpl2/userspace-rcu/dist/include/urcu/lfstack.h new file mode 100644 index 0000000000000..2a3073d695b7a --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/lfstack.h @@ -0,0 +1,323 @@ +// SPDX-FileCopyrightText: 2010-2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_LFSTACK_H +#define _URCU_LFSTACK_H + +/* + * Userspace RCU library - Lock-Free Stack + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * Lock-free stack. + * + * Stack implementing push, pop, pop_all operations, as well as iterator + * on the stack head returned by pop_all. + * + * Synchronization table: + * + * External synchronization techniques described in the API below is + * required between pairs marked with "X". No external synchronization + * required between pairs marked with "-". + * + * cds_lfs_push __cds_lfs_pop __cds_lfs_pop_all + * cds_lfs_push - - - + * __cds_lfs_pop - X X + * __cds_lfs_pop_all - X - + * + * cds_lfs_pop_blocking and cds_lfs_pop_all_blocking use an internal + * mutex to provide synchronization. + */ + +/* + * struct cds_lfs_node is returned by cds_lfs_pop, and also used as + * iterator on stack. It is not safe to dereference the node next + * pointer when returned by cds_lfs_pop. + */ +struct cds_lfs_node { + struct cds_lfs_node *next; +}; + +/* + * struct cds_lfs_head is returned by __cds_lfs_pop_all, and can be used + * to begin iteration on the stack. "node" needs to be the first field + * of cds_lfs_head, so the end-of-stack pointer value can be used for + * both types. + */ +struct cds_lfs_head { + struct cds_lfs_node node; +}; + +struct __cds_lfs_stack { + struct cds_lfs_head *head; +}; + +struct cds_lfs_stack { + struct cds_lfs_head *head; + pthread_mutex_t lock; +}; + +/* + * In C, the transparent union allows calling functions that work on + * both struct cds_lfs_stack and struct __cds_lfs_stack on any of those + * two types. + * + * In C++, implement static inline wrappers using function overloading + * to obtain an API similar to C. + * + * Avoid complaints from clang++ not knowing the transparent union + * attribute. + */ +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wignored-attributes" +#endif +typedef union { + struct __cds_lfs_stack *_s; + struct cds_lfs_stack *s; +} __attribute__((__transparent_union__)) cds_lfs_stack_ptr_t; + +typedef union { + const struct __cds_lfs_stack *_s; + const struct cds_lfs_stack *s; +} __attribute__((__transparent_union__)) cds_lfs_stack_const_ptr_t; +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + +#ifdef _LGPL_SOURCE + +#include + +#define cds_lfs_node_init _cds_lfs_node_init +#define cds_lfs_init _cds_lfs_init +#define cds_lfs_destroy _cds_lfs_destroy +#define __cds_lfs_init ___cds_lfs_init +#define cds_lfs_empty _cds_lfs_empty +#define cds_lfs_push _cds_lfs_push + +/* Locking performed internally */ +#define cds_lfs_pop_blocking _cds_lfs_pop_blocking +#define cds_lfs_pop_all_blocking _cds_lfs_pop_all_blocking + +/* Synchronize pop with internal mutex */ +#define cds_lfs_pop_lock _cds_lfs_pop_lock +#define cds_lfs_pop_unlock _cds_lfs_pop_unlock + +/* Synchronization ensured by the caller. See synchronization table. */ +#define __cds_lfs_pop ___cds_lfs_pop +#define __cds_lfs_pop_all ___cds_lfs_pop_all + +#else /* !_LGPL_SOURCE */ + +/* + * cds_lfs_node_init: initialize lock-free stack node. + */ +extern void cds_lfs_node_init(struct cds_lfs_node *node); + +/* + * cds_lfs_init: initialize lock-free stack (with locking). Pair with + * cds_lfs_destroy(). + */ +extern void cds_lfs_init(struct cds_lfs_stack *s); + +/* + * cds_lfs_destroy: destroy lock-free stack (with lock). Pair with + * cds_lfs_init(). + */ +extern void cds_lfs_destroy(struct cds_lfs_stack *s); + +/* + * __cds_lfs_init: initialize lock-free stack (without lock). + * Don't pair with any destroy function. + */ +extern void __cds_lfs_init(struct __cds_lfs_stack *s); + +/* + * cds_lfs_empty: return whether lock-free stack is empty. + * + * No memory barrier is issued. No mutual exclusion is required. + */ +extern bool cds_lfs_empty(cds_lfs_stack_const_ptr_t s); + +/* + * cds_lfs_push: push a node into the stack. + * + * Does not require any synchronization with other push nor pop. + * + * Returns 0 if the stack was empty prior to adding the node. + * Returns non-zero otherwise. + */ +extern bool cds_lfs_push(cds_lfs_stack_ptr_t s, + struct cds_lfs_node *node); + +/* + * cds_lfs_pop_blocking: pop a node from the stack. + * + * Calls __cds_lfs_pop with an internal pop mutex held. + */ +extern struct cds_lfs_node *cds_lfs_pop_blocking(struct cds_lfs_stack *s); + +/* + * cds_lfs_pop_all_blocking: pop all nodes from a stack. + * + * Calls __cds_lfs_pop_all with an internal pop mutex held. + */ +extern struct cds_lfs_head *cds_lfs_pop_all_blocking(struct cds_lfs_stack *s); + +/* + * cds_lfs_pop_lock: lock stack pop-protection mutex. + */ +extern void cds_lfs_pop_lock(struct cds_lfs_stack *s); + +/* + * cds_lfs_pop_unlock: unlock stack pop-protection mutex. + */ +extern void cds_lfs_pop_unlock(struct cds_lfs_stack *s); + +/* + * __cds_lfs_pop: pop a node from the stack. + * + * Returns NULL if stack is empty. + * + * __cds_lfs_pop needs to be synchronized using one of the following + * techniques: + * + * 1) Calling __cds_lfs_pop under rcu read lock critical section. + * Both __cds_lfs_pop and __cds_lfs_pop_all callers must wait for a + * grace period to pass before freeing the returned node or pushing + * the node back into the stack. It is valid to overwrite the content + * of cds_lfs_node immediately after __cds_lfs_pop and + * __cds_lfs_pop_all. + * 2) Using mutual exclusion (e.g. mutexes) to protect __cds_lfs_pop + * and __cds_lfs_pop_all callers. + * 3) Ensuring that only ONE thread can call __cds_lfs_pop() and + * __cds_lfs_pop_all(). (multi-provider/single-consumer scheme). + */ +extern struct cds_lfs_node *__cds_lfs_pop(cds_lfs_stack_ptr_t s); + +/* + * __cds_lfs_pop_all: pop all nodes from a stack. + * + * __cds_lfs_pop_all does not require any synchronization with other + * push, nor with other __cds_lfs_pop_all, but requires synchronization + * matching the technique used to synchronize __cds_lfs_pop: + * + * 1) If __cds_lfs_pop is called under rcu read lock critical section, + * both __cds_lfs_pop and __cds_lfs_pop_all callers must wait for a + * grace period to pass before freeing the returned node or pushing + * the node back into the stack. It is valid to overwrite the content + * of cds_lfs_node immediately after __cds_lfs_pop and + * __cds_lfs_pop_all. No RCU read-side critical section is needed + * around __cds_lfs_pop_all. + * 2) Using mutual exclusion (e.g. mutexes) to protect __cds_lfs_pop and + * __cds_lfs_pop_all callers. + * 3) Ensuring that only ONE thread can call __cds_lfs_pop() and + * __cds_lfs_pop_all(). (multi-provider/single-consumer scheme). + */ +extern struct cds_lfs_head *__cds_lfs_pop_all(cds_lfs_stack_ptr_t s); + +#endif /* !_LGPL_SOURCE */ + +/* + * cds_lfs_for_each: Iterate over all nodes returned by + * __cds_lfs_pop_all. + * @__head: node returned by __cds_lfs_pop_all (struct cds_lfs_head pointer). + * @__node: node to use as iterator (struct cds_lfs_node pointer). + * + * Content written into each node before push is guaranteed to be + * consistent, but no other memory ordering is ensured. + */ +#define cds_lfs_for_each(__head, __node) \ + for (__node = &__head->node; \ + __node != NULL; \ + __node = __node->next) + +/* + * cds_lfs_for_each_safe: Iterate over all nodes returned by + * __cds_lfs_pop_all, safe against node deletion. + * @__head: node returned by __cds_lfs_pop_all (struct cds_lfs_head pointer). + * @__node: node to use as iterator (struct cds_lfs_node pointer). + * @__n: struct cds_lfs_node pointer holding the next pointer (used + * internally). + * + * Content written into each node before push is guaranteed to be + * consistent, but no other memory ordering is ensured. + */ +#define cds_lfs_for_each_safe(__head, __node, __n) \ + for (__node = &__head->node, __n = (__node ? __node->next : NULL); \ + __node != NULL; \ + __node = __n, __n = (__node ? __node->next : NULL)) + +#ifdef __cplusplus +} + +/* + * In C++, implement static inline wrappers using function overloading + * to obtain an API similar to C. + */ + +static inline cds_lfs_stack_ptr_t cds_lfs_stack_cast(struct __cds_lfs_stack *s) +{ + cds_lfs_stack_ptr_t ret = { + ._s = s, + }; + return ret; +} + +static inline cds_lfs_stack_ptr_t cds_lfs_stack_cast(struct cds_lfs_stack *s) +{ + cds_lfs_stack_ptr_t ret = { + .s = s, + }; + return ret; +} + +static inline cds_lfs_stack_const_ptr_t cds_lfs_stack_const_cast(const struct __cds_lfs_stack *s) +{ + cds_lfs_stack_const_ptr_t ret = { + ._s = s, + }; + return ret; +} + +static inline cds_lfs_stack_const_ptr_t cds_lfs_stack_const_cast(const struct cds_lfs_stack *s) +{ + cds_lfs_stack_const_ptr_t ret = { + .s = s, + }; + return ret; +} + +template static inline bool cds_lfs_empty(T s) +{ + return cds_lfs_empty(cds_lfs_stack_const_cast(s)); +} + +template static inline bool cds_lfs_push(T s, + struct cds_lfs_node *node) +{ + return cds_lfs_push(cds_lfs_stack_cast(s), node); +} + +template static inline struct cds_lfs_node *__cds_lfs_pop(T s) +{ + return __cds_lfs_pop(cds_lfs_stack_cast(s)); +} + +template static inline struct cds_lfs_head *__cds_lfs_pop_all(T s) +{ + return __cds_lfs_pop_all(cds_lfs_stack_cast(s)); +} + +#endif /* __cplusplus */ + +#endif /* _URCU_LFSTACK_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/list.h b/external/lgpl2/userspace-rcu/dist/include/urcu/list.h new file mode 100644 index 0000000000000..f2d77bb067d0c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/list.h @@ -0,0 +1,188 @@ +// SPDX-FileCopyrightText: 2002 Free Software Foundation, Inc. +// SPDX-FileCopyrightText: 2009 Pierre-Marc Fournier +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * (originally part of the GNU C Library) + * Contributed by Ulrich Drepper , 2002. + */ + +#ifndef _CDS_LIST_H +#define _CDS_LIST_H 1 + +#include + +/* + * The definitions of this file are adopted from those which can be + * found in the Linux kernel headers to enable people familiar with the + * latter find their way in these sources as well. + */ + +/* Basic type for the double-link list. */ +struct cds_list_head { + struct cds_list_head *next, *prev; +}; + +/* Define a variable with the head and tail of the list. */ +#define CDS_LIST_HEAD(name) \ + struct cds_list_head name = { &(name), &(name) } + +/* Initialize a new list head. */ +#define CDS_INIT_LIST_HEAD(ptr) \ + (ptr)->next = (ptr)->prev = (ptr) + +#define CDS_LIST_HEAD_INIT(name) { .next = &(name), .prev = &(name) } + +/* Add new element at the head of the list. */ +static inline +void cds_list_add(struct cds_list_head *newp, struct cds_list_head *head) +{ + head->next->prev = newp; + newp->next = head->next; + newp->prev = head; + head->next = newp; +} + +/* Add new element at the tail of the list. */ +static inline +void cds_list_add_tail(struct cds_list_head *newp, struct cds_list_head *head) +{ + head->prev->next = newp; + newp->next = head; + newp->prev = head->prev; + head->prev = newp; +} + +/* Remove element from list. */ +static inline +void __cds_list_del(struct cds_list_head *prev, struct cds_list_head *next) +{ + next->prev = prev; + prev->next = next; +} + +/* Remove element from list. */ +static inline +void cds_list_del(struct cds_list_head *elem) +{ + __cds_list_del(elem->prev, elem->next); +} + +/* Remove element from list, initializing the element's list pointers. */ +static inline +void cds_list_del_init(struct cds_list_head *elem) +{ + cds_list_del(elem); + CDS_INIT_LIST_HEAD(elem); +} + +/* Delete from list, add to another list as head. */ +static inline +void cds_list_move(struct cds_list_head *elem, struct cds_list_head *head) +{ + __cds_list_del(elem->prev, elem->next); + cds_list_add(elem, head); +} + +/* Replace an old entry. */ +static inline +void cds_list_replace(const struct cds_list_head *old, struct cds_list_head *_new) +{ + _new->next = old->next; + _new->prev = old->prev; + _new->prev->next = _new; + _new->next->prev = _new; +} + +/* Join two lists. */ +static inline +void cds_list_splice(struct cds_list_head *add, struct cds_list_head *head) +{ + /* Do nothing if the list which gets added is empty. */ + if (add != add->next) { + add->next->prev = head; + add->prev->next = head->next; + head->next->prev = add->prev; + head->next = add->next; + } +} + +/* Get typed element from list at a given position. */ +#define cds_list_entry(ptr, type, member) caa_container_of(ptr, type, member) + + +/* Get first entry from a list. */ +#define cds_list_first_entry(ptr, type, member) \ + cds_list_entry((ptr)->next, type, member) + +/* Iterate forward over the elements of the list. */ +#define cds_list_for_each(pos, head) \ + for (pos = (head)->next; (pos) != (head); pos = (pos)->next) + +/* + * Iterate forward over the elements list. The list elements can be + * removed from the list while doing this. + */ +#define cds_list_for_each_safe(pos, p, head) \ + for (pos = (head)->next, p = (pos)->next; \ + (pos) != (head); \ + pos = (p), p = (pos)->next) + +/* Iterate backward over the elements of the list. */ +#define cds_list_for_each_prev(pos, head) \ + for (pos = (head)->prev; (pos) != (head); pos = (pos)->prev) + +/* + * Iterate backwards over the elements list. The list elements can be + * removed from the list while doing this. + */ +#define cds_list_for_each_prev_safe(pos, p, head) \ + for (pos = (head)->prev, p = (pos)->prev; \ + (pos) != (head); \ + pos = (p), p = (pos)->prev) + +#define cds_list_for_each_entry(pos, head, member) \ + for (pos = cds_list_entry((head)->next, __typeof__(*(pos)), member); \ + &(pos)->member != (head); \ + pos = cds_list_entry((pos)->member.next, __typeof__(*(pos)), member)) + +#define cds_list_for_each_entry_reverse(pos, head, member) \ + for (pos = cds_list_entry((head)->prev, __typeof__(*(pos)), member); \ + &(pos)->member != (head); \ + pos = cds_list_entry((pos)->member.prev, __typeof__(*(pos)), member)) + +#define cds_list_for_each_entry_safe(pos, p, head, member) \ + for (pos = cds_list_entry((head)->next, __typeof__(*(pos)), member), \ + p = cds_list_entry((pos)->member.next, __typeof__(*(pos)), member); \ + &(pos)->member != (head); \ + pos = (p), p = cds_list_entry((pos)->member.next, __typeof__(*(pos)), member)) + +/* + * Same as cds_list_for_each_entry_safe, but starts from "pos" which should + * point to an entry within the list. + */ +#define cds_list_for_each_entry_safe_from(pos, p, head, member) \ + for (p = cds_list_entry((pos)->member.next, __typeof__(*(pos)), member); \ + &(pos)->member != (head); \ + pos = (p), p = cds_list_entry((pos)->member.next, __typeof__(*(pos)), member)) + +static inline +int cds_list_empty(const struct cds_list_head *head) +{ + return head == head->next; +} + +static inline +void cds_list_replace_init(struct cds_list_head *old, + struct cds_list_head *_new) +{ + struct cds_list_head *head = old->next; + + cds_list_del(old); + cds_list_add_tail(_new, head); + CDS_INIT_LIST_HEAD(old); +} + +#endif /* _CDS_LIST_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/map/clear.h b/external/lgpl2/userspace-rcu/dist/include/urcu/map/clear.h new file mode 100644 index 0000000000000..9ab1219d027de --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/map/clear.h @@ -0,0 +1,67 @@ +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU header -- name mapping to allow multiple flavors to be + * used in the same executable. + * + * LGPL-compatible code should include this header with : + * + * #undef _LGPL_SOURCE + * #include + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#undef rcu_read_lock +#undef _rcu_read_lock +#undef rcu_read_unlock +#undef _rcu_read_unlock +#undef rcu_read_ongoing +#undef _rcu_read_ongoing +#undef rcu_quiescent_state +#undef _rcu_quiescent_state +#undef rcu_thread_offline +#undef rcu_thread_online +#undef rcu_register_thread +#undef rcu_unregister_thread +#undef rcu_init +#undef rcu_exit +#undef synchronize_rcu +#undef rcu_reader +#undef rcu_gp + +#undef get_cpu_call_rcu_data +#undef get_call_rcu_thread +#undef create_call_rcu_data +#undef set_cpu_call_rcu_data +#undef get_default_call_rcu_data +#undef get_call_rcu_data +#undef get_thread_call_rcu_data +#undef set_thread_call_rcu_data +#undef create_all_cpu_call_rcu_data +#undef free_all_cpu_call_rcu_data +#undef call_rcu +#undef call_rcu_data_free +#undef call_rcu_before_fork +#undef call_rcu_after_fork_parent +#undef call_rcu_after_fork_child +#undef rcu_barrier + +#undef defer_rcu +#undef rcu_defer_register_thread +#undef rcu_defer_unregister_thread +#undef rcu_defer_barrier + +#undef rcu_defer_barrier_thread +#undef rcu_defer_exit + +#undef rcu_flavor + +#undef urcu_register_rculfhash_atfork +#undef urcu_unregister_rculfhash_atfork + +#undef start_poll_synchronize_rcu +#undef poll_state_synchronize_rcu diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu-bp.h b/external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu-bp.h new file mode 100644 index 0000000000000..da7a5ebd9adef --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu-bp.h @@ -0,0 +1,136 @@ +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU header -- name mapping to allow multiple flavors to be + * used in the same executable. + * + * LGPL-compatible code should include this header with : + * + * #define _LGPL_SOURCE + * #include + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +/* Mapping macros to allow multiple flavors in a single binary. */ + +#define rcu_read_lock urcu_bp_read_lock +#define _rcu_read_lock _urcu_bp_read_lock +#define rcu_read_unlock urcu_bp_read_unlock +#define _rcu_read_unlock _urcu_bp_read_unlock +#define rcu_read_ongoing urcu_bp_read_ongoing +#define _rcu_read_ongoing _urcu_bp_read_ongoing +#define rcu_quiescent_state urcu_bp_quiescent_state +#define _rcu_quiescent_state _urcu_bp_quiescent_state +#define rcu_thread_offline urcu_bp_thread_offline +#define rcu_thread_online urcu_bp_thread_online +#define rcu_register_thread urcu_bp_register_thread +#define rcu_unregister_thread urcu_bp_unregister_thread +#define rcu_init urcu_bp_init +#define rcu_exit urcu_bp_exit +#define synchronize_rcu urcu_bp_synchronize_rcu +#define rcu_reader urcu_bp_reader +#define rcu_gp urcu_bp_gp + +#define get_cpu_call_rcu_data urcu_bp_get_cpu_call_rcu_data +#define get_call_rcu_thread urcu_bp_get_call_rcu_thread +#define create_call_rcu_data urcu_bp_create_call_rcu_data +#define set_cpu_call_rcu_data urcu_bp_set_cpu_call_rcu_data +#define get_default_call_rcu_data urcu_bp_get_default_call_rcu_data +#define get_call_rcu_data urcu_bp_get_call_rcu_data +#define get_thread_call_rcu_data urcu_bp_get_thread_call_rcu_data +#define set_thread_call_rcu_data urcu_bp_set_thread_call_rcu_data +#define create_all_cpu_call_rcu_data urcu_bp_create_all_cpu_call_rcu_data +#define free_all_cpu_call_rcu_data urcu_bp_free_all_cpu_call_rcu_data +#define call_rcu urcu_bp_call_rcu +#define call_rcu_data_free urcu_bp_call_rcu_data_free +#define call_rcu_before_fork urcu_bp_call_rcu_before_fork +#define call_rcu_after_fork_parent urcu_bp_call_rcu_after_fork_parent +#define call_rcu_after_fork_child urcu_bp_call_rcu_after_fork_child +#define rcu_barrier urcu_bp_barrier + +#define defer_rcu urcu_bp_defer_rcu +#define rcu_defer_register_thread urcu_bp_defer_register_thread +#define rcu_defer_unregister_thread urcu_bp_defer_unregister_thread +#define rcu_defer_barrier urcu_bp_defer_barrier +#define rcu_defer_barrier_thread urcu_bp_defer_barrier_thread +#define rcu_defer_exit urcu_bp_defer_exit + +#define rcu_flavor urcu_bp_flavor + +#define rcu_yield_active urcu_bp_yield_active +#define rcu_rand_yield urcu_bp_rand_yield + +#define urcu_register_rculfhash_atfork \ + urcu_bp_register_rculfhash_atfork +#define urcu_unregister_rculfhash_atfork \ + urcu_bp_unregister_rculfhash_atfork + +#define start_poll_synchronize_rcu urcu_bp_start_poll_synchronize_rcu +#define poll_state_synchronize_rcu urcu_bp_poll_state_synchronize_rcu + + +/* Compat identifiers for prior undocumented multiflavor usage */ +#ifndef URCU_NO_COMPAT_IDENTIFIERS + +#define rcu_dereference_bp urcu_bp_dereference +#define rcu_cmpxchg_pointer_bp urcu_bp_cmpxchg_pointer +#define rcu_xchg_pointer_bp urcu_bp_xchg_pointer +#define rcu_set_pointer_bp urcu_bp_set_pointer + +#define rcu_bp_before_fork urcu_bp_before_fork +#define rcu_bp_after_fork_parent urcu_bp_after_fork_parent +#define rcu_bp_after_fork_child urcu_bp_after_fork_child + +#define rcu_read_lock_bp urcu_bp_read_lock +#define _rcu_read_lock_bp _urcu_bp_read_lock +#define rcu_read_unlock_bp urcu_bp_read_unlock +#define _rcu_read_unlock_bp _urcu_bp_read_unlock +#define rcu_read_ongoing_bp urcu_bp_read_ongoing +#define _rcu_read_ongoing_bp _urcu_bp_read_ongoing +#define rcu_register_thread_bp urcu_bp_register_thread +#define rcu_unregister_thread_bp urcu_bp_unregister_thread +#define rcu_init_bp urcu_bp_init +#define rcu_exit_bp urcu_bp_exit +#define synchronize_rcu_bp urcu_bp_synchronize_rcu +#define rcu_reader_bp urcu_bp_reader +#define rcu_gp_bp urcu_bp_gp + +#define get_cpu_call_rcu_data_bp urcu_bp_get_cpu_call_rcu_data +#define get_call_rcu_thread_bp urcu_bp_get_call_rcu_thread +#define create_call_rcu_data_bp urcu_bp_create_call_rcu_data +#define set_cpu_call_rcu_data_bp urcu_bp_set_cpu_call_rcu_data +#define get_default_call_rcu_data_bp urcu_bp_get_default_call_rcu_data +#define get_call_rcu_data_bp urcu_bp_get_call_rcu_data +#define get_thread_call_rcu_data_bp urcu_bp_get_thread_call_rcu_data +#define set_thread_call_rcu_data_bp urcu_bp_set_thread_call_rcu_data +#define create_all_cpu_call_rcu_data_bp urcu_bp_create_all_cpu_call_rcu_data +#define free_all_cpu_call_rcu_data_bp urcu_bp_free_all_cpu_call_rcu_data +#define call_rcu_bp urcu_bp_call_rcu +#define call_rcu_data_free_bp urcu_bp_call_rcu_data_free +#define call_rcu_before_fork_bp urcu_bp_call_rcu_before_fork +#define call_rcu_after_fork_parent_bp urcu_bp_call_rcu_after_fork_parent +#define call_rcu_after_fork_child_bp urcu_bp_call_rcu_after_fork_child +#define rcu_barrier_bp urcu_bp_barrier + +#define defer_rcu_bp urcu_bp_defer_rcu +#define rcu_defer_register_thread_bp urcu_bp_defer_register_thread +#define rcu_defer_unregister_thread_bp urcu_bp_defer_unregister_thread +#define rcu_defer_barrier_bp urcu_bp_defer_barrier +#define rcu_defer_barrier_thread_bp urcu_bp_defer_barrier_thread +#define rcu_defer_exit_bp urcu_bp_defer_exit + +#define rcu_flavor_bp urcu_bp_flavor + +#define rcu_yield_active_bp urcu_bp_yield_active +#define rcu_rand_yield_bp urcu_bp_rand_yield + +#define urcu_register_rculfhash_atfork_bp \ + urcu_bp_register_rculfhash_atfork +#define urcu_unregister_rculfhash_atfork_bp \ + urcu_bp_unregister_rculfhash_atfork + +#endif /* URCU_NO_COMPAT_IDENTIFIERS */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu-mb.h b/external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu-mb.h new file mode 100644 index 0000000000000..1f1147fe5f8c6 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu-mb.h @@ -0,0 +1,128 @@ +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU header -- name mapping to allow multiple flavors to be + * used in the same executable. + * + * LGPL-compatible code should include this header with : + * + * #define _LGPL_SOURCE + * #include + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#define rcu_read_lock urcu_mb_read_lock +#define _rcu_read_lock _urcu_mb_read_lock +#define rcu_read_unlock urcu_mb_read_unlock +#define _rcu_read_unlock _urcu_mb_read_unlock +#define rcu_read_ongoing urcu_mb_read_ongoing +#define _rcu_read_ongoing _urcu_mb_read_ongoing +#define rcu_quiescent_state urcu_mb_quiescent_state +#define _rcu_quiescent_state _urcu_mb_quiescent_state +#define rcu_thread_offline urcu_mb_thread_offline +#define rcu_thread_online urcu_mb_thread_online +#define rcu_register_thread urcu_mb_register_thread +#define rcu_unregister_thread urcu_mb_unregister_thread +#define rcu_init urcu_mb_init +#define rcu_exit urcu_mb_exit +#define synchronize_rcu urcu_mb_synchronize_rcu +#define rcu_reader urcu_mb_reader +#define rcu_gp urcu_mb_gp + +#define get_cpu_call_rcu_data urcu_mb_get_cpu_call_rcu_data +#define get_call_rcu_thread urcu_mb_get_call_rcu_thread +#define create_call_rcu_data urcu_mb_create_call_rcu_data +#define set_cpu_call_rcu_data urcu_mb_set_cpu_call_rcu_data +#define get_default_call_rcu_data urcu_mb_get_default_call_rcu_data +#define get_call_rcu_data urcu_mb_get_call_rcu_data +#define get_thread_call_rcu_data urcu_mb_get_thread_call_rcu_data +#define set_thread_call_rcu_data urcu_mb_set_thread_call_rcu_data +#define create_all_cpu_call_rcu_data urcu_mb_create_all_cpu_call_rcu_data +#define free_all_cpu_call_rcu_data urcu_mb_free_all_cpu_call_rcu_data +#define call_rcu urcu_mb_call_rcu +#define call_rcu_data_free urcu_mb_call_rcu_data_free +#define call_rcu_before_fork urcu_mb_call_rcu_before_fork +#define call_rcu_after_fork_parent urcu_mb_call_rcu_after_fork_parent +#define call_rcu_after_fork_child urcu_mb_call_rcu_after_fork_child +#define rcu_barrier urcu_mb_barrier + +#define defer_rcu urcu_mb_defer_rcu +#define rcu_defer_register_thread urcu_mb_defer_register_thread +#define rcu_defer_unregister_thread urcu_mb_defer_unregister_thread +#define rcu_defer_barrier urcu_mb_defer_barrier +#define rcu_defer_barrier_thread urcu_mb_defer_barrier_thread +#define rcu_defer_exit urcu_mb_defer_exit + +#define rcu_flavor urcu_mb_flavor + +#define urcu_register_rculfhash_atfork \ + urcu_mb_register_rculfhash_atfork +#define urcu_unregister_rculfhash_atfork \ + urcu_mb_unregister_rculfhash_atfork + +#define start_poll_synchronize_rcu urcu_mb_start_poll_synchronize_rcu +#define poll_state_synchronize_rcu urcu_mb_poll_state_synchronize_rcu + + +/* Compat identifiers for prior undocumented multiflavor usage */ +#ifndef URCU_NO_COMPAT_IDENTIFIERS + +#define rcu_dereference_mb urcu_mb_dereference +#define rcu_cmpxchg_pointer_mb urcu_mb_cmpxchg_pointer +#define rcu_xchg_pointer_mb urcu_mb_xchg_pointer +#define rcu_set_pointer_mb urcu_mb_set_pointer + +#define rcu_mb_before_fork urcu_mb_before_fork +#define rcu_mb_after_fork_parent urcu_mb_after_fork_parent +#define rcu_mb_after_fork_child urcu_mb_after_fork_child + +#define rcu_read_lock_mb urcu_mb_read_lock +#define _rcu_read_lock_mb _urcu_mb_read_lock +#define rcu_read_unlock_mb urcu_mb_read_unlock +#define _rcu_read_unlock_mb _urcu_mb_read_unlock +#define rcu_read_ongoing_mb urcu_mb_read_ongoing +#define _rcu_read_ongoing_mb _urcu_mb_read_ongoing +#define rcu_register_thread_mb urcu_mb_register_thread +#define rcu_unregister_thread_mb urcu_mb_unregister_thread +#define rcu_init_mb urcu_mb_init +#define rcu_exit_mb urcu_mb_exit +#define synchronize_rcu_mb urcu_mb_synchronize_rcu +#define rcu_reader_mb urcu_mb_reader +#define rcu_gp_mb urcu_mb_gp + +#define get_cpu_call_rcu_data_mb urcu_mb_get_cpu_call_rcu_data +#define get_call_rcu_thread_mb urcu_mb_get_call_rcu_thread +#define create_call_rcu_data_mb urcu_mb_create_call_rcu_data +#define set_cpu_call_rcu_data_mb urcu_mb_set_cpu_call_rcu_data +#define get_default_call_rcu_data_mb urcu_mb_get_default_call_rcu_data +#define get_call_rcu_data_mb urcu_mb_get_call_rcu_data +#define get_thread_call_rcu_data_mb urcu_mb_get_thread_call_rcu_data +#define set_thread_call_rcu_data_mb urcu_mb_set_thread_call_rcu_data +#define create_all_cpu_call_rcu_data_mb urcu_mb_create_all_cpu_call_rcu_data +#define free_all_cpu_call_rcu_data_mb urcu_mb_free_all_cpu_call_rcu_data +#define call_rcu_mb urcu_mb_call_rcu +#define call_rcu_data_free_mb urcu_mb_call_rcu_data_free +#define call_rcu_before_fork_mb urcu_mb_call_rcu_before_fork +#define call_rcu_after_fork_parent_mb urcu_mb_call_rcu_after_fork_parent +#define call_rcu_after_fork_child_mb urcu_mb_call_rcu_after_fork_child +#define rcu_barrier_mb urcu_mb_barrier + +#define defer_rcu_mb urcu_mb_defer_rcu +#define rcu_defer_register_thread_mb urcu_mb_defer_register_thread +#define rcu_defer_unregister_thread_mb urcu_mb_defer_unregister_thread +#define rcu_defer_barrier_mb urcu_mb_defer_barrier +#define rcu_defer_barrier_thread_mb urcu_mb_defer_barrier_thread +#define rcu_defer_exit_mb urcu_mb_defer_exit + +#define rcu_flavor_mb urcu_mb_flavor + +#define urcu_register_rculfhash_atfork_mb \ + urcu_mb_register_rculfhash_atfork +#define urcu_unregister_rculfhash_atfork_mb \ + urcu_mb_unregister_rculfhash_atfork + +#endif /* URCU_NO_COMPAT_IDENTIFIERS */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu-memb.h b/external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu-memb.h new file mode 100644 index 0000000000000..9ae4279692842 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu-memb.h @@ -0,0 +1,130 @@ +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU header -- name mapping to allow multiple flavors to be + * used in the same executable. + * + * LGPL-compatible code should include this header with : + * + * #define _LGPL_SOURCE + * #include + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#define rcu_read_lock urcu_memb_read_lock +#define _rcu_read_lock _urcu_memb_read_lock +#define rcu_read_unlock urcu_memb_read_unlock +#define _rcu_read_unlock _urcu_memb_read_unlock +#define rcu_read_ongoing urcu_memb_read_ongoing +#define _rcu_read_ongoing _urcu_memb_read_ongoing +#define rcu_quiescent_state urcu_memb_quiescent_state +#define _rcu_quiescent_state _urcu_memb_quiescent_state +#define rcu_thread_offline urcu_memb_thread_offline +#define rcu_thread_online urcu_memb_thread_online +#define rcu_register_thread urcu_memb_register_thread +#define rcu_unregister_thread urcu_memb_unregister_thread +#define rcu_init urcu_memb_init +#define rcu_exit urcu_memb_exit +#define synchronize_rcu urcu_memb_synchronize_rcu +#define rcu_reader urcu_memb_reader +#define rcu_gp urcu_memb_gp + +#define get_cpu_call_rcu_data urcu_memb_get_cpu_call_rcu_data +#define get_call_rcu_thread urcu_memb_get_call_rcu_thread +#define create_call_rcu_data urcu_memb_create_call_rcu_data +#define set_cpu_call_rcu_data urcu_memb_set_cpu_call_rcu_data +#define get_default_call_rcu_data urcu_memb_get_default_call_rcu_data +#define get_call_rcu_data urcu_memb_get_call_rcu_data +#define get_thread_call_rcu_data urcu_memb_get_thread_call_rcu_data +#define set_thread_call_rcu_data urcu_memb_set_thread_call_rcu_data +#define create_all_cpu_call_rcu_data urcu_memb_create_all_cpu_call_rcu_data +#define free_all_cpu_call_rcu_data urcu_memb_free_all_cpu_call_rcu_data +#define call_rcu urcu_memb_call_rcu +#define call_rcu_data_free urcu_memb_call_rcu_data_free +#define call_rcu_before_fork urcu_memb_call_rcu_before_fork +#define call_rcu_after_fork_parent urcu_memb_call_rcu_after_fork_parent +#define call_rcu_after_fork_child urcu_memb_call_rcu_after_fork_child +#define rcu_barrier urcu_memb_barrier + +#define defer_rcu urcu_memb_defer_rcu +#define rcu_defer_register_thread urcu_memb_defer_register_thread +#define rcu_defer_unregister_thread urcu_memb_defer_unregister_thread +#define rcu_defer_barrier urcu_memb_defer_barrier +#define rcu_defer_barrier_thread urcu_memb_defer_barrier_thread +#define rcu_defer_exit urcu_memb_defer_exit + +#define rcu_flavor urcu_memb_flavor + +#define urcu_register_rculfhash_atfork \ + urcu_memb_register_rculfhash_atfork +#define urcu_unregister_rculfhash_atfork \ + urcu_memb_unregister_rculfhash_atfork + +#define start_poll_synchronize_rcu urcu_memb_start_poll_synchronize_rcu +#define poll_state_synchronize_rcu urcu_memb_poll_state_synchronize_rcu + + +/* Compat identifiers for prior undocumented multiflavor usage */ +#ifndef URCU_NO_COMPAT_IDENTIFIERS + +#define rcu_dereference_memb urcu_memb_dereference +#define rcu_cmpxchg_pointer_memb urcu_memb_cmpxchg_pointer +#define rcu_xchg_pointer_memb urcu_memb_xchg_pointer +#define rcu_set_pointer_memb urcu_memb_set_pointer + +#define rcu_memb_before_fork urcu_memb_before_fork +#define rcu_memb_after_fork_parent urcu_memb_after_fork_parent +#define rcu_memb_after_fork_child urcu_memb_after_fork_child + +#define rcu_read_lock_memb urcu_memb_read_lock +#define _rcu_read_lock_memb _urcu_memb_read_lock +#define rcu_read_unlock_memb urcu_memb_read_unlock +#define _rcu_read_unlock_memb _urcu_memb_read_unlock +#define rcu_read_ongoing_memb urcu_memb_read_ongoing +#define _rcu_read_ongoing_memb _urcu_memb_read_ongoing +#define rcu_register_thread_memb urcu_memb_register_thread +#define rcu_unregister_thread_memb urcu_memb_unregister_thread +#define rcu_init_memb urcu_memb_init +#define rcu_exit_memb urcu_memb_exit +#define synchronize_rcu_memb urcu_memb_synchronize_rcu +#define rcu_reader_memb urcu_memb_reader +#define rcu_gp_memb urcu_memb_gp + +#define get_cpu_call_rcu_data_memb urcu_memb_get_cpu_call_rcu_data +#define get_call_rcu_thread_memb urcu_memb_get_call_rcu_thread +#define create_call_rcu_data_memb urcu_memb_create_call_rcu_data +#define set_cpu_call_rcu_data_memb urcu_memb_set_cpu_call_rcu_data +#define get_default_call_rcu_data_memb urcu_memb_get_default_call_rcu_data +#define get_call_rcu_data_memb urcu_memb_get_call_rcu_data +#define get_thread_call_rcu_data_memb urcu_memb_get_thread_call_rcu_data +#define set_thread_call_rcu_data_memb urcu_memb_set_thread_call_rcu_data +#define create_all_cpu_call_rcu_data_memb \ + urcu_memb_create_all_cpu_call_rcu_data +#define free_all_cpu_call_rcu_data_memb urcu_memb_free_all_cpu_call_rcu_data +#define call_rcu_memb urcu_memb_call_rcu +#define call_rcu_data_free_memb urcu_memb_call_rcu_data_free +#define call_rcu_before_fork_memb urcu_memb_call_rcu_before_fork +#define call_rcu_after_fork_parent_memb urcu_memb_call_rcu_after_fork_parent +#define call_rcu_after_fork_child_memb urcu_memb_call_rcu_after_fork_child +#define rcu_barrier_memb urcu_memb_barrier + +#define defer_rcu_memb urcu_memb_defer_rcu +#define rcu_defer_register_thread_memb urcu_memb_defer_register_thread +#define rcu_defer_unregister_thread_memb \ + urcu_memb_defer_unregister_thread +#define rcu_defer_barrier_memb urcu_memb_defer_barrier +#define rcu_defer_barrier_thread_memb urcu_memb_defer_barrier_thread +#define rcu_defer_exit_memb urcu_memb_defer_exit + +#define rcu_flavor_memb urcu_memb_flavor + +#define urcu_register_rculfhash_atfork_memb \ + urcu_memb_register_rculfhash_atfork +#define urcu_unregister_rculfhash_atfork_memb \ + urcu_memb_unregister_rculfhash_atfork + +#endif /* URCU_NO_COMPAT_IDENTIFIERS */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu-qsbr.h b/external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu-qsbr.h new file mode 100644 index 0000000000000..d177fc53eebd7 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu-qsbr.h @@ -0,0 +1,129 @@ +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU header -- name mapping to allow multiple flavors to be + * used in the same executable. + * + * LGPL-compatible code should include this header with : + * + * #define _LGPL_SOURCE + * #include + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#define rcu_read_lock urcu_qsbr_read_lock +#define _rcu_read_lock _urcu_qsbr_read_lock +#define rcu_read_unlock urcu_qsbr_read_unlock +#define _rcu_read_unlock _urcu_qsbr_read_unlock +#define rcu_read_ongoing urcu_qsbr_read_ongoing +#define _rcu_read_ongoing _urcu_qsbr_read_ongoing +#define rcu_quiescent_state urcu_qsbr_quiescent_state +#define _rcu_quiescent_state _urcu_qsbr_quiescent_state +#define rcu_thread_offline urcu_qsbr_thread_offline +#define rcu_thread_online urcu_qsbr_thread_online +#define rcu_register_thread urcu_qsbr_register_thread +#define rcu_unregister_thread urcu_qsbr_unregister_thread +#define rcu_exit urcu_qsbr_exit +#define synchronize_rcu urcu_qsbr_synchronize_rcu +#define rcu_reader urcu_qsbr_reader +#define rcu_gp urcu_qsbr_gp + +#define get_cpu_call_rcu_data urcu_qsbr_get_cpu_call_rcu_data +#define get_call_rcu_thread urcu_qsbr_get_call_rcu_thread +#define create_call_rcu_data urcu_qsbr_create_call_rcu_data +#define set_cpu_call_rcu_data urcu_qsbr_set_cpu_call_rcu_data +#define get_default_call_rcu_data urcu_qsbr_get_default_call_rcu_data +#define get_call_rcu_data urcu_qsbr_get_call_rcu_data +#define get_thread_call_rcu_data urcu_qsbr_get_thread_call_rcu_data +#define set_thread_call_rcu_data urcu_qsbr_set_thread_call_rcu_data +#define create_all_cpu_call_rcu_data urcu_qsbr_create_all_cpu_call_rcu_data +#define free_all_cpu_call_rcu_data urcu_qsbr_free_all_cpu_call_rcu_data +#define call_rcu urcu_qsbr_call_rcu +#define call_rcu_data_free urcu_qsbr_call_rcu_data_free +#define call_rcu_before_fork urcu_qsbr_call_rcu_before_fork +#define call_rcu_after_fork_parent urcu_qsbr_call_rcu_after_fork_parent +#define call_rcu_after_fork_child urcu_qsbr_call_rcu_after_fork_child +#define rcu_barrier urcu_qsbr_barrier + +#define defer_rcu urcu_qsbr_defer_rcu +#define rcu_defer_register_thread urcu_qsbr_defer_register_thread +#define rcu_defer_unregister_thread urcu_qsbr_defer_unregister_thread +#define rcu_defer_barrier urcu_qsbr_defer_barrier +#define rcu_defer_barrier_thread urcu_qsbr_defer_barrier_thread +#define rcu_defer_exit urcu_qsbr_defer_exit + +#define rcu_flavor urcu_qsbr_flavor + +#define urcu_register_rculfhash_atfork \ + urcu_qsbr_register_rculfhash_atfork +#define urcu_unregister_rculfhash_atfork \ + urcu_qsbr_unregister_rculfhash_atfork + +#define start_poll_synchronize_rcu urcu_qsbr_start_poll_synchronize_rcu +#define poll_state_synchronize_rcu urcu_qsbr_poll_state_synchronize_rcu + + +/* Compat identifiers for prior undocumented multiflavor usage */ +#ifndef URCU_NO_COMPAT_IDENTIFIERS + +#define rcu_dereference_qsbr urcu_qsbr_dereference +#define rcu_cmpxchg_pointer_qsbr urcu_qsbr_cmpxchg_pointer +#define rcu_xchg_pointer_qsbr urcu_qsbr_xchg_pointer +#define rcu_set_pointer_qsbr urcu_qsbr_set_pointer + +#define rcu_qsbr_before_fork urcu_qsbr_before_fork +#define rcu_qsbr_after_fork_parent urcu_qsbr_after_fork_parent +#define rcu_qsbr_after_fork_child urcu_qsbr_after_fork_child + +#define rcu_read_lock_qsbr urcu_qsbr_read_lock +#define _rcu_read_lock_qsbr _urcu_qsbr_read_lock +#define rcu_read_unlock_qsbr urcu_qsbr_read_unlock +#define _rcu_read_unlock_qsbr _urcu_qsbr_read_unlock +#define rcu_read_ongoing_qsbr urcu_qsbr_read_ongoing +#define _rcu_read_ongoing_qsbr _urcu_qsbr_read_ongoing +#define rcu_register_thread_qsbr urcu_qsbr_register_thread +#define rcu_unregister_thread_qsbr urcu_qsbr_unregister_thread +#define rcu_init_qsbr urcu_qsbr_init +#define rcu_exit_qsbr urcu_qsbr_exit +#define synchronize_rcu_qsbr urcu_qsbr_synchronize_rcu +#define rcu_reader_qsbr urcu_qsbr_reader +#define rcu_gp_qsbr urcu_qsbr_gp + +#define get_cpu_call_rcu_data_qsbr urcu_qsbr_get_cpu_call_rcu_data +#define get_call_rcu_thread_qsbr urcu_qsbr_get_call_rcu_thread +#define create_call_rcu_data_qsbr urcu_qsbr_create_call_rcu_data +#define set_cpu_call_rcu_data_qsbr urcu_qsbr_set_cpu_call_rcu_data +#define get_default_call_rcu_data_qsbr urcu_qsbr_get_default_call_rcu_data +#define get_call_rcu_data_qsbr urcu_qsbr_get_call_rcu_data +#define get_thread_call_rcu_data_qsbr urcu_qsbr_get_thread_call_rcu_data +#define set_thread_call_rcu_data_qsbr urcu_qsbr_set_thread_call_rcu_data +#define create_all_cpu_call_rcu_data_qsbr \ + urcu_qsbr_create_all_cpu_call_rcu_data +#define free_all_cpu_call_rcu_data_qsbr urcu_qsbr_free_all_cpu_call_rcu_data +#define call_rcu_qsbr urcu_qsbr_call_rcu +#define call_rcu_data_free_qsbr urcu_qsbr_call_rcu_data_free +#define call_rcu_before_fork_qsbr urcu_qsbr_call_rcu_before_fork +#define call_rcu_after_fork_parent_qsbr urcu_qsbr_call_rcu_after_fork_parent +#define call_rcu_after_fork_child_qsbr urcu_qsbr_call_rcu_after_fork_child +#define rcu_barrier_qsbr urcu_qsbr_barrier + +#define defer_rcu_qsbr urcu_qsbr_defer_rcu +#define rcu_defer_register_thread_qsbr urcu_qsbr_defer_register_thread +#define rcu_defer_unregister_thread_qsbr \ + urcu_qsbr_defer_unregister_thread +#define rcu_defer_barrier_qsbr urcu_qsbr_defer_barrier +#define rcu_defer_barrier_thread_qsbr urcu_qsbr_defer_barrier_thread +#define rcu_defer_exit_qsbr urcu_qsbr_defer_exit + +#define rcu_flavor_qsbr urcu_qsbr_flavor + +#define urcu_register_rculfhash_atfork_qsbr \ + urcu_qsbr_register_rculfhash_atfork +#define urcu_unregister_rculfhash_atfork_qsbr \ + urcu_qsbr_unregister_rculfhash_atfork + +#endif /* URCU_NO_COMPAT_IDENTIFIERS */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu.h b/external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu.h new file mode 100644 index 0000000000000..96c53472f5e60 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/map/urcu.h @@ -0,0 +1,24 @@ +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU header -- name mapping to allow multiple flavors to be + * used in the same executable. + * + * LGPL-compatible code should include this header with : + * + * #define _LGPL_SOURCE + * #include + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#ifdef RCU_MEMBARRIER +#include +#elif defined(RCU_MB) +#include +#else +#error "Undefined selection" +#endif diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/pointer.h b/external/lgpl2/userspace-rcu/dist/include/urcu/pointer.h new file mode 100644 index 0000000000000..7a673d6197e7f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/pointer.h @@ -0,0 +1,115 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_POINTER_H +#define _URCU_POINTER_H + +/* + * Userspace RCU header. Operations on pointers. + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_LGPL_SOURCE) || defined(URCU_INLINE_SMALL_FUNCTIONS) + +#include + +/* + * rcu_dereference(ptr) + * + * Fetch a RCU-protected pointer. Typically used to copy the variable ptr to a + * local variable. + */ +#define rcu_dereference _rcu_dereference + +/* + * type *rcu_cmpxchg_pointer(type **ptr, type *old, type *new) + * type *rcu_xchg_pointer(type **ptr, type *new) + * void rcu_set_pointer(type **ptr, type *new) + * + * RCU pointer updates. + * @ptr: address of the pointer to modify + * @new: new pointer value + * @old: old pointer value (expected) + * + * return: old pointer value + */ +#define rcu_cmpxchg_pointer _rcu_cmpxchg_pointer +#define rcu_xchg_pointer _rcu_xchg_pointer +#define rcu_set_pointer _rcu_set_pointer + +#else /* !(defined(_LGPL_SOURCE) || defined(URCU_INLINE_SMALL_FUNCTIONS)) */ + +extern void *rcu_dereference_sym(void *p); +#define rcu_dereference(p) \ + __extension__ \ + ({ \ + __typeof__(p) _________p1 = URCU_FORCE_CAST(__typeof__(p), \ + rcu_dereference_sym(URCU_FORCE_CAST(void *, p))); \ + (_________p1); \ + }) + +extern void *rcu_cmpxchg_pointer_sym(void **p, void *old, void *_new); +#define rcu_cmpxchg_pointer(p, old, _new) \ + __extension__ \ + ({ \ + __typeof__(*(p)) _________pold = (old); \ + __typeof__(*(p)) _________pnew = (_new); \ + __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)), \ + rcu_cmpxchg_pointer_sym(URCU_FORCE_CAST(void **, p), \ + _________pold, \ + _________pnew)); \ + (_________p1); \ + }) + +extern void *rcu_xchg_pointer_sym(void **p, void *v); +#define rcu_xchg_pointer(p, v) \ + __extension__ \ + ({ \ + __typeof__(*(p)) _________pv = (v); \ + __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)), \ + rcu_xchg_pointer_sym(URCU_FORCE_CAST(void **, p), \ + _________pv)); \ + (_________p1); \ + }) + +/* + * Note: rcu_set_pointer_sym returns @v because we don't want to break + * the ABI. At the API level, rcu_set_pointer() now returns void. Use of + * the return value is therefore deprecated, and will cause a build + * error. + */ +extern void *rcu_set_pointer_sym(void **p, void *v); +#define rcu_set_pointer(p, v) \ + do { \ + __typeof__(*(p)) _________pv = (v); \ + (void) rcu_set_pointer_sym(URCU_FORCE_CAST(void **, p), \ + _________pv); \ + } while (0) + +#endif /* !(defined(_LGPL_SOURCE) || defined(URCU_INLINE_SMALL_FUNCTIONS)) */ + +/* + * void rcu_assign_pointer(type *ptr, type *new) + * + * Same as rcu_set_pointer, but takes the pointer to assign to rather than its + * address as first parameter. Provided for compatibility with the Linux kernel + * RCU semantic. + */ +#define rcu_assign_pointer(p, v) rcu_set_pointer((&p), (v)) + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_POINTER_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/rcuhlist.h b/external/lgpl2/userspace-rcu/dist/include/urcu/rcuhlist.h new file mode 100644 index 0000000000000..6dab12a8d062c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/rcuhlist.h @@ -0,0 +1,68 @@ +// SPDX-FileCopyrightText: 2002 Free Software Foundation, Inc. +// SPDX-FileCopyrightText: 2009 Pierre-Marc Fournier +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * (originally part of the GNU C Library) + * Contributed by Ulrich Drepper , 2002. + */ + +#ifndef _URCU_RCUHLIST_H +#define _URCU_RCUHLIST_H + +#include +#include +#include + +/* Add new element at the head of the list. */ +static inline +void cds_hlist_add_head_rcu(struct cds_hlist_node *newp, + struct cds_hlist_head *head) +{ + newp->next = head->next; + newp->prev = (struct cds_hlist_node *)head; + if (head->next) + head->next->prev = newp; + rcu_assign_pointer(head->next, newp); +} + +/* Remove element from list. */ +static inline +void cds_hlist_del_rcu(struct cds_hlist_node *elem) +{ + if (elem->next) + elem->next->prev = elem->prev; + CMM_STORE_SHARED(elem->prev->next, elem->next); +} + +/* + * Iterate through elements of the list. + * This must be done while rcu_read_lock() is held. + */ +#define cds_hlist_for_each_rcu(pos, head) \ + for (pos = rcu_dereference((head)->next); (pos) != NULL; \ + pos = rcu_dereference((pos)->next)) + +/* + * cds_hlist_for_each_entry_rcu takes 4 arguments, while the Linux + * kernel API only takes 3. + * We implement cds_hlist_for_each_entry_rcu_2() to follow the Linux + * kernel APIs. + */ +#define cds_hlist_for_each_entry_rcu(entry, pos, head, member) \ + for (pos = rcu_dereference((head)->next), \ + entry = cds_hlist_entry(pos, __typeof__(*(entry)), member); \ + (pos) != NULL; \ + pos = rcu_dereference((pos)->next), \ + entry = cds_hlist_entry(pos, __typeof__(*(entry)), member)) + +#define cds_hlist_for_each_entry_rcu_2(entry, head, member) \ + for (entry = cds_hlist_entry_safe(rcu_dereference((head)->next), \ + __typeof__(*(entry)), member); \ + (entry) != NULL; \ + entry = cds_hlist_entry_safe(rcu_dereference((entry)->member.next), \ + __typeof__(*(entry)), member)) + +#endif /* _URCU_RCUHLIST_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/rculfhash.h b/external/lgpl2/userspace-rcu/dist/include/urcu/rculfhash.h new file mode 100644 index 0000000000000..69a251c29c5e5 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/rculfhash.h @@ -0,0 +1,630 @@ +// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2011 Lai Jiangshan +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_RCULFHASH_H +#define _URCU_RCULFHASH_H + +/* + * Userspace RCU library - Lock-Free RCU Hash Table + * + * For use with URCU_API_MAP (API mapping of liburcu), include this file + * _after_ including your URCU flavor. + */ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct cds_lfht; + +/* + * cds_lfht_node: Contains the next pointers and reverse-hash + * value required for lookup and traversal of the hash table. + * + * struct cds_lfht_node should be aligned on 8-bytes boundaries because + * the three lower bits are used as flags. It is worth noting that the + * information contained within these three bits could be represented on + * two bits by re-using the same bit for REMOVAL_OWNER_FLAG and + * BUCKET_FLAG. This can be done if we ensure that no iterator nor + * updater check the BUCKET_FLAG after it detects that the REMOVED_FLAG + * is set. Given the minimum size of struct cds_lfht_node is 8 bytes on + * 32-bit architectures, we choose to go for simplicity and reserve + * three bits. + * + * struct cds_lfht_node can be embedded into a structure (as a field). + * caa_container_of() can be used to get the structure from the struct + * cds_lfht_node after a lookup. + * + * The structure which embeds it typically holds the key (or key-value + * pair) of the object. The caller code is responsible for calculation + * of the hash value for cds_lfht APIs. + */ +struct cds_lfht_node { + struct cds_lfht_node *next; /* ptr | REMOVAL_OWNER_FLAG | BUCKET_FLAG | REMOVED_FLAG */ + unsigned long reverse_hash; +} __attribute__((aligned(8))); + +/* cds_lfht_iter: Used to track state while traversing a hash chain. */ +struct cds_lfht_iter { + struct cds_lfht_node *node, *next; + /* + * For debugging purposes, build both API users and rculfhash + * library with CDS_LFHT_ITER_DEBUG defined. This enables extra + * consistency checks for calls to a cds_lfht_next() or + * cds_lfht_next_duplicate() after the iterator has been + * re-purposed to iterate on a different hash table. This is a + * common programming mistake when performing hash table lookup + * nested in a hash table traversal. + */ +#ifdef CONFIG_CDS_LFHT_ITER_DEBUG + struct cds_lfht *lfht; +#endif +}; + +/* + * cds_lfht_alloc: Callbacks if we want to use custom memory allocator. + */ +struct cds_lfht_alloc { + void *(*malloc)(void *state, size_t size); + void *(*calloc)(void *state, size_t nmemb, size_t size); + void *(*realloc)(void *state, void *ptr, size_t size); + void *(*aligned_alloc)(void *state, size_t alignment, size_t size); + void (*free)(void *state, void *ptr); + void *state; +}; + +static inline +struct cds_lfht_node *cds_lfht_iter_get_node(const struct cds_lfht_iter *iter) +{ + return iter->node; +} + +struct rcu_flavor_struct; + +/* + * Caution ! + * Ensure reader and writer threads are registered as urcu readers. + */ + +typedef int (*cds_lfht_match_fct)(struct cds_lfht_node *node, const void *key); + +/* + * cds_lfht_node_init - initialize a hash table node + * @node: the node to initialize. + * + * This function is kept to be eventually used for debugging purposes + * (detection of memory corruption). + */ +static inline +void cds_lfht_node_init(struct cds_lfht_node *node __attribute__((unused))) +{ +} + +/* + * cds_lfht_node_init_deleted - initialize a hash table node to "removed" state + * @node: the node to initialize. + * + * Initialize the node such that cds_lfht_is_node_deleted() can be used + * on the node before it is added to a hash table. + */ +extern +void cds_lfht_node_init_deleted(struct cds_lfht_node *node); + +/* + * Hash table creation flags. + */ +enum { + CDS_LFHT_AUTO_RESIZE = (1U << 0), + CDS_LFHT_ACCOUNTING = (1U << 1), +}; + +struct cds_lfht_mm_type { + struct cds_lfht *(*alloc_cds_lfht)(unsigned long min_nr_alloc_buckets, + unsigned long max_nr_buckets, const struct cds_lfht_alloc *alloc); + void (*alloc_bucket_table)(struct cds_lfht *ht, unsigned long order); + void (*free_bucket_table)(struct cds_lfht *ht, unsigned long order); + struct cds_lfht_node *(*bucket_at)(struct cds_lfht *ht, + unsigned long index); +}; + +extern const struct cds_lfht_mm_type cds_lfht_mm_order; +extern const struct cds_lfht_mm_type cds_lfht_mm_chunk; +extern const struct cds_lfht_mm_type cds_lfht_mm_mmap; + +/* + * _cds_lfht_new - API used by cds_lfht_new wrapper. Do not use directly. + */ +extern +struct cds_lfht *_cds_lfht_new(unsigned long init_size, + unsigned long min_nr_alloc_buckets, + unsigned long max_nr_buckets, + int flags, + const struct cds_lfht_mm_type *mm, + const struct rcu_flavor_struct *flavor, + pthread_attr_t *attr); + +/* + * _cds_lfht_new_with_alloc - API used by cds_lfht_new_with_flavor_alloc. + */ +extern +struct cds_lfht *_cds_lfht_new_with_alloc(unsigned long init_size, + unsigned long min_nr_alloc_buckets, + unsigned long max_nr_buckets, + int flags, + const struct cds_lfht_mm_type *mm, + const struct rcu_flavor_struct *flavor, + const struct cds_lfht_alloc *alloc, + pthread_attr_t *attr); + +/* + * cds_lfht_new_flavor - allocate a hash table tied to a RCU flavor. + * @init_size: number of buckets to allocate initially. Must be power of two. + * @min_nr_alloc_buckets: the minimum number of allocated buckets. + * (must be power of two) + * @max_nr_buckets: the maximum number of hash table buckets allowed. + * (must be power of two, 0 is accepted, means + * "infinite") + * @flavor: flavor of liburcu to use to synchronize the hash table + * @flags: hash table creation flags (can be combined with bitwise or: '|'). + * 0: no flags. + * CDS_LFHT_AUTO_RESIZE: automatically resize hash table. + * CDS_LFHT_ACCOUNTING: count the number of node addition + * and removal in the table + * @attr: optional resize worker thread attributes. NULL for default. + * + * Return NULL on error. + * Note: the RCU flavor must be already included before the hash table header. + * + * The programmer is responsible for ensuring that resize operation has a + * priority equal to hash table updater threads. It should be performed by + * specifying the appropriate priority in the pthread "attr" argument, and, + * for CDS_LFHT_AUTO_RESIZE, by ensuring that call_rcu worker threads also have + * this priority level. Having lower priority for call_rcu and resize threads + * does not pose any correctness issue, but the resize operations could be + * starved by updates, thus leading to long hash table bucket chains. + * Threads calling cds_lfht_new are NOT required to be registered RCU + * read-side threads. It can be called very early. (e.g. before RCU is + * initialized) + */ +static inline +struct cds_lfht *cds_lfht_new_flavor(unsigned long init_size, + unsigned long min_nr_alloc_buckets, + unsigned long max_nr_buckets, + int flags, + const struct rcu_flavor_struct *flavor, + pthread_attr_t *attr) +{ + return _cds_lfht_new(init_size, min_nr_alloc_buckets, max_nr_buckets, + flags, NULL, flavor, attr); +} + +/* + * cds_lfht_new_with_flavor_alloc - allocate a hash table tied to a RCU flavor. + * @init_size: number of buckets to allocate initially. Must be power of two. + * @min_nr_alloc_buckets: the minimum number of allocated buckets. + * (must be power of two) + * @max_nr_buckets: the maximum number of hash table buckets allowed. + * (must be power of two, 0 is accepted, means + * "infinite") + * @flavor: flavor of liburcu to use to synchronize the hash table + * @alloc: Custom memory allocator for hash table memory management. + * NULL for default. If a custom allocator is used, then + * the whole interface of struct cds_lfht_alloc must be implemented. + * @flags: hash table creation flags (can be combined with bitwise or: '|'). + * 0: no flags. + * CDS_LFHT_AUTO_RESIZE: automatically resize hash table. + * CDS_LFHT_ACCOUNTING: count the number of node addition + * and removal in the table + * @attr: optional resize worker thread attributes. NULL for default. + * + * Return NULL on error. + * Note: the RCU flavor must be already included before the hash table header. + * + * The programmer is responsible for ensuring that resize operation has a + * priority equal to hash table updater threads. It should be performed by + * specifying the appropriate priority in the pthread "attr" argument, and, + * for CDS_LFHT_AUTO_RESIZE, by ensuring that call_rcu worker threads also have + * this priority level. Having lower priority for call_rcu and resize threads + * does not pose any correctness issue, but the resize operations could be + * starved by updates, thus leading to long hash table bucket chains. + * Threads calling cds_lfht_new are NOT required to be registered RCU + * read-side threads. It can be called very early. (e.g. before RCU is + * initialized) + */ +static inline +struct cds_lfht *cds_lfht_new_with_flavor_alloc(unsigned long init_size, + unsigned long min_nr_alloc_buckets, + unsigned long max_nr_buckets, + int flags, + const struct rcu_flavor_struct *flavor, + const struct cds_lfht_alloc *alloc, + pthread_attr_t *attr) +{ + return _cds_lfht_new_with_alloc(init_size, min_nr_alloc_buckets, max_nr_buckets, + flags, NULL, flavor, alloc, attr); +} + + +#ifdef URCU_API_MAP +/* + * cds_lfht_new - allocate a hash table. + * @init_size: number of buckets to allocate initially. Must be power of two. + * @min_nr_alloc_buckets: the minimum number of allocated buckets. + * (must be power of two) + * @max_nr_buckets: the maximum number of hash table buckets allowed. + * (must be power of two, 0 is accepted, means + * "infinite") + * @flags: hash table creation flags (can be combined with bitwise or: '|'). + * 0: no flags. + * CDS_LFHT_AUTO_RESIZE: automatically resize hash table. + * CDS_LFHT_ACCOUNTING: count the number of node addition + * and removal in the table + * @attr: optional resize worker thread attributes. NULL for default. + * + * Return NULL on error. + * Note: the RCU flavor must be already included before the hash table header. + * + * The programmer is responsible for ensuring that resize operation has a + * priority equal to hash table updater threads. It should be performed by + * specifying the appropriate priority in the pthread "attr" argument, and, + * for CDS_LFHT_AUTO_RESIZE, by ensuring that call_rcu worker threads also have + * this priority level. Having lower priority for call_rcu and resize threads + * does not pose any correctness issue, but the resize operations could be + * starved by updates, thus leading to long hash table bucket chains. + * Threads calling cds_lfht_new are NOT required to be registered RCU + * read-side threads. It can be called very early. (e.g. before RCU is + * initialized) + */ +static inline +struct cds_lfht *cds_lfht_new(unsigned long init_size, + unsigned long min_nr_alloc_buckets, + unsigned long max_nr_buckets, + int flags, + pthread_attr_t *attr) +{ + return _cds_lfht_new(init_size, min_nr_alloc_buckets, max_nr_buckets, + flags, NULL, &rcu_flavor, attr); +} +#endif /* URCU_API_MAP */ + +/* + * cds_lfht_destroy - destroy a hash table. + * @ht: the hash table to destroy. + * @attr: (output) resize worker thread attributes, as received by cds_lfht_new. + * The caller will typically want to free this pointer if dynamically + * allocated. The attr point can be NULL if the caller does not + * need to be informed of the value passed to cds_lfht_new(). + * + * Return 0 on success, negative error value on error. + + * Threads calling this API need to be registered RCU read-side threads. + * + * Prior to liburcu 0.10: + * - cds_lfht_destroy should *not* be called from a RCU read-side + * critical section. It should *not* be called from a call_rcu thread + * context neither. + * + * Starting from liburcu 0.10, rculfhash implements its own worker + * thread to handle resize operations, which removes the above RCU + * read-side critical section requirement on cds_lfht_destroy. + */ +extern +int cds_lfht_destroy(struct cds_lfht *ht, pthread_attr_t **attr); + +/* + * cds_lfht_count_nodes - count the number of nodes in the hash table. + * @ht: the hash table. + * @split_count_before: sample the node count split-counter before traversal. + * @count: traverse the hash table, count the number of nodes observed. + * @split_count_after: sample the node count split-counter after traversal. + * + * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. + */ +extern +void cds_lfht_count_nodes(struct cds_lfht *ht, + long *split_count_before, + unsigned long *count, + long *split_count_after); + +/* + * cds_lfht_lookup - lookup a node by key. + * @ht: the hash table. + * @hash: the key hash. + * @match: the key match function. + * @key: the current node key. + * @iter: node, if found (output). *iter->node set to NULL if not found. + * + * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. + * This function acts as a rcu_dereference() to read the node pointer. + */ +extern +void cds_lfht_lookup(struct cds_lfht *ht, unsigned long hash, + cds_lfht_match_fct match, const void *key, + struct cds_lfht_iter *iter); + +/* + * cds_lfht_next_duplicate - get the next item with same key, after iterator. + * @ht: the hash table. + * @match: the key match function. + * @key: the current node key. + * @iter: input: current iterator. + * output: node, if found. *iter->node set to NULL if not found. + * + * Uses an iterator initialized by a lookup or traversal. Important: the + * iterator _needs_ to be initialized before calling + * cds_lfht_next_duplicate. + * Sets *iter-node to the following node with same key. + * Sets *iter->node to NULL if no following node exists with same key. + * RCU read-side lock must be held across cds_lfht_lookup and + * cds_lfht_next calls, and also between cds_lfht_next calls using the + * node returned by a previous cds_lfht_next. + * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. + * This function acts as a rcu_dereference() to read the node pointer. + */ +extern +void cds_lfht_next_duplicate(struct cds_lfht *ht, + cds_lfht_match_fct match, const void *key, + struct cds_lfht_iter *iter); + +/* + * cds_lfht_first - get the first node in the table. + * @ht: the hash table. + * @iter: First node, if exists (output). *iter->node set to NULL if not found. + * + * Output in "*iter". *iter->node set to NULL if table is empty. + * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. + * This function acts as a rcu_dereference() to read the node pointer. + */ +extern +void cds_lfht_first(struct cds_lfht *ht, struct cds_lfht_iter *iter); + +/* + * cds_lfht_next - get the next node in the table. + * @ht: the hash table. + * @iter: input: current iterator. + * output: next node, if exists. *iter->node set to NULL if not found. + * + * Input/Output in "*iter". *iter->node set to NULL if *iter was + * pointing to the last table node. + * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. + * This function acts as a rcu_dereference() to read the node pointer. + */ +extern +void cds_lfht_next(struct cds_lfht *ht, struct cds_lfht_iter *iter); + +/* + * cds_lfht_add - add a node to the hash table. + * @ht: the hash table. + * @hash: the key hash. + * @node: the node to add. + * + * This function supports adding redundant keys into the table. + * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. + * This function issues a full memory barrier before and after its + * atomic commit. + */ +extern +void cds_lfht_add(struct cds_lfht *ht, unsigned long hash, + struct cds_lfht_node *node); + +/* + * cds_lfht_add_unique - add a node to hash table, if key is not present. + * @ht: the hash table. + * @hash: the node's hash. + * @match: the key match function. + * @key: the node's key. + * @node: the node to try adding. + * + * Return the node added upon success. + * Return the unique node already present upon failure. If + * cds_lfht_add_unique fails, the node passed as parameter should be + * freed by the caller. In this case, the caller does NOT need to wait + * for a grace period before freeing or re-using the node. + * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. + * + * The semantic of this function is that if only this function is used + * to add keys into the table, no duplicated keys should ever be + * observable in the table. The same guarantee apply for combination of + * add_unique and add_replace (see below). + * + * Upon success, this function issues a full memory barrier before and + * after its atomic commit. Upon failure, this function acts like a + * simple lookup operation: it acts as a rcu_dereference() to read the + * node pointer. The failure case does not guarantee any other memory + * barrier. + */ +extern +struct cds_lfht_node *cds_lfht_add_unique(struct cds_lfht *ht, + unsigned long hash, + cds_lfht_match_fct match, + const void *key, + struct cds_lfht_node *node); + +/* + * cds_lfht_add_replace - replace or add a node within hash table. + * @ht: the hash table. + * @hash: the node's hash. + * @match: the key match function. + * @key: the node's key. + * @node: the node to add. + * + * Return the node replaced upon success. If no node matching the key + * was present, return NULL, which also means the operation succeeded. + * This replacement operation should never fail. + * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. + * After successful replacement, a grace period must be waited for before + * freeing or re-using the memory reserved for the returned node. + * + * The semantic of replacement vs lookups and traversals is the + * following: if lookups and traversals are performed between a key + * unique insertion and its removal, we guarantee that the lookups and + * traversals will always find exactly one instance of the key if it is + * replaced concurrently with the lookups. + * + * Providing this semantic allows us to ensure that replacement-only + * schemes will never generate duplicated keys. It also allows us to + * guarantee that a combination of add_replace and add_unique updates + * will never generate duplicated keys. + * + * This function issues a full memory barrier before and after its + * atomic commit. + */ +extern +struct cds_lfht_node *cds_lfht_add_replace(struct cds_lfht *ht, + unsigned long hash, + cds_lfht_match_fct match, + const void *key, + struct cds_lfht_node *node); + +/* + * cds_lfht_replace - replace a node pointed to by iter within hash table. + * @ht: the hash table. + * @old_iter: the iterator position of the node to replace. + * @hash: the node's hash. + * @match: the key match function. + * @key: the node's key. + * @new_node: the new node to use as replacement. + * + * Return 0 if replacement is successful, negative value otherwise. + * Replacing a NULL old node or an already removed node will fail with + * -ENOENT. + * If the hash or value of the node to replace and the new node differ, + * this function returns -EINVAL without proceeding to the replacement. + * Old node can be looked up with cds_lfht_lookup and cds_lfht_next. + * RCU read-side lock must be held between lookup and replacement. + * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. + * After successful replacement, a grace period must be waited for before + * freeing or re-using the memory reserved for the old node (which can + * be accessed with cds_lfht_iter_get_node). + * + * The semantic of replacement vs lookups is the same as + * cds_lfht_add_replace(). + * + * Upon success, this function issues a full memory barrier before and + * after its atomic commit. Upon failure, this function does not issue + * any memory barrier. + */ +extern +int cds_lfht_replace(struct cds_lfht *ht, + struct cds_lfht_iter *old_iter, + unsigned long hash, + cds_lfht_match_fct match, + const void *key, + struct cds_lfht_node *new_node); + +/* + * cds_lfht_del - remove node pointed to by iterator from hash table. + * @ht: the hash table. + * @node: the node to delete. + * + * Return 0 if the node is successfully removed, negative value + * otherwise. + * Deleting a NULL node or an already removed node will fail with a + * negative value. + * Node can be looked up with cds_lfht_lookup and cds_lfht_next, + * followed by use of cds_lfht_iter_get_node. + * RCU read-side lock must be held between lookup and removal. + * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. + * After successful removal, a grace period must be waited for before + * freeing or re-using the memory reserved for old node (which can be + * accessed with cds_lfht_iter_get_node). + * Upon success, this function issues a full memory barrier before and + * after its atomic commit. Upon failure, this function does not issue + * any memory barrier. + */ +extern +int cds_lfht_del(struct cds_lfht *ht, struct cds_lfht_node *node); + +/* + * cds_lfht_is_node_deleted - query whether a node is removed from hash table. + * + * Return non-zero if the node is deleted from the hash table, 0 + * otherwise. + * Node can be looked up with cds_lfht_lookup and cds_lfht_next, + * followed by use of cds_lfht_iter_get_node. + * RCU read-side lock must be held between lookup and call to this + * function. + * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. + * This function does not issue any memory barrier. + */ +extern +int cds_lfht_is_node_deleted(const struct cds_lfht_node *node); + +/* + * cds_lfht_resize - Force a hash table resize + * @ht: the hash table. + * @new_size: update to this hash table size. + * + * Threads calling this API need to be registered RCU read-side threads. + * This function does not (necessarily) issue memory barriers. + * cds_lfht_resize should *not* be called from a RCU read-side critical + * section. + */ +extern +void cds_lfht_resize(struct cds_lfht *ht, unsigned long new_size); + +/* + * Note: it is safe to perform element removal (del), replacement, or + * any hash table update operation during any of the following hash + * table traversals. + * These functions act as rcu_dereference() to read the node pointers. + */ +#define cds_lfht_for_each(ht, iter, node) \ + for (cds_lfht_first(ht, iter), \ + node = cds_lfht_iter_get_node(iter); \ + node != NULL; \ + cds_lfht_next(ht, iter), \ + node = cds_lfht_iter_get_node(iter)) + +#define cds_lfht_for_each_duplicate(ht, hash, match, key, iter, node) \ + for (cds_lfht_lookup(ht, hash, match, key, iter), \ + node = cds_lfht_iter_get_node(iter); \ + node != NULL; \ + cds_lfht_next_duplicate(ht, match, key, iter), \ + node = cds_lfht_iter_get_node(iter)) + +#define cds_lfht_entry(ptr, type, member) \ + caa_container_of_check_null(ptr, type, member) + +#define cds_lfht_for_each_entry(ht, iter, pos, member) \ + for (cds_lfht_first(ht, iter), \ + pos = cds_lfht_entry(cds_lfht_iter_get_node(iter), \ + __typeof__(*(pos)), member); \ + pos != NULL; \ + cds_lfht_next(ht, iter), \ + pos = cds_lfht_entry(cds_lfht_iter_get_node(iter), \ + __typeof__(*(pos)), member)) + +#define cds_lfht_for_each_entry_duplicate(ht, hash, match, key, \ + iter, pos, member) \ + for (cds_lfht_lookup(ht, hash, match, key, iter), \ + pos = cds_lfht_entry(cds_lfht_iter_get_node(iter), \ + __typeof__(*(pos)), member); \ + pos != NULL; \ + cds_lfht_next_duplicate(ht, match, key, iter), \ + pos = cds_lfht_entry(cds_lfht_iter_get_node(iter), \ + __typeof__(*(pos)), member)) + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_RCULFHASH_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/rculfqueue.h b/external/lgpl2/userspace-rcu/dist/include/urcu/rculfqueue.h new file mode 100644 index 0000000000000..0e3c9109a9288 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/rculfqueue.h @@ -0,0 +1,76 @@ +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_RCULFQUEUE_H +#define _URCU_RCULFQUEUE_H + +/* + * Userspace RCU library - Lock-Free RCU Queue + */ + + +#ifdef __cplusplus +extern "C" { +#endif + +struct cds_lfq_queue_rcu; +struct rcu_head; + +struct cds_lfq_node_rcu { + struct cds_lfq_node_rcu *next; + int dummy; +}; + +struct cds_lfq_queue_rcu { + struct cds_lfq_node_rcu *head, *tail; + void (*queue_call_rcu)(struct rcu_head *head, + void (*func)(struct rcu_head *head)); +}; + +#ifdef _LGPL_SOURCE + +#include + +#define cds_lfq_node_init_rcu _cds_lfq_node_init_rcu +#define cds_lfq_init_rcu _cds_lfq_init_rcu +#define cds_lfq_destroy_rcu _cds_lfq_destroy_rcu +#define cds_lfq_enqueue_rcu _cds_lfq_enqueue_rcu +#define cds_lfq_dequeue_rcu _cds_lfq_dequeue_rcu + +#else /* !_LGPL_SOURCE */ + +extern void cds_lfq_node_init_rcu(struct cds_lfq_node_rcu *node); +extern void cds_lfq_init_rcu(struct cds_lfq_queue_rcu *q, + void queue_call_rcu(struct rcu_head *head, + void (*func)(struct rcu_head *head))); +/* + * The queue should be emptied before calling destroy. + * + * Return 0 on success, -EPERM if queue is not empty. + */ +extern int cds_lfq_destroy_rcu(struct cds_lfq_queue_rcu *q); + +/* + * Should be called under rcu read lock critical section. + */ +extern void cds_lfq_enqueue_rcu(struct cds_lfq_queue_rcu *q, + struct cds_lfq_node_rcu *node); + +/* + * Should be called under rcu read lock critical section. + * + * The caller must wait for a grace period to pass before freeing the returned + * node or modifying the cds_lfq_node_rcu structure. + * Returns NULL if queue is empty. + */ +extern +struct cds_lfq_node_rcu *cds_lfq_dequeue_rcu(struct cds_lfq_queue_rcu *q); + +#endif /* !_LGPL_SOURCE */ + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_RCULFQUEUE_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/rculfstack.h b/external/lgpl2/userspace-rcu/dist/include/urcu/rculfstack.h new file mode 100644 index 0000000000000..b0f4221bf2d29 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/rculfstack.h @@ -0,0 +1,86 @@ +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_RCULFSTACK_H +#define _URCU_RCULFSTACK_H + +/* + * Userspace RCU library - Lock-Free RCU Stack + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef CDS_LFS_RCU_DEPRECATED +#define CDS_LFS_RCU_DEPRECATED \ + CDS_DEPRECATED("urcu/rculfstack.h is deprecated. Please use urcu/lfstack.h instead.") +#endif + +struct cds_lfs_node_rcu { + struct cds_lfs_node_rcu *next; +}; + +struct cds_lfs_stack_rcu { + struct cds_lfs_node_rcu *head; +}; + +#ifdef _LGPL_SOURCE + +#include + +static inline CDS_LFS_RCU_DEPRECATED +void cds_lfs_node_init_rcu(struct cds_lfs_node_rcu *node) +{ + _cds_lfs_node_init_rcu(node); +} + +static inline +void cds_lfs_init_rcu(struct cds_lfs_stack_rcu *s) +{ + _cds_lfs_init_rcu(s); +} + +static inline CDS_LFS_RCU_DEPRECATED +int cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s, + struct cds_lfs_node_rcu *node) +{ + return _cds_lfs_push_rcu(s, node); +} + +static inline CDS_LFS_RCU_DEPRECATED +struct cds_lfs_node_rcu *cds_lfs_pop_rcu(struct cds_lfs_stack_rcu *s) +{ + return _cds_lfs_pop_rcu(s); +} + +#else /* !_LGPL_SOURCE */ + +extern CDS_LFS_RCU_DEPRECATED +void cds_lfs_node_init_rcu(struct cds_lfs_node_rcu *node); +extern CDS_LFS_RCU_DEPRECATED +void cds_lfs_init_rcu(struct cds_lfs_stack_rcu *s); +extern CDS_LFS_RCU_DEPRECATED +int cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s, + struct cds_lfs_node_rcu *node); + +/* + * Should be called under rcu read lock critical section. + * + * The caller must wait for a grace period to pass before freeing the returned + * node or modifying the cds_lfs_node_rcu structure. + * Returns NULL if stack is empty. + */ +extern CDS_LFS_RCU_DEPRECATED +struct cds_lfs_node_rcu *cds_lfs_pop_rcu(struct cds_lfs_stack_rcu *s); + +#endif /* !_LGPL_SOURCE */ + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_RCULFSTACK_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/rculist.h b/external/lgpl2/userspace-rcu/dist/include/urcu/rculist.h new file mode 100644 index 0000000000000..9cd0a37de5927 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/rculist.h @@ -0,0 +1,78 @@ +// SPDX-FileCopyrightText: Free Software Foundation, Inc. +// SPDX-FileCopyrightText: 2009 Pierre-Marc Fournier +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * (originally part of the GNU C Library) + * Contributed by Ulrich Drepper , 2002. + */ + +#ifndef _URCU_RCULIST_H +#define _URCU_RCULIST_H + +#include +#include +#include + +/* Add new element at the head of the list. */ +static inline +void cds_list_add_rcu(struct cds_list_head *newp, struct cds_list_head *head) +{ + newp->next = head->next; + newp->prev = head; + head->next->prev = newp; + rcu_assign_pointer(head->next, newp); +} + +/* Add new element at the tail of the list. */ +static inline +void cds_list_add_tail_rcu(struct cds_list_head *newp, + struct cds_list_head *head) +{ + newp->next = head; + newp->prev = head->prev; + rcu_assign_pointer(head->prev->next, newp); + head->prev = newp; +} + +/* + * Replace an old entry atomically with respect to concurrent RCU + * traversal. Mutual exclusion against concurrent updates is required + * though. + */ +static inline +void cds_list_replace_rcu(struct cds_list_head *old, struct cds_list_head *_new) +{ + _new->next = old->next; + _new->prev = old->prev; + rcu_assign_pointer(_new->prev->next, _new); + _new->next->prev = _new; +} + +/* Remove element from list. */ +static inline +void cds_list_del_rcu(struct cds_list_head *elem) +{ + elem->next->prev = elem->prev; + CMM_STORE_SHARED(elem->prev->next, elem->next); +} + +/* + * Iteration through all elements of the list must be done while rcu_read_lock() + * is held. + */ + +/* Iterate forward over the elements of the list. */ +#define cds_list_for_each_rcu(pos, head) \ + for (pos = rcu_dereference((head)->next); (pos) != (head); \ + pos = rcu_dereference((pos)->next)) + +/* Iterate through elements of the list. */ +#define cds_list_for_each_entry_rcu(pos, head, member) \ + for (pos = cds_list_entry(rcu_dereference((head)->next), __typeof__(*(pos)), member); \ + &(pos)->member != (head); \ + pos = cds_list_entry(rcu_dereference((pos)->member.next), __typeof__(*(pos)), member)) + +#endif /* _URCU_RCULIST_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/ref.h b/external/lgpl2/userspace-rcu/dist/include/urcu/ref.h new file mode 100644 index 0000000000000..408cfe2cfd409 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/ref.h @@ -0,0 +1,96 @@ +// SPDX-FileCopyrightText: 2009 Novell Inc. +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-only + +#ifndef _URCU_REF_H +#define _URCU_REF_H + +/* + * Userspace RCU - Reference counting + * + * Author: Jan Blunck + */ + +#include +#include +#include +#include +#include + +struct urcu_ref { + long refcount; /* ATOMIC */ +}; + +static inline void urcu_ref_set(struct urcu_ref *ref, long val) +{ + uatomic_set(&ref->refcount, val); +} + +static inline void urcu_ref_init(struct urcu_ref *ref) +{ + urcu_ref_set(ref, 1); +} + +static inline bool __attribute__((warn_unused_result)) + urcu_ref_get_safe(struct urcu_ref *ref) +{ + long old, _new, res; + + old = uatomic_read(&ref->refcount); + for (;;) { + if (old == LONG_MAX) { + return false; /* Failure. */ + } + _new = old + 1; + res = uatomic_cmpxchg(&ref->refcount, old, _new); + if (res == old) { + return true; /* Success. */ + } + old = res; + } +} + +static inline void urcu_ref_get(struct urcu_ref *ref) +{ + if (!urcu_ref_get_safe(ref)) + abort(); +} + +static inline void urcu_ref_put(struct urcu_ref *ref, + void (*release)(struct urcu_ref *)) +{ + long res = uatomic_sub_return(&ref->refcount, 1); + urcu_posix_assert(res >= 0); + if (res == 0) + release(ref); +} + +/* + * urcu_ref_get_unless_zero + * + * Allows getting a reference atomically if the reference count is not + * zero. Returns true if the reference is taken, false otherwise. This + * needs to be used in conjunction with another synchronization + * technique (e.g. RCU or mutex) to ensure existence of the reference + * count. False is also returned in case incrementing the refcount would + * result in an overflow. + */ +static inline bool urcu_ref_get_unless_zero(struct urcu_ref *ref) +{ + long old, _new, res; + + old = uatomic_read(&ref->refcount); + for (;;) { + if (old == 0 || old == LONG_MAX) + return false; /* Failure. */ + _new = old + 1; + res = uatomic_cmpxchg(&ref->refcount, old, _new); + if (res == old) { + return true; /* Success. */ + } + old = res; + } +} + +#endif /* _URCU_REF_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/static/lfstack.h b/external/lgpl2/userspace-rcu/dist/include/urcu/static/lfstack.h new file mode 100644 index 0000000000000..22233d8d22b3d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/static/lfstack.h @@ -0,0 +1,319 @@ +// SPDX-FileCopyrightText: 2010-2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_STATIC_LFSTACK_H +#define _URCU_STATIC_LFSTACK_H + +/* + * Userspace RCU library - Lock-Free Stack + * + * TO BE INCLUDED ONLY IN LGPL-COMPATIBLE CODE. See urcu/lfstack.h for + * linking dynamically with the userspace rcu library. + */ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Lock-free stack. + * + * Stack implementing push, pop, pop_all operations, as well as iterator + * on the stack head returned by pop_all. + * + * Synchronization table: + * + * External synchronization techniques described in the API below is + * required between pairs marked with "X". No external synchronization + * required between pairs marked with "-". + * + * cds_lfs_push __cds_lfs_pop __cds_lfs_pop_all + * cds_lfs_push - - - + * __cds_lfs_pop - X X + * __cds_lfs_pop_all - X - + * + * cds_lfs_pop_blocking and cds_lfs_pop_all_blocking use an internal + * mutex to provide synchronization. + */ + +/* + * cds_lfs_node_init: initialize lock-free stack node. + */ +static inline +void _cds_lfs_node_init(struct cds_lfs_node *node __attribute__((unused))) +{ +} + +/* + * cds_lfs_init: initialize lock-free stack (with lock). Pair with + * cds_lfs_destroy(). + */ +static inline +void _cds_lfs_init(struct cds_lfs_stack *s) +{ + int ret; + + s->head = NULL; + ret = pthread_mutex_init(&s->lock, NULL); + urcu_posix_assert(!ret); +} + +/* + * cds_lfs_destroy: destroy lock-free stack (with lock). Pair with + * cds_lfs_init(). + */ +static inline +void _cds_lfs_destroy(struct cds_lfs_stack *s) +{ + int ret = pthread_mutex_destroy(&s->lock); + urcu_posix_assert(!ret); +} + +/* + * ___cds_lfs_init: initialize lock-free stack (without lock). + * Don't pair with any destroy function. + */ +static inline +void ___cds_lfs_init(struct __cds_lfs_stack *s) +{ + s->head = NULL; +} + +static inline +bool ___cds_lfs_empty_head(const struct cds_lfs_head *head) +{ + return head == NULL; +} + +/* + * cds_lfs_empty: return whether lock-free stack is empty. + * + * No memory barrier is issued. No mutual exclusion is required. + */ +static inline +bool _cds_lfs_empty(cds_lfs_stack_const_ptr_t s) +{ + return ___cds_lfs_empty_head(uatomic_load(&s._s->head, CMM_RELAXED)); +} + +/* + * cds_lfs_push: push a node into the stack. + * + * Does not require any synchronization with other push nor pop. + * + * Operations before push are consistent when observed after associated pop. + * + * Lock-free stack push is not subject to ABA problem, so no need to + * take the RCU read-side lock. Even if "head" changes between two + * uatomic_cmpxchg() invocations here (being popped, and then pushed + * again by one or more concurrent threads), the second + * uatomic_cmpxchg() invocation only cares about pushing a new entry at + * the head of the stack, ensuring consistency by making sure the new + * node->next is the same pointer value as the value replaced as head. + * It does not care about the content of the actual next node, so it can + * very well be reallocated between the two uatomic_cmpxchg(). + * + * We take the approach of expecting the stack to be usually empty, so + * we first try an initial uatomic_cmpxchg() on a NULL old_head, and + * retry if the old head was non-NULL (the value read by the first + * uatomic_cmpxchg() is used as old head for the following loop). The + * upside of this scheme is to minimize the amount of cacheline traffic, + * always performing an exclusive cacheline access, rather than doing + * non-exclusive followed by exclusive cacheline access (which would be + * required if we first read the old head value). This design decision + * might be revisited after more thorough benchmarking on various + * platforms. + * + * Returns 0 if the stack was empty prior to adding the node. + * Returns non-zero otherwise. + */ +static inline +bool _cds_lfs_push(cds_lfs_stack_ptr_t u_s, + struct cds_lfs_node *node) +{ + struct __cds_lfs_stack *s = u_s._s; + struct cds_lfs_head *head = NULL; + struct cds_lfs_head *new_head = + caa_container_of(node, struct cds_lfs_head, node); + + for (;;) { + struct cds_lfs_head *old_head = head; + + /* + * node->next is still private at this point, no need to + * perform a _CMM_STORE_SHARED(). + */ + node->next = &head->node; + /* + * uatomic_cmpxchg() implicit memory barrier orders earlier + * stores to node before publication. + */ + cmm_emit_legacy_smp_mb(); + head = uatomic_cmpxchg_mo(&s->head, old_head, new_head, + CMM_SEQ_CST, CMM_SEQ_CST); + if (old_head == head) + break; + } + return !___cds_lfs_empty_head(head); +} + +/* + * __cds_lfs_pop: pop a node from the stack. + * + * Returns NULL if stack is empty. + * + * Operations after pop are consistent when observed before associated push. + * + * __cds_lfs_pop needs to be synchronized using one of the following + * techniques: + * + * 1) Calling __cds_lfs_pop under rcu read lock critical section. + * Both __cds_lfs_pop and __cds_lfs_pop_all callers must wait for a + * grace period to pass before freeing the returned node or pushing + * the node back into the stack. It is valid to overwrite the content + * of cds_lfs_node immediately after __cds_lfs_pop and + * __cds_lfs_pop_all. No RCU read-side critical section is needed + * around __cds_lfs_pop_all. + * 2) Using mutual exclusion (e.g. mutexes) to protect __cds_lfs_pop + * and __cds_lfs_pop_all callers. + * 3) Ensuring that only ONE thread can call __cds_lfs_pop() and + * __cds_lfs_pop_all(). (multi-provider/single-consumer scheme). + */ +static inline +struct cds_lfs_node *___cds_lfs_pop(cds_lfs_stack_ptr_t u_s) +{ + struct __cds_lfs_stack *s = u_s._s; + + for (;;) { + struct cds_lfs_head *head, *next_head; + struct cds_lfs_node *next; + + head = uatomic_load(&s->head, CMM_CONSUME); + if (___cds_lfs_empty_head(head)) + return NULL; /* Empty stack */ + + /* + * Read head before head->next. Matches the implicit + * memory barrier before uatomic_cmpxchg() in + * cds_lfs_push. + */ + next = uatomic_load(&head->node.next, CMM_RELAXED); + next_head = caa_container_of(next, + struct cds_lfs_head, node); + if (uatomic_cmpxchg_mo(&s->head, head, next_head, + CMM_SEQ_CST, CMM_SEQ_CST) == head){ + cmm_emit_legacy_smp_mb(); + return &head->node; + } + /* busy-loop if head changed under us */ + } +} + +/* + * __cds_lfs_pop_all: pop all nodes from a stack. + * + * __cds_lfs_pop_all does not require any synchronization with other + * push, nor with other __cds_lfs_pop_all, but requires synchronization + * matching the technique used to synchronize __cds_lfs_pop: + * + * 1) If __cds_lfs_pop is called under rcu read lock critical section, + * both __cds_lfs_pop and __cds_lfs_pop_all callers must wait for a + * grace period to pass before freeing the returned node or pushing + * the node back into the stack. It is valid to overwrite the content + * of cds_lfs_node immediately after __cds_lfs_pop and + * __cds_lfs_pop_all. No RCU read-side critical section is needed + * around __cds_lfs_pop_all. + * 2) Using mutual exclusion (e.g. mutexes) to protect __cds_lfs_pop and + * __cds_lfs_pop_all callers. + * 3) Ensuring that only ONE thread can call __cds_lfs_pop() and + * __cds_lfs_pop_all(). (multi-provider/single-consumer scheme). + */ +static inline +struct cds_lfs_head *___cds_lfs_pop_all(cds_lfs_stack_ptr_t u_s) +{ + struct __cds_lfs_stack *s = u_s._s; + struct cds_lfs_head *head; + + /* + * Implicit memory barrier after uatomic_xchg() matches implicit + * memory barrier before uatomic_cmpxchg() in cds_lfs_push. It + * ensures that all nodes of the returned list are consistent. + * There is no need to issue memory barriers when iterating on + * the returned list, because the full memory barrier issued + * prior to each uatomic_cmpxchg, which each write to head, are + * taking care to order writes to each node prior to the full + * memory barrier after this uatomic_xchg(). + */ + head = uatomic_xchg_mo(&s->head, NULL, CMM_SEQ_CST); + cmm_emit_legacy_smp_mb(); + return head; +} + +/* + * cds_lfs_pop_lock: lock stack pop-protection mutex. + */ +static inline void _cds_lfs_pop_lock(struct cds_lfs_stack *s) +{ + int ret; + + ret = pthread_mutex_lock(&s->lock); + urcu_posix_assert(!ret); +} + +/* + * cds_lfs_pop_unlock: unlock stack pop-protection mutex. + */ +static inline void _cds_lfs_pop_unlock(struct cds_lfs_stack *s) +{ + int ret; + + ret = pthread_mutex_unlock(&s->lock); + urcu_posix_assert(!ret); +} + +/* + * Call __cds_lfs_pop with an internal pop mutex held. + */ +static inline +struct cds_lfs_node * +_cds_lfs_pop_blocking(struct cds_lfs_stack *s) +{ + struct cds_lfs_node *retnode; + cds_lfs_stack_ptr_t stack; + + _cds_lfs_pop_lock(s); + stack.s = s; + retnode = ___cds_lfs_pop(stack); + _cds_lfs_pop_unlock(s); + return retnode; +} + +/* + * Call __cds_lfs_pop_all with an internal pop mutex held. + */ +static inline +struct cds_lfs_head * +_cds_lfs_pop_all_blocking(struct cds_lfs_stack *s) +{ + struct cds_lfs_head *rethead; + cds_lfs_stack_ptr_t stack; + + _cds_lfs_pop_lock(s); + stack.s = s; + rethead = ___cds_lfs_pop_all(stack); + _cds_lfs_pop_unlock(s); + return rethead; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_STATIC_LFSTACK_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/static/pointer.h b/external/lgpl2/userspace-rcu/dist/include/urcu/static/pointer.h new file mode 100644 index 0000000000000..8b87b8344ecbe --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/static/pointer.h @@ -0,0 +1,257 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_POINTER_STATIC_H +#define _URCU_POINTER_STATIC_H + +/* + * Userspace RCU header. Operations on pointers. + * + * TO BE INCLUDED ONLY IN CODE THAT IS TO BE RECOMPILED ON EACH LIBURCU + * RELEASE. See urcu.h for linking dynamically with the userspace rcu library. + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * _rcu_dereference - reads (copy) a RCU-protected pointer to a local variable + * into a RCU read-side critical section. The pointer can later be safely + * dereferenced within the critical section. + * + * This ensures that the pointer copy is invariant thorough the whole critical + * section. + * + * Inserts memory barriers on architectures that require them (currently only + * Alpha) and documents which pointers are protected by RCU. + * + * With C standards prior to C11/C++11, the compiler memory barrier in + * CMM_LOAD_SHARED() ensures that value-speculative optimizations (e.g. + * VSS: Value Speculation Scheduling) does not perform the data read + * before the pointer read by speculating the value of the pointer. + * Correct ordering is ensured because the pointer is read as a volatile + * access. This acts as a global side-effect operation, which forbids + * reordering of dependent memory operations. + * + * With C standards C11/C++11, concerns about dependency-breaking + * optimizations are taken care of by the "memory_order_consume" atomic + * load. + * + * Use the gcc __atomic_load() rather than C11/C++11 atomic load + * explicit because the pointer used as input argument is a pointer, + * not an _Atomic type as required by C11/C++11. + * + * By defining URCU_DEREFERENCE_USE_VOLATILE, the user requires use of + * volatile access to implement rcu_dereference rather than + * memory_order_consume load from the C11/C++11 standards. + * + * CAUTION: If URCU_DEREFERENCE_USE_VOLATILE is defined, pointers comparisons + * _must_ be done using the `cmm_ptr_eq' static inline helper function to + * prevent the compiler optimizations from losing addresses dependencies, + * resulting in the loss of the publication guarantee. + * + * This may improve performance on weakly-ordered architectures where + * the compiler implements memory_order_consume as a + * memory_order_acquire, which is stricter than required by the + * standard. + * + * Note that using volatile accesses for rcu_dereference may cause + * LTO to generate incorrectly ordered code starting from C11/C++11. + * + * Should match rcu_assign_pointer() or rcu_xchg_pointer(). + * + * This macro is less than 10 lines long. The intent is that this macro + * meets the 10-line criterion in LGPL, allowing this function to be + * expanded directly in non-LGPL code. + */ +#ifdef URCU_DEREFERENCE_USE_VOLATILE +# define _rcu_dereference(p) \ + __extension__ \ + ({ \ + cmm_smp_rmc(); \ + CMM_ACCESS_ONCE(p); \ + }) +#else +# define _rcu_dereference(p) \ + uatomic_load(&(p), CMM_CONSUME) +#endif + +/** + * Compare pointers A and B, but prevent the compiler from using this knowledge + * for optimization. + * + * This may introduce some overhead. For example, compilers might allocate more + * register, resulting in register spilling. + * + * For example, in the following code, `cmm_ptr_eq' prevents the compiler from + * re-using the derefence of `a' at the first call of `do_func()' for the second + * call. If a simple equality comparison was used, the compiler could use the + * value of `global->x' across two RCU critical regions. + * + * struct work { + * long x; + * } + * + * struct work *global; + * + * void func(void) + * { + * struct work *a, *b; + * + * rcu_read_lock(); + * a = rcu_dereference(global); + * if (a) + * do_func(a->x); + * rcu_read_unlock(); + * + * some_stuff(); + * + * rcu_read_lock(); + * b = rcu_dereference(global); + * if (b && cmm_ptr_eq(a, b)) // force to use b->x and not a->x + * do_func(b->x); + * rcu_read_unlock(); + * } + * + * Consider what could happen if such compiler optimization was done while the + * following mutator exists. The mutator removes a `work' node that was + * previously stored in a global location by storing NULL. It then call + * rcu_synchronize() to ensure no readers can see the node. From there, a new + * work is created for the node and the node is commited with + * rcu_assign_pointer(), thus the same pointer is now visible to readers. This + * fictional mutator is purposely trying to create a ABA problem for the sake of + * the argument: + * + * void mutator(void) + * { + * struct work *work; + * + * work = global; + * rcu_assign_pointer(global, NULL); + * rcu_synchronize(); + * work->x = new_work(); + * rcu_assign_pointer(global, work); + * } + * + * Then, the following execution could happen, where the new work assigned is + * not executed. In other words, the compiler optimizations can introduce a ABA + * problem, defeating one of RCU's purposes. + * + * Worker: Mutator: + * let a, b let work = global + * let tmp + * rcu_read_lock() + * a = rcu_dereference(global) + * if (a) { + * tmp = a->x + * do_func(tmp) + * } + * rcu_read_unlock() + * do_stuff() ... + * ... rcu_assign_pointer(global, NULL) + * ... rcu_synchronize() + * ... work->x = new_work() + * ... rcu_assign_pointer(global, work) + * rcu_read_lock() + * b = rcu_dereference(global) + * if (b && (a == b)) // BUGGY !!! + * do_func(tmp) + * rcu_read_unlock() + * + * In other words, the publication guarantee is lost here. The store to + * `work->x' in the mutator is supposed to be observable by the second + * rcu_dereference() in the worker, because of the matching + * rcu_assign_pointer(). But due to the equality comparison, the compiler + * decides to reuse the prior rcu_dereference(). + */ +static inline int cmm_ptr_eq(const void *a, const void *b) +{ + _CMM_OPTIMIZER_HIDE_VAR(a); + _CMM_OPTIMIZER_HIDE_VAR(b); + + return a == b; +} + +/** + * _rcu_cmpxchg_pointer - same as rcu_assign_pointer, but tests if the pointer + * is as expected by "old". If succeeds, returns the previous pointer to the + * data structure, which can be safely freed after waiting for a quiescent state + * using synchronize_rcu(). If fails (unexpected value), returns old (which + * should not be freed !). + * + * uatomic_cmpxchg() acts as both release and acquire barriers on success. + * + * This macro is less than 10 lines long. The intent is that this macro + * meets the 10-line criterion in LGPL, allowing this function to be + * expanded directly in non-LGPL code. + */ +#define _rcu_cmpxchg_pointer(p, old, _new) \ + __extension__ \ + ({ \ + __typeof__(*p) _________pold = (old); \ + __typeof__(*p) _________pnew = (_new); \ + uatomic_cmpxchg_mo(p, _________pold, _________pnew, \ + CMM_SEQ_CST, CMM_RELAXED); \ + }); + +/** + * _rcu_xchg_pointer - same as rcu_assign_pointer, but returns the previous + * pointer to the data structure, which can be safely freed after waiting for a + * quiescent state using synchronize_rcu(). + * + * uatomic_xchg() acts as both release and acquire barriers. + * + * This macro is less than 10 lines long. The intent is that this macro + * meets the 10-line criterion in LGPL, allowing this function to be + * expanded directly in non-LGPL code. + */ +#define _rcu_xchg_pointer(p, v) \ + __extension__ \ + ({ \ + __typeof__(*p) _________pv = (v); \ + uatomic_xchg_mo(p, _________pv, \ + CMM_SEQ_CST); \ + }) + + +#define _rcu_set_pointer(p, v) \ + do { \ + __typeof__(*p) _________pv = (v); \ + uatomic_store(p, _________pv, \ + __builtin_constant_p(v) && (v) == NULL ? \ + CMM_RELAXED : CMM_RELEASE); \ + } while (0) + +/** + * _rcu_assign_pointer - assign (publicize) a pointer to a new data structure + * meant to be read by RCU read-side critical sections. Returns the assigned + * value. + * + * Documents which pointers will be dereferenced by RCU read-side critical + * sections and adds the required memory barriers on architectures requiring + * them. It also makes sure the compiler does not reorder code initializing the + * data structure before its publication. + * + * Should match rcu_dereference(). + * + * This macro is less than 10 lines long. The intent is that this macro + * meets the 10-line criterion in LGPL, allowing this function to be + * expanded directly in non-LGPL code. + */ +#define _rcu_assign_pointer(p, v) _rcu_set_pointer(&(p), v) + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_POINTER_STATIC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/static/rculfqueue.h b/external/lgpl2/userspace-rcu/dist/include/urcu/static/rculfqueue.h new file mode 100644 index 0000000000000..03c4ecdef76c6 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/static/rculfqueue.h @@ -0,0 +1,219 @@ +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_RCULFQUEUE_STATIC_H +#define _URCU_RCULFQUEUE_STATIC_H + +/* + * Userspace RCU library - Lock-Free RCU Queue + * + * TO BE INCLUDED ONLY IN LGPL-COMPATIBLE CODE. See rculfqueue.h for linking + * dynamically with the userspace rcu library. + */ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct cds_lfq_node_rcu_dummy { + struct cds_lfq_node_rcu parent; + struct rcu_head head; + struct cds_lfq_queue_rcu *q; +}; + +/* + * Lock-free RCU queue. Enqueue and dequeue operations hold a RCU read + * lock to deal with cmpxchg ABA problem. This queue is *not* circular: + * head points to the oldest node, tail points to the newest node. + * A dummy node is kept to ensure enqueue and dequeue can always proceed + * concurrently. Keeping a separate head and tail helps with large + * queues: enqueue and dequeue can proceed concurrently without + * wrestling for exclusive access to the same variables. + * + * Dequeue retry if it detects that it would be dequeueing the last node + * (it means a dummy node dequeue-requeue is in progress). This ensures + * that there is always at least one node in the queue. + * + * In the dequeue operation, we internally reallocate the dummy node + * upon dequeue/requeue and use call_rcu to free the old one after a + * grace period. + */ + +static inline +struct cds_lfq_node_rcu *make_dummy(struct cds_lfq_queue_rcu *q, + struct cds_lfq_node_rcu *next) +{ + struct cds_lfq_node_rcu_dummy *dummy; + + dummy = (struct cds_lfq_node_rcu_dummy *) + malloc(sizeof(struct cds_lfq_node_rcu_dummy)); + urcu_posix_assert(dummy); + dummy->parent.next = next; + dummy->parent.dummy = 1; + dummy->q = q; + return &dummy->parent; +} + +static inline +void free_dummy_cb(struct rcu_head *head) +{ + struct cds_lfq_node_rcu_dummy *dummy = + caa_container_of(head, struct cds_lfq_node_rcu_dummy, head); + free(dummy); +} + +static inline +void rcu_free_dummy(struct cds_lfq_node_rcu *node) +{ + struct cds_lfq_node_rcu_dummy *dummy; + + urcu_posix_assert(node->dummy); + dummy = caa_container_of(node, struct cds_lfq_node_rcu_dummy, parent); + dummy->q->queue_call_rcu(&dummy->head, free_dummy_cb); +} + +static inline +void free_dummy(struct cds_lfq_node_rcu *node) +{ + struct cds_lfq_node_rcu_dummy *dummy; + + urcu_posix_assert(node->dummy); + dummy = caa_container_of(node, struct cds_lfq_node_rcu_dummy, parent); + free(dummy); +} + +static inline +void _cds_lfq_node_init_rcu(struct cds_lfq_node_rcu *node) +{ + node->next = NULL; + node->dummy = 0; +} + +static inline +void _cds_lfq_init_rcu(struct cds_lfq_queue_rcu *q, + void queue_call_rcu(struct rcu_head *head, + void (*func)(struct rcu_head *head))) +{ + q->tail = make_dummy(q, NULL); + q->head = q->tail; + q->queue_call_rcu = queue_call_rcu; +} + +/* + * The queue should be emptied before calling destroy. + * + * Return 0 on success, -EPERM if queue is not empty. + */ +static inline +int _cds_lfq_destroy_rcu(struct cds_lfq_queue_rcu *q) +{ + struct cds_lfq_node_rcu *head; + + head = rcu_dereference(q->head); + if (!(head->dummy && head->next == NULL)) + return -EPERM; /* not empty */ + free_dummy(head); + return 0; +} + +/* + * Should be called under rcu read lock critical section. + */ +static inline +void _cds_lfq_enqueue_rcu(struct cds_lfq_queue_rcu *q, + struct cds_lfq_node_rcu *node) +{ + /* + * uatomic_cmpxchg() implicit memory barrier orders earlier stores to + * node before publication. + */ + for (;;) { + struct cds_lfq_node_rcu *tail, *next; + + tail = rcu_dereference(q->tail); + cmm_emit_legacy_smp_mb(); + next = uatomic_cmpxchg_mo(&tail->next, NULL, node, + CMM_SEQ_CST, CMM_SEQ_CST); + if (next == NULL) { + /* + * Tail was at the end of queue, we successfully + * appended to it. Now move tail (another + * enqueue might beat us to it, that's fine). + */ + (void) uatomic_cmpxchg_mo(&q->tail, tail, node, + CMM_SEQ_CST, CMM_SEQ_CST); + return; + } else { + /* + * Failure to append to current tail. + * Help moving tail further and retry. + */ + (void) uatomic_cmpxchg_mo(&q->tail, tail, next, + CMM_SEQ_CST, CMM_SEQ_CST); + continue; + } + } +} + +static inline +void enqueue_dummy(struct cds_lfq_queue_rcu *q) +{ + struct cds_lfq_node_rcu *node; + + /* We need to reallocate to protect from ABA. */ + node = make_dummy(q, NULL); + _cds_lfq_enqueue_rcu(q, node); +} + +/* + * Should be called under rcu read lock critical section. + * + * The caller must wait for a grace period to pass before freeing the returned + * node or modifying the cds_lfq_node_rcu structure. + * Returns NULL if queue is empty. + */ +static inline +struct cds_lfq_node_rcu *_cds_lfq_dequeue_rcu(struct cds_lfq_queue_rcu *q) +{ + for (;;) { + struct cds_lfq_node_rcu *head, *next; + + head = rcu_dereference(q->head); + next = rcu_dereference(head->next); + if (head->dummy && next == NULL) + return NULL; /* empty */ + /* + * We never, ever allow dequeue to get to a state where + * the queue is empty (we need at least one node in the + * queue). This is ensured by checking if the head next + * is NULL, which means we need to enqueue a dummy node + * before we can hope dequeuing anything. + */ + if (!next) { + enqueue_dummy(q); + next = rcu_dereference(head->next); + } + if (uatomic_cmpxchg_mo(&q->head, head, next, + CMM_SEQ_CST, CMM_SEQ_CST) != head) + continue; /* Concurrently pushed. */ + if (head->dummy) { + /* Free dummy after grace period. */ + rcu_free_dummy(head); + continue; /* try again */ + } + return head; + } +} + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_RCULFQUEUE_STATIC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/static/rculfstack.h b/external/lgpl2/userspace-rcu/dist/include/urcu/static/rculfstack.h new file mode 100644 index 0000000000000..b44b9e29fdbad --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/static/rculfstack.h @@ -0,0 +1,118 @@ +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_RCULFSTACK_STATIC_H +#define _URCU_RCULFSTACK_STATIC_H + +/* + * Userspace RCU library - Lock-Free RCU Stack + * + * TO BE INCLUDED ONLY IN LGPL-COMPATIBLE CODE. See rculfstack.h for linking + * dynamically with the userspace rcu library. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +static inline +void _cds_lfs_node_init_rcu(struct cds_lfs_node_rcu *node __attribute__((unused))) +{ +} + +static inline +void _cds_lfs_init_rcu(struct cds_lfs_stack_rcu *s) +{ + s->head = NULL; +} + +/* + * Lock-free stack push is not subject to ABA problem, so no need to + * take the RCU read-side lock. Even if "head" changes between two + * uatomic_cmpxchg() invocations here (being popped, and then pushed + * again by one or more concurrent threads), the second + * uatomic_cmpxchg() invocation only cares about pushing a new entry at + * the head of the stack, ensuring consistency by making sure the new + * node->next is the same pointer value as the value replaced as head. + * It does not care about the content of the actual next node, so it can + * very well be reallocated between the two uatomic_cmpxchg(). + * + * We take the approach of expecting the stack to be usually empty, so + * we first try an initial uatomic_cmpxchg() on a NULL old_head, and + * retry if the old head was non-NULL (the value read by the first + * uatomic_cmpxchg() is used as old head for the following loop). The + * upside of this scheme is to minimize the amount of cacheline traffic, + * always performing an exclusive cacheline access, rather than doing + * non-exclusive followed by exclusive cacheline access (which would be + * required if we first read the old head value). This design decision + * might be revisited after more thorough benchmarking on various + * platforms. + * + * Returns 0 if the stack was empty prior to adding the node. + * Returns non-zero otherwise. + */ +static inline +int _cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s, + struct cds_lfs_node_rcu *node) +{ + struct cds_lfs_node_rcu *head = NULL; + + for (;;) { + struct cds_lfs_node_rcu *old_head = head; + + node->next = head; + /* + * uatomic_cmpxchg() implicit memory barrier orders earlier + * stores to node before publication. + */ + cmm_emit_legacy_smp_mb(); + head = uatomic_cmpxchg_mo(&s->head, old_head, node, + CMM_SEQ_CST, CMM_SEQ_CST); + if (old_head == head) + break; + } + return (int) !!((unsigned long) head); +} + +/* + * Should be called under rcu read-side lock. + * + * The caller must wait for a grace period to pass before freeing the returned + * node or modifying the cds_lfs_node_rcu structure. + * Returns NULL if stack is empty. + */ +static inline +struct cds_lfs_node_rcu * +_cds_lfs_pop_rcu(struct cds_lfs_stack_rcu *s) +{ + for (;;) { + struct cds_lfs_node_rcu *head; + + head = rcu_dereference(s->head); + if (head) { + struct cds_lfs_node_rcu *next = rcu_dereference(head->next); + + if (uatomic_cmpxchg_mo(&s->head, head, next, + CMM_SEQ_CST, CMM_SEQ_CST) == head) { + cmm_emit_legacy_smp_mb(); + return head; + } else { + /* Concurrent modification. Retry. */ + continue; + } + } else { + /* Empty stack */ + return NULL; + } + } +} + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_RCULFSTACK_STATIC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-bp.h b/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-bp.h new file mode 100644 index 0000000000000..e660154094e7a --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-bp.h @@ -0,0 +1,203 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_BP_STATIC_H +#define _URCU_BP_STATIC_H + +/* + * Userspace RCU header. + * + * TO BE INCLUDED ONLY IN CODE THAT IS TO BE RECOMPILED ON EACH LIBURCU + * RELEASE. See urcu.h for linking dynamically with the userspace rcu library. + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * This code section can only be included in LGPL 2.1 compatible source code. + * See below for the function call wrappers which can be used in code meant to + * be only linked with the Userspace RCU library. This comes with a small + * performance degradation on the read-side due to the added function calls. + * This is required to permit relinking with newer versions of the library. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +enum urcu_bp_state { + URCU_BP_READER_ACTIVE_CURRENT, + URCU_BP_READER_ACTIVE_OLD, + URCU_BP_READER_INACTIVE, +}; + +/* + * The trick here is that URCU_BP_GP_CTR_PHASE must be a multiple of 8 so we can use a + * full 8-bits, 16-bits or 32-bits bitmask for the lower order bits. + */ +#define URCU_BP_GP_COUNT (1UL << 0) +/* Use the amount of bits equal to half of the architecture long size */ +#define URCU_BP_GP_CTR_PHASE (1UL << (sizeof(long) << 2)) +#define URCU_BP_GP_CTR_NEST_MASK (URCU_BP_GP_CTR_PHASE - 1) + +/* + * Used internally by _urcu_bp_read_lock. + */ +extern void urcu_bp_register(void); + +struct urcu_bp_gp { + /* + * Global grace period counter. + * Contains the current URCU_BP_GP_CTR_PHASE. + * Also has a URCU_BP_GP_COUNT of 1, to accelerate the reader fast path. + * Written to only by writer with mutex taken. + * Read by both writer and readers. + */ + unsigned long ctr; +} __attribute__((aligned(CAA_CACHE_LINE_SIZE))); + +extern struct urcu_bp_gp urcu_bp_gp; + +struct urcu_bp_reader { + /* Data used by both reader and urcu_bp_synchronize_rcu() */ + unsigned long ctr; + /* Data used for registry */ + struct cds_list_head node __attribute__((aligned(CAA_CACHE_LINE_SIZE))); + pthread_t tid; + int alloc; /* registry entry allocated */ +}; + +/* + * Bulletproof version keeps a pointer to a registry not part of the TLS. + * Adds a pointer dereference on the read-side, but won't require to unregister + * the reader thread. + */ +extern DECLARE_URCU_TLS(struct urcu_bp_reader *, urcu_bp_reader); + +#ifdef CONFIG_RCU_FORCE_SYS_MEMBARRIER +#define urcu_bp_has_sys_membarrier 1 +#else +extern int urcu_bp_has_sys_membarrier; +#endif + +static inline void urcu_bp_smp_mb_slave(void) +{ + if (caa_likely(urcu_bp_has_sys_membarrier)) + cmm_barrier(); + else + cmm_smp_mb(); +} + +static inline enum urcu_bp_state urcu_bp_reader_state(unsigned long *ctr, + cmm_annotate_t *group) +{ + unsigned long v; + + if (ctr == NULL) + return URCU_BP_READER_INACTIVE; + /* + * Make sure both tests below are done on the same version of *value + * to insure consistency. + */ + v = uatomic_load(ctr, CMM_RELAXED); + cmm_annotate_group_mem_acquire(group, ctr); + + if (!(v & URCU_BP_GP_CTR_NEST_MASK)) + return URCU_BP_READER_INACTIVE; + if (!((v ^ urcu_bp_gp.ctr) & URCU_BP_GP_CTR_PHASE)) + return URCU_BP_READER_ACTIVE_CURRENT; + return URCU_BP_READER_ACTIVE_OLD; +} + +/* + * Helper for _urcu_bp_read_lock(). The format of urcu_bp_gp.ctr (as well as + * the per-thread rcu_reader.ctr) has the lower-order bits containing a count of + * _urcu_bp_read_lock() nesting, and a single high-order URCU_BP_GP_CTR_PHASE bit + * that contains either zero or one. The smp_mb_slave() ensures that the accesses in + * _urcu_bp_read_lock() happen before the subsequent read-side critical section. + */ +static inline void _urcu_bp_read_lock_update(unsigned long tmp) +{ + if (caa_likely(!(tmp & URCU_BP_GP_CTR_NEST_MASK))) { + _CMM_STORE_SHARED(URCU_TLS(urcu_bp_reader)->ctr, _CMM_LOAD_SHARED(urcu_bp_gp.ctr)); + urcu_bp_smp_mb_slave(); + } else + _CMM_STORE_SHARED(URCU_TLS(urcu_bp_reader)->ctr, tmp + URCU_BP_GP_COUNT); +} + +/* + * Enter an RCU read-side critical section. + * + * The first cmm_barrier() call ensures that the compiler does not reorder + * the body of _urcu_bp_read_lock() with a mutex. + * + * This function and its helper are both less than 10 lines long. The + * intent is that this function meets the 10-line criterion in LGPL, + * allowing this function to be invoked directly from non-LGPL code. + */ +static inline void _urcu_bp_read_lock(void) +{ + unsigned long tmp; + + if (caa_unlikely(!URCU_TLS(urcu_bp_reader))) + urcu_bp_register(); /* If not yet registered. */ + cmm_barrier(); /* Ensure the compiler does not reorder us with mutex */ + tmp = URCU_TLS(urcu_bp_reader)->ctr; + urcu_assert_debug((tmp & URCU_BP_GP_CTR_NEST_MASK) != URCU_BP_GP_CTR_NEST_MASK); + _urcu_bp_read_lock_update(tmp); +} + +/* + * Exit an RCU read-side critical section. This function is less than + * 10 lines of code, and is intended to be usable by non-LGPL code, as + * called out in LGPL. + */ +static inline void _urcu_bp_read_unlock(void) +{ + unsigned long tmp; + unsigned long *ctr = &URCU_TLS(urcu_bp_reader)->ctr; + + tmp = URCU_TLS(urcu_bp_reader)->ctr; + urcu_assert_debug(tmp & URCU_BP_GP_CTR_NEST_MASK); + /* Finish using rcu before decrementing the pointer. */ + urcu_bp_smp_mb_slave(); + cmm_annotate_mem_release(ctr); + uatomic_store(ctr, tmp - URCU_BP_GP_COUNT, CMM_RELAXED); + cmm_barrier(); /* Ensure the compiler does not reorder us with mutex */ +} + +/* + * Returns whether within a RCU read-side critical section. + * + * This function is less than 10 lines long. The intent is that this + * function meets the 10-line criterion for LGPL, allowing this function + * to be invoked directly from non-LGPL code. + */ +static inline int _urcu_bp_read_ongoing(void) +{ + if (caa_unlikely(!URCU_TLS(urcu_bp_reader))) + urcu_bp_register(); /* If not yet registered. */ + return URCU_TLS(urcu_bp_reader)->ctr & URCU_BP_GP_CTR_NEST_MASK; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_BP_STATIC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-common.h b/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-common.h new file mode 100644 index 0000000000000..d0fd06a3e2217 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-common.h @@ -0,0 +1,118 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_COMMON_STATIC_H +#define _URCU_COMMON_STATIC_H + +/* + * Userspace RCU header. + * + * TO BE INCLUDED ONLY IN CODE THAT IS TO BE RECOMPILED ON EACH LIBURCU + * RELEASE. See urcu.h for linking dynamically with the userspace rcu library. + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +enum urcu_state { + URCU_READER_ACTIVE_CURRENT, + URCU_READER_ACTIVE_OLD, + URCU_READER_INACTIVE, +}; + +/* + * The trick here is that URCU_GP_CTR_PHASE must be a multiple of 8 so + * we can use a full 8-bits, 16-bits or 32-bits bitmask for the lower + * order bits. + */ +#define URCU_GP_COUNT (1UL << 0) +/* Use the amount of bits equal to half of the architecture long size */ +#define URCU_GP_CTR_PHASE (1UL << (sizeof(unsigned long) << 2)) +#define URCU_GP_CTR_NEST_MASK (URCU_GP_CTR_PHASE - 1) + +struct urcu_gp { + /* + * Global grace period counter. + * Contains the current URCU_GP_CTR_PHASE. + * Also has a URCU_GP_COUNT of 1, to accelerate the reader fast path. + * Written to only by writer with mutex taken. + * Read by both writer and readers. + */ + unsigned long ctr; + + int32_t futex; +} __attribute__((aligned(CAA_CACHE_LINE_SIZE))); + +struct urcu_reader { + /* Data used by both reader and synchronize_rcu() */ + unsigned long ctr; + char need_mb; + /* Data used for registry */ + struct cds_list_head node __attribute__((aligned(CAA_CACHE_LINE_SIZE))); + pthread_t tid; + /* Reader registered flag, for internal checks. */ + unsigned int registered:1; +}; + +/* + * Wake-up waiting synchronize_rcu(). Called from many concurrent threads. + */ +static inline void urcu_common_wake_up_gp(struct urcu_gp *gp) +{ + if (caa_unlikely(uatomic_read(&gp->futex) == -1)) { + uatomic_set(&gp->futex, 0); + /* + * Ignoring return value until we can make this function + * return something (because urcu_die() is not publicly + * exposed). + */ + (void) futex_async(&gp->futex, FUTEX_WAKE, 1, + NULL, NULL, 0); + } +} + +static inline enum urcu_state urcu_common_reader_state(struct urcu_gp *gp, + unsigned long *ctr, + cmm_annotate_t *group) +{ + unsigned long v; + + /* + * Make sure both tests below are done on the same version of *value + * to insure consistency. + */ + v = uatomic_load(ctr, CMM_RELAXED); + cmm_annotate_group_mem_acquire(group, ctr); + + if (!(v & URCU_GP_CTR_NEST_MASK)) + return URCU_READER_INACTIVE; + if (!((v ^ gp->ctr) & URCU_GP_CTR_PHASE)) + return URCU_READER_ACTIVE_CURRENT; + return URCU_READER_ACTIVE_OLD; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_COMMON_STATIC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-mb.h b/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-mb.h new file mode 100644 index 0000000000000..8ddbd0026cbcc --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-mb.h @@ -0,0 +1,139 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_MB_STATIC_H +#define _URCU_MB_STATIC_H + +/* + * Userspace RCU header. + * + * TO BE INCLUDED ONLY IN CODE THAT IS TO BE RECOMPILED ON EACH LIBURCU + * RELEASE. See urcu.h for linking dynamically with the userspace rcu library. + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This code section can only be included in LGPL 2.1 compatible source code. + * See below for the function call wrappers which can be used in code meant to + * be only linked with the Userspace RCU library. This comes with a small + * performance degradation on the read-side due to the added function calls. + * This is required to permit relinking with newer versions of the library. + */ + +extern struct urcu_gp urcu_mb_gp; + +extern DECLARE_URCU_TLS(struct urcu_reader, urcu_mb_reader); + +/* + * Helper for _urcu_mb_read_lock(). The format of urcu_mb_gp.ctr (as well as + * the per-thread rcu_reader.ctr) has the lower-order bits containing a count of + * _urcu_mb_read_lock() nesting, and a single high-order URCU_BP_GP_CTR_PHASE bit + * that contains either zero or one. The cmm_smp_mb() ensures that the accesses in + * _urcu_mb_read_lock() happen before the subsequent read-side critical section. + */ +static inline void _urcu_mb_read_lock_update(unsigned long tmp) +{ + if (caa_likely(!(tmp & URCU_GP_CTR_NEST_MASK))) { + _CMM_STORE_SHARED(URCU_TLS(urcu_mb_reader).ctr, _CMM_LOAD_SHARED(urcu_mb_gp.ctr)); + cmm_smp_mb(); + } else + _CMM_STORE_SHARED(URCU_TLS(urcu_mb_reader).ctr, tmp + URCU_GP_COUNT); +} + +/* + * Enter an RCU read-side critical section. + * + * The first cmm_barrier() call ensures that the compiler does not reorder + * the body of _urcu_mb_read_lock() with a mutex. + * + * This function and its helper are both less than 10 lines long. The + * intent is that this function meets the 10-line criterion in LGPL, + * allowing this function to be invoked directly from non-LGPL code. + */ +static inline void _urcu_mb_read_lock(void) +{ + unsigned long tmp; + + urcu_assert_debug(URCU_TLS(urcu_mb_reader).registered); + cmm_barrier(); + tmp = URCU_TLS(urcu_mb_reader).ctr; + urcu_assert_debug((tmp & URCU_GP_CTR_NEST_MASK) != URCU_GP_CTR_NEST_MASK); + _urcu_mb_read_lock_update(tmp); +} + +/* + * This is a helper function for _urcu_mb_read_unlock(). + * + * The first cmm_smp_mb() call ensures that the critical section is + * seen to precede the store to rcu_reader.ctr. + * The second cmm_smp_mb() call ensures that we write to rcu_reader.ctr + * before reading the update-side futex. + */ +static inline void _urcu_mb_read_unlock_update_and_wakeup(unsigned long tmp) +{ + unsigned long *ctr = &URCU_TLS(urcu_mb_reader).ctr; + + if (caa_likely((tmp & URCU_GP_CTR_NEST_MASK) == URCU_GP_COUNT)) { + uatomic_store(ctr, tmp - URCU_GP_COUNT, CMM_SEQ_CST); + urcu_common_wake_up_gp(&urcu_mb_gp); + } else { + uatomic_store(ctr, tmp - URCU_GP_COUNT, CMM_RELAXED); + } +} + +/* + * Exit an RCU read-side critical section. Both this function and its + * helper are smaller than 10 lines of code, and are intended to be + * usable by non-LGPL code, as called out in LGPL. + */ +static inline void _urcu_mb_read_unlock(void) +{ + unsigned long tmp; + + urcu_assert_debug(URCU_TLS(urcu_mb_reader).registered); + tmp = URCU_TLS(urcu_mb_reader).ctr; + urcu_assert_debug(tmp & URCU_GP_CTR_NEST_MASK); + _urcu_mb_read_unlock_update_and_wakeup(tmp); + cmm_barrier(); /* Ensure the compiler does not reorder us with mutex */ +} + +/* + * Returns whether within a RCU read-side critical section. + * + * This function is less than 10 lines long. The intent is that this + * function meets the 10-line criterion for LGPL, allowing this function + * to be invoked directly from non-LGPL code. + */ +static inline int _urcu_mb_read_ongoing(void) +{ + return URCU_TLS(urcu_mb_reader).ctr & URCU_GP_CTR_NEST_MASK; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_MB_STATIC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-memb.h b/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-memb.h new file mode 100644 index 0000000000000..b9178c879e1ac --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-memb.h @@ -0,0 +1,175 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_MEMB_STATIC_H +#define _URCU_MEMB_STATIC_H + +/* + * Userspace RCU header. + * + * TO BE INCLUDED ONLY IN CODE THAT IS TO BE RECOMPILED ON EACH LIBURCU + * RELEASE. See urcu.h for linking dynamically with the userspace rcu library. + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This code section can only be included in LGPL 2.1 compatible source code. + * See below for the function call wrappers which can be used in code meant to + * be only linked with the Userspace RCU library. This comes with a small + * performance degradation on the read-side due to the added function calls. + * This is required to permit relinking with newer versions of the library. + */ + +/* + * Slave barriers are only guaranteed to be ordered wrt master barriers. + * + * The pair ordering is detailed as (O: ordered, X: not ordered) : + * slave master + * slave X O + * master O O + */ + +#ifdef CONFIG_RCU_FORCE_SYS_MEMBARRIER +#define urcu_memb_has_sys_membarrier 1 +#else +extern int urcu_memb_has_sys_membarrier; +#endif + +static inline void urcu_memb_smp_mb_slave(void) +{ + if (caa_likely(urcu_memb_has_sys_membarrier)) + cmm_barrier(); + else + cmm_smp_mb(); +} + +extern struct urcu_gp urcu_memb_gp; + +extern DECLARE_URCU_TLS(struct urcu_reader, urcu_memb_reader); + +/* + * Helper for _rcu_read_lock(). The format of urcu_memb_gp.ctr (as well as + * the per-thread rcu_reader.ctr) has the lower-order bits containing a count of + * _rcu_read_lock() nesting, and a single high-order URCU_BP_GP_CTR_PHASE bit + * that contains either zero or one. The smp_mb_slave() ensures that the accesses in + * _rcu_read_lock() happen before the subsequent read-side critical section. + */ +static inline void _urcu_memb_read_lock_update(unsigned long tmp) +{ + unsigned long *ctr = &URCU_TLS(urcu_memb_reader).ctr; + + if (caa_likely(!(tmp & URCU_GP_CTR_NEST_MASK))) { + unsigned long *pgctr = &urcu_memb_gp.ctr; + unsigned long gctr = uatomic_load(pgctr, CMM_RELAXED); + + /* Paired with following mb slave. */ + cmm_annotate_mem_acquire(pgctr); + uatomic_store(ctr, gctr, CMM_RELAXED); + + urcu_memb_smp_mb_slave(); + } else { + uatomic_store(ctr, tmp + URCU_GP_COUNT, CMM_RELAXED); + } +} + +/* + * Enter an RCU read-side critical section. + * + * The first cmm_barrier() call ensures that the compiler does not reorder + * the body of _rcu_read_lock() with a mutex. + * + * This function and its helper are both less than 10 lines long. The + * intent is that this function meets the 10-line criterion in LGPL, + * allowing this function to be invoked directly from non-LGPL code. + */ +static inline void _urcu_memb_read_lock(void) +{ + unsigned long tmp; + + urcu_assert_debug(URCU_TLS(urcu_memb_reader).registered); + cmm_barrier(); + tmp = URCU_TLS(urcu_memb_reader).ctr; + urcu_assert_debug((tmp & URCU_GP_CTR_NEST_MASK) != URCU_GP_CTR_NEST_MASK); + _urcu_memb_read_lock_update(tmp); +} + +/* + * This is a helper function for _rcu_read_unlock(). + * + * The first smp_mb_slave() call ensures that the critical section is + * seen to precede the store to rcu_reader.ctr. + * The second smp_mb_slave() call ensures that we write to rcu_reader.ctr + * before reading the update-side futex. + */ +static inline void _urcu_memb_read_unlock_update_and_wakeup(unsigned long tmp) +{ + unsigned long *ctr = &URCU_TLS(urcu_memb_reader).ctr; + + if (caa_likely((tmp & URCU_GP_CTR_NEST_MASK) == URCU_GP_COUNT)) { + urcu_memb_smp_mb_slave(); + cmm_annotate_mem_release(ctr); + uatomic_store(ctr, tmp - URCU_GP_COUNT, CMM_RELAXED); + urcu_memb_smp_mb_slave(); + urcu_common_wake_up_gp(&urcu_memb_gp); + } else { + uatomic_store(ctr, tmp - URCU_GP_COUNT, CMM_RELAXED); + } +} + +/* + * Exit an RCU read-side critical section. Both this function and its + * helper are smaller than 10 lines of code, and are intended to be + * usable by non-LGPL code, as called out in LGPL. + */ +static inline void _urcu_memb_read_unlock(void) +{ + unsigned long tmp; + + urcu_assert_debug(URCU_TLS(urcu_memb_reader).registered); + tmp = URCU_TLS(urcu_memb_reader).ctr; + urcu_assert_debug(tmp & URCU_GP_CTR_NEST_MASK); + _urcu_memb_read_unlock_update_and_wakeup(tmp); + cmm_barrier(); /* Ensure the compiler does not reorder us with mutex */ +} + +/* + * Returns whether within a RCU read-side critical section. + * + * This function is less than 10 lines long. The intent is that this + * function meets the 10-line criterion for LGPL, allowing this function + * to be invoked directly from non-LGPL code. + */ +static inline int _urcu_memb_read_ongoing(void) +{ + return URCU_TLS(urcu_memb_reader).ctr & URCU_GP_CTR_NEST_MASK; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_MEMB_STATIC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-qsbr.h b/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-qsbr.h new file mode 100644 index 0000000000000..de798831bb5c1 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu-qsbr.h @@ -0,0 +1,220 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_QSBR_STATIC_H +#define _URCU_QSBR_STATIC_H + +/* + * Userspace RCU QSBR header. + * + * TO BE INCLUDED ONLY IN CODE THAT IS TO BE RECOMPILED ON EACH LIBURCU + * RELEASE. See urcu.h for linking dynamically with the userspace rcu library. + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This code section can only be included in LGPL 2.1 compatible source code. + * See below for the function call wrappers which can be used in code meant to + * be only linked with the Userspace RCU library. This comes with a small + * performance degradation on the read-side due to the added function calls. + * This is required to permit relinking with newer versions of the library. + */ + +#define URCU_QSBR_GP_ONLINE (1UL << 0) +#define URCU_QSBR_GP_CTR (1UL << 1) + +extern struct urcu_gp urcu_qsbr_gp; + +struct urcu_qsbr_reader { + /* Data used by both reader and synchronize_rcu() */ + unsigned long ctr; + /* Data used for registry */ + struct cds_list_head node __attribute__((aligned(CAA_CACHE_LINE_SIZE))); + int waiting; + pthread_t tid; + /* Reader registered flag, for internal checks. */ + unsigned int registered:1; +}; + +extern DECLARE_URCU_TLS(struct urcu_qsbr_reader, urcu_qsbr_reader); + +/* + * Wake-up waiting synchronize_rcu(). Called from many concurrent threads. + */ +static inline void urcu_qsbr_wake_up_gp(void) +{ + if (caa_unlikely(_CMM_LOAD_SHARED(URCU_TLS(urcu_qsbr_reader).waiting))) { + _CMM_STORE_SHARED(URCU_TLS(urcu_qsbr_reader).waiting, 0); + cmm_smp_mb(); + if (uatomic_read(&urcu_qsbr_gp.futex) != -1) + return; + uatomic_set(&urcu_qsbr_gp.futex, 0); + /* + * Ignoring return value until we can make this function + * return something (because urcu_die() is not publicly + * exposed). + */ + (void) futex_noasync(&urcu_qsbr_gp.futex, FUTEX_WAKE, 1, + NULL, NULL, 0); + } +} + +static inline enum urcu_state urcu_qsbr_reader_state(unsigned long *ctr, + cmm_annotate_t *group) +{ + unsigned long v; + + v = uatomic_load(ctr, CMM_RELAXED); + cmm_annotate_group_mem_acquire(group, ctr); + + if (!v) + return URCU_READER_INACTIVE; + if (v == urcu_qsbr_gp.ctr) + return URCU_READER_ACTIVE_CURRENT; + return URCU_READER_ACTIVE_OLD; +} + +/* + * Enter an RCU read-side critical section. + * + * This function is less than 10 lines long. The intent is that this + * function meets the 10-line criterion for LGPL, allowing this function + * to be invoked directly from non-LGPL code. + */ +static inline void _urcu_qsbr_read_lock(void) +{ + urcu_assert_debug(URCU_TLS(urcu_qsbr_reader).ctr); +} + +/* + * Exit an RCU read-side critical section. + * + * This function is less than 10 lines long. The intent is that this + * function meets the 10-line criterion for LGPL, allowing this function + * to be invoked directly from non-LGPL code. + */ +static inline void _urcu_qsbr_read_unlock(void) +{ + urcu_assert_debug(URCU_TLS(urcu_qsbr_reader).ctr); +} + +/* + * Returns whether within a RCU read-side critical section. + * + * This function is less than 10 lines long. The intent is that this + * function meets the 10-line criterion for LGPL, allowing this function + * to be invoked directly from non-LGPL code. + */ +static inline int _urcu_qsbr_read_ongoing(void) +{ + return URCU_TLS(urcu_qsbr_reader).ctr; +} + +/* + * This is a helper function for _rcu_quiescent_state(). + * The first cmm_smp_mb() ensures memory accesses in the prior read-side + * critical sections are not reordered with store to + * URCU_TLS(urcu_qsbr_reader).ctr, and ensures that mutexes held within an + * offline section that would happen to end with this + * urcu_qsbr_quiescent_state() call are not reordered with + * store to URCU_TLS(urcu_qsbr_reader).ctr. + */ +static inline void _urcu_qsbr_quiescent_state_update_and_wakeup(unsigned long gp_ctr) +{ + uatomic_store(&URCU_TLS(urcu_qsbr_reader).ctr, gp_ctr, CMM_SEQ_CST); + + /* write URCU_TLS(urcu_qsbr_reader).ctr before read futex */ + urcu_qsbr_wake_up_gp(); + cmm_smp_mb(); +} + +/* + * Inform RCU of a quiescent state. + * + * This function is less than 10 lines long. The intent is that this + * function meets the 10-line criterion for LGPL, allowing this function + * to be invoked directly from non-LGPL code. + * + * We skip the memory barriers and gp store if our local ctr already + * matches the global urcu_qsbr_gp.ctr value: this is OK because a prior + * _rcu_quiescent_state() or _rcu_thread_online() already updated it + * within our thread, so we have no quiescent state to report. + */ +static inline void _urcu_qsbr_quiescent_state(void) +{ + unsigned long gp_ctr; + + urcu_assert_debug(URCU_TLS(urcu_qsbr_reader).registered); + gp_ctr = uatomic_load(&urcu_qsbr_gp.ctr, CMM_RELAXED); + if (gp_ctr == URCU_TLS(urcu_qsbr_reader).ctr) + return; + _urcu_qsbr_quiescent_state_update_and_wakeup(gp_ctr); +} + +/* + * Take a thread offline, prohibiting it from entering further RCU + * read-side critical sections. + * + * This function is less than 10 lines long. The intent is that this + * function meets the 10-line criterion for LGPL, allowing this function + * to be invoked directly from non-LGPL code. + */ +static inline void _urcu_qsbr_thread_offline(void) +{ + urcu_assert_debug(URCU_TLS(urcu_qsbr_reader).registered); + uatomic_store(&URCU_TLS(urcu_qsbr_reader).ctr, 0, CMM_SEQ_CST); + /* write URCU_TLS(urcu_qsbr_reader).ctr before read futex */ + urcu_qsbr_wake_up_gp(); + cmm_barrier(); /* Ensure the compiler does not reorder us with mutex */ +} + +/* + * Bring a thread online, allowing it to once again enter RCU + * read-side critical sections. + * + * This function is less than 10 lines long. The intent is that this + * function meets the 10-line criterion for LGPL, allowing this function + * to be invoked directly from non-LGPL code. + */ +static inline void _urcu_qsbr_thread_online(void) +{ + unsigned long *pctr = &URCU_TLS(urcu_qsbr_reader).ctr; + unsigned long ctr; + + urcu_assert_debug(URCU_TLS(urcu_qsbr_reader).registered); + cmm_barrier(); /* Ensure the compiler does not reorder us with mutex */ + ctr = uatomic_load(&urcu_qsbr_gp.ctr, CMM_RELAXED); + cmm_annotate_mem_acquire(&urcu_qsbr_gp.ctr); + uatomic_store(pctr, ctr, CMM_RELAXED); + cmm_smp_mb(); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_QSBR_STATIC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu.h b/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu.h new file mode 100644 index 0000000000000..c164ae31bca00 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/static/urcu.h @@ -0,0 +1,31 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_STATIC_H +#define _URCU_STATIC_H + +/* + * Userspace RCU header. + * + * TO BE INCLUDED ONLY IN CODE THAT IS TO BE RECOMPILED ON EACH LIBURCU + * RELEASE. See urcu.h for linking dynamically with the userspace rcu library. + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +/* Default is RCU_MEMBARRIER */ +#if !defined(RCU_MEMBARRIER) && !defined(RCU_MB) +#define RCU_MEMBARRIER +#endif + +#ifdef RCU_MEMBARRIER +#include +#endif + +#ifdef RCU_MB +#include +#endif + +#endif /* _URCU_STATIC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/static/wfcqueue.h b/external/lgpl2/userspace-rcu/dist/include/urcu/static/wfcqueue.h new file mode 100644 index 0000000000000..2799c61bb38b3 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/static/wfcqueue.h @@ -0,0 +1,675 @@ +// SPDX-FileCopyrightText: 2010-2012 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2011-2012 Lai Jiangshan +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_WFCQUEUE_STATIC_H +#define _URCU_WFCQUEUE_STATIC_H + +/* + * Userspace RCU library - Concurrent Queue with Wait-Free Enqueue/Blocking Dequeue + * + * TO BE INCLUDED ONLY IN LGPL-COMPATIBLE CODE. See urcu/wfcqueue.h for + * linking dynamically with the userspace rcu library. + */ + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Concurrent queue with wait-free enqueue/blocking dequeue. + * + * This queue has been designed and implemented collaboratively by + * Mathieu Desnoyers and Lai Jiangshan. Inspired from + * half-wait-free/half-blocking queue implementation done by Paul E. + * McKenney. + * + * Mutual exclusion of cds_wfcq_* / __cds_wfcq_* API + * + * Synchronization table: + * + * External synchronization techniques described in the API below is + * required between pairs marked with "X". No external synchronization + * required between pairs marked with "-". + * + * Legend: + * [1] cds_wfcq_enqueue + * [2] __cds_wfcq_splice (destination queue) + * [3] __cds_wfcq_dequeue + * [4] __cds_wfcq_splice (source queue) + * [5] __cds_wfcq_first + * [6] __cds_wfcq_next + * + * [1] [2] [3] [4] [5] [6] + * [1] - - - - - - + * [2] - - - - - - + * [3] - - X X X X + * [4] - - X - X X + * [5] - - X X - - + * [6] - - X X - - + * + * Mutual exclusion can be ensured by holding cds_wfcq_dequeue_lock(). + * + * For convenience, cds_wfcq_dequeue_blocking() and + * cds_wfcq_splice_blocking() hold the dequeue lock. + * + * Besides locking, mutual exclusion of dequeue, splice and iteration + * can be ensured by performing all of those operations from a single + * thread, without requiring any lock. + */ + +#define WFCQ_ADAPT_ATTEMPTS 10 /* Retry if being set */ +#define WFCQ_WAIT 10 /* Wait 10 ms if being set */ + +/* + * cds_wfcq_node_init: initialize wait-free queue node. + */ +static inline void _cds_wfcq_node_init(struct cds_wfcq_node *node) +{ + node->next = NULL; +} + +static inline void _cds_wfcq_node_init_atomic(struct cds_wfcq_node *node) +{ + uatomic_store(&node->next, NULL, CMM_RELAXED); +} + +/* + * cds_wfcq_init: initialize wait-free queue (with lock). Pair with + * cds_wfcq_destroy(). + */ +static inline void _cds_wfcq_init(struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail) +{ + int ret; + + /* Set queue head and tail */ + _cds_wfcq_node_init(&head->node); + tail->p = &head->node; + ret = pthread_mutex_init(&head->lock, NULL); + urcu_posix_assert(!ret); +} + +/* + * cds_wfcq_destroy: destroy wait-free queue (with lock). Pair with + * cds_wfcq_init(). + */ +static inline void _cds_wfcq_destroy(struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail __attribute__((unused))) +{ + int ret = pthread_mutex_destroy(&head->lock); + urcu_posix_assert(!ret); +} + +/* + * __cds_wfcq_init: initialize wait-free queue (without lock). Don't + * pair with any destroy function. + */ +static inline void ___cds_wfcq_init(struct __cds_wfcq_head *head, + struct cds_wfcq_tail *tail) +{ + /* Set queue head and tail */ + _cds_wfcq_node_init(&head->node); + tail->p = &head->node; +} + +/* + * cds_wfcq_empty: return whether wait-free queue is empty. + * + * No memory barrier is issued. No mutual exclusion is required. + * + * We perform the test on head->node.next to check if the queue is + * possibly empty, but we confirm this by checking if the tail pointer + * points to the head node because the tail pointer is the linearisation + * point of the enqueuers. Just checking the head next pointer could + * make a queue appear empty if an enqueuer is preempted for a long time + * between xchg() and setting the previous node's next pointer. + */ +static inline bool _cds_wfcq_empty(cds_wfcq_head_const_ptr_t u_head, + const struct cds_wfcq_tail *tail) +{ + const struct __cds_wfcq_head *head = u_head._h; + /* + * Queue is empty if no node is pointed by head->node.next nor + * tail->p. Even though the tail->p check is sufficient to find + * out of the queue is empty, we first check head->node.next as a + * common case to ensure that dequeuers do not frequently access + * enqueuer's tail->p cache line. + */ + return uatomic_load(&head->node.next, CMM_CONSUME) == NULL + && uatomic_load(&tail->p, CMM_CONSUME) == &head->node; +} + +static inline void _cds_wfcq_dequeue_lock(struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail __attribute__((unused))) +{ + int ret; + + ret = pthread_mutex_lock(&head->lock); + urcu_posix_assert(!ret); +} + +static inline void _cds_wfcq_dequeue_unlock(struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail __attribute__((unused))) +{ + int ret; + + ret = pthread_mutex_unlock(&head->lock); + urcu_posix_assert(!ret); +} + +static inline bool ___cds_wfcq_append(cds_wfcq_head_ptr_t u_head, + struct cds_wfcq_tail *tail, + struct cds_wfcq_node *new_head, + struct cds_wfcq_node *new_tail) +{ + struct __cds_wfcq_head *head = u_head._h; + struct cds_wfcq_node *old_tail; + + /* + * Implicit memory barrier before uatomic_xchg() orders earlier + * stores to data structure containing node and setting + * node->next to NULL before publication. + */ + old_tail = uatomic_xchg_mo(&tail->p, new_tail, CMM_SEQ_CST); + + /* + * Implicit memory barrier after uatomic_xchg() orders store to + * q->tail before store to old_tail->next. + * + * At this point, dequeuers see a NULL tail->p->next, which + * indicates that the queue is being appended to. The following + * store will append "node" to the queue from a dequeuer + * perspective. + */ + uatomic_store(&old_tail->next, new_head, CMM_RELEASE); + + /* + * Return false if queue was empty prior to adding the node, + * else return true. + */ + return old_tail != &head->node; +} + +/* + * cds_wfcq_enqueue: enqueue a node into a wait-free queue. + * + * Operations prior to enqueue are consistant with respect to dequeuing or + * splicing and iterating. + * + * Returns false if the queue was empty prior to adding the node. + * Returns true otherwise. + */ +static inline bool _cds_wfcq_enqueue(cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail, + struct cds_wfcq_node *new_tail) +{ + cmm_emit_legacy_smp_mb(); + + return ___cds_wfcq_append(head, tail, new_tail, new_tail); +} + +/* + * CDS_WFCQ_WAIT_SLEEP: + * + * By default, this sleeps for the given @msec milliseconds. + * This is a macro which LGPL users may #define themselves before + * including wfcqueue.h to override the default behavior (e.g. + * to log a warning or perform other background work). + */ +#ifndef CDS_WFCQ_WAIT_SLEEP +#define CDS_WFCQ_WAIT_SLEEP(msec) ___cds_wfcq_wait_sleep(msec) +#endif + +static inline void ___cds_wfcq_wait_sleep(int msec) +{ + (void) poll(NULL, 0, msec); +} + +/* + * ___cds_wfcq_busy_wait: adaptative busy-wait. + * + * Returns 1 if nonblocking and needs to block, 0 otherwise. + */ +static inline bool +___cds_wfcq_busy_wait(int *attempt, int blocking) +{ + if (!blocking) + return 1; + if (++(*attempt) >= WFCQ_ADAPT_ATTEMPTS) { + CDS_WFCQ_WAIT_SLEEP(WFCQ_WAIT); /* Wait for 10ms */ + *attempt = 0; + } else { + caa_cpu_relax(); + } + return 0; +} + +/* + * Waiting for enqueuer to complete enqueue and return the next node. + */ +static inline struct cds_wfcq_node * +___cds_wfcq_node_sync_next(struct cds_wfcq_node *node, int blocking) +{ + struct cds_wfcq_node *next; + int attempt = 0; + + /* + * Adaptative busy-looping waiting for enqueuer to complete enqueue. + * + * Load node.next before loading node's content + */ + while ((next = uatomic_load(&node->next, CMM_CONSUME)) == NULL) { + if (___cds_wfcq_busy_wait(&attempt, blocking)) + return CDS_WFCQ_WOULDBLOCK; + } + + return next; +} + +static inline struct cds_wfcq_node * +___cds_wfcq_first(cds_wfcq_head_ptr_t u_head, + struct cds_wfcq_tail *tail, + int blocking) +{ + struct __cds_wfcq_head *head = u_head._h; + struct cds_wfcq_node *node; + + if (_cds_wfcq_empty(__cds_wfcq_head_const_cast(head), tail)) + return NULL; + node = ___cds_wfcq_node_sync_next(&head->node, blocking); + + return node; +} + +/* + * __cds_wfcq_first_blocking: get first node of a queue, without dequeuing. + * + * Content written into the node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + * Dequeue/splice/iteration mutual exclusion should be ensured by the + * caller. + * + * Used by for-like iteration macros in urcu/wfqueue.h: + * __cds_wfcq_for_each_blocking() + * __cds_wfcq_for_each_blocking_safe() + * + * Returns NULL if queue is empty, first node otherwise. + */ +static inline struct cds_wfcq_node * +___cds_wfcq_first_blocking(cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail) +{ + return ___cds_wfcq_first(head, tail, 1); +} + + +/* + * __cds_wfcq_first_nonblocking: get first node of a queue, without dequeuing. + * + * Same as __cds_wfcq_first_blocking, but returns CDS_WFCQ_WOULDBLOCK if + * it needs to block. + */ +static inline struct cds_wfcq_node * +___cds_wfcq_first_nonblocking(cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail) +{ + return ___cds_wfcq_first(head, tail, 0); +} + +static inline struct cds_wfcq_node * +___cds_wfcq_next(cds_wfcq_head_ptr_t head __attribute__((unused)), + struct cds_wfcq_tail *tail, + struct cds_wfcq_node *node, + int blocking) +{ + struct cds_wfcq_node *next; + + /* + * Even though the following tail->p check is sufficient to find + * out if we reached the end of the queue, we first check + * node->next as a common case to ensure that iteration on nodes + * do not frequently access enqueuer's tail->p cache line. + * + * Load node->next before loading next's content + */ + if ((next = uatomic_load(&node->next, CMM_CONSUME)) == NULL) { + if (uatomic_load(&tail->p, CMM_RELAXED) == node) + return NULL; + next = ___cds_wfcq_node_sync_next(node, blocking); + } + + return next; +} + +/* + * __cds_wfcq_next_blocking: get next node of a queue, without dequeuing. + * + * Content written into the node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + * Dequeue/splice/iteration mutual exclusion should be ensured by the + * caller. + * + * Used by for-like iteration macros in urcu/wfqueue.h: + * __cds_wfcq_for_each_blocking() + * __cds_wfcq_for_each_blocking_safe() + * + * Returns NULL if reached end of queue, non-NULL next queue node + * otherwise. + */ +static inline struct cds_wfcq_node * +___cds_wfcq_next_blocking(cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail, + struct cds_wfcq_node *node) +{ + return ___cds_wfcq_next(head, tail, node, 1); +} + +/* + * __cds_wfcq_next_blocking: get next node of a queue, without dequeuing. + * + * Same as __cds_wfcq_next_blocking, but returns CDS_WFCQ_WOULDBLOCK if + * it needs to block. + */ +static inline struct cds_wfcq_node * +___cds_wfcq_next_nonblocking(cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail, + struct cds_wfcq_node *node) +{ + return ___cds_wfcq_next(head, tail, node, 0); +} + +static inline struct cds_wfcq_node * +___cds_wfcq_dequeue_with_state(cds_wfcq_head_ptr_t u_head, + struct cds_wfcq_tail *tail, + int *state, + int blocking) +{ + struct __cds_wfcq_head *head = u_head._h; + struct cds_wfcq_node *node, *next; + + if (state) + *state = 0; + + if (_cds_wfcq_empty(__cds_wfcq_head_const_cast(head), tail)) { + return NULL; + } + + node = ___cds_wfcq_node_sync_next(&head->node, blocking); + if (!blocking && node == CDS_WFCQ_WOULDBLOCK) { + return CDS_WFCQ_WOULDBLOCK; + } + + if ((next = uatomic_load(&node->next, CMM_CONSUME)) == NULL) { + /* + * @node is probably the only node in the queue. + * Try to move the tail to &q->head. + * q->head.next is set to NULL here, and stays + * NULL if the cmpxchg succeeds. Should the + * cmpxchg fail due to a concurrent enqueue, the + * q->head.next will be set to the next node. + */ + _cds_wfcq_node_init_atomic(&head->node); + if (uatomic_cmpxchg_mo(&tail->p, node, &head->node, + CMM_SEQ_CST, CMM_SEQ_CST) == node) { + if (state) + *state |= CDS_WFCQ_STATE_LAST; + cmm_emit_legacy_smp_mb(); + return node; + } + next = ___cds_wfcq_node_sync_next(node, blocking); + /* + * In nonblocking mode, if we would need to block to + * get node's next, set the head next node pointer + * (currently NULL) back to its original value. + */ + if (!blocking && next == CDS_WFCQ_WOULDBLOCK) { + uatomic_store(&head->node.next, node, CMM_RELAXED); + return CDS_WFCQ_WOULDBLOCK; + } + } + + /* + * Move queue head forward. + */ + uatomic_store(&head->node.next, next, CMM_RELAXED); + cmm_emit_legacy_smp_mb(); + + return node; +} + +/* + * __cds_wfcq_dequeue_with_state_blocking: dequeue node from queue, with state. + * + * Content written into the node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + * It is valid to reuse and free a dequeued node immediately. + * Dequeue/splice/iteration mutual exclusion should be ensured by the + * caller. + */ +static inline struct cds_wfcq_node * +___cds_wfcq_dequeue_with_state_blocking(cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail, int *state) +{ + return ___cds_wfcq_dequeue_with_state(head, tail, state, 1); +} + +/* + * ___cds_wfcq_dequeue_blocking: dequeue node from queue. + * + * Same as __cds_wfcq_dequeue_with_state_blocking, but without saving + * state. + */ +static inline struct cds_wfcq_node * +___cds_wfcq_dequeue_blocking(cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail) +{ + return ___cds_wfcq_dequeue_with_state_blocking(head, tail, NULL); +} + +/* + * __cds_wfcq_dequeue_with_state_nonblocking: dequeue node, with state. + * + * Same as __cds_wfcq_dequeue_blocking, but returns CDS_WFCQ_WOULDBLOCK + * if it needs to block. + */ +static inline struct cds_wfcq_node * +___cds_wfcq_dequeue_with_state_nonblocking(cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail, int *state) +{ + return ___cds_wfcq_dequeue_with_state(head, tail, state, 0); +} + +/* + * ___cds_wfcq_dequeue_nonblocking: dequeue node from queue. + * + * Same as __cds_wfcq_dequeue_with_state_nonblocking, but without saving + * state. + */ +static inline struct cds_wfcq_node * +___cds_wfcq_dequeue_nonblocking(cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail) +{ + return ___cds_wfcq_dequeue_with_state_nonblocking(head, tail, NULL); +} + +/* + * __cds_wfcq_splice: enqueue all src_q nodes at the end of dest_q. + * + * Operations after splice are consistant with respect to enqueue. + * + * Dequeue all nodes from src_q. + * dest_q must be already initialized. + * Mutual exclusion for src_q should be ensured by the caller as + * specified in the "Synchronisation table". + * Returns enum cds_wfcq_ret which indicates the state of the src or + * dest queue. + */ +static inline enum cds_wfcq_ret +___cds_wfcq_splice( + cds_wfcq_head_ptr_t u_dest_q_head, + struct cds_wfcq_tail *dest_q_tail, + cds_wfcq_head_ptr_t u_src_q_head, + struct cds_wfcq_tail *src_q_tail, + int blocking) +{ + struct __cds_wfcq_head *dest_q_head = u_dest_q_head._h; + struct __cds_wfcq_head *src_q_head = u_src_q_head._h; + struct cds_wfcq_node *head, *tail; + int attempt = 0; + + /* + * Initial emptiness check to speed up cases where queue is + * empty: only require loads to check if queue is empty. + */ + if (_cds_wfcq_empty(__cds_wfcq_head_const_cast(src_q_head), src_q_tail)) + return CDS_WFCQ_RET_SRC_EMPTY; + + for (;;) { + /* + * Open-coded _cds_wfcq_empty() by testing result of + * uatomic_xchg, as well as tail pointer vs head node + * address. + */ + head = uatomic_xchg_mo(&src_q_head->node.next, NULL, CMM_SEQ_CST); + if (head) + break; /* non-empty */ + if (uatomic_load(&src_q_tail->p, CMM_CONSUME) == &src_q_head->node) + return CDS_WFCQ_RET_SRC_EMPTY; + if (___cds_wfcq_busy_wait(&attempt, blocking)) + return CDS_WFCQ_RET_WOULDBLOCK; + } + + /* + * Memory barrier implied before uatomic_xchg() orders store to + * src_q->head before store to src_q->tail. This is required by + * concurrent enqueue on src_q, which exchanges the tail before + * updating the previous tail's next pointer. + */ + cmm_emit_legacy_smp_mb(); + tail = uatomic_xchg_mo(&src_q_tail->p, &src_q_head->node, CMM_SEQ_CST); + + /* + * Append the spliced content of src_q into dest_q. Does not + * require mutual exclusion on dest_q (wait-free). + */ + if (___cds_wfcq_append(__cds_wfcq_head_cast(dest_q_head), dest_q_tail, + head, tail)) + return CDS_WFCQ_RET_DEST_NON_EMPTY; + else + return CDS_WFCQ_RET_DEST_EMPTY; +} + +/* + * __cds_wfcq_splice_blocking: enqueue all src_q nodes at the end of dest_q. + * + * Dequeue all nodes from src_q. + * dest_q must be already initialized. + * Mutual exclusion for src_q should be ensured by the caller as + * specified in the "Synchronisation table". + * Returns enum cds_wfcq_ret which indicates the state of the src or + * dest queue. Never returns CDS_WFCQ_RET_WOULDBLOCK. + */ +static inline enum cds_wfcq_ret +___cds_wfcq_splice_blocking( + cds_wfcq_head_ptr_t dest_q_head, + struct cds_wfcq_tail *dest_q_tail, + cds_wfcq_head_ptr_t src_q_head, + struct cds_wfcq_tail *src_q_tail) +{ + return ___cds_wfcq_splice(dest_q_head, dest_q_tail, + src_q_head, src_q_tail, 1); +} + +/* + * __cds_wfcq_splice_nonblocking: enqueue all src_q nodes at the end of dest_q. + * + * Same as __cds_wfcq_splice_blocking, but returns + * CDS_WFCQ_RET_WOULDBLOCK if it needs to block. + */ +static inline enum cds_wfcq_ret +___cds_wfcq_splice_nonblocking( + cds_wfcq_head_ptr_t dest_q_head, + struct cds_wfcq_tail *dest_q_tail, + cds_wfcq_head_ptr_t src_q_head, + struct cds_wfcq_tail *src_q_tail) +{ + return ___cds_wfcq_splice(dest_q_head, dest_q_tail, + src_q_head, src_q_tail, 0); +} + +/* + * cds_wfcq_dequeue_with_state_blocking: dequeue a node from a wait-free queue. + * + * Content written into the node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + * Mutual exclusion with cds_wfcq_splice_blocking and dequeue lock is + * ensured. + * It is valid to reuse and free a dequeued node immediately. + */ +static inline struct cds_wfcq_node * +_cds_wfcq_dequeue_with_state_blocking(struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail, int *state) +{ + struct cds_wfcq_node *retval; + + _cds_wfcq_dequeue_lock(head, tail); + retval = ___cds_wfcq_dequeue_with_state_blocking(cds_wfcq_head_cast(head), + tail, state); + _cds_wfcq_dequeue_unlock(head, tail); + return retval; +} + +/* + * cds_wfcq_dequeue_blocking: dequeue node from queue. + * + * Same as cds_wfcq_dequeue_blocking, but without saving state. + */ +static inline struct cds_wfcq_node * +_cds_wfcq_dequeue_blocking(struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail) +{ + return _cds_wfcq_dequeue_with_state_blocking(head, tail, NULL); +} + +/* + * cds_wfcq_splice_blocking: enqueue all src_q nodes at the end of dest_q. + * + * Dequeue all nodes from src_q. + * dest_q must be already initialized. + * Content written into the node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + * Mutual exclusion with cds_wfcq_dequeue_blocking and dequeue lock is + * ensured. + * Returns enum cds_wfcq_ret which indicates the state of the src or + * dest queue. Never returns CDS_WFCQ_RET_WOULDBLOCK. + */ +static inline enum cds_wfcq_ret +_cds_wfcq_splice_blocking( + struct cds_wfcq_head *dest_q_head, + struct cds_wfcq_tail *dest_q_tail, + struct cds_wfcq_head *src_q_head, + struct cds_wfcq_tail *src_q_tail) +{ + enum cds_wfcq_ret ret; + + _cds_wfcq_dequeue_lock(src_q_head, src_q_tail); + ret = ___cds_wfcq_splice_blocking(cds_wfcq_head_cast(dest_q_head), dest_q_tail, + cds_wfcq_head_cast(src_q_head), src_q_tail); + _cds_wfcq_dequeue_unlock(src_q_head, src_q_tail); + return ret; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_WFCQUEUE_STATIC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/static/wfqueue.h b/external/lgpl2/userspace-rcu/dist/include/urcu/static/wfqueue.h new file mode 100644 index 0000000000000..0cb7b1b98cd96 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/static/wfqueue.h @@ -0,0 +1,158 @@ +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_WFQUEUE_STATIC_H +#define _URCU_WFQUEUE_STATIC_H + +/* + * Userspace RCU library - Queue with Wait-Free Enqueue/Blocking Dequeue + * + * TO BE INCLUDED ONLY IN LGPL-COMPATIBLE CODE. See wfqueue.h for linking + * dynamically with the userspace rcu library. + */ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Queue with wait-free enqueue/blocking dequeue. + * This implementation adds a dummy head node when the queue is empty to ensure + * we can always update the queue locklessly. + * + * Inspired from half-wait-free/half-blocking queue implementation done by + * Paul E. McKenney. + */ + +#define WFQ_ADAPT_ATTEMPTS 10 /* Retry if being set */ +#define WFQ_WAIT 10 /* Wait 10 ms if being set */ + +static inline void _cds_wfq_node_init(struct cds_wfq_node *node) +{ + node->next = NULL; +} + +static inline void _cds_wfq_init(struct cds_wfq_queue *q) +{ + int ret; + + _cds_wfq_node_init(&q->dummy); + /* Set queue head and tail */ + q->head = &q->dummy; + q->tail = &q->dummy.next; + ret = pthread_mutex_init(&q->lock, NULL); + urcu_posix_assert(!ret); +} + +static inline void _cds_wfq_destroy(struct cds_wfq_queue *q) +{ + int ret = pthread_mutex_destroy(&q->lock); + urcu_posix_assert(!ret); +} + +static inline void _cds_wfq_enqueue(struct cds_wfq_queue *q, + struct cds_wfq_node *node) +{ + struct cds_wfq_node **old_tail; + + /* + * uatomic_xchg() implicit memory barrier orders earlier stores to data + * structure containing node and setting node->next to NULL before + * publication. + */ + cmm_emit_legacy_smp_mb(); + old_tail = uatomic_xchg_mo(&q->tail, &node->next, CMM_SEQ_CST); + /* + * At this point, dequeuers see a NULL old_tail->next, which indicates + * that the queue is being appended to. The following store will append + * "node" to the queue from a dequeuer perspective. + */ + uatomic_store(old_tail, node, CMM_RELEASE); +} + +/* + * Waiting for enqueuer to complete enqueue and return the next node + */ +static inline struct cds_wfq_node * +___cds_wfq_node_sync_next(struct cds_wfq_node *node) +{ + struct cds_wfq_node *next; + int attempt = 0; + + /* + * Adaptative busy-looping waiting for enqueuer to complete enqueue. + */ + while ((next = uatomic_load(&node->next, CMM_CONSUME)) == NULL) { + if (++attempt >= WFQ_ADAPT_ATTEMPTS) { + (void) poll(NULL, 0, WFQ_WAIT); /* Wait for 10ms */ + attempt = 0; + } else + caa_cpu_relax(); + } + + return next; +} + +/* + * It is valid to reuse and free a dequeued node immediately. + * + * No need to go on a waitqueue here, as there is no possible state in which the + * list could cause dequeue to busy-loop needlessly while waiting for another + * thread to be scheduled. The queue appears empty until tail->next is set by + * enqueue. + */ +static inline struct cds_wfq_node * +___cds_wfq_dequeue_blocking(struct cds_wfq_queue *q) +{ + struct cds_wfq_node *node, *next; + + /* + * Queue is empty if it only contains the dummy node. + */ + if (q->head == &q->dummy && uatomic_load(&q->tail, CMM_CONSUME) == &q->dummy.next) + return NULL; + node = q->head; + + next = ___cds_wfq_node_sync_next(node); + + /* + * Move queue head forward. + */ + q->head = next; + /* + * Requeue dummy node if we just dequeued it. + */ + if (node == &q->dummy) { + _cds_wfq_node_init(node); + _cds_wfq_enqueue(q, node); + return ___cds_wfq_dequeue_blocking(q); + } + return node; +} + +static inline struct cds_wfq_node * +_cds_wfq_dequeue_blocking(struct cds_wfq_queue *q) +{ + struct cds_wfq_node *retnode; + int ret; + + ret = pthread_mutex_lock(&q->lock); + urcu_posix_assert(!ret); + retnode = ___cds_wfq_dequeue_blocking(q); + ret = pthread_mutex_unlock(&q->lock); + urcu_posix_assert(!ret); + return retnode; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_WFQUEUE_STATIC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/static/wfstack.h b/external/lgpl2/userspace-rcu/dist/include/urcu/static/wfstack.h new file mode 100644 index 0000000000000..97c5192a8f975 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/static/wfstack.h @@ -0,0 +1,452 @@ +// SPDX-FileCopyrightText: 2010-2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_STATIC_WFSTACK_H +#define _URCU_STATIC_WFSTACK_H + +/* + * Userspace RCU library - Stack with with wait-free push, blocking traversal. + * + * TO BE INCLUDED ONLY IN LGPL-COMPATIBLE CODE. See urcu/wfstack.h for + * linking dynamically with the userspace rcu library. + */ + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CDS_WFS_END ((struct cds_wfs_head *) 0x1UL) +#define CDS_WFS_ADAPT_ATTEMPTS 10 /* Retry if being set */ +#define CDS_WFS_WAIT 10 /* Wait 10 ms if being set */ + +/* + * Stack with wait-free push, blocking traversal. + * + * Stack implementing push, pop, pop_all operations, as well as iterator + * on the stack head returned by pop_all. + * + * Wait-free operations: cds_wfs_push, __cds_wfs_pop_all, cds_wfs_empty, + * cds_wfs_first. + * Blocking operations: cds_wfs_pop, cds_wfs_pop_all, cds_wfs_next, + * iteration on stack head returned by pop_all. + * + * Synchronization table: + * + * External synchronization techniques described in the API below is + * required between pairs marked with "X". No external synchronization + * required between pairs marked with "-". + * + * cds_wfs_push __cds_wfs_pop __cds_wfs_pop_all + * cds_wfs_push - - - + * __cds_wfs_pop - X X + * __cds_wfs_pop_all - X - + * + * cds_wfs_pop and cds_wfs_pop_all use an internal mutex to provide + * synchronization. + */ + +/* + * cds_wfs_node_init: initialize wait-free stack node. + */ +static inline +void _cds_wfs_node_init(struct cds_wfs_node *node) +{ + node->next = NULL; +} + +/* + * __cds_wfs_init: initialize wait-free stack. Don't pair with + * any destroy function. + */ +static inline void ___cds_wfs_init(struct __cds_wfs_stack *s) +{ + s->head = CDS_WFS_END; +} + +/* + * cds_wfs_init: initialize wait-free stack. Pair with + * cds_wfs_destroy(). + */ +static inline +void _cds_wfs_init(struct cds_wfs_stack *s) +{ + int ret; + + s->head = CDS_WFS_END; + ret = pthread_mutex_init(&s->lock, NULL); + urcu_posix_assert(!ret); +} + +/* + * cds_wfs_destroy: destroy wait-free stack. Pair with + * cds_wfs_init(). + */ +static inline +void _cds_wfs_destroy(struct cds_wfs_stack *s) +{ + int ret = pthread_mutex_destroy(&s->lock); + urcu_posix_assert(!ret); +} + +static inline bool ___cds_wfs_end(void *node) +{ + return node == CDS_WFS_END; +} + +/* + * cds_wfs_empty: return whether wait-free stack is empty. + * + * No memory barrier is issued. No mutual exclusion is required. + */ +static inline bool _cds_wfs_empty(cds_wfs_stack_const_ptr_t u_stack) +{ + const struct __cds_wfs_stack *s = u_stack._s; + + return ___cds_wfs_end(uatomic_load(&s->head, CMM_RELAXED)); +} + +/* + * cds_wfs_push: push a node into the stack. + * + * Issues a full memory barrier before push. No mutual exclusion is + * required. + * + * Operations before push are consistent when observed after associated pop. + * + * Returns 0 if the stack was empty prior to adding the node. + * Returns non-zero otherwise. + */ +static inline +int _cds_wfs_push(cds_wfs_stack_ptr_t u_stack, struct cds_wfs_node *node) +{ + struct __cds_wfs_stack *s = u_stack._s; + struct cds_wfs_head *old_head, *new_head; + + urcu_posix_assert(node->next == NULL); + new_head = caa_container_of(node, struct cds_wfs_head, node); + /* + * uatomic_xchg() implicit memory barrier orders earlier stores + * to node (setting it to NULL) before publication. + */ + cmm_emit_legacy_smp_mb(); + old_head = uatomic_xchg_mo(&s->head, new_head, CMM_SEQ_CST); + /* + * At this point, dequeuers see a NULL node->next, they should + * busy-wait until node->next is set to old_head. + */ + uatomic_store(&node->next, &old_head->node, CMM_RELEASE); + return !___cds_wfs_end(old_head); +} + +/* + * Waiting for push to complete enqueue and return the next node. + */ +static inline struct cds_wfs_node * +___cds_wfs_node_sync_next(struct cds_wfs_node *node, int blocking) +{ + struct cds_wfs_node *next; + int attempt = 0; + + /* + * Adaptative busy-looping waiting for push to complete. + */ + while ((next = uatomic_load(&node->next, CMM_CONSUME)) == NULL) { + if (!blocking) + return CDS_WFS_WOULDBLOCK; + if (++attempt >= CDS_WFS_ADAPT_ATTEMPTS) { + (void) poll(NULL, 0, CDS_WFS_WAIT); /* Wait for 10ms */ + attempt = 0; + } else { + caa_cpu_relax(); + } + } + + return next; +} + +static inline +struct cds_wfs_node * +___cds_wfs_pop(cds_wfs_stack_ptr_t u_stack, int *state, int blocking) +{ + struct cds_wfs_head *head, *new_head; + struct cds_wfs_node *next; + struct __cds_wfs_stack *s = u_stack._s; + + if (state) + *state = 0; + for (;;) { + head = uatomic_load(&s->head, CMM_CONSUME); + if (___cds_wfs_end(head)) { + return NULL; + } + next = ___cds_wfs_node_sync_next(&head->node, blocking); + if (!blocking && next == CDS_WFS_WOULDBLOCK) { + return CDS_WFS_WOULDBLOCK; + } + new_head = caa_container_of(next, struct cds_wfs_head, node); + if (uatomic_cmpxchg_mo(&s->head, head, new_head, + CMM_SEQ_CST, CMM_SEQ_CST) == head) { + if (state && ___cds_wfs_end(new_head)) + *state |= CDS_WFS_STATE_LAST; + cmm_emit_legacy_smp_mb(); + return &head->node; + } + if (!blocking) { + return CDS_WFS_WOULDBLOCK; + } + /* busy-loop if head changed under us */ + } +} + +/* + * __cds_wfs_pop_with_state_blocking: pop a node from the stack, with state. + * + * Returns NULL if stack is empty. + * + * Operations after pop push are consistent when observed before associated push. + * + * __cds_wfs_pop_blocking needs to be synchronized using one of the + * following techniques: + * + * 1) Calling __cds_wfs_pop_blocking under rcu read lock critical + * section. The caller must wait for a grace period to pass before + * freeing the returned node or modifying the cds_wfs_node structure. + * 2) Using mutual exclusion (e.g. mutexes) to protect + * __cds_wfs_pop_blocking and __cds_wfs_pop_all callers. + * 3) Ensuring that only ONE thread can call __cds_wfs_pop_blocking() + * and __cds_wfs_pop_all(). (multi-provider/single-consumer scheme). + * + * "state" saves state flags atomically sampled with pop operation. + */ +static inline +struct cds_wfs_node * +___cds_wfs_pop_with_state_blocking(cds_wfs_stack_ptr_t u_stack, int *state) +{ + return ___cds_wfs_pop(u_stack, state, 1); +} + +static inline +struct cds_wfs_node * +___cds_wfs_pop_blocking(cds_wfs_stack_ptr_t u_stack) +{ + return ___cds_wfs_pop_with_state_blocking(u_stack, NULL); +} + +/* + * __cds_wfs_pop_with_state_nonblocking: pop a node from the stack. + * + * Same as __cds_wfs_pop_with_state_blocking, but returns + * CDS_WFS_WOULDBLOCK if it needs to block. + * + * "state" saves state flags atomically sampled with pop operation. + */ +static inline +struct cds_wfs_node * +___cds_wfs_pop_with_state_nonblocking(cds_wfs_stack_ptr_t u_stack, int *state) +{ + return ___cds_wfs_pop(u_stack, state, 0); +} + +/* + * __cds_wfs_pop_nonblocking: pop a node from the stack. + * + * Same as __cds_wfs_pop_blocking, but returns CDS_WFS_WOULDBLOCK if + * it needs to block. + */ +static inline +struct cds_wfs_node * +___cds_wfs_pop_nonblocking(cds_wfs_stack_ptr_t u_stack) +{ + return ___cds_wfs_pop_with_state_nonblocking(u_stack, NULL); +} + +/* + * __cds_wfs_pop_all: pop all nodes from a stack. + * + * Operations after pop push are consistent when observed before associated push. + * + * __cds_wfs_pop_all does not require any synchronization with other + * push, nor with other __cds_wfs_pop_all, but requires synchronization + * matching the technique used to synchronize __cds_wfs_pop_blocking: + * + * 1) If __cds_wfs_pop_blocking is called under rcu read lock critical + * section, both __cds_wfs_pop_blocking and cds_wfs_pop_all callers + * must wait for a grace period to pass before freeing the returned + * node or modifying the cds_wfs_node structure. However, no RCU + * read-side critical section is needed around __cds_wfs_pop_all. + * 2) Using mutual exclusion (e.g. mutexes) to protect + * __cds_wfs_pop_blocking and __cds_wfs_pop_all callers. + * 3) Ensuring that only ONE thread can call __cds_wfs_pop_blocking() + * and __cds_wfs_pop_all(). (multi-provider/single-consumer scheme). + */ +static inline +struct cds_wfs_head * +___cds_wfs_pop_all(cds_wfs_stack_ptr_t u_stack) +{ + struct __cds_wfs_stack *s = u_stack._s; + struct cds_wfs_head *head; + + /* + * Implicit memory barrier after uatomic_xchg() matches implicit + * memory barrier before uatomic_xchg() in cds_wfs_push. It + * ensures that all nodes of the returned list are consistent. + * There is no need to issue memory barriers when iterating on + * the returned list, because the full memory barrier issued + * prior to each uatomic_cmpxchg, which each write to head, are + * taking care to order writes to each node prior to the full + * memory barrier after this uatomic_xchg(). + */ + head = uatomic_xchg_mo(&s->head, CDS_WFS_END, CMM_SEQ_CST); + cmm_emit_legacy_smp_mb(); + if (___cds_wfs_end(head)) + return NULL; + return head; +} + +/* + * cds_wfs_pop_lock: lock stack pop-protection mutex. + */ +static inline void _cds_wfs_pop_lock(struct cds_wfs_stack *s) +{ + int ret; + + ret = pthread_mutex_lock(&s->lock); + urcu_posix_assert(!ret); +} + +/* + * cds_wfs_pop_unlock: unlock stack pop-protection mutex. + */ +static inline void _cds_wfs_pop_unlock(struct cds_wfs_stack *s) +{ + int ret; + + ret = pthread_mutex_unlock(&s->lock); + urcu_posix_assert(!ret); +} + +/* + * Call __cds_wfs_pop_with_state_blocking with an internal pop mutex held. + */ +static inline +struct cds_wfs_node * +_cds_wfs_pop_with_state_blocking(struct cds_wfs_stack *s, int *state) +{ + struct cds_wfs_node *retnode; + cds_wfs_stack_ptr_t stack; + + _cds_wfs_pop_lock(s); + stack.s = s; + retnode = ___cds_wfs_pop_with_state_blocking(stack, state); + _cds_wfs_pop_unlock(s); + return retnode; +} + +/* + * Call _cds_wfs_pop_with_state_blocking without saving any state. + */ +static inline +struct cds_wfs_node * +_cds_wfs_pop_blocking(struct cds_wfs_stack *s) +{ + return _cds_wfs_pop_with_state_blocking(s, NULL); +} + +/* + * Call __cds_wfs_pop_all with an internal pop mutex held. + */ +static inline +struct cds_wfs_head * +_cds_wfs_pop_all_blocking(struct cds_wfs_stack *s) +{ + struct cds_wfs_head *rethead; + cds_wfs_stack_ptr_t stack; + + _cds_wfs_pop_lock(s); + stack.s = s; + rethead = ___cds_wfs_pop_all(stack); + _cds_wfs_pop_unlock(s); + return rethead; +} + +/* + * cds_wfs_first: get first node of a popped stack. + * + * Content written into the node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + * + * Used by for-like iteration macros in urcu/wfstack.h: + * cds_wfs_for_each_blocking() + * cds_wfs_for_each_blocking_safe() + * + * Returns NULL if popped stack is empty, top stack node otherwise. + */ +static inline struct cds_wfs_node * +_cds_wfs_first(struct cds_wfs_head *head) +{ + if (___cds_wfs_end(head)) + return NULL; + return &head->node; +} + +static inline struct cds_wfs_node * +___cds_wfs_next(struct cds_wfs_node *node, int blocking) +{ + struct cds_wfs_node *next; + + next = ___cds_wfs_node_sync_next(node, blocking); + /* + * CDS_WFS_WOULDBLOCK != CSD_WFS_END, so we can check for end + * even if ___cds_wfs_node_sync_next returns CDS_WFS_WOULDBLOCK, + * and still return CDS_WFS_WOULDBLOCK. + */ + if (___cds_wfs_end(next)) + return NULL; + return next; +} + +/* + * cds_wfs_next_blocking: get next node of a popped stack. + * + * Content written into the node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + * + * Used by for-like iteration macros in urcu/wfstack.h: + * cds_wfs_for_each_blocking() + * cds_wfs_for_each_blocking_safe() + * + * Returns NULL if reached end of popped stack, non-NULL next stack + * node otherwise. + */ +static inline struct cds_wfs_node * +_cds_wfs_next_blocking(struct cds_wfs_node *node) +{ + return ___cds_wfs_next(node, 1); +} + + +/* + * cds_wfs_next_nonblocking: get next node of a popped stack. + * + * Same as cds_wfs_next_blocking, but returns CDS_WFS_WOULDBLOCK if it + * needs to block. + */ +static inline struct cds_wfs_node * +_cds_wfs_next_nonblocking(struct cds_wfs_node *node) +{ + return ___cds_wfs_next(node, 0); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_STATIC_WFSTACK_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/syscall-compat.h b/external/lgpl2/userspace-rcu/dist/include/urcu/syscall-compat.h new file mode 100644 index 0000000000000..d49b9886b8d00 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/syscall-compat.h @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2013 Pierre-Luc St-Charles +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_SYSCALL_COMPAT_H +#define _URCU_SYSCALL_COMPAT_H + +/* + * Userspace RCU library - Syscall Compatibility Header + */ + +#if defined(__ANDROID__) || defined(__sun__) || defined(__GNU__) +#include +#elif defined(__linux__) || defined(__GLIBC__) +#include + +#elif defined(__CYGWIN__) || defined(__APPLE__) || \ + defined(__FreeBSD__) || defined(__DragonFly__) || \ + defined(__OpenBSD__) +/* Don't include anything on these platforms. */ + +#else +#error "Add platform support to urcu/syscall-compat.h" +#endif + +#endif /* _URCU_SYSCALL_COMPAT_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/system.h b/external/lgpl2/userspace-rcu/dist/include/urcu/system.h new file mode 100644 index 0000000000000..139c37f6d474a --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/system.h @@ -0,0 +1,71 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +#ifndef _URCU_SYSTEM_H +#define _URCU_SYSTEM_H + +/* + * System definitions. + */ + +#include +#include +#include + +#ifdef CONFIG_RCU_USE_ATOMIC_BUILTINS + +#define CMM_LOAD_SHARED(x) \ + __atomic_load_n(cmm_cast_volatile(&(x)), __ATOMIC_RELAXED) + +#define _CMM_LOAD_SHARED(x) CMM_LOAD_SHARED(x) + +#define CMM_STORE_SHARED(x, v) \ + __extension__ \ + ({ \ + __typeof__(v) _v = (v); \ + __atomic_store_n(cmm_cast_volatile(&(x)), _v, \ + __ATOMIC_RELAXED); \ + _v; \ + }) + +#define _CMM_STORE_SHARED(x, v) CMM_STORE_SHARED(x, v) + +#else +/* + * Identify a shared load. A cmm_smp_rmc() or cmm_smp_mc() should come + * before the load. + */ +#define _CMM_LOAD_SHARED(p) CMM_ACCESS_ONCE(p) + +/* + * Load a data from shared memory, doing a cache flush if required. + */ +#define CMM_LOAD_SHARED(p) \ + __extension__ \ + ({ \ + cmm_smp_rmc(); \ + _CMM_LOAD_SHARED(p); \ + }) + +/* + * Identify a shared store. A cmm_smp_wmc() or cmm_smp_mc() should + * follow the store. + */ +#define _CMM_STORE_SHARED(x, v) __extension__ ({ CMM_ACCESS_ONCE(x) = (v); }) + +/* + * Store v into x, where x is located in shared memory. Performs the + * required cache flush after writing. Returns v. + */ +#define CMM_STORE_SHARED(x, v) \ + __extension__ \ + ({ \ + __typeof__(x) _v = _CMM_STORE_SHARED(x, v); \ + cmm_smp_wmc(); \ + _v = _v; /* Work around clang "unused result" */ \ + }) + +#endif /* CONFIG_RCU_USE_ATOMIC_BUILTINS */ + +#endif /* _URCU_SYSTEM_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/tls-compat.h b/external/lgpl2/userspace-rcu/dist/include/urcu/tls-compat.h new file mode 100644 index 0000000000000..1f3ef0fbbdb5b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/tls-compat.h @@ -0,0 +1,151 @@ +// SPDX-FileCopyrightText: 2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_TLS_COMPAT_H +#define _URCU_TLS_COMPAT_H + +/* + * Userspace RCU library - Thread-Local Storage Compatibility Header + */ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef CONFIG_RCU_TLS + +/* + * Default to '__thread' on all C and C++ compilers except MSVC. While C11 has + * '_Thread_local' and C++11 has 'thread_local', only '__thread' seems to have + * a compatible implementation when linking public extern symbols across + * language boundaries. + * + * For more details, see 'https://gcc.gnu.org/onlinedocs/gcc/Thread-Local.html'. + */ +#if defined(_MSC_VER) +# define URCU_TLS_STORAGE_CLASS __declspec(thread) +#else +# define URCU_TLS_STORAGE_CLASS __thread +#endif + +/* + * Hint: How to define/declare TLS variables of compound types + * such as array or function pointers? + * + * Answer: Use typedef to assign a type_name to the compound type. + * Example: Define a TLS variable which is an int array with len=4: + * + * typedef int my_int_array_type[4]; + * DEFINE_URCU_TLS(my_int_array_type, var_name); + * + * Another example: + * typedef void (*call_rcu_flavor)(struct rcu_head *, XXXX); + * DECLARE_URCU_TLS(call_rcu_flavor, p_call_rcu); + * + * NOTE: URCU_TLS() is NOT async-signal-safe, you can't use it + * inside any function which can be called from signal handler. + * + * But if pthread_getspecific() is async-signal-safe in your + * platform, you can make URCU_TLS() async-signal-safe via: + * ensuring the first call to URCU_TLS() of a given TLS variable of + * all threads is called earliest from a non-signal handler function. + * + * Example: In any thread, the first call of URCU_TLS(rcu_reader) + * is called from rcu_register_thread(), so we can ensure all later + * URCU_TLS(rcu_reader) in any thread is async-signal-safe. + * + * Moreover, URCU_TLS variables should not be touched from signal + * handlers setup with with sigaltstack(2). + */ + +# define DECLARE_URCU_TLS(type, name) \ + URCU_TLS_STORAGE_CLASS type name + +# define DEFINE_URCU_TLS(type, name) \ + URCU_TLS_STORAGE_CLASS type name + +# define DEFINE_URCU_TLS_INIT(type, name, init) \ + URCU_TLS_STORAGE_CLASS type name = (init) + +# define URCU_TLS(name) (name) + +#else /* #ifndef CONFIG_RCU_TLS */ + +/* + * The *_1() macros ensure macro parameters are expanded. + */ + +# include + +struct urcu_tls { + pthread_key_t key; + pthread_mutex_t init_mutex; + int init_done; +}; + +# define DECLARE_URCU_TLS_1(type, name) \ + type *__tls_access_ ## name(void) +# define DECLARE_URCU_TLS(type, name) \ + DECLARE_URCU_TLS_1(type, name) + +/* + * Note: we don't free memory at process exit, since it will be dealt + * with by the OS. + */ +# define DEFINE_URCU_TLS_INIT_1(type, name, do_init) \ + type *__tls_access_ ## name(void) \ + { \ + static struct urcu_tls __tls_ ## name = { \ + .key = 0, \ + .init_mutex = PTHREAD_MUTEX_INITIALIZER,\ + .init_done = 0, \ + }; \ + __typeof__(type) *__tls_p; \ + if (!__tls_ ## name.init_done) { \ + /* Mutex to protect concurrent init */ \ + pthread_mutex_lock(&__tls_ ## name.init_mutex); \ + if (!__tls_ ## name.init_done) { \ + (void) pthread_key_create(&__tls_ ## name.key, \ + free); \ + cmm_smp_wmb(); /* create key before write init_done */ \ + __tls_ ## name.init_done = 1; \ + } \ + pthread_mutex_unlock(&__tls_ ## name.init_mutex); \ + } \ + cmm_smp_rmb(); /* read init_done before getting key */ \ + __tls_p = (__typeof__(type) *) pthread_getspecific(__tls_ ## name.key); \ + if (caa_unlikely(__tls_p == NULL)) { \ + __tls_p = (__typeof__(type) *) calloc(1, sizeof(type)); \ + do_init \ + (void) pthread_setspecific(__tls_ ## name.key, \ + __tls_p); \ + } \ + return __tls_p; \ + } + +# define _URCU_TLS_INIT(init) \ + *__tls_p = (init); + +# define DEFINE_URCU_TLS_INIT(type, name, init) \ + DEFINE_URCU_TLS_INIT_1(type, name, _URCU_TLS_INIT(init)) + +# define DEFINE_URCU_TLS(type, name) \ + DEFINE_URCU_TLS_INIT_1(type, name, /* empty */) + +# define URCU_TLS_1(name) (*__tls_access_ ## name()) + +# define URCU_TLS(name) URCU_TLS_1(name) + +#endif /* #else #ifndef CONFIG_RCU_TLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_TLS_COMPAT_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic.h new file mode 100644 index 0000000000000..1af3cd898ebe1 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic.h @@ -0,0 +1,104 @@ +// SPDX-FileCopyrightText: 2020 Michael Jeanson +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_UATOMIC_H +#define _URCU_UATOMIC_H + +#include +#include +#include + +enum cmm_memorder { + CMM_RELAXED = 0, + CMM_CONSUME = 1, + CMM_ACQUIRE = 2, + CMM_RELEASE = 3, + CMM_ACQ_REL = 4, + CMM_SEQ_CST = 5, + CMM_SEQ_CST_FENCE = 6, +}; + +#if defined(_CMM_TOOLCHAIN_SUPPORT_C11_MM) + +/* + * Make sure that CMM_SEQ_CST_FENCE is not equivalent to other memory orders. + */ +urcu_static_assert(CMM_RELAXED == __ATOMIC_RELAXED, "CMM_RELAXED vs __ATOMIC_RELAXED values mismatch", cmm_relaxed_values_mismatch); +urcu_static_assert(CMM_CONSUME == __ATOMIC_CONSUME, "CMM_CONSUME vs __ATOMIC_CONSUME values mismatch", cmm_consume_values_mismatch); +urcu_static_assert(CMM_ACQUIRE == __ATOMIC_ACQUIRE, "CMM_ACQUIRE vs __ATOMIC_ACQUIRE values mismatch", cmm_acquire_values_mismatch); +urcu_static_assert(CMM_RELEASE == __ATOMIC_RELEASE, "CMM_RELEASE vs __ATOMIC_RELEASE values mismatch", cmm_release_values_mismatch); +urcu_static_assert(CMM_ACQ_REL == __ATOMIC_ACQ_REL, "CMM_ACQ_REL vs __ATOMIC_ACQ_REL values mismatch", cmm_acq_rel_values_mismatch); +urcu_static_assert(CMM_SEQ_CST == __ATOMIC_SEQ_CST, "CMM_SEQ_CST vs __ATOMIC_SEQ_CST values mismatch", cmm_seq_cst_values_mismatch); + +/* + * This is not part of the public API. It it used internally to implement the + * CMM_SEQ_CST_FENCE memory order. + * + * NOTE: Using switch here instead of if statement to avoid -Wduplicated-cond + * warning when memory order is conditionally determined. + */ +static inline void cmm_seq_cst_fence_after_atomic(enum cmm_memorder mo) +{ + switch (mo) { + case CMM_SEQ_CST_FENCE: + cmm_smp_mb(); + break; + default: + break; + } +} + +#endif + +/* + * This is not part of the public API. It is used internally to convert from the + * CMM memory model to the C11 memory model. + */ +static inline int cmm_to_c11(int mo) +{ + if (mo == CMM_SEQ_CST_FENCE) { + return CMM_SEQ_CST; + } + return mo; +} + +#include + +#if defined(CONFIG_RCU_USE_ATOMIC_BUILTINS) +#include +#elif defined(URCU_ARCH_X86) +#include +#elif defined(URCU_ARCH_PPC) +#include +#elif defined(URCU_ARCH_S390) +#include +#elif defined(URCU_ARCH_SPARC64) +#include +#elif defined(URCU_ARCH_ALPHA) +#include +#elif defined(URCU_ARCH_IA64) +#include +#elif defined(URCU_ARCH_ARM) +#include +#elif defined(URCU_ARCH_AARCH64) +#include +#elif defined(URCU_ARCH_MIPS) +#include +#elif defined(URCU_ARCH_NIOS2) +#include +#elif defined(URCU_ARCH_TILE) +#include +#elif defined(URCU_ARCH_HPPA) +#include +#elif defined(URCU_ARCH_M68K) +#include +#elif defined(URCU_ARCH_RISCV) +#include +#elif defined(URCU_ARCH_LOONGARCH) +#include +#else +#error "Cannot build: unrecognized architecture, see ." +#endif + +#endif /* _URCU_UATOMIC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/aarch64.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/aarch64.h new file mode 100644 index 0000000000000..31d428d339ece --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/aarch64.h @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: 1991-1994 by Xerox Corporation. All rights reserved. +// SPDX-FileCopyrightText: 1996-1999 by Silicon Graphics. All rights reserved. +// SPDX-FileCopyrightText: 1999-2004 Hewlett-Packard Development Company, L.P. +// SPDX-FileCopyrightText: 2009-2015 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2010 Paul E. McKenney, IBM Corporation +// +// SPDX-License-Identifier: LicenseRef-Boehm-GC + +#ifndef _URCU_ARCH_UATOMIC_AARCH64_H +#define _URCU_ARCH_UATOMIC_AARCH64_H + +/* + * Code inspired from libuatomic_ops-1.2, inherited in part from the + * Boehm-Demers-Weiser conservative garbage collector. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define UATOMIC_HAS_ATOMIC_BYTE +#define UATOMIC_HAS_ATOMIC_SHORT + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_UATOMIC_AARCH64_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/alpha.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/alpha.h new file mode 100644 index 0000000000000..afa7dff0268f1 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/alpha.h @@ -0,0 +1,16 @@ +// SPDX-FileCopyrightText: 2010 Paolo Bonzini +// +// SPDX-License-Identifier: MIT + +#ifndef _URCU_UATOMIC_ARCH_ALPHA_H +#define _URCU_UATOMIC_ARCH_ALPHA_H + +/* + * Atomic exchange operations for the Alpha architecture. Let GCC do it. + */ + +#include +#include +#include + +#endif /* _URCU_UATOMIC_ARCH_ALPHA_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/api.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/api.h new file mode 100644 index 0000000000000..4b92464092e8b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/api.h @@ -0,0 +1,71 @@ +#ifndef _URCU_UATOMIC_API_H +#define _URCU_UATOMIC_API_H + +/* + * Select second argument. Use inside macros to implement optional last macro + * argument, such as: + * + * #define macro(_a, _b, _c, _optional...) \ + * _uatomic_select_arg1(_, ##_optional, do_default_macro()) + */ +#define _uatomic_select_arg1(arg0, arg1, ...) arg1 + +/* + * Like _uatomic_select_arg2(), but can be used for selecting a second optional + * argument. + */ +#define _uatomic_select_arg2(arg0, arg1, arg2, ...) arg2 + +#define _uatomic_default_mo(dflt, mo...) \ + _uatomic_select_arg1(_, ##mo, dflt) + +#define _uatomic_default_mo2(dflt, mo...) \ + _uatomic_select_arg2(_, ##mo, dflt, dflt) + +#define uatomic_load(addr, mo...) \ + uatomic_load_mo(addr, _uatomic_default_mo(CMM_RELAXED, ##mo)) + +#define uatomic_read(addr, mo...) \ + uatomic_load_mo(addr, _uatomic_default_mo(CMM_RELAXED, ##mo)) + +#define uatomic_store(addr, value, mo...) \ + uatomic_store_mo(addr, value, _uatomic_default_mo(CMM_RELAXED, ##mo)) + +#define uatomic_set(addr, value, mo...) \ + uatomic_store_mo(addr, value, _uatomic_default_mo(CMM_RELAXED, ##mo)) + +#define uatomic_add_return(addr, v, mo...) \ + uatomic_add_return_mo(addr, v, _uatomic_default_mo(CMM_SEQ_CST_FENCE, ##mo)) + +#define uatomic_sub_return(addr, v, mo...) \ + uatomic_sub_return_mo(addr, v, _uatomic_default_mo(CMM_SEQ_CST_FENCE, ##mo)) + +#define uatomic_and(addr, mask, mo...) \ + uatomic_and_mo(addr, mask, _uatomic_default_mo(CMM_SEQ_CST, ##mo)) + +#define uatomic_or(addr, mask, mo...) \ + uatomic_or_mo(addr, mask, _uatomic_default_mo(CMM_RELAXED, ##mo)) + +#define uatomic_add(addr, v, mo...) \ + uatomic_add_mo(addr, v, _uatomic_default_mo(CMM_RELAXED, ##mo)) + +#define uatomic_sub(addr, v, mo...) \ + uatomic_sub_mo(addr, v, _uatomic_default_mo(CMM_RELAXED, ##mo)) + +#define uatomic_inc(addr, mo...) \ + uatomic_inc_mo(addr, _uatomic_default_mo(CMM_RELAXED, ##mo)) + +#define uatomic_dec(addr, mo...) \ + uatomic_dec_mo(addr, _uatomic_default_mo(CMM_RELAXED, ##mo)) + +#define uatomic_xchg(addr, value, mo...) \ + uatomic_xchg_mo(addr, value, \ + _uatomic_default_mo(CMM_SEQ_CST_FENCE, ##mo)) + +#define uatomic_cmpxchg(addr, value, _new, mo...) \ + uatomic_cmpxchg_mo(addr, value, _new, \ + _uatomic_default_mo(CMM_SEQ_CST_FENCE, ##mo), \ + _uatomic_default_mo2(CMM_RELAXED, ##mo)) + + +#endif /* _URUC_UATOMIC_API_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/arm.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/arm.h new file mode 100644 index 0000000000000..d2ceb714b540e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/arm.h @@ -0,0 +1,86 @@ +// SPDX-FileCopyrightText: 1991-1994 by Xerox Corporation. All rights reserved. +// SPDX-FileCopyrightText: 1996-1999 by Silicon Graphics. All rights reserved. +// SPDX-FileCopyrightText: 1999-2004 Hewlett-Packard Development Company, L.P. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2010 Paul E. McKenney, IBM Corporation +// +// SPDX-License-Identifier: LicenseRef-Boehm-GC + +#ifndef _URCU_ARCH_UATOMIC_ARM_H +#define _URCU_ARCH_UATOMIC_ARM_H + +/* + * Atomics for ARM. This approach is usable on kernels back to 2.6.15. + * + * Code inspired from libuatomic_ops-1.2, inherited in part from the + * Boehm-Demers-Weiser conservative garbage collector. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* xchg */ + +/* + * If the toolchain supports the C11 memory model, then it is safe to implement + * `uatomic_xchg()' in term of __atomic builtins. This has the effect of + * reducing the number of emitted memory barriers except for the + * CMM_SEQ_CST_FENCE memory order. + */ +#ifdef _CMM_TOOLCHAIN_SUPPORT_C11_MM +# define uatomic_xchg_mo(addr, v, mo) \ + __extension__ \ + ({ \ + __typeof__((*addr)) _old = \ + __atomic_exchange_n(cmm_cast_volatile(addr), v, \ + cmm_to_c11(mo)); \ + cmm_seq_cst_fence_after_atomic(mo); \ + _old; \ + }) +#else + +static inline void _cmm_compat_c11_smp_mb__before_xchg_mo(enum cmm_memorder mo) +{ + switch (mo) { + case CMM_SEQ_CST_FENCE: + case CMM_SEQ_CST: + case CMM_ACQ_REL: + case CMM_RELEASE: + cmm_smp_mb(); + break; + case CMM_ACQUIRE: + case CMM_CONSUME: + case CMM_RELAXED: + break; + default: + abort(); + } +} + +/* + * Based on [1], __sync_lock_test_and_set() is not a full barrier, but + * instead only an acquire barrier. Given that uatomic_xchg() acts as + * both release and acquire barriers, we therefore need to have our own + * release barrier before this operation. + * + * [1] https://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html + */ +# define uatomic_xchg_mo(addr, v, mo) \ + ({ \ + _cmm_compat_c11_smp_mb__before_xchg_mo(mo); \ + __sync_lock_test_and_set(addr, v); \ + }) +#endif /* _CMM_TOOLCHAIN_SUPPORT_C11_MM */ + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_UATOMIC_ARM_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/builtins-generic.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/builtins-generic.h new file mode 100644 index 0000000000000..ca11cf146cefb --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/builtins-generic.h @@ -0,0 +1,127 @@ +// SPDX-FileCopyrightText: 2023 Olivier Dion +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * urcu/uatomic/builtins-generic.h + */ + +#ifndef _URCU_UATOMIC_BUILTINS_GENERIC_H +#define _URCU_UATOMIC_BUILTINS_GENERIC_H + +#include +#include + +#define uatomic_store_mo(addr, v, mo) \ + do { \ + __atomic_store_n(cmm_cast_volatile(addr), v, \ + cmm_to_c11(mo)); \ + cmm_seq_cst_fence_after_atomic(mo); \ + } while (0) + +#define uatomic_load_mo(addr, mo) \ + __extension__ \ + ({ \ + __typeof__(*(addr)) _value = \ + __atomic_load_n(cmm_cast_volatile(addr), \ + cmm_to_c11(mo)); \ + cmm_seq_cst_fence_after_atomic(mo); \ + \ + _value; \ + }) + +#define uatomic_cmpxchg_mo(addr, old, new, mos, mof) \ + __extension__ \ + ({ \ + __typeof__(*(addr)) _old = (__typeof__(*(addr)))old; \ + \ + if (__atomic_compare_exchange_n(cmm_cast_volatile(addr), \ + &_old, new, 0, \ + cmm_to_c11(mos), \ + cmm_to_c11(mof))) { \ + cmm_seq_cst_fence_after_atomic(mos); \ + } else { \ + cmm_seq_cst_fence_after_atomic(mof); \ + } \ + _old; \ + }) + +#define uatomic_xchg_mo(addr, v, mo) \ + __extension__ \ + ({ \ + __typeof__((*addr)) _old = \ + __atomic_exchange_n(cmm_cast_volatile(addr), v, \ + cmm_to_c11(mo)); \ + cmm_seq_cst_fence_after_atomic(mo); \ + _old; \ + }) + +#define uatomic_add_return_mo(addr, v, mo) \ + __extension__ \ + ({ \ + __typeof__(*(addr)) _old = \ + __atomic_add_fetch(cmm_cast_volatile(addr), v, \ + cmm_to_c11(mo)); \ + cmm_seq_cst_fence_after_atomic(mo); \ + _old; \ + }) + + +#define uatomic_sub_return_mo(addr, v, mo) \ + __extension__ \ + ({ \ + __typeof__(*(addr)) _old = \ + __atomic_sub_fetch(cmm_cast_volatile(addr), v, \ + cmm_to_c11(mo)); \ + cmm_seq_cst_fence_after_atomic(mo); \ + _old; \ + }) + + +#define uatomic_and_mo(addr, mask, mo) \ + do { \ + (void) __atomic_and_fetch(cmm_cast_volatile(addr), mask, \ + cmm_to_c11(mo)); \ + cmm_seq_cst_fence_after_atomic(mo); \ + } while (0) + + +#define uatomic_or_mo(addr, mask, mo) \ + do { \ + (void) __atomic_or_fetch(cmm_cast_volatile(addr), mask, \ + cmm_to_c11(mo)); \ + cmm_seq_cst_fence_after_atomic(mo); \ + } while (0) + + +#define uatomic_add_mo(addr, v, mo) \ + (void) uatomic_add_return_mo(addr, v, mo) + +#define uatomic_sub_mo(addr, v, mo) \ + (void) uatomic_sub_return_mo(addr, v, mo) + +#define uatomic_inc_mo(addr, mo) \ + uatomic_add_mo(addr, 1, mo) + +#define uatomic_dec_mo(addr, mo) \ + uatomic_sub_mo(addr, 1, mo) + +#define cmm_smp_mb__before_uatomic_and() cmm_smp_mb() +#define cmm_smp_mb__after_uatomic_and() cmm_smp_mb() + +#define cmm_smp_mb__before_uatomic_or() cmm_smp_mb() +#define cmm_smp_mb__after_uatomic_or() cmm_smp_mb() + +#define cmm_smp_mb__before_uatomic_add() cmm_smp_mb() +#define cmm_smp_mb__after_uatomic_add() cmm_smp_mb() + +#define cmm_smp_mb__before_uatomic_sub() cmm_smp_mb() +#define cmm_smp_mb__after_uatomic_sub() cmm_smp_mb() + +#define cmm_smp_mb__before_uatomic_inc() cmm_smp_mb() +#define cmm_smp_mb__after_uatomic_inc() cmm_smp_mb() + +#define cmm_smp_mb__before_uatomic_dec() cmm_smp_mb() +#define cmm_smp_mb__after_uatomic_dec() cmm_smp_mb() + +#endif /* _URCU_UATOMIC_BUILTINS_GENERIC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/builtins.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/builtins.h new file mode 100644 index 0000000000000..5b92700545031 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/builtins.h @@ -0,0 +1,67 @@ +// SPDX-FileCopyrightText: 2023 Olivier Dion +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * urcu/uatomic/builtins.h + */ + +#ifndef _URCU_UATOMIC_BUILTINS_H +#define _URCU_UATOMIC_BUILTINS_H + +#include + +#if defined(__has_builtin) +# if !__has_builtin(__atomic_store_n) +# error "Toolchain does not support __atomic_store_n." +# endif +# if !__has_builtin(__atomic_load_n) +# error "Toolchain does not support __atomic_load_n." +# endif +# if !__has_builtin(__atomic_exchange_n) +# error "Toolchain does not support __atomic_exchange_n." +# endif +# if !__has_builtin(__atomic_compare_exchange_n) +# error "Toolchain does not support __atomic_compare_exchange_n." +# endif +# if !__has_builtin(__atomic_add_fetch) +# error "Toolchain does not support __atomic_add_fetch." +# endif +# if !__has_builtin(__atomic_sub_fetch) +# error "Toolchain does not support __atomic_sub_fetch." +# endif +# if !__has_builtin(__atomic_or_fetch) +# error "Toolchain does not support __atomic_or_fetch." +# endif +# if !__has_builtin(__atomic_thread_fence) +# error "Toolchain does not support __atomic_thread_fence." +# endif +# if !__has_builtin(__atomic_signal_fence) +# error "Toolchain does not support __atomic_signal_fence." +# endif +#elif defined(__GNUC__) +# define GCC_VERSION (__GNUC__ * 10000 + \ + __GNUC_MINOR__ * 100 + \ + __GNUC_PATCHLEVEL__) +# if GCC_VERSION < 40700 +# error "GCC version is too old. Version must be 4.7 or greater" +# endif +# undef GCC_VERSION +#else +# error "Toolchain is not supported." +#endif + +#if defined(__GNUC__) +# define UATOMIC_HAS_ATOMIC_BYTE __GCC_ATOMIC_CHAR_LOCK_FREE +# define UATOMIC_HAS_ATOMIC_SHORT __GCC_ATOMIC_SHORT_LOCK_FREE +#elif defined(__clang__) +# define UATOMIC_HAS_ATOMIC_BYTE __CLANG_ATOMIC_CHAR_LOCK_FREE +# define UATOMIC_HAS_ATOMIC_SHORT __CLANG_ATOMIC_SHORT_LOCK_FREE +#else +/* # define UATOMIC_HAS_ATOMIC_BYTE */ +/* # define UATOMIC_HAS_ATOMIC_SHORT */ +#endif + +#include + +#endif /* _URCU_UATOMIC_BUILTINS_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/gcc.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/gcc.h new file mode 100644 index 0000000000000..e0763afeffd9d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/gcc.h @@ -0,0 +1,38 @@ +// SPDX-FileCopyrightText: 1991-1994 by Xerox Corporation. All rights reserved. +// SPDX-FileCopyrightText: 1996-1999 by Silicon Graphics. All rights reserved. +// SPDX-FileCopyrightText: 1999-2004 Hewlett-Packard Development Company, L.P. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2010 Paul E. McKenney, IBM Corporation +// +// SPDX-License-Identifier: LicenseRef-Boehm-GC + +#ifndef _URCU_ARCH_UATOMIC_GCC_H +#define _URCU_ARCH_UATOMIC_GCC_H + +/* + * Code inspired from libuatomic_ops-1.2, inherited in part from the + * Boehm-Demers-Weiser conservative garbage collector. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * If your platform doesn't have a full set of atomics, you will need + * a separate uatomic_arch_*.h file for your architecture. Otherwise, + * just rely on the definitions in uatomic/generic.h. + */ +#define UATOMIC_HAS_ATOMIC_BYTE +#define UATOMIC_HAS_ATOMIC_SHORT + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_UATOMIC_GCC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/generic.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/generic.h new file mode 100644 index 0000000000000..5a81e007ea1c8 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/generic.h @@ -0,0 +1,716 @@ +// SPDX-FileCopyrightText: 1991-1994 by Xerox Corporation. All rights reserved. +// SPDX-FileCopyrightText: 1996-1999 by Silicon Graphics. All rights reserved. +// SPDX-FileCopyrightText: 1999-2004 Hewlett-Packard Development Company, L.P. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2010 Paolo Bonzini +// +// SPDX-License-Identifier: LicenseRef-Boehm-GC + +#ifndef _URCU_UATOMIC_GENERIC_H +#define _URCU_UATOMIC_GENERIC_H + +/* + * Code inspired from libuatomic_ops-1.2, inherited in part from the + * Boehm-Demers-Weiser conservative garbage collector. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Can be defined for the architecture. + * + * What needs to be emitted _before_ the `operation' with memory ordering `mo'. + */ +#ifndef _cmm_compat_c11_smp_mb__before_mo +# define _cmm_compat_c11_smp_mb__before_mo(operation, mo) \ + do { \ + switch (mo) { \ + case CMM_SEQ_CST_FENCE: \ + case CMM_SEQ_CST: \ + case CMM_ACQ_REL: \ + case CMM_RELEASE: \ + cmm_smp_mb(); \ + break; \ + case CMM_ACQUIRE: \ + case CMM_CONSUME: \ + case CMM_RELAXED: \ + break; \ + default: \ + abort(); \ + break; \ + \ + } \ + } while(0) + +#endif /* _cmm_compat_c11_smp_mb__before_mo */ + +/* + * Can be defined for the architecture. + * + * What needs to be emitted _after_ the `operation' with memory ordering `mo'. + */ +#ifndef _cmm_compat_c11_smp_mb__after_mo +# define _cmm_compat_c11_smp_mb__after_mo(operation, mo) \ + do { \ + switch (mo) { \ + case CMM_SEQ_CST_FENCE: \ + case CMM_SEQ_CST: \ + case CMM_ACQUIRE: \ + case CMM_CONSUME: \ + case CMM_ACQ_REL: \ + cmm_smp_mb(); \ + break; \ + case CMM_RELEASE: \ + case CMM_RELAXED: \ + break; \ + default: \ + abort(); \ + break; \ + \ + } \ + } while(0) +#endif /* _cmm_compat_c11_smp_mb__after_mo */ + +/* + * If the toolchain supports the C11 memory model, then it is safe to implement + * `uatomic_store_mo()' in term of __atomic builtins. This has the effect of + * reducing the number of emitted memory barriers except for the + * CMM_SEQ_CST_FENCE memory order. + */ +#ifndef uatomic_store_mo +# ifdef _CMM_TOOLCHAIN_SUPPORT_C11_MM +# define uatomic_store_mo(addr, v, mo) \ + do { \ + __atomic_store_n(cmm_cast_volatile(addr), v, \ + cmm_to_c11(mo)); \ + cmm_seq_cst_fence_after_atomic(mo); \ + } while (0) +# else +# define uatomic_store_mo(addr, v, mo) \ + do { \ + _cmm_compat_c11_smp_mb__before_mo(uatomic_store, mo); \ + (void) CMM_STORE_SHARED(*(addr), v); \ + _cmm_compat_c11_smp_mb__after_mo(uatomic_store, mo); \ + } while (0) +# endif /* _CMM_TOOLCHAIN_SUPPORT_C11_MM */ +#endif /* !uatomic_store */ + +/* + * If the toolchain supports the C11 memory model, then it is safe to implement + * `uatomic_load_mo()' in term of __atomic builtins. This has the effect of + * reducing the number of emitted memory barriers except for the + * CMM_SEQ_CST_FENCE memory order. + */ +#ifndef uatomic_load_mo +# ifdef _CMM_TOOLCHAIN_SUPPORT_C11_MM +# define uatomic_load_mo(addr, mo) \ + __extension__ \ + ({ \ + __typeof__(*(addr)) _value = \ + __atomic_load_n(cmm_cast_volatile(addr), \ + cmm_to_c11(mo)); \ + cmm_seq_cst_fence_after_atomic(mo); \ + \ + _value; \ + }) +# else +# define uatomic_load_mo(addr, mo) \ + __extension__ \ + ({ \ + _cmm_compat_c11_smp_mb__before_mo(uatomic_load, mo); \ + __typeof__(*(addr)) _rcu_value = CMM_LOAD_SHARED(*(addr)); \ + _cmm_compat_c11_smp_mb__after_mo(uatomic_load, mo); \ + \ + _rcu_value; \ + }) +# endif /* _CMM_TOOLCHAIN_SUPPORT_C11_MM */ +#endif /* !uatomic_load */ + +#if !defined __OPTIMIZE__ || defined UATOMIC_NO_LINK_ERROR +#ifdef ILLEGAL_INSTR +static inline __attribute__((always_inline)) +void _uatomic_link_error(void) +{ + /* + * generate an illegal instruction. Cannot catch this with + * linker tricks when optimizations are disabled. + */ + __asm__ __volatile__(ILLEGAL_INSTR); +} +#else +static inline __attribute__((always_inline, __noreturn__)) +void _uatomic_link_error(void) +{ + __builtin_trap(); +} +#endif + + +/* + * NOTE: All RMW operations are implemented using the `__sync' builtins. All + * builtins used are documented to be considered a "full barrier". Therefore, + * for RMW operations, nothing is emitted for any memory order. + */ + +#else /* #if !defined __OPTIMIZE__ || defined UATOMIC_NO_LINK_ERROR */ +extern void _uatomic_link_error(void); +#endif /* #else #if !defined __OPTIMIZE__ || defined UATOMIC_NO_LINK_ERROR */ + +/* uatomic_cmpxchg_mo */ + +#ifndef uatomic_cmpxchg_mo +static inline __attribute__((always_inline)) +unsigned long _uatomic_cmpxchg(void *addr, unsigned long old, + unsigned long _new, int len) +{ + switch (len) { +#ifdef UATOMIC_HAS_ATOMIC_BYTE + case 1: + return __sync_val_compare_and_swap_1((uint8_t *) addr, old, + _new); +#endif +#ifdef UATOMIC_HAS_ATOMIC_SHORT + case 2: + return __sync_val_compare_and_swap_2((uint16_t *) addr, old, + _new); +#endif + case 4: + return __sync_val_compare_and_swap_4((uint32_t *) addr, old, + _new); +#if (CAA_BITS_PER_LONG == 64) + case 8: + return __sync_val_compare_and_swap_8((uint64_t *) addr, old, + _new); +#endif + } + _uatomic_link_error(); + return 0; +} + +#define uatomic_cmpxchg_mo(addr, old, _new, mos, mof) \ + ((__typeof__(*(addr))) _uatomic_cmpxchg((addr), \ + caa_cast_long_keep_sign(old), \ + caa_cast_long_keep_sign(_new), \ + sizeof(*(addr)))) +/* uatomic_and_mo */ + +#ifndef uatomic_and_mo +static inline __attribute__((always_inline)) +void _uatomic_and(void *addr, unsigned long val, + int len) +{ + switch (len) { +#ifdef UATOMIC_HAS_ATOMIC_BYTE + case 1: + __sync_and_and_fetch_1((uint8_t *) addr, val); + return; +#endif +#ifdef UATOMIC_HAS_ATOMIC_SHORT + case 2: + __sync_and_and_fetch_2((uint16_t *) addr, val); + return; +#endif + case 4: + __sync_and_and_fetch_4((uint32_t *) addr, val); + return; +#if (CAA_BITS_PER_LONG == 64) + case 8: + __sync_and_and_fetch_8((uint64_t *) addr, val); + return; +#endif + } + _uatomic_link_error(); +} + +#define uatomic_and_mo(addr, v, mo) \ + (_uatomic_and((addr), \ + caa_cast_long_keep_sign(v), \ + sizeof(*(addr)))) +#define cmm_smp_mb__before_uatomic_and() cmm_barrier() +#define cmm_smp_mb__after_uatomic_and() cmm_barrier() + +#endif + +/* uatomic_or_mo */ + +#ifndef uatomic_or_mo +static inline __attribute__((always_inline)) +void _uatomic_or(void *addr, unsigned long val, + int len) +{ + switch (len) { +#ifdef UATOMIC_HAS_ATOMIC_BYTE + case 1: + __sync_or_and_fetch_1((uint8_t *) addr, val); + return; +#endif +#ifdef UATOMIC_HAS_ATOMIC_SHORT + case 2: + __sync_or_and_fetch_2((uint16_t *) addr, val); + return; +#endif + case 4: + __sync_or_and_fetch_4((uint32_t *) addr, val); + return; +#if (CAA_BITS_PER_LONG == 64) + case 8: + __sync_or_and_fetch_8((uint64_t *) addr, val); + return; +#endif + } + _uatomic_link_error(); + return; +} + +#define uatomic_or_mo(addr, v, mo) \ + (_uatomic_or((addr), \ + caa_cast_long_keep_sign(v), \ + sizeof(*(addr)))) +#define cmm_smp_mb__before_uatomic_or() cmm_barrier() +#define cmm_smp_mb__after_uatomic_or() cmm_barrier() + +#endif + + +/* uatomic_add_return_mo */ + +#ifndef uatomic_add_return_mo +static inline __attribute__((always_inline)) +unsigned long _uatomic_add_return(void *addr, unsigned long val, + int len) +{ + switch (len) { +#ifdef UATOMIC_HAS_ATOMIC_BYTE + case 1: + return __sync_add_and_fetch_1((uint8_t *) addr, val); +#endif +#ifdef UATOMIC_HAS_ATOMIC_SHORT + case 2: + return __sync_add_and_fetch_2((uint16_t *) addr, val); +#endif + case 4: + return __sync_add_and_fetch_4((uint32_t *) addr, val); +#if (CAA_BITS_PER_LONG == 64) + case 8: + return __sync_add_and_fetch_8((uint64_t *) addr, val); +#endif + } + _uatomic_link_error(); + return 0; +} + + +#define uatomic_add_return_mo(addr, v, mo) \ + ((__typeof__(*(addr))) _uatomic_add_return((addr), \ + caa_cast_long_keep_sign(v), \ + sizeof(*(addr)))) +#endif /* #ifndef uatomic_add_return */ + +#ifndef uatomic_xchg_mo +/* xchg */ + +static inline __attribute__((always_inline)) +unsigned long _uatomic_exchange(void *addr, unsigned long val, int len) +{ + switch (len) { +#ifdef UATOMIC_HAS_ATOMIC_BYTE + case 1: + { + uint8_t old; + + do { + old = uatomic_read((uint8_t *) addr); + } while (!__sync_bool_compare_and_swap_1((uint8_t *) addr, + old, val)); + + return old; + } +#endif +#ifdef UATOMIC_HAS_ATOMIC_SHORT + case 2: + { + uint16_t old; + + do { + old = uatomic_read((uint16_t *) addr); + } while (!__sync_bool_compare_and_swap_2((uint16_t *) addr, + old, val)); + + return old; + } +#endif + case 4: + { + uint32_t old; + + do { + old = uatomic_read((uint32_t *) addr); + } while (!__sync_bool_compare_and_swap_4((uint32_t *) addr, + old, val)); + + return old; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + uint64_t old; + + do { + old = uatomic_read((uint64_t *) addr); + } while (!__sync_bool_compare_and_swap_8((uint64_t *) addr, + old, val)); + + return old; + } +#endif + } + _uatomic_link_error(); + return 0; +} + +#define uatomic_xchg_mo(addr, v, mo) \ + ((__typeof__(*(addr))) _uatomic_exchange((addr), \ + caa_cast_long_keep_sign(v), \ + sizeof(*(addr)))) +#endif /* #ifndef uatomic_xchg_mo */ + +#else /* #ifndef uatomic_cmpxchg_mo */ + +#ifndef uatomic_and_mo +/* uatomic_and_mo */ + +static inline __attribute__((always_inline)) +void _uatomic_and(void *addr, unsigned long val, int len) +{ + switch (len) { +#ifdef UATOMIC_HAS_ATOMIC_BYTE + case 1: + { + uint8_t old, oldt; + + oldt = uatomic_read((uint8_t *) addr); + do { + old = oldt; + oldt = _uatomic_cmpxchg(addr, old, old & val, 1); + } while (oldt != old); + + return; + } +#endif +#ifdef UATOMIC_HAS_ATOMIC_SHORT + case 2: + { + uint16_t old, oldt; + + oldt = uatomic_read((uint16_t *) addr); + do { + old = oldt; + oldt = _uatomic_cmpxchg(addr, old, old & val, 2); + } while (oldt != old); + } +#endif + case 4: + { + uint32_t old, oldt; + + oldt = uatomic_read((uint32_t *) addr); + do { + old = oldt; + oldt = _uatomic_cmpxchg(addr, old, old & val, 4); + } while (oldt != old); + + return; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + uint64_t old, oldt; + + oldt = uatomic_read((uint64_t *) addr); + do { + old = oldt; + oldt = _uatomic_cmpxchg(addr, old, old & val, 8); + } while (oldt != old); + + return; + } +#endif + } + _uatomic_link_error(); +} + +#define uatomic_and_mo(addr, v, mo) \ + (_uatomic_and((addr), \ + caa_cast_long_keep_sign(v), \ + sizeof(*(addr)))) +#define cmm_smp_mb__before_uatomic_and() cmm_barrier() +#define cmm_smp_mb__after_uatomic_and() cmm_barrier() + +#endif /* #ifndef uatomic_and_mo */ + +#ifndef uatomic_or_mo +/* uatomic_or_mo */ + +static inline __attribute__((always_inline)) +void _uatomic_or(void *addr, unsigned long val, int len) +{ + switch (len) { +#ifdef UATOMIC_HAS_ATOMIC_BYTE + case 1: + { + uint8_t old, oldt; + + oldt = uatomic_read((uint8_t *) addr); + do { + old = oldt; + oldt = _uatomic_cmpxchg(addr, old, old | val, 1); + } while (oldt != old); + + return; + } +#endif +#ifdef UATOMIC_HAS_ATOMIC_SHORT + case 2: + { + uint16_t old, oldt; + + oldt = uatomic_read((uint16_t *) addr); + do { + old = oldt; + oldt = _uatomic_cmpxchg(addr, old, old | val, 2); + } while (oldt != old); + + return; + } +#endif + case 4: + { + uint32_t old, oldt; + + oldt = uatomic_read((uint32_t *) addr); + do { + old = oldt; + oldt = _uatomic_cmpxchg(addr, old, old | val, 4); + } while (oldt != old); + + return; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + uint64_t old, oldt; + + oldt = uatomic_read((uint64_t *) addr); + do { + old = oldt; + oldt = _uatomic_cmpxchg(addr, old, old | val, 8); + } while (oldt != old); + + return; + } +#endif + } + _uatomic_link_error(); +} + +#define uatomic_or_mo(addr, v, mo) \ + (_uatomic_or((addr), \ + caa_cast_long_keep_sign(v), \ + sizeof(*(addr)))) +#define cmm_smp_mb__before_uatomic_or() cmm_barrier() +#define cmm_smp_mb__after_uatomic_or() cmm_barrier() + +#endif /* #ifndef uatomic_or_mo */ + +#ifndef uatomic_add_return_mo +/* uatomic_add_return_mo */ + +static inline __attribute__((always_inline)) +unsigned long _uatomic_add_return(void *addr, unsigned long val, int len) +{ + switch (len) { +#ifdef UATOMIC_HAS_ATOMIC_BYTE + case 1: + { + uint8_t old, oldt; + + oldt = uatomic_read((uint8_t *) addr); + do { + old = oldt; + oldt = uatomic_cmpxchg((uint8_t *) addr, + old, old + val); + } while (oldt != old); + + return old + val; + } +#endif +#ifdef UATOMIC_HAS_ATOMIC_SHORT + case 2: + { + uint16_t old, oldt; + + oldt = uatomic_read((uint16_t *) addr); + do { + old = oldt; + oldt = uatomic_cmpxchg((uint16_t *) addr, + old, old + val); + } while (oldt != old); + + return old + val; + } +#endif + case 4: + { + uint32_t old, oldt; + + oldt = uatomic_read((uint32_t *) addr); + do { + old = oldt; + oldt = uatomic_cmpxchg((uint32_t *) addr, + old, old + val); + } while (oldt != old); + + return old + val; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + uint64_t old, oldt; + + oldt = uatomic_read((uint64_t *) addr); + do { + old = oldt; + oldt = uatomic_cmpxchg((uint64_t *) addr, + old, old + val); + } while (oldt != old); + + return old + val; + } +#endif + } + _uatomic_link_error(); + return 0; +} + +#define uatomic_add_return_mo(addr, v, mo) \ + ((__typeof__(*(addr))) _uatomic_add_return((addr), \ + caa_cast_long_keep_sign(v), \ + sizeof(*(addr)))) +#endif /* #ifndef uatomic_add_return_mo */ + +#ifndef uatomic_xchg_mo +/* uatomic_xchg_mo */ + +static inline __attribute__((always_inline)) +unsigned long _uatomic_exchange(void *addr, unsigned long val, int len) +{ + switch (len) { +#ifdef UATOMIC_HAS_ATOMIC_BYTE + case 1: + { + uint8_t old, oldt; + + oldt = uatomic_read((uint8_t *) addr); + do { + old = oldt; + oldt = uatomic_cmpxchg((uint8_t *) addr, + old, val); + } while (oldt != old); + + return old; + } +#endif +#ifdef UATOMIC_HAS_ATOMIC_SHORT + case 2: + { + uint16_t old, oldt; + + oldt = uatomic_read((uint16_t *) addr); + do { + old = oldt; + oldt = uatomic_cmpxchg((uint16_t *) addr, + old, val); + } while (oldt != old); + + return old; + } +#endif + case 4: + { + uint32_t old, oldt; + + oldt = uatomic_read((uint32_t *) addr); + do { + old = oldt; + oldt = uatomic_cmpxchg((uint32_t *) addr, + old, val); + } while (oldt != old); + + return old; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + uint64_t old, oldt; + + oldt = uatomic_read((uint64_t *) addr); + do { + old = oldt; + oldt = uatomic_cmpxchg((uint64_t *) addr, + old, val); + } while (oldt != old); + + return old; + } +#endif + } + _uatomic_link_error(); + return 0; +} + +#define uatomic_xchg_mo(addr, v, mo) \ + ((__typeof__(*(addr))) _uatomic_exchange((addr), \ + caa_cast_long_keep_sign(v), \ + sizeof(*(addr)))) +#endif /* #ifndef uatomic_xchg_mo */ + +#endif /* #else #ifndef uatomic_cmpxchg_mo */ + +/* uatomic_sub_return_mo, uatomic_add_mo, uatomic_sub_mo, uatomic_inc_mo, uatomic_dec_mo */ + +#ifndef uatomic_add_mo +#define uatomic_add_mo(addr, v, mo) (void)uatomic_add_return_mo((addr), (v), mo) +#define cmm_smp_mb__before_uatomic_add() cmm_barrier() +#define cmm_smp_mb__after_uatomic_add() cmm_barrier() +#endif + +#define uatomic_sub_return_mo(addr, v, mo) \ + uatomic_add_return_mo((addr), -(caa_cast_long_keep_sign(v)), mo) +#define uatomic_sub_mo(addr, v, mo) \ + uatomic_add_mo((addr), -(caa_cast_long_keep_sign(v)), mo) +#define cmm_smp_mb__before_uatomic_sub() cmm_smp_mb__before_uatomic_add() +#define cmm_smp_mb__after_uatomic_sub() cmm_smp_mb__after_uatomic_add() + +#ifndef uatomic_inc_mo +#define uatomic_inc_mo(addr, mo) uatomic_add_mo((addr), 1, mo) +#define cmm_smp_mb__before_uatomic_inc() cmm_smp_mb__before_uatomic_add() +#define cmm_smp_mb__after_uatomic_inc() cmm_smp_mb__after_uatomic_add() +#endif + +#ifndef uatomic_dec_mo +#define uatomic_dec_mo(addr, mo) uatomic_add((addr), -1, mo) +#define cmm_smp_mb__before_uatomic_dec() cmm_smp_mb__before_uatomic_add() +#define cmm_smp_mb__after_uatomic_dec() cmm_smp_mb__after_uatomic_add() +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_UATOMIC_GENERIC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/hppa.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/hppa.h new file mode 100644 index 0000000000000..82864615e4a34 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/hppa.h @@ -0,0 +1,14 @@ +// SPDX-FileCopyrightText: 2014 Helge Deller +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_ARCH_UATOMIC_HPPA_H +#define _URCU_ARCH_UATOMIC_HPPA_H + +#include +#include + +#define UATOMIC_HAS_ATOMIC_SHORT +#include + +#endif /* _URCU_ARCH_UATOMIC_HPPA_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/ia64.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/ia64.h new file mode 100644 index 0000000000000..381594c0c40d4 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/ia64.h @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: 1991-1994 by Xerox Corporation. All rights reserved. +// SPDX-FileCopyrightText: 1996-1999 by Silicon Graphics. All rights reserved. +// SPDX-FileCopyrightText: 1999-2004 Hewlett-Packard Development Company, L.P. +// SPDX-FileCopyrightText: 2009-2015 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2010 Paul E. McKenney, IBM Corporation +// +// SPDX-License-Identifier: LicenseRef-Boehm-GC + +#ifndef _URCU_ARCH_UATOMIC_IA64_H +#define _URCU_ARCH_UATOMIC_IA64_H + +/* + * Code inspired from libuatomic_ops-1.2, inherited in part from the + * Boehm-Demers-Weiser conservative garbage collector. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define UATOMIC_HAS_ATOMIC_BYTE +#define UATOMIC_HAS_ATOMIC_SHORT + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_UATOMIC_IA64_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/loongarch.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/loongarch.h new file mode 100644 index 0000000000000..3454d41294af3 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/loongarch.h @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: 2021 Wang Jing +// +// SPDX-License-Identifier: MIT + +#ifndef _URCU_UATOMIC_ARCH_LOONGARCH_H +#define _URCU_UATOMIC_ARCH_LOONGARCH_H + +/* + * Atomic exchange operations for the LoongArch architecture. Let GCC do it. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * LoongArch implements byte and short atomics with LL/SC instructions, + * which retry if the cache line is modified concurrently between LL and + * SC. + */ +#define UATOMIC_HAS_ATOMIC_BYTE +#define UATOMIC_HAS_ATOMIC_SHORT + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_UATOMIC_ARCH_LOONGARCH_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/m68k.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/m68k.h new file mode 100644 index 0000000000000..9a28e7c223e9a --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/m68k.h @@ -0,0 +1,28 @@ +// SPDX-FileCopyrightText: 2017 Michael Jeanson +// +// SPDX-License-Identifier: MIT + +/* + * Atomic exchange operations for the m68k architecture. Let GCC do it. + */ + +#ifndef _URCU_ARCH_UATOMIC_M68K_H +#define _URCU_ARCH_UATOMIC_M68K_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define UATOMIC_HAS_ATOMIC_BYTE +#define UATOMIC_HAS_ATOMIC_SHORT + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_UATOMIC_M68K_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/mips.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/mips.h new file mode 100644 index 0000000000000..265401db95891 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/mips.h @@ -0,0 +1,16 @@ +// SPDX-FileCopyrightText: 2010 Paolo Bonzini +// +// SPDX-License-Identifier: MIT + +#ifndef _URCU_UATOMIC_ARCH_MIPS_H +#define _URCU_UATOMIC_ARCH_MIPS_H + +/* + * Atomic exchange operations for the MIPS architecture. Let GCC do it. + */ + +#include +#include +#include + +#endif /* _URCU_UATOMIC_ARCH_MIPS_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/nios2.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/nios2.h new file mode 100644 index 0000000000000..0eca72729f516 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/nios2.h @@ -0,0 +1,16 @@ +// SPDX-FileCopyrightText: 2016 Marek Vasut +// +// SPDX-License-Identifier: MIT + +#ifndef _URCU_UATOMIC_ARCH_NIOS2_H +#define _URCU_UATOMIC_ARCH_NIOS2_H + +/* + * Atomic exchange operations for the NIOS2 architecture. Let GCC do it. + */ + +#include +#include +#include + +#endif /* _URCU_UATOMIC_ARCH_NIOS2_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/ppc.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/ppc.h new file mode 100644 index 0000000000000..1f9a292dd7219 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/ppc.h @@ -0,0 +1,230 @@ +// SPDX-FileCopyrightText: 1991-1994 by Xerox Corporation. All rights reserved. +// SPDX-FileCopyrightText: 1996-1999 by Silicon Graphics. All rights reserved. +// SPDX-FileCopyrightText: 1999-2004 Hewlett-Packard Development Company, L.P. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: LicenseRef-Boehm-GC + +#ifndef _URCU_ARCH_UATOMIC_PPC_H +#define _URCU_ARCH_UATOMIC_PPC_H + +/* + * Code inspired from libuatomic_ops-1.2, inherited in part from the + * Boehm-Demers-Weiser conservative garbage collector. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define ILLEGAL_INSTR ".long 0xd00d00" + +/* + * Providing sequential consistency semantic with respect to other + * instructions for cmpxchg and add_return family of atomic primitives. + * + * This is achieved with: + * lwsync (prior stores can be reordered after following loads) + * lwarx + * stwcx. + * test if success (retry) + * sync + * + * Explanation of the sequential consistency provided by this scheme + * from Paul E. McKenney: + * + * The reason we can get away with the lwsync before is that if a prior + * store reorders with the lwarx, then you have to store to the atomic + * variable from some other CPU to detect it. + * + * And if you do that, the lwarx will lose its reservation, so the stwcx + * will fail. The atomic operation will retry, so that the caller won't be + * able to see the misordering. + */ + +/* xchg */ + +static inline __attribute__((always_inline)) +unsigned long _uatomic_exchange(void *addr, unsigned long val, int len) +{ + switch (len) { + case 4: + { + unsigned int result; + + __asm__ __volatile__( + LWSYNC_OPCODE + "1:\t" "lwarx %0,0,%1\n" /* load and reserve */ + "stwcx. %2,0,%1\n" /* else store conditional */ + "bne- 1b\n" /* retry if lost reservation */ + "sync\n" + : "=&r"(result) + : "r"(addr), "r"(val) + : "memory", "cc"); + + return result; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + unsigned long result; + + __asm__ __volatile__( + LWSYNC_OPCODE + "1:\t" "ldarx %0,0,%1\n" /* load and reserve */ + "stdcx. %2,0,%1\n" /* else store conditional */ + "bne- 1b\n" /* retry if lost reservation */ + "sync\n" + : "=&r"(result) + : "r"(addr), "r"(val) + : "memory", "cc"); + + return result; + } +#endif + } + /* + * generate an illegal instruction. Cannot catch this with + * linker tricks when optimizations are disabled. + */ + __asm__ __volatile__(ILLEGAL_INSTR); + return 0; +} + +#define uatomic_xchg_mo(addr, v, mo) \ + ((__typeof__(*(addr))) _uatomic_exchange((addr), \ + caa_cast_long_keep_sign(v), \ + sizeof(*(addr)))) +/* cmpxchg */ + +static inline __attribute__((always_inline)) +unsigned long _uatomic_cmpxchg(void *addr, unsigned long old, + unsigned long _new, int len) +{ + switch (len) { + case 4: + { + unsigned int old_val; + + __asm__ __volatile__( + LWSYNC_OPCODE + "1:\t" "lwarx %0,0,%1\n" /* load and reserve */ + "cmpw %0,%3\n" /* if load is not equal to */ + "bne 2f\n" /* old, fail */ + "stwcx. %2,0,%1\n" /* else store conditional */ + "bne- 1b\n" /* retry if lost reservation */ + "sync\n" + "2:\n" + : "=&r"(old_val) + : "r"(addr), "r"((unsigned int)_new), + "r"((unsigned int)old) + : "memory", "cc"); + + return old_val; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + unsigned long old_val; + + __asm__ __volatile__( + LWSYNC_OPCODE + "1:\t" "ldarx %0,0,%1\n" /* load and reserve */ + "cmpd %0,%3\n" /* if load is not equal to */ + "bne 2f\n" /* old, fail */ + "stdcx. %2,0,%1\n" /* else store conditional */ + "bne- 1b\n" /* retry if lost reservation */ + "sync\n" + "2:\n" + : "=&r"(old_val) + : "r"(addr), "r"((unsigned long)_new), + "r"((unsigned long)old) + : "memory", "cc"); + + return old_val; + } +#endif + } + /* + * generate an illegal instruction. Cannot catch this with + * linker tricks when optimizations are disabled. + */ + __asm__ __volatile__(ILLEGAL_INSTR); + return 0; +} + + +#define uatomic_cmpxchg_mo(addr, old, _new, mos, mof) \ + ((__typeof__(*(addr))) _uatomic_cmpxchg((addr), \ + caa_cast_long_keep_sign(old), \ + caa_cast_long_keep_sign(_new),\ + sizeof(*(addr)))) + +/* uatomic_add_return */ + +static inline __attribute__((always_inline)) +unsigned long _uatomic_add_return(void *addr, unsigned long val, + int len) +{ + switch (len) { + case 4: + { + unsigned int result; + + __asm__ __volatile__( + LWSYNC_OPCODE + "1:\t" "lwarx %0,0,%1\n" /* load and reserve */ + "add %0,%2,%0\n" /* add val to value loaded */ + "stwcx. %0,0,%1\n" /* store conditional */ + "bne- 1b\n" /* retry if lost reservation */ + "sync\n" + : "=&r"(result) + : "r"(addr), "r"(val) + : "memory", "cc"); + + return result; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + unsigned long result; + + __asm__ __volatile__( + LWSYNC_OPCODE + "1:\t" "ldarx %0,0,%1\n" /* load and reserve */ + "add %0,%2,%0\n" /* add val to value loaded */ + "stdcx. %0,0,%1\n" /* store conditional */ + "bne- 1b\n" /* retry if lost reservation */ + "sync\n" + : "=&r"(result) + : "r"(addr), "r"(val) + : "memory", "cc"); + + return result; + } +#endif + } + /* + * generate an illegal instruction. Cannot catch this with + * linker tricks when optimizations are disabled. + */ + __asm__ __volatile__(ILLEGAL_INSTR); + return 0; +} + + +#define uatomic_add_return_mo(addr, v, mo) \ + ((__typeof__(*(addr))) _uatomic_add_return((addr), \ + caa_cast_long_keep_sign(v), \ + sizeof(*(addr)))) + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_UATOMIC_PPC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/riscv.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/riscv.h new file mode 100644 index 0000000000000..abe73d4623ce0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/riscv.h @@ -0,0 +1,47 @@ +// SPDX-FileCopyrightText: 2018 Michael Jeanson +// +// SPDX-License-Identifier: MIT + +/* + * Atomic exchange operations for the RISC-V architecture. + * + * Let the compiler do it. + */ + +#ifndef _URCU_ARCH_UATOMIC_RISCV_H +#define _URCU_ARCH_UATOMIC_RISCV_H + +#include +#include + +/* + * See for details. + * + * The following GCC patches are required to have a working Userspace RCU on + * the RISC-V architecture. The were introduced in GCC 14 and backported to + * 13.3.0. + * + * - + * - + * - + */ +#ifdef URCU_GCC_VERSION +# if (URCU_GCC_VERSION < 130300) +# error "Implementations of some atomic operations of GCC < 13.3.0 for RISC-V are insufficient for sequential consistency. For this reason Userspace RCU is currently marked as 'broken' for RISC-V on these GCC versions." +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define UATOMIC_HAS_ATOMIC_BYTE +#define UATOMIC_HAS_ATOMIC_SHORT + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_UATOMIC_RISCV_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/s390.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/s390.h new file mode 100644 index 0000000000000..40ad5697b2010 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/s390.h @@ -0,0 +1,155 @@ +// SPDX-FileCopyrightText: 2009 Novell, Inc. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + +#ifndef _URCU_UATOMIC_ARCH_S390_H +#define _URCU_UATOMIC_ARCH_S390_H + +/* + * Atomic exchange operations for the S390 architecture. Based on information + * taken from the Principles of Operation Appendix A "Conditional Swapping + * Instructions (CS, CDS)". + * + * Author: Jan Blunck + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2) +#define COMPILER_HAVE_SHORT_MEM_OPERAND +#endif + +/* + * MEMOP assembler operand rules: + * - op refer to MEMOP_IN operand + * - MEMOP_IN can expand to more than a single operand. Use it at the end of + * operand list only. + */ + +#ifdef COMPILER_HAVE_SHORT_MEM_OPERAND + +#define MEMOP_OUT(addr) "=Q" (*(addr)) +#define MEMOP_IN(addr) "Q" (*(addr)) +#define MEMOP_REF(op) #op /* op refer to MEMOP_IN operand */ + +#else /* !COMPILER_HAVE_SHORT_MEM_OPERAND */ + +#define MEMOP_OUT(addr) "=m" (*(addr)) +#define MEMOP_IN(addr) "a" (addr), "m" (*(addr)) +#define MEMOP_REF(op) "0(" #op ")" /* op refer to MEMOP_IN operand */ + +#endif /* !COMPILER_HAVE_SHORT_MEM_OPERAND */ + +/* + * The __hp() macro casts the void pointer @x to a pointer to a structure + * containing an array of char of the specified size. This allows passing the + * @addr arguments of the following inline functions as "m" and "+m" operands + * to the assembly. The @size parameter should be a constant to support + * compilers such as clang which do not support VLA. Create typedefs because + * C++ does not allow types be defined in casts. + */ + +typedef struct { char v[4]; } __hp_4; +typedef struct { char v[8]; } __hp_8; + +#define __hp(size, x) ((__hp_##size *)(x)) + +/* xchg */ + +static inline __attribute__((always_inline)) +unsigned long _uatomic_exchange(volatile void *addr, unsigned long val, int len) +{ + switch (len) { + case 4: + { + unsigned int old_val; + + __asm__ __volatile__( + "0: cs %0,%2," MEMOP_REF(%3) "\n" + " brc 4,0b\n" + : "=&r" (old_val), MEMOP_OUT (__hp(4, addr)) + : "r" (val), MEMOP_IN (__hp(4, addr)) + : "memory", "cc"); + return old_val; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + unsigned long old_val; + + __asm__ __volatile__( + "0: csg %0,%2," MEMOP_REF(%3) "\n" + " brc 4,0b\n" + : "=&r" (old_val), MEMOP_OUT (__hp(8, addr)) + : "r" (val), MEMOP_IN (__hp(8, addr)) + : "memory", "cc"); + return old_val; + } +#endif + default: + __asm__ __volatile__(".long 0xd00d00"); + } + + return 0; +} + +#define uatomic_xchg_mo(addr, v, mo) \ + (__typeof__(*(addr))) _uatomic_exchange((addr), \ + caa_cast_long_keep_sign(v), \ + sizeof(*(addr))) + +/* cmpxchg */ + +static inline __attribute__((always_inline)) +unsigned long _uatomic_cmpxchg(void *addr, unsigned long old, + unsigned long _new, int len) +{ + switch (len) { + case 4: + { + unsigned int old_val = (unsigned int)old; + + __asm__ __volatile__( + " cs %0,%2," MEMOP_REF(%3) "\n" + : "+r" (old_val), MEMOP_OUT (__hp(4, addr)) + : "r" (_new), MEMOP_IN (__hp(4, addr)) + : "memory", "cc"); + return old_val; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + __asm__ __volatile__( + " csg %0,%2," MEMOP_REF(%3) "\n" + : "+r" (old), MEMOP_OUT (__hp(8, addr)) + : "r" (_new), MEMOP_IN (__hp(8, addr)) + : "memory", "cc"); + return old; + } +#endif + default: + __asm__ __volatile__(".long 0xd00d00"); + } + + return 0; +} + +#define uatomic_cmpxchg_mo(addr, old, _new, mos, mof) \ + (__typeof__(*(addr))) _uatomic_cmpxchg((addr), \ + caa_cast_long_keep_sign(old), \ + caa_cast_long_keep_sign(_new),\ + sizeof(*(addr))) + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_UATOMIC_ARCH_S390_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/sparc64.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/sparc64.h new file mode 100644 index 0000000000000..c6baeaccf94aa --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/sparc64.h @@ -0,0 +1,74 @@ +// SPDX-FileCopyrightText: 1991-1994 by Xerox Corporation. All rights reserved. +// SPDX-FileCopyrightText: 1996-1999 by Silicon Graphics. All rights reserved. +// SPDX-FileCopyrightText: 1999-2003 Hewlett-Packard Development Company, L.P. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: LicenseRef-Boehm-GC + +#ifndef _URCU_ARCH_UATOMIC_SPARC64_H +#define _URCU_ARCH_UATOMIC_SPARC64_H + +/* + * Code inspired from libuatomic_ops-1.2, inherited in part from the + * Boehm-Demers-Weiser conservative garbage collector. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* cmpxchg */ + +static inline __attribute__((always_inline)) +unsigned long _uatomic_cmpxchg(void *addr, unsigned long old, + unsigned long _new, int len) +{ + switch (len) { + case 4: + { + __asm__ __volatile__ ( + "membar #StoreLoad | #LoadLoad\n\t" + "cas [%1],%2,%0\n\t" + "membar #StoreLoad | #StoreStore\n\t" + : "+&r" (_new) + : "r" (addr), "r" (old) + : "memory"); + + return _new; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + __asm__ __volatile__ ( + "membar #StoreLoad | #LoadLoad\n\t" + "casx [%1],%2,%0\n\t" + "membar #StoreLoad | #StoreStore\n\t" + : "+&r" (_new) + : "r" (addr), "r" (old) + : "memory"); + + return _new; + } +#endif + } + __builtin_trap(); + return 0; +} + + +#define uatomic_cmpxchg_mo(addr, old, _new, mos, mof) \ + ((__typeof__(*(addr))) _uatomic_cmpxchg((addr), \ + caa_cast_long_keep_sign(old), \ + caa_cast_long_keep_sign(_new), \ + sizeof(*(addr)))) + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_UATOMIC_PPC_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/tile.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/tile.h new file mode 100644 index 0000000000000..412c9ed8992a8 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/tile.h @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: 1991-1994 by Xerox Corporation. All rights reserved. +// SPDX-FileCopyrightText: 1996-1999 by Silicon Graphics. All rights reserved. +// SPDX-FileCopyrightText: 1999-2004 Hewlett-Packard Development Company, L.P. +// SPDX-FileCopyrightText: 2009-2015 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2010 Paul E. McKenney, IBM Corporation +// +// SPDX-License-Identifier: LicenseRef-Boehm-GC + +#ifndef _URCU_ARCH_UATOMIC_TILE_H +#define _URCU_ARCH_UATOMIC_TILE_H + +/* + * Code inspired from libuatomic_ops-1.2, inherited in part from the + * Boehm-Demers-Weiser conservative garbage collector. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define UATOMIC_HAS_ATOMIC_BYTE +#define UATOMIC_HAS_ATOMIC_SHORT + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_UATOMIC_TILE_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/x86.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/x86.h new file mode 100644 index 0000000000000..4706458be7493 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic/x86.h @@ -0,0 +1,771 @@ +// SPDX-FileCopyrightText: 1991-1994 by Xerox Corporation. All rights reserved. +// SPDX-FileCopyrightText: 1996-1999 by Silicon Graphics. All rights reserved. +// SPDX-FileCopyrightText: 1999-2004 Hewlett-Packard Development Company, L.P. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: LicenseRef-Boehm-GC + +#ifndef _URCU_ARCH_UATOMIC_X86_H +#define _URCU_ARCH_UATOMIC_X86_H + +#include /* For abort(3). */ + +/* + * Code inspired from libuatomic_ops-1.2, inherited in part from the + * Boehm-Demers-Weiser conservative garbage collector. + */ + +#include +#include +#include +#include + +#define UATOMIC_HAS_ATOMIC_BYTE +#define UATOMIC_HAS_ATOMIC_SHORT + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Derived from AO_compare_and_swap() and AO_test_and_set_full(). + */ + +/* + * The __hp() macro casts the void pointer @x to a pointer to a structure + * containing an array of char of the specified size. This allows passing the + * @addr arguments of the following inline functions as "m" and "+m" operands + * to the assembly. The @size parameter should be a constant to support + * compilers such as clang which do not support VLA. Create typedefs because + * C++ does not allow types be defined in casts. + */ + +typedef struct { char v[1]; } __hp_1; +typedef struct { char v[2]; } __hp_2; +typedef struct { char v[4]; } __hp_4; +typedef struct { char v[8]; } __hp_8; + +#define __hp(size, x) ((__hp_##size *)(x)) + +/* cmpxchg */ + +static inline __attribute__((always_inline)) +unsigned long __uatomic_cmpxchg(void *addr, unsigned long old, + unsigned long _new, int len) +{ + switch (len) { + case 1: + { + unsigned char result = old; + + __asm__ __volatile__( + "lock; cmpxchgb %2, %1" + : "+a"(result), "+m"(*__hp(1, addr)) + : "q"((unsigned char)_new) + : "memory"); + return result; + } + case 2: + { + unsigned short result = old; + + __asm__ __volatile__( + "lock; cmpxchgw %2, %1" + : "+a"(result), "+m"(*__hp(2, addr)) + : "r"((unsigned short)_new) + : "memory"); + return result; + } + case 4: + { + unsigned int result = old; + + __asm__ __volatile__( + "lock; cmpxchgl %2, %1" + : "+a"(result), "+m"(*__hp(4, addr)) + : "r"((unsigned int)_new) + : "memory"); + return result; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + unsigned long result = old; + + __asm__ __volatile__( + "lock; cmpxchgq %2, %1" + : "+a"(result), "+m"(*__hp(8, addr)) + : "r"((unsigned long)_new) + : "memory"); + return result; + } +#endif + } + /* + * generate an illegal instruction. Cannot catch this with + * linker tricks when optimizations are disabled. + */ + __asm__ __volatile__("ud2"); + return 0; +} + +#define _uatomic_cmpxchg(addr, old, _new) \ + ((__typeof__(*(addr))) __uatomic_cmpxchg((addr), \ + caa_cast_long_keep_sign(old), \ + caa_cast_long_keep_sign(_new),\ + sizeof(*(addr)))) + +/* xchg */ + +static inline __attribute__((always_inline)) +unsigned long __uatomic_exchange(void *addr, unsigned long val, int len) +{ + /* Note: the "xchg" instruction does not need a "lock" prefix. */ + switch (len) { + case 1: + { + unsigned char result; + __asm__ __volatile__( + "xchgb %0, %1" + : "=q"(result), "+m"(*__hp(1, addr)) + : "0" ((unsigned char)val) + : "memory"); + return result; + } + case 2: + { + unsigned short result; + __asm__ __volatile__( + "xchgw %0, %1" + : "=r"(result), "+m"(*__hp(2, addr)) + : "0" ((unsigned short)val) + : "memory"); + return result; + } + case 4: + { + unsigned int result; + __asm__ __volatile__( + "xchgl %0, %1" + : "=r"(result), "+m"(*__hp(4, addr)) + : "0" ((unsigned int)val) + : "memory"); + return result; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + unsigned long result; + __asm__ __volatile__( + "xchgq %0, %1" + : "=r"(result), "+m"(*__hp(8, addr)) + : "0" ((unsigned long)val) + : "memory"); + return result; + } +#endif + } + /* + * generate an illegal instruction. Cannot catch this with + * linker tricks when optimizations are disabled. + */ + __asm__ __volatile__("ud2"); + return 0; +} + +#define _uatomic_xchg(addr, v) \ + ((__typeof__(*(addr))) __uatomic_exchange((addr), \ + caa_cast_long_keep_sign(v), \ + sizeof(*(addr)))) + +/* uatomic_add_return */ + +static inline __attribute__((always_inline)) +unsigned long __uatomic_add_return(void *addr, unsigned long val, + int len) +{ + switch (len) { + case 1: + { + unsigned char result = val; + + __asm__ __volatile__( + "lock; xaddb %1, %0" + : "+m"(*__hp(1, addr)), "+q" (result) + : + : "memory"); + return result + (unsigned char)val; + } + case 2: + { + unsigned short result = val; + + __asm__ __volatile__( + "lock; xaddw %1, %0" + : "+m"(*__hp(2, addr)), "+r" (result) + : + : "memory"); + return result + (unsigned short)val; + } + case 4: + { + unsigned int result = val; + + __asm__ __volatile__( + "lock; xaddl %1, %0" + : "+m"(*__hp(4, addr)), "+r" (result) + : + : "memory"); + return result + (unsigned int)val; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + unsigned long result = val; + + __asm__ __volatile__( + "lock; xaddq %1, %0" + : "+m"(*__hp(8, addr)), "+r" (result) + : + : "memory"); + return result + (unsigned long)val; + } +#endif + } + /* + * generate an illegal instruction. Cannot catch this with + * linker tricks when optimizations are disabled. + */ + __asm__ __volatile__("ud2"); + return 0; +} + +#define _uatomic_add_return(addr, v) \ + ((__typeof__(*(addr))) __uatomic_add_return((addr), \ + caa_cast_long_keep_sign(v), \ + sizeof(*(addr)))) + +/* uatomic_and */ + +static inline __attribute__((always_inline)) +void __uatomic_and(void *addr, unsigned long val, int len) +{ + switch (len) { + case 1: + { + __asm__ __volatile__( + "lock; andb %1, %0" + : "=m"(*__hp(1, addr)) + : "iq" ((unsigned char)val) + : "memory"); + return; + } + case 2: + { + __asm__ __volatile__( + "lock; andw %1, %0" + : "=m"(*__hp(2, addr)) + : "ir" ((unsigned short)val) + : "memory"); + return; + } + case 4: + { + __asm__ __volatile__( + "lock; andl %1, %0" + : "=m"(*__hp(4, addr)) + : "ir" ((unsigned int)val) + : "memory"); + return; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + __asm__ __volatile__( + "lock; andq %1, %0" + : "=m"(*__hp(8, addr)) + : "er" ((unsigned long)val) + : "memory"); + return; + } +#endif + } + /* + * generate an illegal instruction. Cannot catch this with + * linker tricks when optimizations are disabled. + */ + __asm__ __volatile__("ud2"); + return; +} + +#define _uatomic_and(addr, v) \ + (__uatomic_and((addr), caa_cast_long_keep_sign(v), sizeof(*(addr)))) + +/* uatomic_or */ + +static inline __attribute__((always_inline)) +void __uatomic_or(void *addr, unsigned long val, int len) +{ + switch (len) { + case 1: + { + __asm__ __volatile__( + "lock; orb %1, %0" + : "=m"(*__hp(1, addr)) + : "iq" ((unsigned char)val) + : "memory"); + return; + } + case 2: + { + __asm__ __volatile__( + "lock; orw %1, %0" + : "=m"(*__hp(2, addr)) + : "ir" ((unsigned short)val) + : "memory"); + return; + } + case 4: + { + __asm__ __volatile__( + "lock; orl %1, %0" + : "=m"(*__hp(4, addr)) + : "ir" ((unsigned int)val) + : "memory"); + return; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + __asm__ __volatile__( + "lock; orq %1, %0" + : "=m"(*__hp(8, addr)) + : "er" ((unsigned long)val) + : "memory"); + return; + } +#endif + } + /* + * generate an illegal instruction. Cannot catch this with + * linker tricks when optimizations are disabled. + */ + __asm__ __volatile__("ud2"); + return; +} + +#define _uatomic_or(addr, v) \ + (__uatomic_or((addr), caa_cast_long_keep_sign(v), sizeof(*(addr)))) + +/* uatomic_add */ + +static inline __attribute__((always_inline)) +void __uatomic_add(void *addr, unsigned long val, int len) +{ + switch (len) { + case 1: + { + __asm__ __volatile__( + "lock; addb %1, %0" + : "=m"(*__hp(1, addr)) + : "iq" ((unsigned char)val) + : "memory"); + return; + } + case 2: + { + __asm__ __volatile__( + "lock; addw %1, %0" + : "=m"(*__hp(2, addr)) + : "ir" ((unsigned short)val) + : "memory"); + return; + } + case 4: + { + __asm__ __volatile__( + "lock; addl %1, %0" + : "=m"(*__hp(4, addr)) + : "ir" ((unsigned int)val) + : "memory"); + return; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + __asm__ __volatile__( + "lock; addq %1, %0" + : "=m"(*__hp(8, addr)) + : "er" ((unsigned long)val) + : "memory"); + return; + } +#endif + } + /* + * generate an illegal instruction. Cannot catch this with + * linker tricks when optimizations are disabled. + */ + __asm__ __volatile__("ud2"); + return; +} + +#define _uatomic_add(addr, v) \ + (__uatomic_add((addr), caa_cast_long_keep_sign(v), sizeof(*(addr)))) + + +/* uatomic_inc */ + +static inline __attribute__((always_inline)) +void __uatomic_inc(void *addr, int len) +{ + switch (len) { + case 1: + { + __asm__ __volatile__( + "lock; incb %0" + : "=m"(*__hp(1, addr)) + : + : "memory"); + return; + } + case 2: + { + __asm__ __volatile__( + "lock; incw %0" + : "=m"(*__hp(2, addr)) + : + : "memory"); + return; + } + case 4: + { + __asm__ __volatile__( + "lock; incl %0" + : "=m"(*__hp(4, addr)) + : + : "memory"); + return; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + __asm__ __volatile__( + "lock; incq %0" + : "=m"(*__hp(8, addr)) + : + : "memory"); + return; + } +#endif + } + /* generate an illegal instruction. Cannot catch this with linker tricks + * when optimizations are disabled. */ + __asm__ __volatile__("ud2"); + return; +} + +#define _uatomic_inc(addr) (__uatomic_inc((addr), sizeof(*(addr)))) + +/* uatomic_dec */ + +static inline __attribute__((always_inline)) +void __uatomic_dec(void *addr, int len) +{ + switch (len) { + case 1: + { + __asm__ __volatile__( + "lock; decb %0" + : "=m"(*__hp(1, addr)) + : + : "memory"); + return; + } + case 2: + { + __asm__ __volatile__( + "lock; decw %0" + : "=m"(*__hp(2, addr)) + : + : "memory"); + return; + } + case 4: + { + __asm__ __volatile__( + "lock; decl %0" + : "=m"(*__hp(4, addr)) + : + : "memory"); + return; + } +#if (CAA_BITS_PER_LONG == 64) + case 8: + { + __asm__ __volatile__( + "lock; decq %0" + : "=m"(*__hp(8, addr)) + : + : "memory"); + return; + } +#endif + } + /* + * generate an illegal instruction. Cannot catch this with + * linker tricks when optimizations are disabled. + */ + __asm__ __volatile__("ud2"); + return; +} + +#define _uatomic_dec(addr) (__uatomic_dec((addr), sizeof(*(addr)))) + +#ifdef URCU_ARCH_X86_NO_CAS + +/* For backwards compat */ +#define CONFIG_RCU_COMPAT_ARCH 1 + +extern int __rcu_cas_avail; +extern int __rcu_cas_init(void); + +#define UATOMIC_COMPAT(insn) \ + ((caa_likely(__rcu_cas_avail > 0)) \ + ? (_uatomic_##insn) \ + : ((caa_unlikely(__rcu_cas_avail < 0) \ + ? ((__rcu_cas_init() > 0) \ + ? (_uatomic_##insn) \ + : (compat_uatomic_##insn)) \ + : (compat_uatomic_##insn)))) + +/* + * We leave the return value so we don't break the ABI, but remove the + * return value from the API. + */ +extern unsigned long _compat_uatomic_set(void *addr, + unsigned long _new, int len); +#define compat_uatomic_set(addr, _new) \ + ((void) _compat_uatomic_set((addr), \ + caa_cast_long_keep_sign(_new), \ + sizeof(*(addr)))) + + +extern unsigned long _compat_uatomic_xchg(void *addr, + unsigned long _new, int len); +#define compat_uatomic_xchg(addr, _new) \ + ((__typeof__(*(addr))) _compat_uatomic_xchg((addr), \ + caa_cast_long_keep_sign(_new), \ + sizeof(*(addr)))) + +extern unsigned long _compat_uatomic_cmpxchg(void *addr, unsigned long old, + unsigned long _new, int len); +#define compat_uatomic_cmpxchg(addr, old, _new) \ + ((__typeof__(*(addr))) _compat_uatomic_cmpxchg((addr), \ + caa_cast_long_keep_sign(old), \ + caa_cast_long_keep_sign(_new), \ + sizeof(*(addr)))) + +extern void _compat_uatomic_and(void *addr, unsigned long _new, int len); +#define compat_uatomic_and(addr, v) \ + (_compat_uatomic_and((addr), \ + caa_cast_long_keep_sign(v), \ + sizeof(*(addr)))) + +extern void _compat_uatomic_or(void *addr, unsigned long _new, int len); +#define compat_uatomic_or(addr, v) \ + (_compat_uatomic_or((addr), \ + caa_cast_long_keep_sign(v), \ + sizeof(*(addr)))) + +extern unsigned long _compat_uatomic_add_return(void *addr, + unsigned long _new, int len); +#define compat_uatomic_add_return(addr, v) \ + ((__typeof__(*(addr))) _compat_uatomic_add_return((addr), \ + caa_cast_long_keep_sign(v), \ + sizeof(*(addr)))) + +#define compat_uatomic_add(addr, v) \ + ((void)compat_uatomic_add_return((addr), (v))) +#define compat_uatomic_inc(addr) \ + (compat_uatomic_add((addr), 1)) +#define compat_uatomic_dec(addr) \ + (compat_uatomic_add((addr), -1)) + +#else +#define UATOMIC_COMPAT(insn) (_uatomic_##insn) +#endif + +/* + * All RMW operations have an implicit lock prefix. Thus, ignoring memory + * ordering for these operations, since they can all be respected by not + * emitting any memory barrier. + */ + +#define uatomic_cmpxchg_mo(addr, old, _new, mos, mof) \ + UATOMIC_COMPAT(cmpxchg(addr, old, _new)) + +#define uatomic_xchg_mo(addr, v, mo) \ + UATOMIC_COMPAT(xchg(addr, v)) + +#define uatomic_and_mo(addr, v, mo) \ + UATOMIC_COMPAT(and(addr, v)) +#define cmm_smp_mb__before_uatomic_and() cmm_barrier() +#define cmm_smp_mb__after_uatomic_and() cmm_barrier() + +#define uatomic_or_mo(addr, v, mo) \ + UATOMIC_COMPAT(or(addr, v)) +#define cmm_smp_mb__before_uatomic_or() cmm_barrier() +#define cmm_smp_mb__after_uatomic_or() cmm_barrier() + +#define uatomic_add_return_mo(addr, v, mo) \ + UATOMIC_COMPAT(add_return(addr, v)) + +#define uatomic_add_mo(addr, v, mo) UATOMIC_COMPAT(add(addr, v)) +#define cmm_smp_mb__before_uatomic_add() cmm_barrier() +#define cmm_smp_mb__after_uatomic_add() cmm_barrier() + +#define uatomic_inc_mo(addr, mo) UATOMIC_COMPAT(inc(addr)) +#define cmm_smp_mb__before_uatomic_inc() cmm_barrier() +#define cmm_smp_mb__after_uatomic_inc() cmm_barrier() + +#define uatomic_dec_mo(addr, mo) UATOMIC_COMPAT(dec(addr)) +#define cmm_smp_mb__before_uatomic_dec() cmm_barrier() +#define cmm_smp_mb__after_uatomic_dec() cmm_barrier() + + +static inline void _cmm_compat_c11_smp_mb__before_uatomic_load_mo(enum cmm_memorder mo) +{ + /* + * A SMP barrier is not necessary for CMM_SEQ_CST because, only a + * previous store can be reordered with the load. However, emitting the + * memory barrier after the store is sufficient to prevent reordering + * between the two. This follows toolchains decision of emitting the + * memory fence on the stores instead of the loads. + * + * A compiler barrier is necessary because the underlying operation does + * not clobber the registers. + */ + switch (mo) { + case CMM_RELAXED: /* Fall-through */ + case CMM_ACQUIRE: /* Fall-through */ + case CMM_CONSUME: /* Fall-through */ + case CMM_SEQ_CST: /* Fall-through */ + case CMM_SEQ_CST_FENCE: + cmm_barrier(); + break; + case CMM_ACQ_REL: /* Fall-through */ + case CMM_RELEASE: /* Fall-through */ + default: + abort(); + break; + } +} + +static inline void _cmm_compat_c11_smp_mb__after_uatomic_load_mo(enum cmm_memorder mo) +{ + /* + * A SMP barrier is not necessary for CMM_SEQ_CST because following + * loads and stores cannot be reordered with the load. + * + * A SMP barrier is however necessary for CMM_SEQ_CST_FENCE to respect + * the memory model, since the underlying operation does not have a lock + * prefix. + * + * A compiler barrier is necessary because the underlying operation does + * not clobber the registers. + */ + switch (mo) { + case CMM_SEQ_CST_FENCE: + cmm_smp_mb(); + break; + case CMM_RELAXED: /* Fall-through */ + case CMM_ACQUIRE: /* Fall-through */ + case CMM_CONSUME: /* Fall-through */ + case CMM_SEQ_CST: + cmm_barrier(); + break; + case CMM_ACQ_REL: /* Fall-through */ + case CMM_RELEASE: /* Fall-through */ + default: + abort(); + break; + } +} + +static inline void _cmm_compat_c11_smp_mb__before_uatomic_store_mo(enum cmm_memorder mo) +{ + /* + * A SMP barrier is not necessary for CMM_SEQ_CST because the store can + * only be reodered with later loads + * + * A compiler barrier is necessary because the underlying operation does + * not clobber the registers. + */ + switch (mo) { + case CMM_RELAXED: /* Fall-through */ + case CMM_RELEASE: /* Fall-through */ + case CMM_SEQ_CST: /* Fall-through */ + case CMM_SEQ_CST_FENCE: + cmm_barrier(); + break; + case CMM_ACQ_REL: /* Fall-through */ + case CMM_ACQUIRE: /* Fall-through */ + case CMM_CONSUME: /* Fall-through */ + default: + abort(); + break; + } +} + +static inline void _cmm_compat_c11_smp_mb__after_uatomic_store_mo(enum cmm_memorder mo) +{ + /* + * A SMP barrier is necessary for CMM_SEQ_CST because the store can be + * reorded with later loads. Since no memory barrier is being emitted + * before loads, one has to be emitted after the store. This follows + * toolchains decision of emitting the memory fence on the stores instead + * of the loads. + * + * A SMP barrier is necessary for CMM_SEQ_CST_FENCE to respect the + * memory model, since the underlying store does not have a lock prefix. + * + * A compiler barrier is necessary because the underlying operation does + * not clobber the registers. + */ + switch (mo) { + case CMM_SEQ_CST: /* Fall-through */ + case CMM_SEQ_CST_FENCE: + cmm_smp_mb(); + break; + case CMM_RELAXED: /* Fall-through */ + case CMM_RELEASE: + cmm_barrier(); + break; + case CMM_ACQ_REL: /* Fall-through */ + case CMM_ACQUIRE: /* Fall-through */ + case CMM_CONSUME: /* Fall-through */ + default: + abort(); + break; + } +} + +#define _cmm_compat_c11_smp_mb__before_mo(operation, mo) \ + do { \ + _cmm_compat_c11_smp_mb__before_ ## operation ## _mo (mo); \ + } while (0) + +#define _cmm_compat_c11_smp_mb__after_mo(operation, mo) \ + do { \ + _cmm_compat_c11_smp_mb__after_ ## operation ## _mo (mo); \ + } while (0) + + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_UATOMIC_X86_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic_arch.h b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic_arch.h new file mode 100644 index 0000000000000..5c3510fe82198 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/uatomic_arch.h @@ -0,0 +1,6 @@ +// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#warning "urcu/uatomic_arch.h is deprecated. Please include urcu/uatomic.h instead." +#include diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-bp.h b/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-bp.h new file mode 100644 index 0000000000000..152c53665ddf6 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-bp.h @@ -0,0 +1,191 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_BP_H +#define _URCU_BP_H + +/* + * Userspace RCU header, "bulletproof" version. + * + * Slower RCU read-side adapted for tracing library. Does not require thread + * registration nor unregistration. Also signal-safe. + * + * LGPL-compatible code should include this header with : + * + * #define _LGPL_SOURCE + * #include + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#include +#include +#include + +#include + +/* + * Important ! + * + * Each thread containing read-side critical sections must be registered + * with rcu_register_thread() before calling rcu_read_lock(). + * rcu_unregister_thread() should be called before the thread exits. + */ + +/* + * See urcu/pointer.h and urcu/static/pointer.h for pointer + * publication headers. + */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _LGPL_SOURCE + +#include + +/* + * Mappings for static use of the userspace RCU library. + * Should only be used in LGPL-compatible code. + */ + +/* + * rcu_read_lock() + * rcu_read_unlock() + * + * Mark the beginning and end of a read-side critical section. + */ +#define urcu_bp_read_lock _urcu_bp_read_lock +#define urcu_bp_read_unlock _urcu_bp_read_unlock +#define urcu_bp_read_ongoing _urcu_bp_read_ongoing + +#define urcu_bp_dereference rcu_dereference +#define urcu_bp_cmpxchg_pointer rcu_cmpxchg_pointer +#define urcu_bp_xchg_pointer rcu_xchg_pointer +#define urcu_bp_set_pointer rcu_set_pointer + +#else /* !_LGPL_SOURCE */ + +/* + * library wrappers to be used by non-LGPL compatible source code. + * See LGPL-only urcu/static/pointer.h for documentation. + */ + +extern void urcu_bp_read_lock(void); +extern void urcu_bp_read_unlock(void); +extern int urcu_bp_read_ongoing(void); + +extern void *urcu_bp_dereference_sym(void *p); +#define urcu_bp_dereference(p) \ + __extension__ \ + ({ \ + __typeof__(p) _________p1 = URCU_FORCE_CAST(__typeof__(p), \ + urcu_bp_dereference_sym(URCU_FORCE_CAST(void *, p))); \ + (_________p1); \ + }) + +extern void *urcu_bp_cmpxchg_pointer_sym(void **p, void *old, void *_new); +#define urcu_bp_cmpxchg_pointer(p, old, _new) \ + __extension__ \ + ({ \ + __typeof__(*(p)) _________pold = (old); \ + __typeof__(*(p)) _________pnew = (_new); \ + __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)), \ + urcu_bp_cmpxchg_pointer_sym(URCU_FORCE_CAST(void **, p), \ + _________pold, \ + _________pnew)); \ + (_________p1); \ + }) + +extern void *urcu_bp_xchg_pointer_sym(void **p, void *v); +#define urcu_bp_xchg_pointer(p, v) \ + __extension__ \ + ({ \ + __typeof__(*(p)) _________pv = (v); \ + __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)),\ + urcu_bp_xchg_pointer_sym(URCU_FORCE_CAST(void **, p), \ + _________pv)); \ + (_________p1); \ + }) + +extern void *urcu_bp_set_pointer_sym(void **p, void *v); +#define urcu_bp_set_pointer(p, v) \ + __extension__ \ + ({ \ + __typeof__(*(p)) _________pv = (v); \ + __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)), \ + urcu_bp_set_pointer_sym(URCU_FORCE_CAST(void **, p), \ + _________pv)); \ + (_________p1); \ + }) + +#endif /* !_LGPL_SOURCE */ + +extern void urcu_bp_synchronize_rcu(void); + +/* + * RCU grace period polling API. + */ +extern struct urcu_gp_poll_state urcu_bp_start_poll_synchronize_rcu(void); +extern bool urcu_bp_poll_state_synchronize_rcu(struct urcu_gp_poll_state state); + +/* + * urcu_bp_before_fork, urcu_bp_after_fork_parent and urcu_bp_after_fork_child + * should be called around fork() system calls when the child process is not + * expected to immediately perform an exec(). For pthread users, see + * pthread_atfork(3). + */ +extern void urcu_bp_before_fork(void); +extern void urcu_bp_after_fork_parent(void); +extern void urcu_bp_after_fork_child(void); + +/* + * In the bulletproof version, thread registration is performed lazily, + * but it can be forced by issuing an explicit urcu_bp_register_thread(). + */ +extern void urcu_bp_register_thread(void); + +/* + * In the bulletproof version, the following functions are no-ops. + */ +static inline void urcu_bp_unregister_thread(void) +{ +} + +static inline void urcu_bp_init(void) +{ +} + +/* + * Q.S. reporting are no-ops for these URCU flavors. + */ +static inline void urcu_bp_quiescent_state(void) +{ +} + +static inline void urcu_bp_thread_offline(void) +{ +} + +static inline void urcu_bp_thread_online(void) +{ +} + +#ifdef __cplusplus +} +#endif + +#include +#include +#include + +#ifndef URCU_API_MAP +#include +#endif + +#endif /* _URCU_BP_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-futex.h b/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-futex.h new file mode 100644 index 0000000000000..65c2a6b8efc54 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-futex.h @@ -0,0 +1,6 @@ +// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#warning "urcu/urcu-futex.h is deprecated. Please include urcu/futex.h instead." +#include diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-mb.h b/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-mb.h new file mode 100644 index 0000000000000..acd02d0975041 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-mb.h @@ -0,0 +1,125 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_MB_H +#define _URCU_MB_H + +/* + * Userspace RCU header + * + * LGPL-compatible code should include this header with : + * + * #define _LGPL_SOURCE + * #include + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#include +#include +#include + +/* + * See urcu/pointer.h and urcu/static/pointer.h for pointer + * publication headers. + */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * Important ! + * + * Each thread containing read-side critical sections must be registered + * with rcu_register_thread_mb() before calling rcu_read_lock_mb(). + * rcu_unregister_thread_mb() should be called before the thread exits. + */ + +#ifdef _LGPL_SOURCE + +#include + +/* + * Mappings for static use of the userspace RCU library. + * Should only be used in LGPL-compatible code. + */ + +/* + * rcu_read_lock() + * rcu_read_unlock() + * + * Mark the beginning and end of a read-side critical section. + * DON'T FORGET TO USE RCU_REGISTER/UNREGISTER_THREAD() FOR EACH THREAD WITH + * READ-SIDE CRITICAL SECTION. + */ +#define urcu_mb_read_lock _urcu_mb_read_lock +#define urcu_mb_read_unlock _urcu_mb_read_unlock +#define urcu_mb_read_ongoing _urcu_mb_read_ongoing + +#else /* !_LGPL_SOURCE */ + +/* + * library wrappers to be used by non-LGPL compatible source code. + * See LGPL-only urcu/static/pointer.h for documentation. + */ + +extern void urcu_mb_read_lock(void); +extern void urcu_mb_read_unlock(void); +extern int urcu_mb_read_ongoing(void); + +#endif /* !_LGPL_SOURCE */ + +extern void urcu_mb_synchronize_rcu(void); + +/* + * RCU grace period polling API. + */ +extern struct urcu_gp_poll_state urcu_mb_start_poll_synchronize_rcu(void); +extern bool urcu_mb_poll_state_synchronize_rcu(struct urcu_gp_poll_state state); + +/* + * Reader thread registration. + */ +extern void urcu_mb_register_thread(void); +extern void urcu_mb_unregister_thread(void); + +/* + * Explicit rcu initialization, for "early" use within library constructors. + */ +extern void urcu_mb_init(void); + +/* + * Q.S. reporting are no-ops for these URCU flavors. + */ +static inline void urcu_mb_quiescent_state(void) +{ +} + +static inline void urcu_mb_thread_offline(void) +{ +} + +static inline void urcu_mb_thread_online(void) +{ +} + +#ifdef __cplusplus +} +#endif + +#include +#include +#include + +#ifndef URCU_API_MAP +#include +#endif + +#endif /* _URCU_MB_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-memb.h b/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-memb.h new file mode 100644 index 0000000000000..c89b4c0d6f3fb --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-memb.h @@ -0,0 +1,125 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_MEMB_H +#define _URCU_MEMB_H + +/* + * Userspace RCU header + * + * LGPL-compatible code should include this header with : + * + * #define _LGPL_SOURCE + * #include + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#include +#include +#include + +/* + * See urcu/pointer.h and urcu/static/pointer.h for pointer + * publication headers. + */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * Important ! + * + * Each thread containing read-side critical sections must be registered + * with rcu_register_thread_mb() before calling rcu_read_lock_mb(). + * rcu_unregister_thread_mb() should be called before the thread exits. + */ + +#ifdef _LGPL_SOURCE + +#include + +/* + * Mappings for static use of the userspace RCU library. + * Should only be used in LGPL-compatible code. + */ + +/* + * rcu_read_lock() + * rcu_read_unlock() + * + * Mark the beginning and end of a read-side critical section. + * DON'T FORGET TO USE RCU_REGISTER/UNREGISTER_THREAD() FOR EACH THREAD WITH + * READ-SIDE CRITICAL SECTION. + */ +#define urcu_memb_read_lock _urcu_memb_read_lock +#define urcu_memb_read_unlock _urcu_memb_read_unlock +#define urcu_memb_read_ongoing _urcu_memb_read_ongoing + +#else /* !_LGPL_SOURCE */ + +/* + * library wrappers to be used by non-LGPL compatible source code. + * See LGPL-only urcu/static/pointer.h for documentation. + */ + +extern void urcu_memb_read_lock(void); +extern void urcu_memb_read_unlock(void); +extern int urcu_memb_read_ongoing(void); + +#endif /* !_LGPL_SOURCE */ + +extern void urcu_memb_synchronize_rcu(void); + +/* + * RCU grace period polling API. + */ +extern struct urcu_gp_poll_state urcu_memb_start_poll_synchronize_rcu(void); +extern bool urcu_memb_poll_state_synchronize_rcu(struct urcu_gp_poll_state state); + +/* + * Reader thread registration. + */ +extern void urcu_memb_register_thread(void); +extern void urcu_memb_unregister_thread(void); + +/* + * Explicit rcu initialization, for "early" use within library constructors. + */ +extern void urcu_memb_init(void); + +/* + * Q.S. reporting are no-ops for these URCU flavors. + */ +static inline void urcu_memb_quiescent_state(void) +{ +} + +static inline void urcu_memb_thread_offline(void) +{ +} + +static inline void urcu_memb_thread_online(void) +{ +} + +#ifdef __cplusplus +} +#endif + +#include +#include +#include + +#ifndef URCU_API_MAP +#include +#endif + +#endif /* _URCU_MEMB_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-poll.h b/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-poll.h new file mode 100644 index 0000000000000..c52d695d63967 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-poll.h @@ -0,0 +1,16 @@ +// SPDX-FileCopyrightText: 2023 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_POLL_H +#define _URCU_POLL_H + +/* + * Userspace RCU polling header + */ + +struct urcu_gp_poll_state { + unsigned long grace_period_id; +}; + +#endif /* _URCU_POLL_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-qsbr.h b/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-qsbr.h new file mode 100644 index 0000000000000..c2a3e1929a64d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/urcu-qsbr.h @@ -0,0 +1,143 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_QSBR_H +#define _URCU_QSBR_H + +/* + * Userspace RCU QSBR header. + * + * LGPL-compatible code should include this header with : + * + * #define _LGPL_SOURCE + * #include + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#include +#include +#include + +#include + +/* + * See urcu/pointer.h and urcu/static/pointer.h for pointer + * publication headers. + */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef RCU_DEBUG /* For backward compatibility */ +#define DEBUG_RCU +#endif + +/* + * Important ! + * + * Each thread containing read-side critical sections must be registered + * with rcu_register_thread() before calling rcu_read_lock(). + * rcu_unregister_thread() should be called before the thread exits. + */ + +#ifdef _LGPL_SOURCE + +#include + +/* + * Mappings for static use of the userspace RCU library. + * Should only be used in LGPL-compatible code. + */ + +/* + * rcu_read_lock() + * rcu_read_unlock() + * + * Mark the beginning and end of a read-side critical section. + * DON'T FORGET TO USE rcu_register_thread/rcu_unregister_thread() + * FOR EACH THREAD WITH READ-SIDE CRITICAL SECTION. + */ +#define urcu_qsbr_read_lock _urcu_qsbr_read_lock +#define urcu_qsbr_read_unlock _urcu_qsbr_read_unlock +#define urcu_qsbr_read_ongoing _urcu_qsbr_read_ongoing + +#define urcu_qsbr_quiescent_state _urcu_qsbr_quiescent_state +#define urcu_qsbr_thread_offline _urcu_qsbr_thread_offline +#define urcu_qsbr_thread_online _urcu_qsbr_thread_online + +#else /* !_LGPL_SOURCE */ + +/* + * library wrappers to be used by non-LGPL compatible source code. + */ + +/* + * QSBR read lock/unlock are guaranteed to be no-ops. Therefore, we expose them + * in the LGPL header for any code to use. However, the debug version is not + * nops and may contain sanity checks. To activate it, applications must be + * recompiled with -DDEBUG_RCU (even non-LGPL/GPL applications), or + * compiled against a urcu/config.h that has CONFIG_RCU_DEBUG defined. + * This is the best trade-off between license/performance/code + * triviality and library debugging & tracing features we could come up + * with. + */ + +#if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG)) + +static inline void urcu_qsbr_read_lock(void) +{ +} + +static inline void urcu_qsbr_read_unlock(void) +{ +} + +#else /* #if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG)) */ + +extern void urcu_qsbr_read_lock(void); +extern void urcu_qsbr_read_unlock(void); + +#endif /* #else #if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG)) */ + +extern int urcu_qsbr_read_ongoing(void); +extern void urcu_qsbr_quiescent_state(void); +extern void urcu_qsbr_thread_offline(void); +extern void urcu_qsbr_thread_online(void); + +#endif /* !_LGPL_SOURCE */ + +extern void urcu_qsbr_synchronize_rcu(void); + +/* + * RCU grace period polling API. + */ +extern struct urcu_gp_poll_state urcu_qsbr_start_poll_synchronize_rcu(void); +extern bool urcu_qsbr_poll_state_synchronize_rcu(struct urcu_gp_poll_state state); + +/* + * Reader thread registration. + */ +extern void urcu_qsbr_register_thread(void); +extern void urcu_qsbr_unregister_thread(void); + +#ifdef __cplusplus +} +#endif + +#include +#include +#include + +#ifndef URCU_API_MAP +#include +#endif + +#endif /* _URCU_QSBR_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/urcu.h b/external/lgpl2/userspace-rcu/dist/include/urcu/urcu.h new file mode 100644 index 0000000000000..4df48e4ba3cd1 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/urcu.h @@ -0,0 +1,32 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_H +#define _URCU_H + +/* + * Userspace RCU header + * + * LGPL-compatible code should include this header with : + * + * #define _LGPL_SOURCE + * #include + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#if !defined(RCU_MEMBARRIER) && !defined(RCU_MB) +#define RCU_MEMBARRIER +#endif + +#ifdef RCU_MEMBARRIER +#include +#elif defined(RCU_MB) +#include +#else +#error "Unknown urcu flavor" +#endif + +#endif /* _URCU_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/urcu_ref.h b/external/lgpl2/userspace-rcu/dist/include/urcu/urcu_ref.h new file mode 100644 index 0000000000000..916a9df317dc7 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/urcu_ref.h @@ -0,0 +1,6 @@ +// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#warning "urcu/urcu_ref.h is deprecated. Please include urcu/ref.h instead." +#include diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/wfcqueue.h b/external/lgpl2/userspace-rcu/dist/include/urcu/wfcqueue.h new file mode 100644 index 0000000000000..5a4add454f59d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/wfcqueue.h @@ -0,0 +1,653 @@ +// SPDX-FileCopyrightText: 2010-2012 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2011-2012 Lai Jiangshan +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_WFCQUEUE_H +#define _URCU_WFCQUEUE_H + +/* + * Userspace RCU library - Concurrent Queue with Wait-Free Enqueue/Blocking Dequeue + */ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Concurrent queue with wait-free enqueue/blocking dequeue. + * + * This queue has been designed and implemented collaboratively by + * Mathieu Desnoyers and Lai Jiangshan. Inspired from + * half-wait-free/half-blocking queue implementation done by Paul E. + * McKenney. + */ + +#define CDS_WFCQ_WOULDBLOCK ((struct cds_wfcq_node *) -1UL) + +enum cds_wfcq_ret { + CDS_WFCQ_RET_WOULDBLOCK = -1, + CDS_WFCQ_RET_DEST_EMPTY = 0, + CDS_WFCQ_RET_DEST_NON_EMPTY = 1, + CDS_WFCQ_RET_SRC_EMPTY = 2, +}; + +enum cds_wfcq_state { + CDS_WFCQ_STATE_LAST = (1U << 0), +}; + +struct cds_wfcq_node { + struct cds_wfcq_node *next; +}; + +/* + * Do not put head and tail on the same cache-line if concurrent + * enqueue/dequeue are expected from many CPUs. This eliminates + * false-sharing between enqueue and dequeue. + */ +struct __cds_wfcq_head { + struct cds_wfcq_node node; +}; + +struct cds_wfcq_head { + struct cds_wfcq_node node; + pthread_mutex_t lock; +}; + +/* + * In C, the transparent union allows calling functions that work on both + * struct cds_wfcq_head and struct __cds_wfcq_head on any of those two + * types. + * + * In C++, implement static inline wrappers using function overloading + * to obtain an API similar to C. + * + * Avoid complaints from clang++ not knowing the transparent union + * attribute. + */ +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wignored-attributes" +#endif +typedef union { + struct __cds_wfcq_head *_h; + struct cds_wfcq_head *h; +} __attribute__((__transparent_union__)) cds_wfcq_head_ptr_t; + +typedef union { + const struct __cds_wfcq_head *_h; + const struct cds_wfcq_head *h; +} __attribute__((__transparent_union__)) cds_wfcq_head_const_ptr_t; +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + +#ifndef __cplusplus +/* + * This static inline is only present for compatibility with C++. It is + * effect-less in C. + */ +static inline struct __cds_wfcq_head *__cds_wfcq_head_cast(struct __cds_wfcq_head *head) +{ + return head; +} + +/* + * This static inline is only present for compatibility with C++. It is + * effect-less in C. + */ +static inline struct cds_wfcq_head *cds_wfcq_head_cast(struct cds_wfcq_head *head) +{ + return head; +} + +/* + * This static inline is only present for compatibility with C++. It is + * effect-less in C. + */ +static inline const struct __cds_wfcq_head *__cds_wfcq_head_const_cast(const struct __cds_wfcq_head *head) +{ + return head; +} + +/* + * This static inline is only present for compatibility with C++. It is + * effect-less in C. + */ +static inline const struct cds_wfcq_head *cds_wfcq_head_const_cast(const struct cds_wfcq_head *head) +{ + return head; +} + +#else /* #ifndef __cplusplus */ + +/* + * This static inline is used by internally in the static inline + * implementation of the API. + */ +static inline cds_wfcq_head_ptr_t __cds_wfcq_head_cast(struct __cds_wfcq_head *head) +{ + cds_wfcq_head_ptr_t ret = { ._h = head }; + return ret; +} + +/* + * This static inline is used by internally in the static inline + * implementation of the API. + */ +static inline cds_wfcq_head_ptr_t cds_wfcq_head_cast(struct cds_wfcq_head *head) +{ + cds_wfcq_head_ptr_t ret = { .h = head }; + return ret; +} + +/* + * This static inline is used by internally in the static inline + * implementation of the API. + */ +static inline cds_wfcq_head_const_ptr_t __cds_wfcq_head_const_cast(const struct __cds_wfcq_head *head) +{ + cds_wfcq_head_const_ptr_t ret = { ._h = head }; + return ret; +} + +/* + * This static inline is used by internally in the static inline + * implementation of the API. + */ +static inline cds_wfcq_head_const_ptr_t cds_wfcq_head_const_cast(const struct cds_wfcq_head *head) +{ + cds_wfcq_head_const_ptr_t ret = { .h = head }; + return ret; +} + +#endif /* #else #ifndef __cplusplus */ + +struct cds_wfcq_tail { + struct cds_wfcq_node *p; +}; + +#ifdef _LGPL_SOURCE + +#include + +#define cds_wfcq_node_init _cds_wfcq_node_init +#define cds_wfcq_init _cds_wfcq_init +#define __cds_wfcq_init ___cds_wfcq_init +#define cds_wfcq_destroy _cds_wfcq_destroy +#define cds_wfcq_empty _cds_wfcq_empty +#define cds_wfcq_enqueue _cds_wfcq_enqueue + +/* Dequeue locking */ +#define cds_wfcq_dequeue_lock _cds_wfcq_dequeue_lock +#define cds_wfcq_dequeue_unlock _cds_wfcq_dequeue_unlock + +/* Locking performed within cds_wfcq calls. */ +#define cds_wfcq_dequeue_blocking _cds_wfcq_dequeue_blocking +#define cds_wfcq_dequeue_with_state_blocking \ + _cds_wfcq_dequeue_with_state_blocking +#define cds_wfcq_splice_blocking _cds_wfcq_splice_blocking +#define cds_wfcq_first_blocking _cds_wfcq_first_blocking +#define cds_wfcq_next_blocking _cds_wfcq_next_blocking + +/* Locking ensured by caller by holding cds_wfcq_dequeue_lock() */ +#define __cds_wfcq_dequeue_blocking ___cds_wfcq_dequeue_blocking +#define __cds_wfcq_dequeue_with_state_blocking \ + ___cds_wfcq_dequeue_with_state_blocking +#define __cds_wfcq_splice_blocking ___cds_wfcq_splice_blocking +#define __cds_wfcq_first_blocking ___cds_wfcq_first_blocking +#define __cds_wfcq_next_blocking ___cds_wfcq_next_blocking + +/* + * Locking ensured by caller by holding cds_wfcq_dequeue_lock(). + * Non-blocking: deque, first, next return CDS_WFCQ_WOULDBLOCK if they + * need to block. splice returns nonzero if it needs to block. + */ +#define __cds_wfcq_dequeue_nonblocking ___cds_wfcq_dequeue_nonblocking +#define __cds_wfcq_dequeue_with_state_nonblocking \ + ___cds_wfcq_dequeue_with_state_nonblocking +#define __cds_wfcq_splice_nonblocking ___cds_wfcq_splice_nonblocking +#define __cds_wfcq_first_nonblocking ___cds_wfcq_first_nonblocking +#define __cds_wfcq_next_nonblocking ___cds_wfcq_next_nonblocking + +#else /* !_LGPL_SOURCE */ + +/* + * Mutual exclusion of cds_wfcq_* / __cds_wfcq_* API + * + * Synchronization table: + * + * External synchronization techniques described in the API below is + * required between pairs marked with "X". No external synchronization + * required between pairs marked with "-". + * + * Legend: + * [1] cds_wfcq_enqueue + * [2] __cds_wfcq_splice (destination queue) + * [3] __cds_wfcq_dequeue + * [4] __cds_wfcq_splice (source queue) + * [5] __cds_wfcq_first + * [6] __cds_wfcq_next + * + * [1] [2] [3] [4] [5] [6] + * [1] - - - - - - + * [2] - - - - - - + * [3] - - X X X X + * [4] - - X - X X + * [5] - - X X - - + * [6] - - X X - - + * + * Mutual exclusion can be ensured by holding cds_wfcq_dequeue_lock(). + * + * For convenience, cds_wfcq_dequeue_blocking() and + * cds_wfcq_splice_blocking() hold the dequeue lock. + * + * Besides locking, mutual exclusion of dequeue, splice and iteration + * can be ensured by performing all of those operations from a single + * thread, without requiring any lock. + */ + +/* + * cds_wfcq_node_init: initialize wait-free queue node. + */ +extern void cds_wfcq_node_init(struct cds_wfcq_node *node); + +/* + * cds_wfcq_init: initialize wait-free queue. Pair with + * cds_wfcq_destroy(). + */ +extern void cds_wfcq_init(struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail); + +/* + * cds_wfcq_destroy: destroy wait-free queue. Pair with + * cds_wfcq_init(). + */ +extern void cds_wfcq_destroy(struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail); + +/* + * __cds_wfcq_init: initialize wait-free queue (without lock). Don't + * pair with any destroy function. + */ +extern void __cds_wfcq_init(struct __cds_wfcq_head *head, + struct cds_wfcq_tail *tail); + +/* + * cds_wfcq_empty: return whether wait-free queue is empty. + * + * No memory barrier is issued. No mutual exclusion is required. + */ +extern bool cds_wfcq_empty(cds_wfcq_head_const_ptr_t head, + const struct cds_wfcq_tail *tail); + +/* + * cds_wfcq_dequeue_lock: take the dequeue mutual exclusion lock. + */ +extern void cds_wfcq_dequeue_lock(struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail); + +/* + * cds_wfcq_dequeue_unlock: release the dequeue mutual exclusion lock. + */ +extern void cds_wfcq_dequeue_unlock(struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail); + +/* + * cds_wfcq_enqueue: enqueue a node into a wait-free queue. + * + * Issues a full memory barrier before enqueue. No mutual exclusion is + * required. + * + * Returns false if the queue was empty prior to adding the node. + * Returns true otherwise. + */ +extern bool cds_wfcq_enqueue(cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail, + struct cds_wfcq_node *node); + +/* + * cds_wfcq_dequeue_blocking: dequeue a node from a wait-free queue. + * + * Content written into the node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + * It is valid to reuse and free a dequeued node immediately. + * Mutual exclusion with cds_wfcq_dequeue_blocking and dequeue lock is + * ensured. + */ +extern struct cds_wfcq_node *cds_wfcq_dequeue_blocking( + struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail); + +/* + * cds_wfcq_dequeue_with_state_blocking: dequeue with state. + * + * Same as cds_wfcq_dequeue_blocking, but saves whether dequeueing the + * last node of the queue into state (CDS_WFCQ_STATE_LAST). + */ +extern struct cds_wfcq_node *cds_wfcq_dequeue_with_state_blocking( + struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail, + int *state); + +/* + * cds_wfcq_splice_blocking: enqueue all src_q nodes at the end of dest_q. + * + * Dequeue all nodes from src_q. + * dest_q must be already initialized. + * Content written into the node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + * Mutual exclusion with cds_wfcq_dequeue_blocking and dequeue lock is + * ensured. + * + * Returns enum cds_wfcq_ret which indicates the state of the src or + * dest queue. + */ +extern enum cds_wfcq_ret cds_wfcq_splice_blocking( + struct cds_wfcq_head *dest_q_head, + struct cds_wfcq_tail *dest_q_tail, + struct cds_wfcq_head *src_q_head, + struct cds_wfcq_tail *src_q_tail); + +/* + * __cds_wfcq_dequeue_blocking: dequeue a node from a wait-free queue. + * + * Content written into the node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + * It is valid to reuse and free a dequeued node immediately. + * Dequeue/splice/iteration mutual exclusion should be ensured by the + * caller. + */ +extern struct cds_wfcq_node *__cds_wfcq_dequeue_blocking( + cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail); + +/* + * __cds_wfcq_dequeue_with_state_blocking: dequeue with state. + * + * Same as __cds_wfcq_dequeue_blocking, but saves whether dequeueing the + * last node of the queue into state (CDS_WFCQ_STATE_LAST). + */ +extern struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_blocking( + cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail, + int *state); + +/* + * __cds_wfcq_dequeue_nonblocking: dequeue a node from a wait-free queue. + * + * Same as __cds_wfcq_dequeue_blocking, but returns CDS_WFCQ_WOULDBLOCK + * if it needs to block. + */ +extern struct cds_wfcq_node *__cds_wfcq_dequeue_nonblocking( + cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail); + +/* + * __cds_wfcq_dequeue_with_state_blocking: dequeue with state. + * + * Same as __cds_wfcq_dequeue_nonblocking, but saves whether dequeueing + * the last node of the queue into state (CDS_WFCQ_STATE_LAST). + */ +extern struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_nonblocking( + cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail, + int *state); + +/* + * __cds_wfcq_splice_blocking: enqueue all src_q nodes at the end of dest_q. + * + * Dequeue all nodes from src_q. + * dest_q must be already initialized. + * Mutual exclusion for src_q should be ensured by the caller as + * specified in the "Synchronisation table". + * Returns enum cds_wfcq_ret which indicates the state of the src or + * dest queue. Never returns CDS_WFCQ_RET_WOULDBLOCK. + */ +extern enum cds_wfcq_ret __cds_wfcq_splice_blocking( + cds_wfcq_head_ptr_t dest_q_head, + struct cds_wfcq_tail *dest_q_tail, + cds_wfcq_head_ptr_t src_q_head, + struct cds_wfcq_tail *src_q_tail); + +/* + * __cds_wfcq_splice_nonblocking: enqueue all src_q nodes at the end of dest_q. + * + * Same as __cds_wfcq_splice_blocking, but returns + * CDS_WFCQ_RET_WOULDBLOCK if it needs to block. + */ +extern enum cds_wfcq_ret __cds_wfcq_splice_nonblocking( + cds_wfcq_head_ptr_t dest_q_head, + struct cds_wfcq_tail *dest_q_tail, + cds_wfcq_head_ptr_t src_q_head, + struct cds_wfcq_tail *src_q_tail); + +/* + * __cds_wfcq_first_blocking: get first node of a queue, without dequeuing. + * + * Content written into the node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + * Dequeue/splice/iteration mutual exclusion should be ensured by the + * caller. + * + * Used by for-like iteration macros: + * __cds_wfcq_for_each_blocking() + * __cds_wfcq_for_each_blocking_safe() + * + * Returns NULL if queue is empty, first node otherwise. + */ +extern struct cds_wfcq_node *__cds_wfcq_first_blocking( + cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail); + +/* + * __cds_wfcq_first_nonblocking: get first node of a queue, without dequeuing. + * + * Same as __cds_wfcq_first_blocking, but returns CDS_WFCQ_WOULDBLOCK if + * it needs to block. + */ +extern struct cds_wfcq_node *__cds_wfcq_first_nonblocking( + cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail); + +/* + * __cds_wfcq_next_blocking: get next node of a queue, without dequeuing. + * + * Content written into the node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + * Dequeue/splice/iteration mutual exclusion should be ensured by the + * caller. + * + * Used by for-like iteration macros: + * __cds_wfcq_for_each_blocking() + * __cds_wfcq_for_each_blocking_safe() + * + * Returns NULL if reached end of queue, non-NULL next queue node + * otherwise. + */ +extern struct cds_wfcq_node *__cds_wfcq_next_blocking( + cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail, + struct cds_wfcq_node *node); + +/* + * __cds_wfcq_next_blocking: get next node of a queue, without dequeuing. + * + * Same as __cds_wfcq_next_blocking, but returns CDS_WFCQ_WOULDBLOCK if + * it needs to block. + */ +extern struct cds_wfcq_node *__cds_wfcq_next_nonblocking( + cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail, + struct cds_wfcq_node *node); + +#endif /* !_LGPL_SOURCE */ + +/* + * __cds_wfcq_for_each_blocking: Iterate over all nodes in a queue, + * without dequeuing them. + * @head: head of the queue (struct cds_wfcq_head or __cds_wfcq_head pointer). + * @tail: tail of the queue (struct cds_wfcq_tail pointer). + * @node: iterator on the queue (struct cds_wfcq_node pointer). + * + * Content written into each node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + * Dequeue/splice/iteration mutual exclusion should be ensured by the + * caller. + */ +#define __cds_wfcq_for_each_blocking(head, tail, node) \ + for (node = __cds_wfcq_first_blocking(head, tail); \ + node != NULL; \ + node = __cds_wfcq_next_blocking(head, tail, node)) + +/* + * __cds_wfcq_for_each_blocking_safe: Iterate over all nodes in a queue, + * without dequeuing them. Safe against deletion. + * @head: head of the queue (struct cds_wfcq_head or __cds_wfcq_head pointer). + * @tail: tail of the queue (struct cds_wfcq_tail pointer). + * @node: iterator on the queue (struct cds_wfcq_node pointer). + * @n: struct cds_wfcq_node pointer holding the next pointer (used + * internally). + * + * Content written into each node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + * Dequeue/splice/iteration mutual exclusion should be ensured by the + * caller. + */ +#define __cds_wfcq_for_each_blocking_safe(head, tail, node, n) \ + for (node = __cds_wfcq_first_blocking(head, tail), \ + n = (node ? __cds_wfcq_next_blocking(head, tail, node) : NULL); \ + node != NULL; \ + node = n, n = (node ? __cds_wfcq_next_blocking(head, tail, node) : NULL)) + +#ifdef __cplusplus +} + +/* + * In C++, implement static inline wrappers using function overloading + * to obtain an API similar to C. + */ + +static inline cds_wfcq_head_ptr_t cds_wfcq_head_cast_cpp(struct __cds_wfcq_head *head) +{ + cds_wfcq_head_ptr_t ret = { ._h = head }; + return ret; +} + +static inline cds_wfcq_head_ptr_t cds_wfcq_head_cast_cpp(struct cds_wfcq_head *head) +{ + cds_wfcq_head_ptr_t ret = { .h = head }; + return ret; +} + +static inline cds_wfcq_head_const_ptr_t cds_wfcq_head_const_cast_cpp(const struct __cds_wfcq_head *head) +{ + cds_wfcq_head_const_ptr_t ret = { ._h = head }; + return ret; +} + +static inline cds_wfcq_head_const_ptr_t cds_wfcq_head_const_cast_cpp(const struct cds_wfcq_head *head) +{ + cds_wfcq_head_const_ptr_t ret = { .h = head }; + return ret; +} + +template static inline bool cds_wfcq_empty(T head, + const struct cds_wfcq_tail *tail) +{ + return cds_wfcq_empty(cds_wfcq_head_const_cast_cpp(head), tail); +} + +template static inline bool cds_wfcq_enqueue(T head, + struct cds_wfcq_tail *tail, + struct cds_wfcq_node *node) +{ + return cds_wfcq_enqueue(cds_wfcq_head_cast_cpp(head), tail, node); +} + +template static inline struct cds_wfcq_node *__cds_wfcq_dequeue_blocking( + T head, struct cds_wfcq_tail *tail) +{ + return __cds_wfcq_dequeue_blocking(cds_wfcq_head_cast_cpp(head), tail); +} + +template static inline struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_blocking( + T head, struct cds_wfcq_tail *tail, int *state) +{ + return __cds_wfcq_dequeue_with_state_blocking(cds_wfcq_head_cast_cpp(head), + tail, state); +} + +template static inline struct cds_wfcq_node *__cds_wfcq_dequeue_nonblocking( + T head, struct cds_wfcq_tail *tail) +{ + return __cds_wfcq_dequeue_nonblocking(cds_wfcq_head_cast_cpp(head), tail); +} + +template static inline struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_nonblocking( + T head, struct cds_wfcq_tail *tail, int *state) +{ + return __cds_wfcq_dequeue_with_state_nonblocking(cds_wfcq_head_cast_cpp(head), + tail, state); +} + +template static inline enum cds_wfcq_ret __cds_wfcq_splice_blocking( + T dest_q_head, + struct cds_wfcq_tail *dest_q_tail, + U src_q_head, + struct cds_wfcq_tail *src_q_tail) +{ + return __cds_wfcq_splice_blocking(cds_wfcq_head_cast_cpp(dest_q_head), + dest_q_tail, + cds_wfcq_head_cast_cpp(src_q_head), + src_q_tail); +} + +template static inline enum cds_wfcq_ret __cds_wfcq_splice_nonblocking( + T dest_q_head, + struct cds_wfcq_tail *dest_q_tail, + U *src_q_head, + struct cds_wfcq_tail *src_q_tail) +{ + return __cds_wfcq_splice_nonblocking(cds_wfcq_head_cast_cpp(dest_q_head), + dest_q_tail, + cds_wfcq_head_cast_cpp(src_q_head), + src_q_tail); +} + +template static inline struct cds_wfcq_node *__cds_wfcq_first_blocking( + T head, struct cds_wfcq_tail *tail) +{ + return __cds_wfcq_first_blocking(cds_wfcq_head_cast_cpp(head), tail); +} + +template static inline struct cds_wfcq_node *__cds_wfcq_first_nonblocking( + T head, struct cds_wfcq_tail *tail) +{ + return __cds_wfcq_first_nonblocking(cds_wfcq_head_cast_cpp(head), tail); +} + +template static inline struct cds_wfcq_node *__cds_wfcq_next_blocking( + T head, + struct cds_wfcq_tail *tail, + struct cds_wfcq_node *node) +{ + return __cds_wfcq_next_blocking(cds_wfcq_head_cast_cpp(head), tail, node); +} + +template static inline struct cds_wfcq_node *__cds_wfcq_next_nonblocking( + T head, + struct cds_wfcq_tail *tail, + struct cds_wfcq_node *node) +{ + return __cds_wfcq_next_nonblocking(cds_wfcq_head_cast_cpp(head), tail, node); +} + +#endif + +#endif /* _URCU_WFCQUEUE_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/wfqueue.h b/external/lgpl2/userspace-rcu/dist/include/urcu/wfqueue.h new file mode 100644 index 0000000000000..45506ea21cf49 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/wfqueue.h @@ -0,0 +1,110 @@ +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_WFQUEUE_H +#define _URCU_WFQUEUE_H + +/* + * Userspace RCU library - Queue with Wait-Free Enqueue/Blocking Dequeue + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef CDS_WFQ_DEPRECATED +#define CDS_WFQ_DEPRECATED \ + CDS_DEPRECATED("urcu/wfqueue.h is deprecated. Please use urcu/wfcqueue.h instead.") +#endif + +/* + * Queue with wait-free enqueue/blocking dequeue. + * This implementation adds a dummy head node when the queue is empty to ensure + * we can always update the queue locklessly. + * + * Inspired from half-wait-free/half-blocking queue implementation done by + * Paul E. McKenney. + */ + +struct cds_wfq_node { + struct cds_wfq_node *next; +}; + +struct cds_wfq_queue { + struct cds_wfq_node *head, **tail; + struct cds_wfq_node dummy; /* Dummy node */ + pthread_mutex_t lock; +}; + +#ifdef _LGPL_SOURCE + +#include + +static inline CDS_WFQ_DEPRECATED +void cds_wfq_node_init(struct cds_wfq_node *node) +{ + _cds_wfq_node_init(node); +} + +static inline CDS_WFQ_DEPRECATED +void cds_wfq_init(struct cds_wfq_queue *q) +{ + _cds_wfq_init(q); +} + +static inline CDS_WFQ_DEPRECATED +void cds_wfq_destroy(struct cds_wfq_queue *q) +{ + _cds_wfq_destroy(q); +} + +static inline CDS_WFQ_DEPRECATED +void cds_wfq_enqueue(struct cds_wfq_queue *q, struct cds_wfq_node *node) +{ + _cds_wfq_enqueue(q, node); +} + +static inline CDS_WFQ_DEPRECATED +struct cds_wfq_node *__cds_wfq_dequeue_blocking(struct cds_wfq_queue *q) +{ + return ___cds_wfq_dequeue_blocking(q); +} + +static inline CDS_WFQ_DEPRECATED +struct cds_wfq_node *cds_wfq_dequeue_blocking(struct cds_wfq_queue *q) +{ + return _cds_wfq_dequeue_blocking(q); +} + +#else /* !_LGPL_SOURCE */ + +extern CDS_WFQ_DEPRECATED +void cds_wfq_node_init(struct cds_wfq_node *node); + +extern CDS_WFQ_DEPRECATED +void cds_wfq_init(struct cds_wfq_queue *q); + +extern CDS_WFQ_DEPRECATED +void cds_wfq_destroy(struct cds_wfq_queue *q); + +extern CDS_WFQ_DEPRECATED +void cds_wfq_enqueue(struct cds_wfq_queue *q, struct cds_wfq_node *node); + +/* __cds_wfq_dequeue_blocking: caller ensures mutual exclusion between dequeues */ +extern CDS_WFQ_DEPRECATED +struct cds_wfq_node *__cds_wfq_dequeue_blocking(struct cds_wfq_queue *q); + +extern CDS_WFQ_DEPRECATED +struct cds_wfq_node *cds_wfq_dequeue_blocking(struct cds_wfq_queue *q); + +#endif /* !_LGPL_SOURCE */ + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_WFQUEUE_H */ diff --git a/external/lgpl2/userspace-rcu/dist/include/urcu/wfstack.h b/external/lgpl2/userspace-rcu/dist/include/urcu/wfstack.h new file mode 100644 index 0000000000000..66d415027ab33 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/include/urcu/wfstack.h @@ -0,0 +1,436 @@ +// SPDX-FileCopyrightText: 2010-2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_WFSTACK_H +#define _URCU_WFSTACK_H + +/* + * Userspace RCU library - Stack with wait-free push, blocking traversal. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Stack with wait-free push, blocking traversal. + * + * Stack implementing push, pop, pop_all operations, as well as iterator + * on the stack head returned by pop_all. + * + * Wait-free operations: cds_wfs_push, __cds_wfs_pop_all, cds_wfs_empty, + * cds_wfs_first. + * Blocking operations: cds_wfs_pop, cds_wfs_pop_all, cds_wfs_next, + * iteration on stack head returned by pop_all. + * + * Synchronization table: + * + * External synchronization techniques described in the API below is + * required between pairs marked with "X". No external synchronization + * required between pairs marked with "-". + * + * cds_wfs_push __cds_wfs_pop __cds_wfs_pop_all + * cds_wfs_push - - - + * __cds_wfs_pop - X X + * __cds_wfs_pop_all - X - + * + * cds_wfs_pop and cds_wfs_pop_all use an internal mutex to provide + * synchronization. + */ + +#define CDS_WFS_WOULDBLOCK ((struct cds_wfs_node *) -1UL) + +enum cds_wfs_state { + CDS_WFS_STATE_LAST = (1U << 0), +}; + +/* + * struct cds_wfs_node is returned by __cds_wfs_pop, and also used as + * iterator on stack. It is not safe to dereference the node next + * pointer when returned by __cds_wfs_pop_blocking. + */ +struct cds_wfs_node { + struct cds_wfs_node *next; +}; + +/* + * struct cds_wfs_head is returned by __cds_wfs_pop_all, and can be used + * to begin iteration on the stack. "node" needs to be the first field of + * cds_wfs_head, so the end-of-stack pointer value can be used for both + * types. + */ +struct cds_wfs_head { + struct cds_wfs_node node; +}; + +struct __cds_wfs_stack { + struct cds_wfs_head *head; +}; + +struct cds_wfs_stack { + struct cds_wfs_head *head; + pthread_mutex_t lock; +}; + +/* + * In C, the transparent union allows calling functions that work on both + * struct cds_wfs_stack and struct __cds_wfs_stack on any of those two + * types. + * + * In C++, implement static inline wrappers using function overloading + * to obtain an API similar to C. + * + * Avoid complaints from clang++ not knowing the transparent union + * attribute. + */ +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wignored-attributes" +#endif +typedef union { + struct __cds_wfs_stack *_s; + struct cds_wfs_stack *s; +} __attribute__((__transparent_union__)) cds_wfs_stack_ptr_t; + +typedef union { + const struct __cds_wfs_stack *_s; + const struct cds_wfs_stack *s; +} __attribute__((__transparent_union__)) cds_wfs_stack_const_ptr_t; +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + +#ifdef _LGPL_SOURCE + +#include + +#define cds_wfs_node_init _cds_wfs_node_init +#define cds_wfs_init _cds_wfs_init +#define cds_wfs_destroy _cds_wfs_destroy +#define __cds_wfs_init ___cds_wfs_init +#define cds_wfs_empty _cds_wfs_empty +#define cds_wfs_push _cds_wfs_push + +/* Locking performed internally */ +#define cds_wfs_pop_blocking _cds_wfs_pop_blocking +#define cds_wfs_pop_with_state_blocking _cds_wfs_pop_with_state_blocking +#define cds_wfs_pop_all_blocking _cds_wfs_pop_all_blocking + +/* + * For iteration on cds_wfs_head returned by __cds_wfs_pop_all or + * cds_wfs_pop_all_blocking. + */ +#define cds_wfs_first _cds_wfs_first +#define cds_wfs_next_blocking _cds_wfs_next_blocking +#define cds_wfs_next_nonblocking _cds_wfs_next_nonblocking + +/* Pop locking with internal mutex */ +#define cds_wfs_pop_lock _cds_wfs_pop_lock +#define cds_wfs_pop_unlock _cds_wfs_pop_unlock + +/* Synchronization ensured by the caller. See synchronization table. */ +#define __cds_wfs_pop_blocking ___cds_wfs_pop_blocking +#define __cds_wfs_pop_with_state_blocking \ + ___cds_wfs_pop_with_state_blocking +#define __cds_wfs_pop_nonblocking ___cds_wfs_pop_nonblocking +#define __cds_wfs_pop_with_state_nonblocking \ + ___cds_wfs_pop_with_state_nonblocking +#define __cds_wfs_pop_all ___cds_wfs_pop_all + +#else /* !_LGPL_SOURCE */ + +/* + * cds_wfs_node_init: initialize wait-free stack node. + */ +extern void cds_wfs_node_init(struct cds_wfs_node *node); + +/* + * cds_wfs_init: initialize wait-free stack (with lock). Pair with + * cds_wfs_destroy(). + */ +extern void cds_wfs_init(struct cds_wfs_stack *s); + +/* + * cds_wfs_destroy: destroy wait-free stack (with lock). Pair with + * cds_wfs_init(). + */ +extern void cds_wfs_destroy(struct cds_wfs_stack *s); + +/* + * __cds_wfs_init: initialize wait-free stack (no lock). Don't pair with + * any destroy function. + */ +extern void __cds_wfs_init(struct __cds_wfs_stack *s); + +/* + * cds_wfs_empty: return whether wait-free stack is empty. + * + * No memory barrier is issued. No mutual exclusion is required. + */ +extern bool cds_wfs_empty(cds_wfs_stack_const_ptr_t u_stack); + +/* + * cds_wfs_push: push a node into the stack. + * + * Issues a full memory barrier before push. No mutual exclusion is + * required. + * + * Returns 0 if the stack was empty prior to adding the node. + * Returns non-zero otherwise. + */ +extern int cds_wfs_push(cds_wfs_stack_ptr_t u_stack, struct cds_wfs_node *node); + +/* + * cds_wfs_pop_blocking: pop a node from the stack. + * + * Calls __cds_wfs_pop_blocking with an internal pop mutex held. + */ +extern struct cds_wfs_node *cds_wfs_pop_blocking(struct cds_wfs_stack *s); + +/* + * cds_wfs_pop_with_state_blocking: pop a node from the stack, with state. + * + * Same as cds_wfs_pop_blocking, but stores whether the stack was + * empty into state (CDS_WFS_STATE_LAST). + */ +extern struct cds_wfs_node * + cds_wfs_pop_with_state_blocking(struct cds_wfs_stack *s, int *state); + +/* + * cds_wfs_pop_all_blocking: pop all nodes from a stack. + * + * Calls __cds_wfs_pop_all with an internal pop mutex held. + */ +extern struct cds_wfs_head *cds_wfs_pop_all_blocking(struct cds_wfs_stack *s); + +/* + * cds_wfs_first: get first node of a popped stack. + * + * Content written into the node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + * + * Used by for-like iteration macros in urcu/wfstack.h: + * cds_wfs_for_each_blocking() + * cds_wfs_for_each_blocking_safe() + * + * Returns NULL if popped stack is empty, top stack node otherwise. + */ +extern struct cds_wfs_node *cds_wfs_first(struct cds_wfs_head *head); + +/* + * cds_wfs_next_blocking: get next node of a popped stack. + * + * Content written into the node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + * + * Used by for-like iteration macros in urcu/wfstack.h: + * cds_wfs_for_each_blocking() + * cds_wfs_for_each_blocking_safe() + * + * Returns NULL if reached end of popped stack, non-NULL next stack + * node otherwise. + */ +extern struct cds_wfs_node *cds_wfs_next_blocking(struct cds_wfs_node *node); + +/* + * cds_wfs_next_nonblocking: get next node of a popped stack. + * + * Same as cds_wfs_next_blocking, but returns CDS_WFS_WOULDBLOCK if it + * needs to block. + */ +extern struct cds_wfs_node *cds_wfs_next_nonblocking(struct cds_wfs_node *node); + +/* + * cds_wfs_pop_lock: lock stack pop-protection mutex. + */ +extern void cds_wfs_pop_lock(struct cds_wfs_stack *s); + +/* + * cds_wfs_pop_unlock: unlock stack pop-protection mutex. + */ +extern void cds_wfs_pop_unlock(struct cds_wfs_stack *s); + +/* + * __cds_wfs_pop_blocking: pop a node from the stack. + * + * Returns NULL if stack is empty. + * + * __cds_wfs_pop_blocking needs to be synchronized using one of the + * following techniques: + * + * 1) Calling __cds_wfs_pop_blocking under rcu read lock critical + * section. The caller must wait for a grace period to pass before + * freeing the returned node or modifying the cds_wfs_node structure. + * 2) Using mutual exclusion (e.g. mutexes) to protect + * __cds_wfs_pop_blocking and __cds_wfs_pop_all callers. + * 3) Ensuring that only ONE thread can call __cds_wfs_pop_blocking() + * and __cds_wfs_pop_all(). (multi-provider/single-consumer scheme). + */ +extern struct cds_wfs_node *__cds_wfs_pop_blocking(cds_wfs_stack_ptr_t u_stack); + +/* + * __cds_wfs_pop_with_state_blocking: pop a node from the stack, with state. + * + * Same as __cds_wfs_pop_blocking, but stores whether the stack was + * empty into state (CDS_WFS_STATE_LAST). + */ +extern struct cds_wfs_node * + __cds_wfs_pop_with_state_blocking(cds_wfs_stack_ptr_t u_stack, + int *state); + +/* + * __cds_wfs_pop_nonblocking: pop a node from the stack. + * + * Same as __cds_wfs_pop_blocking, but returns CDS_WFS_WOULDBLOCK if + * it needs to block. + */ +extern struct cds_wfs_node *__cds_wfs_pop_nonblocking(cds_wfs_stack_ptr_t u_stack); + +/* + * __cds_wfs_pop_with_state_nonblocking: pop a node from the stack, with state. + * + * Same as __cds_wfs_pop_nonblocking, but stores whether the stack was + * empty into state (CDS_WFS_STATE_LAST). + */ +extern struct cds_wfs_node * + __cds_wfs_pop_with_state_nonblocking(cds_wfs_stack_ptr_t u_stack, + int *state); + +/* + * __cds_wfs_pop_all: pop all nodes from a stack. + * + * __cds_wfs_pop_all does not require any synchronization with other + * push, nor with other __cds_wfs_pop_all, but requires synchronization + * matching the technique used to synchronize __cds_wfs_pop_blocking: + * + * 1) If __cds_wfs_pop_blocking is called under rcu read lock critical + * section, both __cds_wfs_pop_blocking and cds_wfs_pop_all callers + * must wait for a grace period to pass before freeing the returned + * node or modifying the cds_wfs_node structure. However, no RCU + * read-side critical section is needed around __cds_wfs_pop_all. + * 2) Using mutual exclusion (e.g. mutexes) to protect + * __cds_wfs_pop_blocking and __cds_wfs_pop_all callers. + * 3) Ensuring that only ONE thread can call __cds_wfs_pop_blocking() + * and __cds_wfs_pop_all(). (multi-provider/single-consumer scheme). + */ +extern struct cds_wfs_head *__cds_wfs_pop_all(cds_wfs_stack_ptr_t u_stack); + +#endif /* !_LGPL_SOURCE */ + +/* + * cds_wfs_for_each_blocking: Iterate over all nodes returned by + * __cds_wfs_pop_all(). + * @head: head of the queue (struct cds_wfs_head pointer). + * @node: iterator (struct cds_wfs_node pointer). + * + * Content written into each node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + */ +#define cds_wfs_for_each_blocking(head, node) \ + for (node = cds_wfs_first(head); \ + node != NULL; \ + node = cds_wfs_next_blocking(node)) + +/* + * cds_wfs_for_each_blocking_safe: Iterate over all nodes returned by + * __cds_wfs_pop_all(). Safe against deletion. + * @head: head of the queue (struct cds_wfs_head pointer). + * @node: iterator (struct cds_wfs_node pointer). + * @n: struct cds_wfs_node pointer holding the next pointer (used + * internally). + * + * Content written into each node before enqueue is guaranteed to be + * consistent, but no other memory ordering is ensured. + */ +#define cds_wfs_for_each_blocking_safe(head, node, n) \ + for (node = cds_wfs_first(head), \ + n = (node ? cds_wfs_next_blocking(node) : NULL); \ + node != NULL; \ + node = n, n = (node ? cds_wfs_next_blocking(node) : NULL)) + +#ifdef __cplusplus +} + +/* + * In C++, implement static inline wrappers using function overloading + * to obtain an API similar to C. + */ + +static inline cds_wfs_stack_ptr_t cds_wfs_stack_cast(struct __cds_wfs_stack *s) +{ + cds_wfs_stack_ptr_t ret = { + ._s = s, + }; + return ret; +} + +static inline cds_wfs_stack_ptr_t cds_wfs_stack_cast(struct cds_wfs_stack *s) +{ + cds_wfs_stack_ptr_t ret = { + .s = s, + }; + return ret; +} + +static inline cds_wfs_stack_const_ptr_t cds_wfs_stack_const_cast(const struct __cds_wfs_stack *s) +{ + cds_wfs_stack_const_ptr_t ret = { + ._s = s, + }; + return ret; +} + +static inline cds_wfs_stack_const_ptr_t cds_wfs_stack_const_cast(const struct cds_wfs_stack *s) +{ + cds_wfs_stack_const_ptr_t ret = { + .s = s, + }; + return ret; +} + +template static inline bool cds_wfs_empty(T s) +{ + return cds_wfs_empty(cds_wfs_stack_const_cast(s)); +} + +template static inline int cds_wfs_push(T s, struct cds_wfs_node *node) +{ + return cds_wfs_push(cds_wfs_stack_cast(s), node); +} + +template static inline struct cds_wfs_node *__cds_wfs_pop_blocking(T s) +{ + return __cds_wfs_pop_blocking(cds_wfs_stack_cast(s)); +} + +template static inline struct cds_wfs_node * + __cds_wfs_pop_with_state_blocking(T s, int *state) +{ + return __cds_wfs_pop_with_state_blocking(cds_wfs_stack_cast(s), state); +} + +template static inline struct cds_wfs_node *__cds_wfs_pop_nonblocking(T s) + +{ + return __cds_wfs_pop_nonblocking(cds_wfs_stack_cast(s)); +} + +template static inline struct cds_wfs_node * + __cds_wfs_pop_with_state_nonblocking(T s, int *state) +{ + return __cds_wfs_pop_with_state_nonblocking(cds_wfs_stack_cast(s), state); +} + +template static inline struct cds_wfs_head *__cds_wfs_pop_all(T s) +{ + return __cds_wfs_pop_all(cds_wfs_stack_cast(s)); +} + +#endif + +#endif /* _URCU_WFSTACK_H */ diff --git a/external/lgpl2/userspace-rcu/dist/lgpl-relicensing.md b/external/lgpl2/userspace-rcu/dist/lgpl-relicensing.md new file mode 100644 index 0000000000000..10e7832edfa6d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/lgpl-relicensing.md @@ -0,0 +1,37 @@ + + +# Userspace-RCU LGPL 2.1+ re-licensing + +Mathieu Desnoyers +May 13th, 2009 + +IBM Corporation allowed LGPLv2.1+ licensing of their contribution to the +userspace RCU library in a patch submitted on May 8, 2009 from Paul E. +McKenney and reviewed by Steven L. Bennett: + + https://lists.lttng.org/pipermail/lttng-dev/2009-May/012835.html + +I (Mathieu Desnoyers) re-implemented ACCESS_ONCE(), likely(), unlikely() and +barrier() from scratch without reference to the original code. + + commit id : 2dc5fa0f7cfbfb0a64a7a67b39626650e863f16a + +Bert Wesarg approved LGPL re-licensing of his +patch in an email dated May 13, 2009 : + + http://lkml.org/lkml/2009/5/13/16 + +xchg() primitives has been rewritten from a MIT-licensed cmpxchg for Intel +and powerpc. They are MIT-licensed and therefore usable in LGPL code. +This cmpxchg code was obtained from the atomic_ops project: + + http://www.hpl.hp.com/research/linux/atomic_ops/ + +I (Mathieu Desnoyers) wrote the remainder of the code. + +The license for the library files in this project was therefore changed to +LGPLv2.1 on May 13, 2009, as detailed in LICENSE. diff --git a/external/lgpl2/userspace-rcu/dist/m4/ae_cc_atomic_builtins.m4 b/external/lgpl2/userspace-rcu/dist/m4/ae_cc_atomic_builtins.m4 new file mode 100644 index 0000000000000..0bdb8d01e9a99 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/m4/ae_cc_atomic_builtins.m4 @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: GPL-2.0-or-later WITH LicenseRef-Autoconf-exception-macro +# SPDX-FileCopyrightText: 2023 Michael Jeanson +# +# SYNOPSIS +# +# AE_CC_ATOMIC_BUILTINS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +# + +#serial 1 + +AC_DEFUN([AE_CC_ATOMIC_BUILTINS], [ +AC_REQUIRE([AC_PROG_CC]) +AC_LANG_PUSH([C]) + +AC_CACHE_CHECK( + [whether $CC supports atomic builtins], + [ae_cv_cc_atomic_builtins], + [ + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ + int x, y; + ],[ + __atomic_store_n(&x, 0, __ATOMIC_RELAXED); + __atomic_load_n(&x, __ATOMIC_RELAXED); + y = __atomic_exchange_n(&x, 1, __ATOMIC_RELAXED); + __atomic_compare_exchange_n(&x, &y, 0, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED); + __atomic_add_fetch(&x, 1, __ATOMIC_RELAXED); + __atomic_sub_fetch(&x, 1, __ATOMIC_RELAXED); + __atomic_and_fetch(&x, 0x01, __ATOMIC_RELAXED); + __atomic_or_fetch(&x, 0x01, __ATOMIC_RELAXED); + __atomic_thread_fence(__ATOMIC_RELAXED); + __atomic_signal_fence(__ATOMIC_RELAXED); + ]) + ],[ + ae_cv_cc_atomic_builtins=yes + ],[ + ae_cv_cc_atomic_builtins=no + ]) + ] +) + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test "x$ae_cv_cc_atomic_builtins" = "xyes"; then + $1 + : +else + $2 + : +fi + +AC_LANG_POP +])dnl AE_CC_ATOMIC_BUILTINS diff --git a/external/lgpl2/userspace-rcu/dist/m4/ae_config_feature.m4 b/external/lgpl2/userspace-rcu/dist/m4/ae_config_feature.m4 new file mode 100644 index 0000000000000..d34f5b50d9555 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/m4/ae_config_feature.m4 @@ -0,0 +1,231 @@ +# SPDX-FileCopyrightText: 2020 Michael Jeanson +# SPDX-FileCopyrightText: 2008 Francesco Salvestrini +# +# SPDX-License-Identifier: GPL-2.0-or-later WITH LicenseRef-Autoconf-exception-macro +# +# SYNOPSIS +# +# AE_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION, +# ACTION-IF-GIVEN?, ACTION-IF-NOT-GIVEN?, +# ACTION-IF-ENABLED?, ACTION-IF-NOT-ENABLED?) +# +# DESCRIPTION +# +# AE_FEATURE is a simple wrapper for AC_ARG_ENABLE. +# +# FEATURE-NAME should consist only of alphanumeric characters, dashes, +# plus signs, and dots. +# +# FEATURE-DESCRIPTION will be formatted with AS_HELP_STRING. +# +# If the user gave configure the option --enable-FEATURE or --disable-FEATURE, +# run shell commands ACTION-IF-GIVEN. If neither option was given, run shell +# commands ACTION-IF-NOT-GIVEN. The name feature indicates an optional +# +# If the feature is enabled, run shell commands ACTION-IF-ENABLED, if it is +# disabled, run shell commands ACTION-IF-NOT-ENABLED. +# +# A FEATURE has 3 different states, enabled, disabled and undefined. The first +# two are self explanatory, the third state means it's disabled by default +# and it was not explicitly enabled or disabled by the user or by the +# AE_FEATURE_ENABLE and AE_FEATURE_DISABLE macros. +# +# A feature is disabled by default, in order to change this behaviour use the +# AE_FEATURE_DEFAULT_ENABLE and AE_FEATURE_DEFAULT_DISABLE +# macros. +# +# A simple example: +# +# AE_FEATURE_DEFAULT_ENABLE +# AE_FEATURE(feature_xxxxx, [turns on/off XXXXX support]) +# +# ... +# +# AE_FEATURE_DEFAULT_DISABLE +# AE_FEATURE(feature_yyyyy, [turns on/off YYYYY support]) +# AM_CONDITIONAL(YYYYY, AE_IS_FEATURE_ENABLED([feature_yyyyy])) +# +# AE_FEATURE_DEFAULT_ENABLE +# AE_FEATURE(...) +# +# ... +# +# Use AE_FEATURE_ENABLE or AE_FEATURE_DISABLE in order to +# enable or disable a specific feature. +# +# Another simple example: +# +# AS_IF([some_test_here],[AE_FEATURE_ENABLE(feature_xxxxx)],[]) +# +# AE_FEATURE(feature_xxxxx, [turns on/off XXXXX support], +# HAVE_XXXXX, [Define if you want XXXXX support]) +# AE_FEATURE(feature_yyyyy, [turns on/off YYYYY support], +# HAVE_YYYYY, [Define if you want YYYYY support]) +# +# ... +# +# NOTE: AE_FEATURE_ENABLE/DISABLE() must be placed first of the relative +# AE_FEATURE() macro if you want the the proper ACTION-IF-ENABLED and +# ACTION-IF-NOT-ENABLED to run. + +#serial 3 + + +# AE_FEATURE_DEFAULT_ENABLE: The next feature defined with AE_FEATURE will +# default to enable. +AC_DEFUN([AE_FEATURE_DEFAULT_ENABLE], [ + m4_define([ae_feature_default_arg], [yes]) + m4_define([ae_feature_default_switch], [disable]) +]) + + +# AE_FEATURE_DEFAULT_DISABLE: The next feature defined with AE_FEATURE will +# default to disable. +# +AC_DEFUN([AE_FEATURE_DEFAULT_DISABLE], [ + m4_define([ae_feature_default_arg], [no]) + m4_define([ae_feature_default_switch], [enable]) +]) + + +# AE_FEATURE_ENABLE(FEATURE-NAME): Enable the FEATURE, this will override the +# user's choice if it was made. +# +AC_DEFUN([AE_FEATURE_ENABLE],[ dnl + enable_[]patsubst([$1], -, _)[]=yes +]) + + +# AE_FEATURE_DISABLE(FEATURE-NAME): Disable the FEATURE, this will override the +# user's choice if it was made. +# +AC_DEFUN([AE_FEATURE_DISABLE],[ dnl + enable_[]patsubst([$1], -, _)[]=no +]) + + +# AE_IF_FEATURE_ENABLED(FEATURE-NAME, ACTION-IF-ENABLED, ACTION-IF-NOT-ENABLED?): +# Run shell code ACTION-IF-ENABLED if the FEATURE is enabled, otherwise run +# shell code ACTION-IF-NOT-ENABLED. +# +AC_DEFUN([AE_IF_FEATURE_ENABLED],[ dnl +m4_pushdef([FEATURE], patsubst([$1], -, _))dnl + + AS_IF([test "$enable_[]FEATURE[]" = yes],[ dnl + $2 + ],[: dnl + $3 + ]) +]) + + +# AE_IF_FEATURE_NOT_ENABLED(FEATURE-NAME, ACTION-IF-NOT-ENABLED, +# ACTION-IF-NOT-NOT-ENABLED?): +# Run shell code ACTION-IF-NOT-ENABLED if the FEATURE is not explicitly +# enabled, otherwise run shell code ACTION-IF-NOT-NOT-DISABLED. +# +# The distinction with AE_IF_FEATURE_DISABLED is that this will also +# match a feature that is undefined. +# +# A feature is undefined when it's disabled by default and was not explicitly +# enabled or disabled by the user or by AE_FEATURE_ENABLE/DISABLE. +# +AC_DEFUN([AE_IF_FEATURE_NOT_ENABLED],[ dnl +m4_pushdef([FEATURE], patsubst([$1], -, _))dnl + + AS_IF([test "$enable_[]FEATURE[]" != yes],[ dnl + $2 + ],[: dnl + $3 + ]) +]) + + +# AE_IF_FEATURE_DISABLED(FEATURE-NAME, ACTION-IF-DISABLED, ACTION-IF-NOT-DISABLED?): +# Run shell code ACTION-IF-DISABLED if the FEATURE is disabled, otherwise run +# shell code ACTION-IF-NOT-DISABLED. +# +AC_DEFUN([AE_IF_FEATURE_DISABLED],[ dnl +m4_pushdef([FEATURE], patsubst([$1], -, _))dnl + + AS_IF([test "$enable_[]FEATURE[]" = no],[ dnl + $2 + ],[: dnl + $3 + ]) +]) + + +# AE_IF_FEATURE_UNDEF(FEATURE-NAME, ACTION-IF-UNDEF, ACTION-IF-NOT-UNDEF?): +# Run shell code ACTION-IF-UNDEF if the FEATURE is undefined, otherwise run +# shell code ACTION-IF-NOT-UNDEF. +# +# A feature is undefined when it's disabled by default and was not explicitly +# enabled or disabled by the user or by AE_FEATURE_ENABLE/DISABLE. +# +AC_DEFUN([AE_IF_FEATURE_UNDEF],[ dnl +m4_pushdef([FEATURE], patsubst([$1], -, _))dnl + + AS_IF([test "x$enable_[]FEATURE[]" = x],[ dnl + $2 + ],[: dnl + $3 + ]) +]) + + +# AE_IS_FEATURE_ENABLED(FEATURE-NAME): outputs a shell condition (suitable +# for use in a shell if statement) that will return true if the FEATURE is +# enabled. +# +AC_DEFUN([AE_IS_FEATURE_ENABLED],[dnl +m4_pushdef([FEATURE], patsubst([$1], -, _))dnl + test "x$enable_[]FEATURE[]" = xyes dnl +]) + + +dnl Disabled by default, unless already overridden +m4_ifndef([ae_feature_default_arg],[AE_FEATURE_DEFAULT_DISABLE]) + + +# AE_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION, +# ACTION-IF-GIVEN?, ACTION-IF-NOT-GIVEN?, +# ACTION-IF-ENABLED?, ACTION-IF-NOT-ENABLED?): +# +# +AC_DEFUN([AE_FEATURE],[ dnl +m4_pushdef([FEATURE], patsubst([$1], -, _))dnl + +dnl If the option wasn't specified and the default is enabled, set enable_FEATURE to yes +AS_IF([test "x$enable_[]FEATURE[]" = x && test "ae_feature_default_arg" = yes],[ dnl + enable_[]FEATURE[]="ae_feature_default_arg" +]) + +AC_ARG_ENABLE([$1], + AS_HELP_STRING([--ae_feature_default_switch-$1],dnl + [$2]),[ +case "${enableval}" in + yes) + enable_[]FEATURE[]=yes + ;; + no) + enable_[]FEATURE[]=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for feature --$1]) + ;; +esac + +$3 +],[: dnl +$4 +]) + +AS_IF([test "$enable_[]FEATURE[]" = yes],[: dnl + $5 +],[: dnl + $6 +]) + +m4_popdef([FEATURE])dnl +]) diff --git a/external/lgpl2/userspace-rcu/dist/m4/ae_pprint.m4 b/external/lgpl2/userspace-rcu/dist/m4/ae_pprint.m4 new file mode 100644 index 0000000000000..029ff99bec074 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/m4/ae_pprint.m4 @@ -0,0 +1,210 @@ +# SPDX-FileCopyrightText: 2016 Philippe Proulx +# +# SPDX-License-Identifier: GPL-2.0-or-later WITH Autoconf-exception-2.0 + +#serial 2 + +# AE_PPRINT_INIT(): initializes the pretty printing system. +# +# Use this macro before using any other AE_PPRINT_* macro. +AC_DEFUN([AE_PPRINT_INIT], [ + m4_define([AE_PPRINT_CONFIG_TS], [50]) + m4_define([AE_PPRINT_CONFIG_INDENT], [2]) + AE_PPRINT_YES_MSG=yes + AE_PPRINT_NO_MSG=no + + # find tput, which tells us if colors are supported and gives us color codes + AC_PATH_PROG([ae_pprint_tput], [tput]) + + AS_IF([test -n "$ae_pprint_tput"], [ + AS_IF([test -n "$PS1" && test `"$ae_pprint_tput" colors` -eq 256 && test -t 1], [ + # interactive shell and colors supported and standard output + # file descriptor is opened on a terminal + AE_PPRINT_COLOR_TXTBLK="`"$ae_pprint_tput" setaf 0`" + AE_PPRINT_COLOR_TXTBLU="`"$ae_pprint_tput" setaf 4`" + AE_PPRINT_COLOR_TXTGRN="`"$ae_pprint_tput" setaf 2`" + AE_PPRINT_COLOR_TXTCYN="`"$ae_pprint_tput" setaf 6`" + AE_PPRINT_COLOR_TXTRED="`"$ae_pprint_tput" setaf 1`" + AE_PPRINT_COLOR_TXTPUR="`"$ae_pprint_tput" setaf 5`" + AE_PPRINT_COLOR_TXTYLW="`"$ae_pprint_tput" setaf 3`" + AE_PPRINT_COLOR_TXTWHT="`"$ae_pprint_tput" setaf 7`" + AE_PPRINT_COLOR_BLD=`"$ae_pprint_tput" bold` + AE_PPRINT_COLOR_BLDBLK="$AE_PPRINT_COLOR_BLD$AE_PPRINT_COLOR_TXTBLK" + AE_PPRINT_COLOR_BLDBLU="$AE_PPRINT_COLOR_BLD$AE_PPRINT_COLOR_TXTBLU" + AE_PPRINT_COLOR_BLDGRN="$AE_PPRINT_COLOR_BLD$AE_PPRINT_COLOR_TXTGRN" + AE_PPRINT_COLOR_BLDCYN="$AE_PPRINT_COLOR_BLD$AE_PPRINT_COLOR_TXTCYN" + AE_PPRINT_COLOR_BLDRED="$AE_PPRINT_COLOR_BLD$AE_PPRINT_COLOR_TXTRED" + AE_PPRINT_COLOR_BLDPUR="$AE_PPRINT_COLOR_BLD$AE_PPRINT_COLOR_TXTPUR" + AE_PPRINT_COLOR_BLDYLW="$AE_PPRINT_COLOR_BLD$AE_PPRINT_COLOR_TXTYLW" + AE_PPRINT_COLOR_BLDWHT="$AE_PPRINT_COLOR_BLD$AE_PPRINT_COLOR_TXTWHT" + AE_PPRINT_COLOR_RST="`"$ae_pprint_tput" sgr0`" + + # colored yes and no + AE_PPRINT_YES_MSG="$AE_PPRINT_COLOR_BLDGRN$AE_PPRINT_YES_MSG$AE_PPRINT_COLOR_RST" + AE_PPRINT_NO_MSG="$AE_PPRINT_COLOR_BLDRED$AE_PPRINT_NO_MSG$AE_PPRINT_COLOR_RST" + + # subtitle color + AE_PPRINT_COLOR_SUBTITLE="$AE_PPRINT_COLOR_BLDCYN" + ]) + ]) +]) + +# AE_PPRINT_SET_INDENT(indent): sets the current indentation. +# +# Use AE_PPRINT_INIT() before using this macro. +AC_DEFUN([AE_PPRINT_SET_INDENT], [ + m4_define([AE_PPRINT_CONFIG_INDENT], [$1]) +]) + +# AE_PPRINT_SET_TS(ts): sets the current tab stop. +# +# Use AE_PPRINT_INIT() before using this macro. +AC_DEFUN([AE_PPRINT_SET_TS], [ + m4_define([AE_PPRINT_CONFIG_TS], [$1]) +]) + +# AE_PPRINT_SUBTITLE(subtitle): pretty prints a subtitle. +# +# The subtitle is put as is in a double-quoted shell string so the user +# needs to escape ". +# +# Use AE_PPRINT_INIT() before using this macro. +AC_DEFUN([AE_PPRINT_SUBTITLE], [ + AS_ECHO(["${AE_PPRINT_COLOR_SUBTITLE}$1$AE_PPRINT_COLOR_RST"]) +]) + +AC_DEFUN([_AE_PPRINT_INDENT], [ + m4_if(AE_PPRINT_CONFIG_INDENT, 0, [ + ], [ + m4_for([ae_pprint_i], [0], m4_eval(AE_PPRINT_CONFIG_INDENT * 2 - 1), [1], [ + AS_ECHO_N([" "]) + ]) + ]) +]) + +# AE_PPRINT_PROP_STRING(title, value, title_color?): pretty prints a +# string property. +# +# The title is put as is in a double-quoted shell string so the user +# needs to escape ". +# +# The $AE_PPRINT_CONFIG_INDENT variable must be set to the desired indentation +# level. +# +# Use AE_PPRINT_INIT() before using this macro. +AC_DEFUN([AE_PPRINT_PROP_STRING], [ + m4_pushdef([ae_pprint_title], [$1]) + m4_pushdef([ae_pprint_value], [$2]) + m4_pushdef([ae_pprint_title_color], m4_default([$3], [])) + m4_pushdef([ae_pprint_title_len], m4_len(ae_pprint_title)) + m4_pushdef([ae_pprint_spaces_cnt], m4_eval(AE_PPRINT_CONFIG_TS - ae_pprint_title_len - (AE_PPRINT_CONFIG_INDENT * 2) - 1)) + + m4_if(m4_eval(ae_pprint_spaces_cnt <= 0), [1], [ + m4_define([ae_pprint_spaces_cnt], [1]) + ]) + + m4_pushdef([ae_pprint_spaces], []) + + m4_for([ae_pprint_i], 0, m4_eval(ae_pprint_spaces_cnt - 1), [1], [ + m4_append([ae_pprint_spaces], [ ]) + ]) + + _AE_PPRINT_INDENT + + AS_ECHO_N(["ae_pprint_title_color""ae_pprint_title$AE_PPRINT_COLOR_RST:ae_pprint_spaces"]) + AS_ECHO(["${AE_PPRINT_COLOR_BLD}ae_pprint_value$AE_PPRINT_COLOR_RST"]) + + m4_popdef([ae_pprint_spaces]) + m4_popdef([ae_pprint_spaces_cnt]) + m4_popdef([ae_pprint_title_len]) + m4_popdef([ae_pprint_title_color]) + m4_popdef([ae_pprint_value]) + m4_popdef([ae_pprint_title]) +]) + +# AE_PPRINT_PROP_BOOL(title, value, title_color?): pretty prints a boolean +# property. +# +# The title is put as is in a double-quoted shell string so the user +# needs to escape ". +# +# The value is evaluated at shell runtime. Its evaluation must be +# 0 (false) or 1 (true). +# +# Uses the AE_PPRINT_PROP_STRING() with the "yes" or "no" string. +# +# Use AE_PPRINT_INIT() before using this macro. +AC_DEFUN([AE_PPRINT_PROP_BOOL], [ + m4_pushdef([ae_pprint_title], [$1]) + m4_pushdef([ae_pprint_value], [$2]) + + test ae_pprint_value -eq 0 && ae_pprint_msg="$AE_PPRINT_NO_MSG" || ae_pprint_msg="$AE_PPRINT_YES_MSG" + + m4_if([$#], [3], [ + AE_PPRINT_PROP_STRING(ae_pprint_title, [$ae_pprint_msg], $3) + ], [ + AE_PPRINT_PROP_STRING(ae_pprint_title, [$ae_pprint_msg]) + ]) + + m4_popdef([ae_pprint_value]) + m4_popdef([ae_pprint_title]) +]) + +# AE_PPRINT_PROP_BOOL_CUSTOM(title, value, no_msg, title_color?): pretty prints a boolean +# property. +# +# The title is put as is in a double-quoted shell string so the user +# needs to escape ". +# +# The value is evaluated at shell runtime. Its evaluation must be +# 0 (false) or 1 (true). +# +# Uses the AE_PPRINT_PROP_STRING() with the "yes" or "no" string. +# +# Use AE_PPRINT_INIT() before using this macro. +AC_DEFUN([AE_PPRINT_PROP_BOOL_CUSTOM], [ + m4_pushdef([ae_pprint_title], [$1]) + m4_pushdef([ae_pprint_value], [$2]) + m4_pushdef([ae_pprint_value_no_msg], [$3]) + + test ae_pprint_value -eq 0 && ae_pprint_msg="$AE_PPRINT_NO_MSG (ae_pprint_value_no_msg)" || ae_pprint_msg="$AE_PPRINT_YES_MSG" + + m4_if([$#], [4], [ + AE_PPRINT_PROP_STRING(ae_pprint_title, [$ae_pprint_msg], $4) + ], [ + AE_PPRINT_PROP_STRING(ae_pprint_title, [$ae_pprint_msg]) + ]) + + m4_popdef([ae_pprint_value_no_msg]) + m4_popdef([ae_pprint_value]) + m4_popdef([ae_pprint_title]) +]) + +# AE_PPRINT_WARN(msg): pretty prints a warning message. +# +# The message is put as is in a double-quoted shell string so the user +# needs to escape ". +# +# Use AE_PPRINT_INIT() before using this macro. +AC_DEFUN([AE_PPRINT_WARN], [ + m4_pushdef([ae_pprint_msg], [$1]) + + _AE_PPRINT_INDENT + AS_ECHO(["${AE_PPRINT_COLOR_TXTYLW}WARNING:$AE_PPRINT_COLOR_RST ${AE_PPRINT_COLOR_BLDYLW}ae_pprint_msg$AE_PPRINT_COLOR_RST"]) + + m4_popdef([ae_pprint_msg]) +]) + +# AE_PPRINT_ERROR(msg): pretty prints an error message and exits. +# +# The message is put as is in a double-quoted shell string so the user +# needs to escape ". +# +# Use AE_PPRINT_INIT() before using this macro. +AC_DEFUN([AE_PPRINT_ERROR], [ + m4_pushdef([ae_pprint_msg], [$1]) + + AC_MSG_ERROR([${AE_PPRINT_COLOR_BLDRED}ae_pprint_msg$AE_PPRINT_COLOR_RST]) + + m4_popdef([ae_pprint_msg]) +]) diff --git a/external/lgpl2/userspace-rcu/dist/m4/ax_append_compile_flags.m4 b/external/lgpl2/userspace-rcu/dist/m4/ax_append_compile_flags.m4 new file mode 100644 index 0000000000000..29d86e0fe876d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/m4/ax_append_compile_flags.m4 @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: FSFAP +# ============================================================================ +# https://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html +# ============================================================================ +# +# SYNOPSIS +# +# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# For every FLAG1, FLAG2 it is checked whether the compiler works with the +# flag. If it does, the flag is added FLAGS-VARIABLE +# +# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. +# CFLAGS) is used. During the check the flag is always added to the +# current language's flags. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_COMPILE_IFELSE. +# +# NOTE: This macro depends on the AX_APPEND_FLAG and +# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with +# AX_APPEND_LINK_FLAGS. +# +# LICENSE +# +# Copyright (c) 2011 Maarten Bosmans +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 7 + +AC_DEFUN([AX_APPEND_COMPILE_FLAGS], +[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) +AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) +for flag in $1; do + AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3], [$4]) +done +])dnl AX_APPEND_COMPILE_FLAGS diff --git a/external/lgpl2/userspace-rcu/dist/m4/ax_append_flag.m4 b/external/lgpl2/userspace-rcu/dist/m4/ax_append_flag.m4 new file mode 100644 index 0000000000000..e1ea0fc46b6da --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/m4/ax_append_flag.m4 @@ -0,0 +1,51 @@ +# SPDX-License-Identifier: FSFAP +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_append_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE]) +# +# DESCRIPTION +# +# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space +# added in between. +# +# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. +# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains +# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly +# FLAG. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +AC_DEFUN([AX_APPEND_FLAG], +[dnl +AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF +AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])]) +AS_VAR_SET_IF(FLAGS,[ + AS_CASE([" AS_VAR_GET(FLAGS) "], + [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])], + [ + AS_VAR_APPEND(FLAGS,[" $1"]) + AC_RUN_LOG([: FLAGS="$FLAGS"]) + ]) + ], + [ + AS_VAR_SET(FLAGS,[$1]) + AC_RUN_LOG([: FLAGS="$FLAGS"]) + ]) +AS_VAR_POPDEF([FLAGS])dnl +])dnl AX_APPEND_FLAG diff --git a/external/lgpl2/userspace-rcu/dist/m4/ax_c___attribute__.m4 b/external/lgpl2/userspace-rcu/dist/m4/ax_c___attribute__.m4 new file mode 100644 index 0000000000000..98999e11f63d9 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/m4/ax_c___attribute__.m4 @@ -0,0 +1,67 @@ +# SPDX-License-Identifier: GPL-2.0-or-later WITH LicenseRef-Autoconf-exception-macro +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_c___attribute__.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_C___ATTRIBUTE__ +# +# DESCRIPTION +# +# Provides a test for the compiler support of __attribute__ extensions. +# Defines HAVE___ATTRIBUTE__ if it is found. +# +# LICENSE +# +# Copyright (c) 2008 Stepan Kasal +# Copyright (c) 2008 Christian Haggstrom +# Copyright (c) 2008 Ryan McCabe +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 9 + +AC_DEFUN([AX_C___ATTRIBUTE__], [ + AC_CACHE_CHECK([for __attribute__], [ax_cv___attribute__], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + static void foo(void) __attribute__ ((unused)); + static void + foo(void) { + exit(1); + } + ]], [])], + [ax_cv___attribute__=yes], + [ax_cv___attribute__=no] + ) + ]) + if test "$ax_cv___attribute__" = "yes"; then + AC_DEFINE([HAVE___ATTRIBUTE__], 1, [define if your compiler has __attribute__]) + fi +]) diff --git a/external/lgpl2/userspace-rcu/dist/m4/ax_check_compile_flag.m4 b/external/lgpl2/userspace-rcu/dist/m4/ax_check_compile_flag.m4 new file mode 100644 index 0000000000000..8f62565e9a60f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/m4/ax_check_compile_flag.m4 @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: FSFAP +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the current language's compiler +# or gives an error. (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_COMPILE_IFELSE. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 6 + +AC_DEFUN([AX_CHECK_COMPILE_FLAG], +[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ + ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS + _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" + AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], + [AS_VAR_SET(CACHEVAR,[yes])], + [AS_VAR_SET(CACHEVAR,[no])]) + _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) +AS_VAR_IF(CACHEVAR,yes, + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_COMPILE_FLAGS diff --git a/external/lgpl2/userspace-rcu/dist/m4/ax_cxx_compile_stdcxx.m4 b/external/lgpl2/userspace-rcu/dist/m4/ax_cxx_compile_stdcxx.m4 new file mode 100644 index 0000000000000..c081ffacc03ac --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/m4/ax_cxx_compile_stdcxx.m4 @@ -0,0 +1,1019 @@ +# SPDX-License-Identifier: FSFAP +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional]) +# +# DESCRIPTION +# +# Check for baseline language coverage in the compiler for the specified +# version of the C++ standard. If necessary, add switches to CXX and +# CXXCPP to enable support. VERSION may be '11', '14', '17', or '20' for +# the respective C++ standard version. +# +# The second argument, if specified, indicates whether you insist on an +# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. +# -std=c++11). If neither is specified, you get whatever works, with +# preference for no added switch, and then for an extended mode. +# +# The third argument, if specified 'mandatory' or if left unspecified, +# indicates that baseline support for the specified C++ standard is +# required and that the macro should error out if no mode with that +# support is found. If specified 'optional', then configuration proceeds +# regardless, after defining HAVE_CXX${VERSION} if and only if a +# supporting mode is found. +# +# LICENSE +# +# Copyright (c) 2008 Benjamin Kosnik +# Copyright (c) 2012 Zack Weinberg +# Copyright (c) 2013 Roy Stogner +# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov +# Copyright (c) 2015 Paul Norman +# Copyright (c) 2015 Moritz Klammler +# Copyright (c) 2016, 2018 Krzesimir Nowak +# Copyright (c) 2019 Enji Cooper +# Copyright (c) 2020 Jason Merrill +# Copyright (c) 2021 Jörn Heusipp +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 18 + +dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro +dnl (serial version number 13). + +AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl + m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], + [$1], [14], [ax_cxx_compile_alternatives="14 1y"], + [$1], [17], [ax_cxx_compile_alternatives="17 1z"], + [$1], [20], [ax_cxx_compile_alternatives="20"], + [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl + m4_if([$2], [], [], + [$2], [ext], [], + [$2], [noext], [], + [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl + m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true], + [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], + [$3], [optional], [ax_cxx_compile_cxx$1_required=false], + [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) + AC_LANG_PUSH([C++])dnl + ac_success=no + + m4_if([$2], [], [dnl + AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, + ax_cv_cxx_compile_cxx$1, + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [ax_cv_cxx_compile_cxx$1=yes], + [ax_cv_cxx_compile_cxx$1=no])]) + if test x$ax_cv_cxx_compile_cxx$1 = xyes; then + ac_success=yes + fi]) + + m4_if([$2], [noext], [], [dnl + if test x$ac_success = xno; then + for alternative in ${ax_cxx_compile_alternatives}; do + switch="-std=gnu++${alternative}" + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, + $cachevar, + [ac_save_CXX="$CXX" + CXX="$CXX $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXX="$ac_save_CXX"]) + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + fi]) + + m4_if([$2], [ext], [], [dnl + if test x$ac_success = xno; then + dnl HP's aCC needs +std=c++11 according to: + dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf + dnl Cray's crayCC needs "-h std=c++11" + dnl MSVC needs -std:c++NN for C++17 and later (default is C++14) + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do + if test x"$switch" = xMSVC; then + dnl AS_TR_SH maps both `:` and `=` to `_` so -std:c++17 would collide + dnl with -std=c++17. We suffix the cache variable name with _MSVC to + dnl avoid this. + switch=-std:c++${alternative} + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_${switch}_MSVC]) + else + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + fi + AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, + $cachevar, + [ac_save_CXX="$CXX" + CXX="$CXX $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXX="$ac_save_CXX"]) + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + if test x$ac_success = xyes; then + break + fi + done + fi]) + AC_LANG_POP([C++]) + if test x$ax_cxx_compile_cxx$1_required = xtrue; then + if test x$ac_success = xno; then + AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.]) + fi + fi + if test x$ac_success = xno; then + HAVE_CXX$1=0 + AC_MSG_NOTICE([No compiler with C++$1 support was found]) + else + HAVE_CXX$1=1 + AC_DEFINE(HAVE_CXX$1,1, + [define if the compiler supports basic C++$1 syntax]) + fi + AC_SUBST(HAVE_CXX$1) +]) + + +dnl Test body for checking C++11 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 +) + +dnl Test body for checking C++14 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 +) + +dnl Test body for checking C++17 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 +) + +dnl Test body for checking C++20 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_20 +) + + +dnl Tests for new features in C++11 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual ~Base() {} + virtual void f() {} + }; + + struct Derived : public Base + { + virtual ~Derived() override {} + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check single_type; + typedef check> double_type; + typedef check>> triple_type; + typedef check>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a = 1; + decltype(a) b = 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value = false; + }; + + template < typename T > + struct is_same + { + static const bool value = true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same::value == true, ""); + static_assert(is_same::value == false, ""); + static_assert(is_same::value == false, ""); + auto ac = c; + auto av = v; + auto sumi = ac + av + 'x'; + auto sumf = ac + av + 1.0; + static_assert(is_same::value == true, ""); + static_assert(is_same::value == true, ""); + static_assert(is_same::value == true, ""); + static_assert(is_same::value == false, ""); + static_assert(is_same::value == true, ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) == false, ""); + static_assert(noexcept(g()) == true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("1") == 1UL, ""); + static_assert(strlen_c("example") == 7UL, ""); + static_assert(strlen_c("another\0example") == 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value = N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i = 0; + const int c = 0; + static_assert(decltype(f(i))::value == 1, ""); + static_assert(decltype(f(c))::value == 2, ""); + static_assert(decltype(f(0))::value == 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero == 0, ""); + static_assert(test::one == 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 = [](){}; + auto lambda2 = lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a = [](int i, int j){ return i + j; }(1, 2); + auto b = []() -> int { return '0'; }(); + auto c = [=](){ return a + b; }(); + auto d = [&](){ return c; }(); + auto e = [a, &b](int x) mutable { + const auto identity = [](int y){ return y; }; + for (auto i = 0; i < a; ++i) + a += b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary = [](){ return 0; }; + const auto unary = [](int x){ return x; }; + using nullary_t = decltype(nullary); + using unary_t = decltype(unary); + const auto higher1st = [](nullary_t f){ return f(); }; + const auto higher2nd = [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template + struct sum; + + template + struct sum + { + static constexpr auto value = N0 + sum::value; + }; + + template <> + struct sum<> + { + static constexpr auto value = 0; + }; + + static_assert(sum<>::value == 0, ""); + static_assert(sum<1>::value == 1, ""); + static_assert(sum<23>::value == 23, ""); + static_assert(sum<1, 2>::value == 3, ""); + static_assert(sum<5, 5, 11>::value == 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template + using member = typename T::member_type; + + template + void func(...) {} + + template + void func(member*) {} + + void test(); + + void test() { func(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >= 201103L + +]]) + + +dnl Tests for new features in C++14 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L && !defined _MSC_VER + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + +]]) + + +dnl Tests for new features in C++17 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ + +// If the compiler admits that it is not ready for C++17, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201703L && !defined _MSC_VER + +#error "This is not a C++17 compiler" + +#else + +#include +#include +#include + +namespace cxx17 +{ + + namespace test_constexpr_lambdas + { + + constexpr int foo = [](){return 42;}(); + + } + + namespace test::nested_namespace::definitions + { + + } + + namespace test_fold_expression + { + + template + int multiply(Args... args) + { + return (args * ... * 1); + } + + template + bool all(Args... args) + { + return (args && ...); + } + + } + + namespace test_extended_static_assert + { + + static_assert (true); + + } + + namespace test_auto_brace_init_list + { + + auto foo = {5}; + auto bar {5}; + + static_assert(std::is_same, decltype(foo)>::value); + static_assert(std::is_same::value); + } + + namespace test_typename_in_template_template_parameter + { + + template typename X> struct D; + + } + + namespace test_fallthrough_nodiscard_maybe_unused_attributes + { + + int f1() + { + return 42; + } + + [[nodiscard]] int f2() + { + [[maybe_unused]] auto unused = f1(); + + switch (f1()) + { + case 17: + f1(); + [[fallthrough]]; + case 42: + f1(); + } + return f1(); + } + + } + + namespace test_extended_aggregate_initialization + { + + struct base1 + { + int b1, b2 = 42; + }; + + struct base2 + { + base2() { + b3 = 42; + } + int b3; + }; + + struct derived : base1, base2 + { + int d; + }; + + derived d1 {{1, 2}, {}, 4}; // full initialization + derived d2 {{}, {}, 4}; // value-initialized bases + + } + + namespace test_general_range_based_for_loop + { + + struct iter + { + int i; + + int& operator* () + { + return i; + } + + const int& operator* () const + { + return i; + } + + iter& operator++() + { + ++i; + return *this; + } + }; + + struct sentinel + { + int i; + }; + + bool operator== (const iter& i, const sentinel& s) + { + return i.i == s.i; + } + + bool operator!= (const iter& i, const sentinel& s) + { + return !(i == s); + } + + struct range + { + iter begin() const + { + return {0}; + } + + sentinel end() const + { + return {5}; + } + }; + + void f() + { + range r {}; + + for (auto i : r) + { + [[maybe_unused]] auto v = i; + } + } + + } + + namespace test_lambda_capture_asterisk_this_by_value + { + + struct t + { + int i; + int foo() + { + return [*this]() + { + return i; + }(); + } + }; + + } + + namespace test_enum_class_construction + { + + enum class byte : unsigned char + {}; + + byte foo {42}; + + } + + namespace test_constexpr_if + { + + template + int f () + { + if constexpr(cond) + { + return 13; + } + else + { + return 42; + } + } + + } + + namespace test_selection_statement_with_initializer + { + + int f() + { + return 13; + } + + int f2() + { + if (auto i = f(); i > 0) + { + return 3; + } + + switch (auto i = f(); i + 4) + { + case 17: + return 2; + + default: + return 1; + } + } + + } + + namespace test_template_argument_deduction_for_class_templates + { + + template + struct pair + { + pair (T1 p1, T2 p2) + : m1 {p1}, + m2 {p2} + {} + + T1 m1; + T2 m2; + }; + + void f() + { + [[maybe_unused]] auto p = pair{13, 42u}; + } + + } + + namespace test_non_type_auto_template_parameters + { + + template + struct B + {}; + + B<5> b1; + B<'a'> b2; + + } + + namespace test_structured_bindings + { + + int arr[2] = { 1, 2 }; + std::pair pr = { 1, 2 }; + + auto f1() -> int(&)[2] + { + return arr; + } + + auto f2() -> std::pair& + { + return pr; + } + + struct S + { + int x1 : 2; + volatile double y1; + }; + + S f3() + { + return {}; + } + + auto [ x1, y1 ] = f1(); + auto& [ xr1, yr1 ] = f1(); + auto [ x2, y2 ] = f2(); + auto& [ xr2, yr2 ] = f2(); + const auto [ x3, y3 ] = f3(); + + } + + namespace test_exception_spec_type_system + { + + struct Good {}; + struct Bad {}; + + void g1() noexcept; + void g2(); + + template + Bad + f(T*, T*); + + template + Good + f(T1*, T2*); + + static_assert (std::is_same_v); + + } + + namespace test_inline_variables + { + + template void f(T) + {} + + template inline T g(T) + { + return T{}; + } + + template<> inline void f<>(int) + {} + + template<> int g<>(int) + { + return 5; + } + + } + +} // namespace cxx17 + +#endif // __cplusplus < 201703L && !defined _MSC_VER + +]]) + + +dnl Tests for new features in C++20 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[ + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 202002L && !defined _MSC_VER + +#error "This is not a C++20 compiler" + +#else + +#include + +namespace cxx20 +{ + +// As C++20 supports feature test macros in the standard, there is no +// immediate need to actually test for feature availability on the +// Autoconf side. + +} // namespace cxx20 + +#endif // __cplusplus < 202002L && !defined _MSC_VER + +]]) diff --git a/external/lgpl2/userspace-rcu/dist/m4/ax_pthread.m4 b/external/lgpl2/userspace-rcu/dist/m4/ax_pthread.m4 new file mode 100644 index 0000000000000..db15ab983a1c3 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/m4/ax_pthread.m4 @@ -0,0 +1,523 @@ +# SPDX-License-Identifier: GPL-2.0-or-later WITH LicenseRef-Autoconf-exception-macro +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_pthread.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +# +# DESCRIPTION +# +# This macro figures out how to build C programs using POSIX threads. It +# sets the PTHREAD_LIBS output variable to the threads library and linker +# flags, and the PTHREAD_CFLAGS output variable to any special C compiler +# flags that are needed. (The user can also force certain compiler +# flags/libs to be tested by setting these environment variables.) +# +# Also sets PTHREAD_CC and PTHREAD_CXX to any special C compiler that is +# needed for multi-threaded programs (defaults to the value of CC +# respectively CXX otherwise). (This is necessary on e.g. AIX to use the +# special cc_r/CC_r compiler alias.) +# +# NOTE: You are assumed to not only compile your program with these flags, +# but also to link with them as well. For example, you might link with +# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS +# $PTHREAD_CXX $CXXFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS +# +# If you are only building threaded programs, you may wish to use these +# variables in your default LIBS, CFLAGS, and CC: +# +# LIBS="$PTHREAD_LIBS $LIBS" +# CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +# CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" +# CC="$PTHREAD_CC" +# CXX="$PTHREAD_CXX" +# +# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant +# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to +# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). +# +# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the +# PTHREAD_PRIO_INHERIT symbol is defined when compiling with +# PTHREAD_CFLAGS. +# +# ACTION-IF-FOUND is a list of shell commands to run if a threads library +# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it +# is not found. If ACTION-IF-FOUND is not specified, the default action +# will define HAVE_PTHREAD. +# +# Please let the authors know if this macro fails on any platform, or if +# you have any other suggestions or comments. This macro was based on work +# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help +# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by +# Alejandro Forero Cuervo to the autoconf macro repository. We are also +# grateful for the helpful feedback of numerous users. +# +# Updated for Autoconf 2.68 by Daniel Richard G. +# +# LICENSE +# +# Copyright (c) 2008 Steven G. Johnson +# Copyright (c) 2011 Daniel Richard G. +# Copyright (c) 2019 Marc Stevens +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 31 + +AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) +AC_DEFUN([AX_PTHREAD], [ +AC_REQUIRE([AC_CANONICAL_HOST]) +AC_REQUIRE([AC_PROG_CC]) +AC_REQUIRE([AC_PROG_SED]) +AC_LANG_PUSH([C]) +ax_pthread_ok=no + +# We used to check for pthread.h first, but this fails if pthread.h +# requires special compiler flags (e.g. on Tru64 or Sequent). +# It gets checked for in the link test anyway. + +# First of all, check if the user has set any of the PTHREAD_LIBS, +# etcetera environment variables, and if threads linking works using +# them: +if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then + ax_pthread_save_CC="$CC" + ax_pthread_save_CFLAGS="$CFLAGS" + ax_pthread_save_LIBS="$LIBS" + AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"]) + AS_IF([test "x$PTHREAD_CXX" != "x"], [CXX="$PTHREAD_CXX"]) + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS]) + AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes]) + AC_MSG_RESULT([$ax_pthread_ok]) + if test "x$ax_pthread_ok" = "xno"; then + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" + fi + CC="$ax_pthread_save_CC" + CFLAGS="$ax_pthread_save_CFLAGS" + LIBS="$ax_pthread_save_LIBS" +fi + +# We must check for the threads library under a number of different +# names; the ordering is very important because some systems +# (e.g. DEC) have both -lpthread and -lpthreads, where one of the +# libraries is broken (non-POSIX). + +# Create a list of thread flags to try. Items with a "," contain both +# C compiler flags (before ",") and linker flags (after ","). Other items +# starting with a "-" are C compiler flags, and remaining items are +# library names, except for "none" which indicates that we try without +# any flags at all, and "pthread-config" which is a program returning +# the flags for the Pth emulation library. + +ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" + +# The ordering *is* (sometimes) important. Some notes on the +# individual items follow: + +# pthreads: AIX (must check this before -lpthread) +# none: in case threads are in libc; should be tried before -Kthread and +# other compiler flags to prevent continual compiler warnings +# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64 +# (Note: HP C rejects this with "bad form for `-t' option") +# -pthreads: Solaris/gcc (Note: HP C also rejects) +# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it +# doesn't hurt to check since this sometimes defines pthreads and +# -D_REENTRANT too), HP C (must be checked before -lpthread, which +# is present but should not be used directly; and before -mthreads, +# because the compiler interprets this as "-mt" + "-hreads") +# -mthreads: Mingw32/gcc, Lynx/gcc +# pthread: Linux, etcetera +# --thread-safe: KAI C++ +# pthread-config: use pthread-config program (for GNU Pth library) + +case $host_os in + + freebsd*) + + # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) + # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) + + ax_pthread_flags="-kthread lthread $ax_pthread_flags" + ;; + + hpux*) + + # From the cc(1) man page: "[-mt] Sets various -D flags to enable + # multi-threading and also sets -lpthread." + + ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags" + ;; + + openedition*) + + # IBM z/OS requires a feature-test macro to be defined in order to + # enable POSIX threads at all, so give the user a hint if this is + # not set. (We don't define these ourselves, as they can affect + # other portions of the system API in unpredictable ways.) + + AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING], + [ +# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS) + AX_PTHREAD_ZOS_MISSING +# endif + ], + [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])]) + ;; + + solaris*) + + # On Solaris (at least, for some versions), libc contains stubbed + # (non-functional) versions of the pthreads routines, so link-based + # tests will erroneously succeed. (N.B.: The stubs are missing + # pthread_cleanup_push, or rather a function called by this macro, + # so we could check for that, but who knows whether they'll stub + # that too in a future libc.) So we'll check first for the + # standard Solaris way of linking pthreads (-mt -lpthread). + + ax_pthread_flags="-mt,-lpthread pthread $ax_pthread_flags" + ;; +esac + +# Are we compiling with Clang? + +AC_CACHE_CHECK([whether $CC is Clang], + [ax_cv_PTHREAD_CLANG], + [ax_cv_PTHREAD_CLANG=no + # Note that Autoconf sets GCC=yes for Clang as well as GCC + if test "x$GCC" = "xyes"; then + AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], + [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ +# if defined(__clang__) && defined(__llvm__) + AX_PTHREAD_CC_IS_CLANG +# endif + ], + [ax_cv_PTHREAD_CLANG=yes]) + fi + ]) +ax_pthread_clang="$ax_cv_PTHREAD_CLANG" + + +# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) + +# Note that for GCC and Clang -pthread generally implies -lpthread, +# except when -nostdlib is passed. +# This is problematic using libtool to build C++ shared libraries with pthread: +# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460 +# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333 +# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555 +# To solve this, first try -pthread together with -lpthread for GCC + +AS_IF([test "x$GCC" = "xyes"], + [ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags"]) + +# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first + +AS_IF([test "x$ax_pthread_clang" = "xyes"], + [ax_pthread_flags="-pthread,-lpthread -pthread"]) + + +# The presence of a feature test macro requesting re-entrant function +# definitions is, on some systems, a strong hint that pthreads support is +# correctly enabled + +case $host_os in + darwin* | hpux* | linux* | osf* | solaris*) + ax_pthread_check_macro="_REENTRANT" + ;; + + aix*) + ax_pthread_check_macro="_THREAD_SAFE" + ;; + + *) + ax_pthread_check_macro="--" + ;; +esac +AS_IF([test "x$ax_pthread_check_macro" = "x--"], + [ax_pthread_check_cond=0], + [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"]) + + +if test "x$ax_pthread_ok" = "xno"; then +for ax_pthread_try_flag in $ax_pthread_flags; do + + case $ax_pthread_try_flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + *,*) + PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"` + PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"` + AC_MSG_CHECKING([whether pthreads work with "$PTHREAD_CFLAGS" and "$PTHREAD_LIBS"]) + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) + PTHREAD_CFLAGS="$ax_pthread_try_flag" + ;; + + pthread-config) + AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) + AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) + PTHREAD_CFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) + PTHREAD_LIBS="-l$ax_pthread_try_flag" + ;; + esac + + ax_pthread_save_CFLAGS="$CFLAGS" + ax_pthread_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include +# if $ax_pthread_check_cond +# error "$ax_pthread_check_macro must be defined" +# endif + static void *some_global = NULL; + static void routine(void *a) + { + /* To avoid any unused-parameter or + unused-but-set-parameter warning. */ + some_global = a; + } + static void *start_routine(void *a) { return a; }], + [pthread_t th; pthread_attr_t attr; + pthread_create(&th, 0, start_routine, 0); + pthread_join(th, 0); + pthread_attr_init(&attr); + pthread_cleanup_push(routine, 0); + pthread_cleanup_pop(0) /* ; */])], + [ax_pthread_ok=yes], + []) + + CFLAGS="$ax_pthread_save_CFLAGS" + LIBS="$ax_pthread_save_LIBS" + + AC_MSG_RESULT([$ax_pthread_ok]) + AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi + + +# Clang needs special handling, because older versions handle the -pthread +# option in a rather... idiosyncratic way + +if test "x$ax_pthread_clang" = "xyes"; then + + # Clang takes -pthread; it has never supported any other flag + + # (Note 1: This will need to be revisited if a system that Clang + # supports has POSIX threads in a separate library. This tends not + # to be the way of modern systems, but it's conceivable.) + + # (Note 2: On some systems, notably Darwin, -pthread is not needed + # to get POSIX threads support; the API is always present and + # active. We could reasonably leave PTHREAD_CFLAGS empty. But + # -pthread does define _REENTRANT, and while the Darwin headers + # ignore this macro, third-party headers might not.) + + # However, older versions of Clang make a point of warning the user + # that, in an invocation where only linking and no compilation is + # taking place, the -pthread option has no effect ("argument unused + # during compilation"). They expect -pthread to be passed in only + # when source code is being compiled. + # + # Problem is, this is at odds with the way Automake and most other + # C build frameworks function, which is that the same flags used in + # compilation (CFLAGS) are also used in linking. Many systems + # supported by AX_PTHREAD require exactly this for POSIX threads + # support, and in fact it is often not straightforward to specify a + # flag that is used only in the compilation phase and not in + # linking. Such a scenario is extremely rare in practice. + # + # Even though use of the -pthread flag in linking would only print + # a warning, this can be a nuisance for well-run software projects + # that build with -Werror. So if the active version of Clang has + # this misfeature, we search for an option to squash it. + + AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread], + [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG], + [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown + # Create an alternate version of $ac_link that compiles and + # links in two steps (.c -> .o, .o -> exe) instead of one + # (.c -> exe), because the warning occurs only in the second + # step + ax_pthread_save_ac_link="$ac_link" + ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' + ax_pthread_link_step=`AS_ECHO(["$ac_link"]) | sed "$ax_pthread_sed"` + ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)" + ax_pthread_save_CFLAGS="$CFLAGS" + for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do + AS_IF([test "x$ax_pthread_try" = "xunknown"], [break]) + CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS" + ac_link="$ax_pthread_save_ac_link" + AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], + [ac_link="$ax_pthread_2step_ac_link" + AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], + [break]) + ]) + done + ac_link="$ax_pthread_save_ac_link" + CFLAGS="$ax_pthread_save_CFLAGS" + AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no]) + ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try" + ]) + + case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in + no | unknown) ;; + *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;; + esac + +fi # $ax_pthread_clang = yes + + + +# Various other checks: +if test "x$ax_pthread_ok" = "xyes"; then + ax_pthread_save_CFLAGS="$CFLAGS" + ax_pthread_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + + # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. + AC_CACHE_CHECK([for joinable pthread attribute], + [ax_cv_PTHREAD_JOINABLE_ATTR], + [ax_cv_PTHREAD_JOINABLE_ATTR=unknown + for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], + [int attr = $ax_pthread_attr; return attr /* ; */])], + [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break], + []) + done + ]) + AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \ + test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \ + test "x$ax_pthread_joinable_attr_defined" != "xyes"], + [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], + [$ax_cv_PTHREAD_JOINABLE_ATTR], + [Define to necessary symbol if this constant + uses a non-standard name on your system.]) + ax_pthread_joinable_attr_defined=yes + ]) + + AC_CACHE_CHECK([whether more special flags are required for pthreads], + [ax_cv_PTHREAD_SPECIAL_FLAGS], + [ax_cv_PTHREAD_SPECIAL_FLAGS=no + case $host_os in + solaris*) + ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS" + ;; + esac + ]) + AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \ + test "x$ax_pthread_special_flags_added" != "xyes"], + [PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS" + ax_pthread_special_flags_added=yes]) + + AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], + [ax_cv_PTHREAD_PRIO_INHERIT], + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[int i = PTHREAD_PRIO_INHERIT; + return i;]])], + [ax_cv_PTHREAD_PRIO_INHERIT=yes], + [ax_cv_PTHREAD_PRIO_INHERIT=no]) + ]) + AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \ + test "x$ax_pthread_prio_inherit_defined" != "xyes"], + [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.]) + ax_pthread_prio_inherit_defined=yes + ]) + + CFLAGS="$ax_pthread_save_CFLAGS" + LIBS="$ax_pthread_save_LIBS" + + # More AIX lossage: compile with *_r variant + if test "x$GCC" != "xyes"; then + case $host_os in + aix*) + AS_CASE(["x/$CC"], + [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], + [#handle absolute path differently from PATH based program lookup + AS_CASE(["x$CC"], + [x/*], + [ + AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"]) + AS_IF([test "x${CXX}" != "x"], [AS_IF([AS_EXECUTABLE_P([${CXX}_r])],[PTHREAD_CXX="${CXX}_r"])]) + ], + [ + AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC]) + AS_IF([test "x${CXX}" != "x"], [AC_CHECK_PROGS([PTHREAD_CXX],[${CXX}_r],[$CXX])]) + ] + ) + ]) + ;; + esac + fi +fi + +test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" +test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX" + +AC_SUBST([PTHREAD_LIBS]) +AC_SUBST([PTHREAD_CFLAGS]) +AC_SUBST([PTHREAD_CC]) +AC_SUBST([PTHREAD_CXX]) + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test "x$ax_pthread_ok" = "xyes"; then + ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1]) + : +else + ax_pthread_ok=no + $2 +fi +AC_LANG_POP +])dnl AX_PTHREAD diff --git a/external/lgpl2/userspace-rcu/dist/m4/ax_require_defined.m4 b/external/lgpl2/userspace-rcu/dist/m4/ax_require_defined.m4 new file mode 100644 index 0000000000000..6de1b2a5a2f06 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/m4/ax_require_defined.m4 @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: FSFAP +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_require_defined.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_REQUIRE_DEFINED(MACRO) +# +# DESCRIPTION +# +# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have +# been defined and thus are available for use. This avoids random issues +# where a macro isn't expanded. Instead the configure script emits a +# non-fatal: +# +# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found +# +# It's like AC_REQUIRE except it doesn't expand the required macro. +# +# Here's an example: +# +# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) +# +# LICENSE +# +# Copyright (c) 2014 Mike Frysinger +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 2 + +AC_DEFUN([AX_REQUIRE_DEFINED], [dnl + m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])]) +])dnl AX_REQUIRE_DEFINED diff --git a/external/lgpl2/userspace-rcu/dist/scripts/urcu-api-list.sh b/external/lgpl2/userspace-rcu/dist/scripts/urcu-api-list.sh new file mode 100755 index 0000000000000..3f065b4c71b9d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/scripts/urcu-api-list.sh @@ -0,0 +1,221 @@ +#!/bin/sh + +# SPDX-FileCopyrightText: 2013 IBM Corporation +# +# SPDX-License-Identifier: GPL-2.0-or-later + +# Run in userspace-rcu git archive. Prints out a list of API members +# and the version in which they were introduced. You need to list all +# the API members immediately below. Depends on "cscope". + +# Authors: Paul E. McKenney + +api="caa_container_of \ + caa_likely \ + caa_max \ + caa_unlikely \ + call_rcu \ + call_rcu_after_fork_child \ + call_rcu_after_fork_parent \ + call_rcu_before_fork \ + call_rcu_data_free \ + cds_hlist_add_head \ + cds_hlist_add_head_rcu \ + cds_hlist_del \ + cds_hlist_del_rcu \ + cds_hlist_entry \ + cds_hlist_for_each_entry \ + cds_hlist_for_each_entry_rcu \ + cds_hlist_for_each_entry_safe \ + CDS_INIT_HLIST_HEAD \ + CDS_INIT_LIST_HEAD \ + cds_lfht_add \ + cds_lfht_add_replace \ + cds_lfht_add_unique \ + cds_lfht_count_nodes \ + cds_lfht_del \ + cds_lfht_destroy \ + cds_lfht_first \ + cds_lfht_for_each \ + cds_lfht_for_each_duplicate \ + cds_lfht_for_each_entry \ + cds_lfht_for_each_entry_duplicate \ + cds_lfht_is_node_deleted \ + cds_lfht_iter_get_node \ + cds_lfht_lookup \ + cds_lfht_new \ + cds_lfht_next \ + cds_lfht_next_duplicate \ + cds_lfht_replace \ + cds_lfht_resize \ + cds_lfq_dequeue_rcu \ + cds_lfq_destroy_rcu \ + cds_lfq_enqueue_rcu \ + cds_lfq_init_rcu \ + cds_lfq_node_init_rcu \ + cds_lfs_empty \ + cds_lfs_for_each \ + cds_lfs_for_each_safe \ + cds_lfs_init \ + cds_lfs_node_init \ + __cds_lfs_pop \ + __cds_lfs_pop_all \ + cds_lfs_pop_all_blocking \ + cds_lfs_pop_blocking \ + cds_lfs_pop_lock \ + cds_lfs_pop_unlock \ + cds_lfs_push \ + cds_list_add \ + cds_list_add_rcu \ + cds_list_add_tail \ + cds_list_del \ + cds_list_del_init \ + cds_list_del_rcu \ + cds_list_empty \ + cds_list_entry \ + cds_list_first_entry \ + cds_list_for_each \ + cds_list_for_each_entry \ + cds_list_for_each_entry_rcu \ + cds_list_for_each_entry_reverse \ + cds_list_for_each_prev \ + cds_list_for_each_prev_safe \ + cds_list_for_each_rcu \ + cds_list_for_each_safe \ + CDS_LIST_HEAD \ + CDS_LIST_HEAD_INIT \ + cds_list_move \ + cds_list_replace \ + cds_list_replace_init \ + cds_list_replace_rcu \ + cds_list_splice \ + __cds_wfcq_dequeue_blocking \ + cds_wfcq_dequeue_blocking \ + cds_wfcq_dequeue_lock \ + __cds_wfcq_dequeue_nonblocking \ + cds_wfcq_dequeue_unlock \ + cds_wfcq_empty \ + cds_wfcq_enqueue \ + __cds_wfcq_first_blocking \ + __cds_wfcq_first_nonblocking \ + __cds_wfcq_for_each_blocking \ + __cds_wfcq_for_each_blocking_safe \ + cds_wfcq_init \ + __cds_wfcq_next_blocking \ + __cds_wfcq_next_nonblocking \ + cds_wfcq_node_init \ + __cds_wfcq_splice_blocking \ + cds_wfcq_splice_blocking \ + __cds_wfcq_splice_nonblocking \ + cds_wfs_empty \ + cds_wfs_first \ + cds_wfs_for_each_blocking \ + cds_wfs_for_each_blocking_safe \ + cds_wfs_init \ + cds_wfs_next_blocking \ + cds_wfs_next_nonblocking \ + cds_wfs_node_init \ + __cds_wfs_pop_all \ + cds_wfs_pop_all_blocking \ + __cds_wfs_pop_blocking \ + cds_wfs_pop_blocking \ + cds_wfs_pop_lock \ + __cds_wfs_pop_nonblocking \ + cds_wfs_pop_unlock \ + cds_wfs_push \ + CMM_ACCESS_ONCE \ + cmm_barrier \ + CMM_LOAD_SHARED \ + cmm_smp_mb \ + cmm_smp_mb__after_uatomic_add \ + cmm_smp_mb__after_uatomic_and \ + cmm_smp_mb__after_uatomic_dec \ + cmm_smp_mb__after_uatomic_inc \ + cmm_smp_mb__after_uatomic_or \ + cmm_smp_mb__before_uatomic_add \ + cmm_smp_mb__before_uatomic_and \ + cmm_smp_mb__before_uatomic_dec \ + cmm_smp_mb__before_uatomic_inc \ + cmm_smp_mb__before_uatomic_or \ + cmm_smp_rmb \ + cmm_smp_wmb \ + CMM_STORE_SHARED \ + create_all_cpu_call_rcu_data \ + create_call_rcu_data \ + DECLARE_URCU_TLS \ + defer_rcu \ + DEFINE_URCU_TLS \ + free_all_cpu_call_rcu_data \ + get_call_rcu_data \ + get_call_rcu_thread \ + get_cpu_call_rcu_data \ + get_default_call_rcu_data \ + get_thread_call_rcu_data \ + rcu_assign_pointer \ + rcu_cmpxchg_pointer \ + rcu_dereference \ + rcu_exit \ + rcu_init \ + rcu_quiescent_state \ + rcu_read_lock \ + rcu_read_unlock \ + rcu_register_thread \ + rcu_set_pointer \ + rcu_thread_offline \ + rcu_thread_online \ + rcu_unregister_thread \ + rcu_xchg_pointer \ + set_cpu_call_rcu_data \ + set_thread_call_rcu_data \ + synchronize_rcu \ + uatomic_add \ + uatomic_add_return \ + uatomic_and \ + uatomic_cmpxchg \ + uatomic_dec \ + uatomic_inc \ + uatomic_or \ + uatomic_read \ + uatomic_set \ + uatomic_xchg \ + URCU_TLS" + +T=/tmp/urcu-api-list.sh.$$ +trap 'rm -rf $T' 0 +mkdir $T + +git remote update 1>&2 +git reset --hard origin/master 1>&2 +git branch -f master 1>&2 +tags=`git tag -l` +lasttag="init" +mkdir $T/init + +for tag in $tags master +do + mkdir $T/$tag + git reset --hard $tag 1>&2 + rm -rf cscope.* tests + find . \( -name SCCS -prune \) -o \( -name .git -prune \) -o \( -name '*.[h]' -print \) | grep -v -e '-impl\.h$' | cscope -bkq -i - + for i in $api + do + cscope -d -L -0 $i > $T/$tag/$i + if test -s $T/$tag/$i + then + : + else + rm $T/$tag/$i + fi + done + # The call_rcu() preceding v0.6.0 is to be ignored + if test -d $T/v0.6.0 + then + : + else + rm $T/$tag/call_rcu + fi + ( ls $T/$tag; ls $T/$lasttag ) | sort | uniq -u | + awk -v tag=$tag '{ print "\t" $1 "" tag "" }' + lasttag=$tag +done + diff --git a/external/lgpl2/userspace-rcu/dist/src/Makefile.am b/external/lgpl2/userspace-rcu/dist/src/Makefile.am new file mode 100644 index 0000000000000..b555c8181f61b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/Makefile.am @@ -0,0 +1,61 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +AM_CPPFLAGS += -I$(top_srcdir)/src + +#Add the -version-info directly here since we are only building +# library that use the version-info +AM_LDFLAGS=-version-info $(URCU_LIBRARY_VERSION) $(LT_NO_UNDEFINED) + +dist_noinst_HEADERS = urcu-die.h urcu-wait.h compat-getcpu.h \ + urcu-utils.h compat-smp.h + +COMPAT = compat_arch.c compat_futex.c + +RCULFHASH = rculfhash.c rculfhash-mm-order.c rculfhash-mm-chunk.c \ + rculfhash-mm-mmap.c + +lib_LTLIBRARIES = liburcu-common.la \ + liburcu.la liburcu-qsbr.la \ + liburcu-mb.la liburcu-bp.la \ + liburcu-memb.la liburcu-cds.la + +# +# liburcu-common contains wait-free queues (needed by call_rcu) as well +# as futex fallbacks. +# +liburcu_common_la_SOURCES = wfqueue.c wfcqueue.c wfstack.c $(COMPAT) + +liburcu_la_SOURCES = urcu.c urcu-pointer.c $(COMPAT) +liburcu_la_CFLAGS = -DRCU_MEMBARRIER $(AM_CFLAGS) +liburcu_la_LIBADD = liburcu-common.la + +liburcu_memb_la_SOURCES = urcu.c urcu-pointer.c $(COMPAT) +liburcu_memb_la_CFLAGS = -DRCU_MEMBARRIER $(AM_CFLAGS) +liburcu_memb_la_LIBADD = liburcu-common.la + +liburcu_qsbr_la_SOURCES = urcu-qsbr.c urcu-pointer.c $(COMPAT) +liburcu_qsbr_la_CFLAGS = -DRCU_QSBR $(AM_CFLAGS) +liburcu_qsbr_la_LIBADD = liburcu-common.la + +liburcu_mb_la_SOURCES = urcu.c urcu-pointer.c $(COMPAT) +liburcu_mb_la_CFLAGS = -DRCU_MB $(AM_CFLAGS) +liburcu_mb_la_LIBADD = liburcu-common.la + +liburcu_bp_la_SOURCES = urcu-bp.c urcu-pointer.c $(COMPAT) +liburcu_bp_la_LIBADD = liburcu-common.la + +liburcu_cds_la_SOURCES = rculfqueue.c rculfstack.c lfstack.c \ + workqueue.c workqueue.h $(RCULFHASH) $(COMPAT) +liburcu_cds_la_LIBADD = liburcu-common.la + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = liburcu-cds.pc liburcu.pc liburcu-bp.pc liburcu-qsbr.pc \ + liburcu-mb.pc liburcu-memb.pc + +EXTRA_DIST = \ + urcu-call-rcu-impl.h \ + urcu-defer-impl.h \ + urcu-poll-impl.h \ + rculfhash-internal.h diff --git a/external/lgpl2/userspace-rcu/dist/src/compat-getcpu.h b/external/lgpl2/userspace-rcu/dist/src/compat-getcpu.h new file mode 100644 index 0000000000000..ad5ec117a324e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/compat-getcpu.h @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: 2015 Michael Jeanson +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _COMPAT_GETCPU_H +#define _COMPAT_GETCPU_H + +#if defined(HAVE_SCHED_GETCPU) +#include + +static inline +int urcu_sched_getcpu(void) +{ + return sched_getcpu(); +} +#elif defined(HAVE_GETCPUID) +#include + +static inline +int urcu_sched_getcpu(void) +{ + return (int) getcpuid(); +} +#else + +static inline +int urcu_sched_getcpu(void) +{ + return -1; +} +#endif + +#endif /* _COMPAT_GETCPU_H */ diff --git a/external/lgpl2/userspace-rcu/dist/src/compat-smp.h b/external/lgpl2/userspace-rcu/dist/src/compat-smp.h new file mode 100644 index 0000000000000..5da8d6a03d7e7 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/compat-smp.h @@ -0,0 +1,275 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright (C) 2011-2012 Mathieu Desnoyers + * Copyright (C) 2019 Michael Jeanson + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define URCU_CPUMASK_SIZE 4096 + +#if defined(HAVE_SYSCONF) +static inline int get_num_possible_cpus_sysconf(void) +{ + return sysconf(_SC_NPROCESSORS_CONF); +} +#else +/* + * On platforms without sysconf(), always return -1. + */ +static inline int get_num_possible_cpus_sysconf(void) +{ + return -1; +} +#endif + +#ifdef __linux__ +/* + * Get the highest CPU id from sysfs. + * + * Iterate on all the folders in "/sys/devices/system/cpu" that start with + * "cpu" followed by an integer, keep the highest CPU id encountered during + * this iteration and add 1 to get a number of CPUs. + * + * Returns the highest CPU id, or -1 on error. + */ +static inline int _get_max_cpuid_from_sysfs(const char *path) +{ + long max_cpuid = -1; + + DIR *cpudir; + struct dirent *entry; + + assert(path); + + cpudir = opendir(path); + if (cpudir == NULL) + goto end; + + /* + * Iterate on all directories named "cpu" followed by an integer. + */ + while ((entry = readdir(cpudir))) { + if (entry->d_type == DT_DIR && + strncmp(entry->d_name, "cpu", 3) == 0) { + + char *endptr; + long cpu_id; + + cpu_id = strtol(entry->d_name + 3, &endptr, 10); + if ((cpu_id < LONG_MAX) && (endptr != entry->d_name + 3) + && (*endptr == '\0')) { + if (cpu_id > max_cpuid) + max_cpuid = cpu_id; + } + } + } + + if (closedir(cpudir)) + perror("closedir"); + + /* + * If the max CPU id is out of bound, set it to -1 so it results in a + * CPU num of 0. + */ + if (max_cpuid < 0 || max_cpuid > INT_MAX) + max_cpuid = -1; + +end: + return max_cpuid; +} + +static inline int get_max_cpuid_from_sysfs(void) +{ + return _get_max_cpuid_from_sysfs("/sys/devices/system/cpu"); +} + + +/* + * As a fallback to parsing the CPU mask in "/sys/devices/system/cpu/possible", + * iterate on all the folders in "/sys/devices/system/cpu" that start with + * "cpu" followed by an integer, keep the highest CPU id encountered during + * this iteration and add 1 to get a number of CPUs. + * + * Then get the value from sysconf(_SC_NPROCESSORS_CONF) as a fallback and + * return the highest one. + * + * On Linux, using the value from sysconf can be unreliable since the way it + * counts CPUs varies between C libraries and even between versions of the same + * library. If we used it directly, getcpu() could return a value greater than + * this sysconf, in which case the arrays indexed by processor would overflow. + * + * As another example, the MUSL libc implementation of the _SC_NPROCESSORS_CONF + * sysconf does not return the number of configured CPUs in the system but + * relies on the cpu affinity mask of the current task. + * + * Returns 0 or less on error. + */ +static inline int get_num_possible_cpus_fallback(void) +{ + /* + * Get the sysconf value as a last resort. Keep the highest number. + */ + return caa_max(get_num_possible_cpus_sysconf(), get_max_cpuid_from_sysfs() + 1); +} + +/* + * Get a CPU mask string from sysfs. + * + * buf: the buffer where the mask will be read. + * max_bytes: the maximum number of bytes to write in the buffer. + * path: file path to read the mask from. + * + * Returns the number of bytes read or -1 on error. + */ +static inline int get_cpu_mask_from_sysfs(char *buf, size_t max_bytes, const char *path) +{ + ssize_t bytes_read = 0; + size_t total_bytes_read = 0; + int fd = -1, ret = -1; + + assert(path); + + if (buf == NULL) + goto end; + + fd = open(path, O_RDONLY); + if (fd < 0) + goto end; + + do { + bytes_read = read(fd, buf + total_bytes_read, + max_bytes - total_bytes_read); + + if (bytes_read < 0) { + if (errno == EINTR) { + continue; /* retry operation */ + } else { + goto end; + } + } + + total_bytes_read += bytes_read; + assert(total_bytes_read <= max_bytes); + } while (max_bytes > total_bytes_read && bytes_read != 0); + + /* + * Make sure the mask read is a null terminated string. + */ + if (total_bytes_read < max_bytes) + buf[total_bytes_read] = '\0'; + else + buf[max_bytes - 1] = '\0'; + + if (total_bytes_read > INT_MAX) + goto end; + + ret = (int) total_bytes_read; + +end: + if (fd >= 0 && close(fd) < 0) + perror("close"); + + return ret; +} + +/* + * Get the CPU possible mask string from sysfs. + * + * buf: the buffer where the mask will be read. + * max_bytes: the maximum number of bytes to write in the buffer. + * + * Returns the number of bytes read or -1 on error. + */ +static inline int get_possible_cpu_mask_from_sysfs(char *buf, size_t max_bytes) +{ + return get_cpu_mask_from_sysfs(buf, max_bytes, + "/sys/devices/system/cpu/possible"); +} + +/* + * Get the highest CPU id from the possible CPU mask. + * + * pmask: the mask to parse. + * len: the len of the mask excluding '\0'. + * + * Returns the highest CPU id from the mask or -1 on error. + */ +static inline int get_max_cpuid_from_mask(const char *pmask, size_t len) +{ + ssize_t i; + unsigned long cpu_index; + char *endptr; + + /* We need at least one char to read */ + if (len < 1) + goto error; + + /* Start from the end to read the last CPU index. */ + for (i = len - 1; i > 0; i--) { + /* Break when we hit the first separator. */ + if ((pmask[i] == ',') || (pmask[i] == '-')) { + i++; + break; + } + } + + cpu_index = strtoul(&pmask[i], &endptr, 10); + + if ((&pmask[i] != endptr) && (cpu_index < INT_MAX)) + return (int) cpu_index; + +error: + return -1; +} + +/* + * On Linux try sysfs first and fallback to sysconf. + */ +static inline int get_possible_cpus_array_len(void) +{ + int ret; + char buf[URCU_CPUMASK_SIZE]; + + /* Get the possible cpu mask from sysfs, fallback to sysconf. */ + ret = get_possible_cpu_mask_from_sysfs((char *) &buf, URCU_CPUMASK_SIZE); + if (ret <= 0) + goto fallback; + + /* Parse the possible cpu mask, on failure fallback to sysconf. */ + ret = get_max_cpuid_from_mask((char *) &buf, ret); + if (ret >= 0) { + /* Add 1 to convert from max cpuid to an array len. */ + ret++; + goto end; + } + +fallback: + /* Fallback to sysconf. */ + ret = get_num_possible_cpus_fallback(); + +end: + return ret; +} +#else +/* + * On other platforms, only use sysconf. + */ +static inline int get_possible_cpus_array_len(void) +{ + return get_num_possible_cpus_sysconf(); +} +#endif diff --git a/external/lgpl2/userspace-rcu/dist/src/compat_arch.c b/external/lgpl2/userspace-rcu/dist/src/compat_arch.c new file mode 100644 index 0000000000000..474a832811a4e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/compat_arch.c @@ -0,0 +1,294 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU library - architecture compatibility checks + */ + +#include + +#ifdef URCU_ARCH_X86_NO_CAS + +#include +#include +#include +#include +#include + +/* + * Using attribute "weak" for __rcu_cas_avail and + * __urcu_x86_compat_mutex. Those are globally visible by the entire + * program, even though many shared objects may have their own version. + * The first version that gets loaded will be used by the entire + * program (executable and all shared objects). + */ + +/* + * It does not really matter if the constructor is called before using + * the library, as long as the caller checks if __rcu_cas_avail < 0 and calls + * compat_arch_init() explicitly if needed. + */ +int __attribute__((constructor)) __rcu_cas_init(void); + +/* + * -1: unknown + * 1: available + * 0: unavailable + */ +__attribute__((weak)) +int __rcu_cas_avail = -1; + +__attribute__((weak)) +pthread_mutex_t __urcu_x86_compat_mutex = PTHREAD_MUTEX_INITIALIZER; + +/* + * get_eflags/set_eflags/compare_and_swap_is_available imported from glibc + * 2.3.5. linuxthreads/sysdeps/i386/pt-machine.h. + */ + +static int get_eflags (void) +{ + int res; + __asm__ __volatile__ ("pushfl; popl %0" : "=r" (res) : ); + return res; +} + +static void set_eflags (int newflags) +{ + __asm__ __volatile__ ("pushl %0; popfl" : : "r" (newflags) : "cc"); +} + +static int compare_and_swap_is_available (void) +{ + int oldflags = get_eflags (); + int changed; + /* Flip AC bit in EFLAGS. */ + set_eflags (oldflags ^ 0x40000); + /* See if bit changed. */ + changed = (get_eflags () ^ oldflags) & 0x40000; + /* Restore EFLAGS. */ + set_eflags (oldflags); + /* If the AC flag did not change, it's a 386 and it lacks cmpxchg. + Otherwise, it's a 486 or above and it has cmpxchg. */ + return changed != 0; +} + +static void mutex_lock_signal_save(pthread_mutex_t *mutex, sigset_t *oldmask) +{ + sigset_t newmask; + int ret; + + /* Disable signals */ + ret = sigfillset(&newmask); + urcu_posix_assert(!ret); + ret = pthread_sigmask(SIG_BLOCK, &newmask, oldmask); + urcu_posix_assert(!ret); + ret = pthread_mutex_lock(&__urcu_x86_compat_mutex); + urcu_posix_assert(!ret); +} + +static void mutex_lock_signal_restore(pthread_mutex_t *mutex, sigset_t *oldmask) +{ + int ret; + + ret = pthread_mutex_unlock(&__urcu_x86_compat_mutex); + urcu_posix_assert(!ret); + ret = pthread_sigmask(SIG_SETMASK, oldmask, NULL); + urcu_posix_assert(!ret); +} + +unsigned long _compat_uatomic_set(void *addr, unsigned long _new, int len) +{ + sigset_t mask; + unsigned long result; + + mutex_lock_signal_save(&__urcu_x86_compat_mutex, &mask); + switch (len) { + case 1: + *(unsigned char *)addr = (unsigned char)_new; + result = *(unsigned char *)addr; + break; + case 2: + *(unsigned short *)addr = (unsigned short)_new; + result = *(unsigned short *)addr; + break; + case 4: + *(unsigned int *)addr = (unsigned int)_new; + result = *(unsigned int *)addr; + break; + default: + /* + * generate an illegal instruction. Cannot catch this with + * linker tricks when optimizations are disabled. + */ + result = 0; + __asm__ __volatile__("ud2"); + } + mutex_lock_signal_restore(&__urcu_x86_compat_mutex, &mask); + return result; +} + +unsigned long _compat_uatomic_xchg(void *addr, unsigned long _new, int len) +{ + sigset_t mask; + unsigned long retval; + + mutex_lock_signal_save(&__urcu_x86_compat_mutex, &mask); + switch (len) { + case 1: + retval = *(unsigned char *)addr; + *(unsigned char *)addr = (unsigned char)_new; + break; + case 2: + retval = *(unsigned short *)addr; + *(unsigned short *)addr = (unsigned short)_new; + break; + case 4: + retval = *(unsigned int *)addr; + *(unsigned int *)addr = (unsigned int)_new; + break; + default: + /* + * generate an illegal instruction. Cannot catch this with + * linker tricks when optimizations are disabled. + */ + retval = 0; /* silence gcc warnings */ + __asm__ __volatile__("ud2"); + } + mutex_lock_signal_restore(&__urcu_x86_compat_mutex, &mask); + return retval; +} + +unsigned long _compat_uatomic_cmpxchg(void *addr, unsigned long old, + unsigned long _new, int len) +{ + unsigned long retval; + sigset_t mask; + + mutex_lock_signal_save(&__urcu_x86_compat_mutex, &mask); + switch (len) { + case 1: + { + unsigned char result = *(unsigned char *)addr; + if (result == (unsigned char)old) + *(unsigned char *)addr = (unsigned char)_new; + retval = result; + break; + } + case 2: + { + unsigned short result = *(unsigned short *)addr; + if (result == (unsigned short)old) + *(unsigned short *)addr = (unsigned short)_new; + retval = result; + break; + } + case 4: + { + unsigned int result = *(unsigned int *)addr; + if (result == (unsigned int)old) + *(unsigned int *)addr = (unsigned int)_new; + retval = result; + break; + } + default: + /* + * generate an illegal instruction. Cannot catch this with + * linker tricks when optimizations are disabled. + */ + retval = 0; /* silence gcc warnings */ + __asm__ __volatile__("ud2"); + } + mutex_lock_signal_restore(&__urcu_x86_compat_mutex, &mask); + return retval; +} + +void _compat_uatomic_or(void *addr, unsigned long v, int len) +{ + sigset_t mask; + + mutex_lock_signal_save(&__urcu_x86_compat_mutex, &mask); + switch (len) { + case 1: + *(unsigned char *)addr |= (unsigned char)v; + break; + case 2: + *(unsigned short *)addr |= (unsigned short)v; + break; + case 4: + *(unsigned int *)addr |= (unsigned int)v; + break; + default: + /* + * generate an illegal instruction. Cannot catch this with + * linker tricks when optimizations are disabled. + */ + __asm__ __volatile__("ud2"); + } + mutex_lock_signal_restore(&__urcu_x86_compat_mutex, &mask); +} + +void _compat_uatomic_and(void *addr, unsigned long v, int len) +{ + sigset_t mask; + + mutex_lock_signal_save(&__urcu_x86_compat_mutex, &mask); + switch (len) { + case 1: + *(unsigned char *)addr &= (unsigned char)v; + break; + case 2: + *(unsigned short *)addr &= (unsigned short)v; + break; + case 4: + *(unsigned int *)addr &= (unsigned int)v; + break; + default: + /* + * generate an illegal instruction. Cannot catch this with + * linker tricks when optimizations are disabled. + */ + __asm__ __volatile__("ud2"); + } + mutex_lock_signal_restore(&__urcu_x86_compat_mutex, &mask); +} + +unsigned long _compat_uatomic_add_return(void *addr, unsigned long v, int len) +{ + sigset_t mask; + unsigned long result; + + mutex_lock_signal_save(&__urcu_x86_compat_mutex, &mask); + switch (len) { + case 1: + *(unsigned char *)addr += (unsigned char)v; + result = *(unsigned char *)addr; + break; + case 2: + *(unsigned short *)addr += (unsigned short)v; + result = *(unsigned short *)addr; + break; + case 4: + *(unsigned int *)addr += (unsigned int)v; + result = *(unsigned int *)addr; + break; + default: + /* + * generate an illegal instruction. Cannot catch this with + * linker tricks when optimizations are disabled. + */ + result = 0; /* silence gcc warnings */ + __asm__ __volatile__("ud2"); + } + mutex_lock_signal_restore(&__urcu_x86_compat_mutex, &mask); + return result; +} + +int __rcu_cas_init(void) +{ + if (__rcu_cas_avail < 0) + __rcu_cas_avail = compare_and_swap_is_available(); + return __rcu_cas_avail; +} +#endif diff --git a/external/lgpl2/userspace-rcu/dist/src/compat_futex.c b/external/lgpl2/userspace-rcu/dist/src/compat_futex.c new file mode 100644 index 0000000000000..151a40cbae2b9 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/compat_futex.c @@ -0,0 +1,140 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU library - sys_futex compatibility code + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +/* + * Using attribute "weak" for __urcu_compat_futex_lock and + * __urcu_compat_futex_cond. Those are globally visible by the entire + * program, even though many shared objects may have their own version. + * The first version that gets loaded will be used by the entire program + * (executable and all shared objects). + */ + +__attribute__((weak)) +pthread_mutex_t __urcu_compat_futex_lock = PTHREAD_MUTEX_INITIALIZER; +__attribute__((weak)) +pthread_cond_t __urcu_compat_futex_cond = PTHREAD_COND_INITIALIZER; + +/* + * _NOT SIGNAL-SAFE_. pthread_cond is not signal-safe anyway. Though. + * For now, timeout, uaddr2 and val3 are unused. + * Waiter will relinquish the CPU until woken up. + */ + +int compat_futex_noasync(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3) +{ + int ret = 0, lockret; + + /* + * Check if NULL. Don't let users expect that they are taken into + * account. + */ + urcu_posix_assert(!timeout); + urcu_posix_assert(!uaddr2); + urcu_posix_assert(!val3); + + /* + * memory barriers to serialize with the previous uaddr modification. + */ + cmm_smp_mb(); + + lockret = pthread_mutex_lock(&__urcu_compat_futex_lock); + if (lockret) { + errno = lockret; + ret = -1; + goto end; + } + switch (op) { + case FUTEX_WAIT: + /* + * Wait until *uaddr is changed to something else than "val". + * Comparing *uaddr content against val figures out which + * thread has been awakened. + */ + while (CMM_LOAD_SHARED(*uaddr) == val) + pthread_cond_wait(&__urcu_compat_futex_cond, + &__urcu_compat_futex_lock); + break; + case FUTEX_WAKE: + /* + * Each wake is sending a broadcast, thus attempting wakeup of + * all awaiting threads, independently of their respective + * uaddr. + */ + pthread_cond_broadcast(&__urcu_compat_futex_cond); + break; + default: + errno = EINVAL; + ret = -1; + } + lockret = pthread_mutex_unlock(&__urcu_compat_futex_lock); + if (lockret) { + errno = lockret; + ret = -1; + } +end: + return ret; +} + +/* + * _ASYNC SIGNAL-SAFE_. + * For now, timeout, uaddr2 and val3 are unused. + * Waiter will busy-loop trying to read the condition. + * It is OK to use compat_futex_async() on a futex address on which + * futex() WAKE operations are also performed. + */ + +int compat_futex_async(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3) +{ + int ret = 0; + + /* + * Check if NULL. Don't let users expect that they are taken into + * account. + */ + urcu_posix_assert(!timeout); + urcu_posix_assert(!uaddr2); + urcu_posix_assert(!val3); + + /* + * Ensure previous memory operations on uaddr have completed. + */ + cmm_smp_mb(); + + switch (op) { + case FUTEX_WAIT: + while (CMM_LOAD_SHARED(*uaddr) == val) { + if (poll(NULL, 0, 10) < 0) { + ret = -1; + /* Keep poll errno. Caller handles EINTR. */ + goto end; + } + } + break; + case FUTEX_WAKE: + break; + default: + errno = EINVAL; + ret = -1; + } +end: + return ret; +} diff --git a/external/lgpl2/userspace-rcu/dist/src/lfstack.c b/external/lgpl2/userspace-rcu/dist/src/lfstack.c new file mode 100644 index 0000000000000..ca3de8595d7bf --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/lfstack.c @@ -0,0 +1,77 @@ +// SPDX-FileCopyrightText: 2010-2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU library - Lock-Free Stack + */ + +/* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */ +#undef _LGPL_SOURCE +#include "urcu/lfstack.h" +#define _LGPL_SOURCE +#include "urcu/static/lfstack.h" + +/* + * library wrappers to be used by non-LGPL compatible source code. + */ + +void cds_lfs_node_init(struct cds_lfs_node *node) +{ + _cds_lfs_node_init(node); +} + +void cds_lfs_init(struct cds_lfs_stack *s) +{ + _cds_lfs_init(s); +} + +void cds_lfs_destroy(struct cds_lfs_stack *s) +{ + _cds_lfs_destroy(s); +} + +void __cds_lfs_init(struct __cds_lfs_stack *s) +{ + ___cds_lfs_init(s); +} + +bool cds_lfs_empty(cds_lfs_stack_const_ptr_t s) +{ + return _cds_lfs_empty(s); +} + +bool cds_lfs_push(cds_lfs_stack_ptr_t s, struct cds_lfs_node *node) +{ + return _cds_lfs_push(s, node); +} + +struct cds_lfs_node *cds_lfs_pop_blocking(struct cds_lfs_stack *s) +{ + return _cds_lfs_pop_blocking(s); +} + +struct cds_lfs_head *cds_lfs_pop_all_blocking(struct cds_lfs_stack *s) +{ + return _cds_lfs_pop_all_blocking(s); +} + +void cds_lfs_pop_lock(struct cds_lfs_stack *s) +{ + _cds_lfs_pop_lock(s); +} + +void cds_lfs_pop_unlock(struct cds_lfs_stack *s) +{ + _cds_lfs_pop_unlock(s); +} + +struct cds_lfs_node *__cds_lfs_pop(cds_lfs_stack_ptr_t s) +{ + return ___cds_lfs_pop(s); +} + +struct cds_lfs_head *__cds_lfs_pop_all(cds_lfs_stack_ptr_t s) +{ + return ___cds_lfs_pop_all(s); +} diff --git a/external/lgpl2/userspace-rcu/dist/src/liburcu-bp.pc.in b/external/lgpl2/userspace-rcu/dist/src/liburcu-bp.pc.in new file mode 100644 index 0000000000000..4f89fc2ea6f54 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/liburcu-bp.pc.in @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: Userspace RCU BulletProof +Description: A userspace RCU (read-copy-update) library, bulletproof version +Version: @PACKAGE_VERSION@ +Requires: +Libs: -L${libdir} -lurcu-common -lurcu-bp +Cflags: -I${includedir} diff --git a/external/lgpl2/userspace-rcu/dist/src/liburcu-cds.pc.in b/external/lgpl2/userspace-rcu/dist/src/liburcu-cds.pc.in new file mode 100644 index 0000000000000..945666c5e1cb4 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/liburcu-cds.pc.in @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: Userspace RCU Concurrent Data Structures +Description: Data structures leveraging RCU and atomic operations to provide efficient concurrency-aware storage +Version: @PACKAGE_VERSION@ +Requires: +Libs: -L${libdir} -lurcu-common -lurcu-cds +Cflags: -I${includedir} diff --git a/external/lgpl2/userspace-rcu/dist/src/liburcu-mb.pc.in b/external/lgpl2/userspace-rcu/dist/src/liburcu-mb.pc.in new file mode 100644 index 0000000000000..fcd32e056f0a2 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/liburcu-mb.pc.in @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: Userspace RCU Memory barriers +Description: A userspace RCU (read-copy-update) library, memory barriers version +Version: @PACKAGE_VERSION@ +Requires: +Libs: -L${libdir} -lurcu-common -lurcu-mb +Cflags: -I${includedir} diff --git a/external/lgpl2/userspace-rcu/dist/src/liburcu-memb.pc.in b/external/lgpl2/userspace-rcu/dist/src/liburcu-memb.pc.in new file mode 100644 index 0000000000000..b72008d4a540b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/liburcu-memb.pc.in @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: Userspace RCU membarrier syscall +Description: A userspace RCU (read-copy-update) library, membarrier syscall version +Version: @PACKAGE_VERSION@ +Requires: +Libs: -L${libdir} -lurcu-common -lurcu-memb +Cflags: -I${includedir} diff --git a/external/lgpl2/userspace-rcu/dist/src/liburcu-qsbr.pc.in b/external/lgpl2/userspace-rcu/dist/src/liburcu-qsbr.pc.in new file mode 100644 index 0000000000000..2dc69985e103e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/liburcu-qsbr.pc.in @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: Userspace RCU QSBR +Description: A userspace RCU (read-copy-update) library, quiescent state version +Version: @PACKAGE_VERSION@ +Requires: +Libs: -L${libdir} -lurcu-common -lurcu-qsbr +Cflags: -I${includedir} diff --git a/external/lgpl2/userspace-rcu/dist/src/liburcu.pc.in b/external/lgpl2/userspace-rcu/dist/src/liburcu.pc.in new file mode 100644 index 0000000000000..8f738aee78121 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/liburcu.pc.in @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: Userspace RCU +Description: A userspace RCU (read-copy-update) library, standard version +Version: @PACKAGE_VERSION@ +Requires: +Libs: -L${libdir} -lurcu-common -lurcu +Cflags: -I${includedir} diff --git a/external/lgpl2/userspace-rcu/dist/src/rculfhash-internal.h b/external/lgpl2/userspace-rcu/dist/src/rculfhash-internal.h new file mode 100644 index 0000000000000..7225ec99e90f2 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/rculfhash-internal.h @@ -0,0 +1,178 @@ +// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2011 Lai Jiangshan +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_RCULFHASH_INTERNAL_H +#define _URCU_RCULFHASH_INTERNAL_H + +/* + * Internal header for Lock-Free RCU Hash Table + */ + +#include +#include +#include +#include + +#include "workqueue.h" + +#ifdef DEBUG +#define dbg_printf(fmt, args...) printf("[debug rculfhash] " fmt, ## args) +#else +#define dbg_printf(fmt, args...) \ +do { \ + /* do nothing but check printf format */ \ + if (0) \ + printf("[debug rculfhash] " fmt, ## args); \ +} while (0) +#endif + +#if (CAA_BITS_PER_LONG == 32) +#define MAX_TABLE_ORDER 32 +#else +#define MAX_TABLE_ORDER 64 +#endif + +#define MAX_CHUNK_TABLE (1UL << 10) + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + +struct ht_items_count; + +/* + * cds_lfht: Top-level data structure representing a lock-free hash + * table. Defined in the implementation file to make it be an opaque + * cookie to users. + * + * The fields used in fast-paths are placed near the end of the + * structure, because we need to have a variable-sized union to contain + * the mm plugin fields, which are used in the fast path. + */ +struct cds_lfht { + /* Initial configuration items */ + unsigned long max_nr_buckets; + const struct cds_lfht_mm_type *mm; /* memory management plugin */ + const struct cds_lfht_alloc *alloc; /* memory allocator for mm */ + const struct rcu_flavor_struct *flavor; /* RCU flavor */ + + long count; /* global approximate item count */ + + /* + * We need to put the work threads offline (QSBR) when taking this + * mutex, because we use synchronize_rcu within this mutex critical + * section, which waits on read-side critical sections, and could + * therefore cause grace-period deadlock if we hold off RCU G.P. + * completion. + */ + pthread_mutex_t resize_mutex; /* resize mutex: add/del mutex */ + pthread_attr_t *caller_resize_attr; /* resize threads attributes from lfht_new caller */ + pthread_attr_t resize_attr; + unsigned int in_progress_destroy; + unsigned long resize_target; + int resize_initiated; + struct urcu_work destroy_work; + + /* + * Variables needed for add and remove fast-paths. + */ + int flags; + unsigned long min_alloc_buckets_order; + unsigned long min_nr_alloc_buckets; + struct ht_items_count *split_count; /* split item count */ + + /* + * Variables needed for the lookup, add and remove fast-paths. + */ + unsigned long size; /* always a power of 2, shared (RCU) */ + /* + * bucket_at pointer is kept here to skip the extra level of + * dereference needed to get to "mm" (this is a fast-path). + */ + struct cds_lfht_node *(*bucket_at)(struct cds_lfht *ht, + unsigned long index); + /* + * Dynamic length "tbl_chunk" needs to be at the end of + * cds_lfht. + */ + union { + /* + * Contains the per order-index-level bucket node table. + * The size of each bucket node table is half the number + * of hashes contained in this order (except for order 0). + * The minimum allocation buckets size parameter allows + * combining the bucket node arrays of the lowermost + * levels to improve cache locality for small index orders. + */ + struct cds_lfht_node *tbl_order[MAX_TABLE_ORDER]; + + /* + * Contains the bucket node chunks. The size of each + * bucket node chunk is ->min_alloc_size (we avoid to + * allocate chunks with different size). Chunks improve + * cache locality for small index orders, and are more + * friendly with environments where allocation of large + * contiguous memory areas is challenging due to memory + * fragmentation concerns or inability to use virtual + * memory addressing. + */ + struct cds_lfht_node *tbl_chunk[0]; + + /* + * Memory mapping with room for all possible buckets. + * Their memory is allocated when needed. + */ + struct cds_lfht_node *tbl_mmap; + }; + /* + * End of variables needed for the lookup, add and remove + * fast-paths. + */ +}; + +extern unsigned int cds_lfht_fls_ulong(unsigned long x); +extern int cds_lfht_get_count_order_ulong(unsigned long x); + +#ifdef POISON_FREE +#define poison_free(alloc, ptr) \ + do { \ + if (ptr) { \ + memset(ptr, 0x42, sizeof(*(ptr))); \ + alloc->free(alloc->state, ptr); \ + } \ + } while (0) +#else +#define poison_free(alloc, ptr) alloc->free(alloc->state, ptr) +#endif + +static inline +struct cds_lfht *__default_alloc_cds_lfht( + const struct cds_lfht_mm_type *mm, + const struct cds_lfht_alloc *alloc, + unsigned long cds_lfht_size, + unsigned long min_nr_alloc_buckets, + unsigned long max_nr_buckets) +{ + struct cds_lfht *ht; + + ht = alloc->calloc(alloc->state, 1, cds_lfht_size); + urcu_posix_assert(ht); + + ht->mm = mm; + ht->alloc = alloc; + ht->bucket_at = mm->bucket_at; + ht->min_nr_alloc_buckets = min_nr_alloc_buckets; + ht->min_alloc_buckets_order = + cds_lfht_get_count_order_ulong(min_nr_alloc_buckets); + ht->max_nr_buckets = max_nr_buckets; + + return ht; +} + +#endif /* _URCU_RCULFHASH_INTERNAL_H */ diff --git a/external/lgpl2/userspace-rcu/dist/src/rculfhash-mm-chunk.c b/external/lgpl2/userspace-rcu/dist/src/rculfhash-mm-chunk.c new file mode 100644 index 0000000000000..93931ee7a7e77 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/rculfhash-mm-chunk.c @@ -0,0 +1,84 @@ +// SPDX-FileCopyrightText: 2011 Lai Jiangshan +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Chunk based memory management for Lock-Free RCU Hash Table + */ + +#include +#include +#include "rculfhash-internal.h" + +static +void cds_lfht_alloc_bucket_table(struct cds_lfht *ht, unsigned long order) +{ + if (order == 0) { + ht->tbl_chunk[0] = ht->alloc->calloc(ht->alloc->state, + ht->min_nr_alloc_buckets, sizeof(struct cds_lfht_node)); + urcu_posix_assert(ht->tbl_chunk[0]); + } else if (order > ht->min_alloc_buckets_order) { + unsigned long i, len = 1UL << (order - 1 - ht->min_alloc_buckets_order); + + for (i = len; i < 2 * len; i++) { + ht->tbl_chunk[i] = ht->alloc->calloc(ht->alloc->state, + ht->min_nr_alloc_buckets, sizeof(struct cds_lfht_node)); + urcu_posix_assert(ht->tbl_chunk[i]); + } + } + /* Nothing to do for 0 < order && order <= ht->min_alloc_buckets_order */ +} + +/* + * cds_lfht_free_bucket_table() should be called with decreasing order. + * When cds_lfht_free_bucket_table(0) is called, it means the whole + * lfht is destroyed. + */ +static +void cds_lfht_free_bucket_table(struct cds_lfht *ht, unsigned long order) +{ + if (order == 0) + poison_free(ht->alloc, ht->tbl_chunk[0]); + else if (order > ht->min_alloc_buckets_order) { + unsigned long i, len = 1UL << (order - 1 - ht->min_alloc_buckets_order); + + for (i = len; i < 2 * len; i++) + poison_free(ht->alloc, ht->tbl_chunk[i]); + } + /* Nothing to do for 0 < order && order <= ht->min_alloc_buckets_order */ +} + +static +struct cds_lfht_node *bucket_at(struct cds_lfht *ht, unsigned long index) +{ + unsigned long chunk, offset; + + chunk = index >> ht->min_alloc_buckets_order; + offset = index & (ht->min_nr_alloc_buckets - 1); + return &ht->tbl_chunk[chunk][offset]; +} + +static +struct cds_lfht *alloc_cds_lfht(unsigned long min_nr_alloc_buckets, + unsigned long max_nr_buckets, const struct cds_lfht_alloc *alloc) +{ + unsigned long nr_chunks, cds_lfht_size; + + min_nr_alloc_buckets = max(min_nr_alloc_buckets, + max_nr_buckets / MAX_CHUNK_TABLE); + nr_chunks = max_nr_buckets / min_nr_alloc_buckets; + cds_lfht_size = offsetof(struct cds_lfht, tbl_chunk) + + sizeof(struct cds_lfht_node *) * nr_chunks; + cds_lfht_size = max(cds_lfht_size, sizeof(struct cds_lfht)); + + return __default_alloc_cds_lfht( + &cds_lfht_mm_chunk, alloc, cds_lfht_size, + min_nr_alloc_buckets, max_nr_buckets); +} + +const struct cds_lfht_mm_type cds_lfht_mm_chunk = { + .alloc_cds_lfht = alloc_cds_lfht, + .alloc_bucket_table = cds_lfht_alloc_bucket_table, + .free_bucket_table = cds_lfht_free_bucket_table, + .bucket_at = bucket_at, +}; diff --git a/external/lgpl2/userspace-rcu/dist/src/rculfhash-mm-mmap.c b/external/lgpl2/userspace-rcu/dist/src/rculfhash-mm-mmap.c new file mode 100644 index 0000000000000..2b4bc421bae0d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/rculfhash-mm-mmap.c @@ -0,0 +1,201 @@ +// SPDX-FileCopyrightText: 2011 Lai Jiangshan +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * mmap/reservation based memory management for Lock-Free RCU Hash Table + */ + +#include +#include +#include +#include +#include +#include +#include "rculfhash-internal.h" + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +/* + * The allocation scheme used by the mmap based RCU hash table is to make a + * large unaccessible mapping to reserve memory without allocating it. + * Then smaller chunks are allocated by overlapping read/write mappings which + * do allocate memory. Deallocation is done by an overlapping unaccessible + * mapping. + * + * This scheme was tested on Linux, macOS and Solaris. However, on Cygwin the + * mmap wrapper is based on the Windows NtMapViewOfSection API which doesn't + * support overlapping mappings. + * + * An alternative to the overlapping mappings is to use mprotect to change the + * protection on chunks of the large mapping, read/write to allocate and none + * to deallocate. This works perfecty on Cygwin and Solaris but on Linux a + * call to madvise is also required to deallocate and it just doesn't work on + * macOS. + * + * For this reason, we keep to original scheme on all platforms except Cygwin. + */ + + +/* Reserve inaccessible memory space without allocating it */ +static +void *memory_map(size_t length) +{ + void *ret; + + ret = mmap(NULL, length, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (ret == MAP_FAILED) { + perror("mmap"); + abort(); + } + return ret; +} + +static +void memory_unmap(void *ptr, size_t length) +{ + if (munmap(ptr, length)) { + perror("munmap"); + abort(); + } +} + +#ifdef __CYGWIN__ +/* Set protection to read/write to allocate a memory chunk */ +static +void memory_populate(void *ptr, size_t length) +{ + if (mprotect(ptr, length, PROT_READ | PROT_WRITE)) { + perror("mprotect"); + abort(); + } +} + +/* Set protection to none to deallocate a memory chunk */ +static +void memory_discard(void *ptr, size_t length) +{ + if (mprotect(ptr, length, PROT_NONE)) { + perror("mprotect"); + abort(); + } +} + +#else /* __CYGWIN__ */ + +static +void memory_populate(void *ptr, size_t length) +{ + if (mmap(ptr, length, PROT_READ | PROT_WRITE, + MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, + -1, 0) != ptr) { + perror("mmap"); + abort(); + } +} + +/* + * Discard garbage memory and avoid system save it when try to swap it out. + * Make it still reserved, inaccessible. + */ +static +void memory_discard(void *ptr, size_t length) +{ + if (mmap(ptr, length, PROT_NONE, + MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, + -1, 0) != ptr) { + perror("mmap"); + abort(); + } +} +#endif /* __CYGWIN__ */ + +static +void cds_lfht_alloc_bucket_table(struct cds_lfht *ht, unsigned long order) +{ + if (order == 0) { + if (ht->min_nr_alloc_buckets == ht->max_nr_buckets) { + /* small table */ + ht->tbl_mmap = ht->alloc->calloc(ht->alloc->state, + ht->max_nr_buckets, sizeof(*ht->tbl_mmap)); + urcu_posix_assert(ht->tbl_mmap); + return; + } + /* large table */ + ht->tbl_mmap = memory_map(ht->max_nr_buckets + * sizeof(*ht->tbl_mmap)); + memory_populate(ht->tbl_mmap, + ht->min_nr_alloc_buckets * sizeof(*ht->tbl_mmap)); + } else if (order > ht->min_alloc_buckets_order) { + /* large table */ + unsigned long len = 1UL << (order - 1); + + urcu_posix_assert(ht->min_nr_alloc_buckets < ht->max_nr_buckets); + memory_populate(ht->tbl_mmap + len, + len * sizeof(*ht->tbl_mmap)); + } + /* Nothing to do for 0 < order && order <= ht->min_alloc_buckets_order */ +} + +/* + * cds_lfht_free_bucket_table() should be called with decreasing order. + * When cds_lfht_free_bucket_table(0) is called, it means the whole + * lfht is destroyed. + */ +static +void cds_lfht_free_bucket_table(struct cds_lfht *ht, unsigned long order) +{ + if (order == 0) { + if (ht->min_nr_alloc_buckets == ht->max_nr_buckets) { + /* small table */ + poison_free(ht->alloc, ht->tbl_mmap); + return; + } + /* large table */ + memory_unmap(ht->tbl_mmap, + ht->max_nr_buckets * sizeof(*ht->tbl_mmap)); + } else if (order > ht->min_alloc_buckets_order) { + /* large table */ + unsigned long len = 1UL << (order - 1); + + urcu_posix_assert(ht->min_nr_alloc_buckets < ht->max_nr_buckets); + memory_discard(ht->tbl_mmap + len, len * sizeof(*ht->tbl_mmap)); + } + /* Nothing to do for 0 < order && order <= ht->min_alloc_buckets_order */ +} + +static +struct cds_lfht_node *bucket_at(struct cds_lfht *ht, unsigned long index) +{ + return &ht->tbl_mmap[index]; +} + +static +struct cds_lfht *alloc_cds_lfht(unsigned long min_nr_alloc_buckets, + unsigned long max_nr_buckets, const struct cds_lfht_alloc *alloc) +{ + unsigned long page_bucket_size; + + page_bucket_size = getpagesize() / sizeof(struct cds_lfht_node); + if (max_nr_buckets <= page_bucket_size) { + /* small table */ + min_nr_alloc_buckets = max_nr_buckets; + } else { + /* large table */ + min_nr_alloc_buckets = max(min_nr_alloc_buckets, + page_bucket_size); + } + + return __default_alloc_cds_lfht( + &cds_lfht_mm_mmap, alloc, sizeof(struct cds_lfht), + min_nr_alloc_buckets, max_nr_buckets); +} + +const struct cds_lfht_mm_type cds_lfht_mm_mmap = { + .alloc_cds_lfht = alloc_cds_lfht, + .alloc_bucket_table = cds_lfht_alloc_bucket_table, + .free_bucket_table = cds_lfht_free_bucket_table, + .bucket_at = bucket_at, +}; diff --git a/external/lgpl2/userspace-rcu/dist/src/rculfhash-mm-order.c b/external/lgpl2/userspace-rcu/dist/src/rculfhash-mm-order.c new file mode 100644 index 0000000000000..2b0f707ef05ca --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/rculfhash-mm-order.c @@ -0,0 +1,77 @@ +// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2011 Lai Jiangshan +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Order based memory management for Lock-Free RCU Hash Table + */ + +#include +#include "rculfhash-internal.h" + +static +void cds_lfht_alloc_bucket_table(struct cds_lfht *ht, unsigned long order) +{ + if (order == 0) { + ht->tbl_order[0] = ht->alloc->calloc(ht->alloc->state, + ht->min_nr_alloc_buckets, sizeof(struct cds_lfht_node)); + urcu_posix_assert(ht->tbl_order[0]); + } else if (order > ht->min_alloc_buckets_order) { + ht->tbl_order[order] = ht->alloc->calloc(ht->alloc->state, + 1UL << (order -1), sizeof(struct cds_lfht_node)); + urcu_posix_assert(ht->tbl_order[order]); + } + /* Nothing to do for 0 < order && order <= ht->min_alloc_buckets_order */ +} + +/* + * cds_lfht_free_bucket_table() should be called with decreasing order. + * When cds_lfht_free_bucket_table(0) is called, it means the whole + * lfht is destroyed. + */ +static +void cds_lfht_free_bucket_table(struct cds_lfht *ht, unsigned long order) +{ + if (order == 0) + poison_free(ht->alloc, ht->tbl_order[0]); + else if (order > ht->min_alloc_buckets_order) + poison_free(ht->alloc, ht->tbl_order[order]); + /* Nothing to do for 0 < order && order <= ht->min_alloc_buckets_order */ +} + +static +struct cds_lfht_node *bucket_at(struct cds_lfht *ht, unsigned long index) +{ + unsigned long order; + + if (index < ht->min_nr_alloc_buckets) { + dbg_printf("bucket index %lu order 0 aridx 0\n", index); + return &ht->tbl_order[0][index]; + } + /* + * equivalent to cds_lfht_get_count_order_ulong(index + 1), but + * optimizes away the non-existing 0 special-case for + * cds_lfht_get_count_order_ulong. + */ + order = cds_lfht_fls_ulong(index); + dbg_printf("bucket index %lu order %lu aridx %lu\n", + index, order, index & ((1UL << (order - 1)) - 1)); + return &ht->tbl_order[order][index & ((1UL << (order - 1)) - 1)]; +} + +static +struct cds_lfht *alloc_cds_lfht(unsigned long min_nr_alloc_buckets, + unsigned long max_nr_buckets, const struct cds_lfht_alloc *alloc) +{ + return __default_alloc_cds_lfht( + &cds_lfht_mm_order, alloc, sizeof(struct cds_lfht), + min_nr_alloc_buckets, max_nr_buckets); +} + +const struct cds_lfht_mm_type cds_lfht_mm_order = { + .alloc_cds_lfht = alloc_cds_lfht, + .alloc_bucket_table = cds_lfht_alloc_bucket_table, + .free_bucket_table = cds_lfht_free_bucket_table, + .bucket_at = bucket_at, +}; diff --git a/external/lgpl2/userspace-rcu/dist/src/rculfhash.c b/external/lgpl2/userspace-rcu/dist/src/rculfhash.c new file mode 100644 index 0000000000000..10f5b8ed58a89 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/rculfhash.c @@ -0,0 +1,2340 @@ +// SPDX-FileCopyrightText: 2010-2011 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2011 Lai Jiangshan +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU library - Lock-Free Resizable RCU Hash Table + */ + +/* + * Based on the following articles: + * - Ori Shalev and Nir Shavit. Split-ordered lists: Lock-free + * extensible hash tables. J. ACM 53, 3 (May 2006), 379-405. + * - Michael, M. M. High performance dynamic lock-free hash tables + * and list-based sets. In Proceedings of the fourteenth annual ACM + * symposium on Parallel algorithms and architectures, ACM Press, + * (2002), 73-82. + * + * Some specificities of this Lock-Free Resizable RCU Hash Table + * implementation: + * + * - RCU read-side critical section allows readers to perform hash + * table lookups, as well as traversals, and use the returned objects + * safely by allowing memory reclaim to take place only after a grace + * period. + * - Add and remove operations are lock-free, and do not need to + * allocate memory. They need to be executed within RCU read-side + * critical section to ensure the objects they read are valid and to + * deal with the cmpxchg ABA problem. + * - add and add_unique operations are supported. add_unique checks if + * the node key already exists in the hash table. It ensures not to + * populate a duplicate key if the node key already exists in the hash + * table. + * - The resize operation executes concurrently with + * add/add_unique/add_replace/remove/lookup/traversal. + * - Hash table nodes are contained within a split-ordered list. This + * list is ordered by incrementing reversed-bits-hash value. + * - An index of bucket nodes is kept. These bucket nodes are the hash + * table "buckets". These buckets are internal nodes that allow to + * perform a fast hash lookup, similarly to a skip list. These + * buckets are chained together in the split-ordered list, which + * allows recursive expansion by inserting new buckets between the + * existing buckets. The split-ordered list allows adding new buckets + * between existing buckets as the table needs to grow. + * - The resize operation for small tables only allows expanding the + * hash table. It is triggered automatically by detecting long chains + * in the add operation. + * - The resize operation for larger tables (and available through an + * API) allows both expanding and shrinking the hash table. + * - Split-counters are used to keep track of the number of + * nodes within the hash table for automatic resize triggering. + * - Resize operation initiated by long chain detection is executed by a + * worker thread, which keeps lock-freedom of add and remove. + * - Resize operations are protected by a mutex. + * - The removal operation is split in two parts: first, a "removed" + * flag is set in the next pointer within the node to remove. Then, + * a "garbage collection" is performed in the bucket containing the + * removed node (from the start of the bucket up to the removed node). + * All encountered nodes with "removed" flag set in their next + * pointers are removed from the linked-list. If the cmpxchg used for + * removal fails (due to concurrent garbage-collection or concurrent + * add), we retry from the beginning of the bucket. This ensures that + * the node with "removed" flag set is removed from the hash table + * (not visible to lookups anymore) before the RCU read-side critical + * section held across removal ends. Furthermore, this ensures that + * the node with "removed" flag set is removed from the linked-list + * before its memory is reclaimed. After setting the "removal" flag, + * only the thread which removal is the first to set the "removal + * owner" flag (with an xchg) into a node's next pointer is considered + * to have succeeded its removal (and thus owns the node to reclaim). + * Because we garbage-collect starting from an invariant node (the + * start-of-bucket bucket node) up to the "removed" node (or find a + * reverse-hash that is higher), we are sure that a successful + * traversal of the chain leads to a chain that is present in the + * linked-list (the start node is never removed) and that it does not + * contain the "removed" node anymore, even if concurrent delete/add + * operations are changing the structure of the list concurrently. + * - The add operations perform garbage collection of buckets if they + * encounter nodes with removed flag set in the bucket where they want + * to add their new node. This ensures lock-freedom of add operation by + * helping the remover unlink nodes from the list rather than to wait + * for it do to so. + * - There are three memory backends for the hash table buckets: the + * "order table", the "chunks", and the "mmap". + * - These bucket containers contain a compact version of the hash table + * nodes. + * - The RCU "order table": + * - has a first level table indexed by log2(hash index) which is + * copied and expanded by the resize operation. This order table + * allows finding the "bucket node" tables. + * - There is one bucket node table per hash index order. The size of + * each bucket node table is half the number of hashes contained in + * this order (except for order 0). + * - The RCU "chunks" is best suited for close interaction with a page + * allocator. It uses a linear array as index to "chunks" containing + * each the same number of buckets. + * - The RCU "mmap" memory backend uses a single memory map to hold + * all buckets. + * - synchronize_rcu is used to garbage-collect the old bucket node table. + * + * Ordering Guarantees: + * + * To discuss these guarantees, we first define "read" operation as any + * of the the basic cds_lfht_lookup, cds_lfht_next_duplicate, + * cds_lfht_first, cds_lfht_next operation, as well as + * cds_lfht_add_unique (failure). + * + * We define "read traversal" operation as any of the following + * group of operations + * - cds_lfht_lookup followed by iteration with cds_lfht_next_duplicate + * (and/or cds_lfht_next, although less common). + * - cds_lfht_add_unique (failure) followed by iteration with + * cds_lfht_next_duplicate (and/or cds_lfht_next, although less + * common). + * - cds_lfht_first followed iteration with cds_lfht_next (and/or + * cds_lfht_next_duplicate, although less common). + * + * We define "write" operations as any of cds_lfht_add, cds_lfht_replace, + * cds_lfht_add_unique (success), cds_lfht_add_replace, cds_lfht_del. + * + * When cds_lfht_add_unique succeeds (returns the node passed as + * parameter), it acts as a "write" operation. When cds_lfht_add_unique + * fails (returns a node different from the one passed as parameter), it + * acts as a "read" operation. A cds_lfht_add_unique failure is a + * cds_lfht_lookup "read" operation, therefore, any ordering guarantee + * referring to "lookup" imply any of "lookup" or cds_lfht_add_unique + * (failure). + * + * We define "prior" and "later" node as nodes observable by reads and + * read traversals respectively before and after a write or sequence of + * write operations. + * + * Hash-table operations are often cascaded, for example, the pointer + * returned by a cds_lfht_lookup() might be passed to a cds_lfht_next(), + * whose return value might in turn be passed to another hash-table + * operation. This entire cascaded series of operations must be enclosed + * by a pair of matching rcu_read_lock() and rcu_read_unlock() + * operations. + * + * The following ordering guarantees are offered by this hash table: + * + * A.1) "read" after "write": if there is ordering between a write and a + * later read, then the read is guaranteed to see the write or some + * later write. + * A.2) "read traversal" after "write": given that there is dependency + * ordering between reads in a "read traversal", if there is + * ordering between a write and the first read of the traversal, + * then the "read traversal" is guaranteed to see the write or + * some later write. + * B.1) "write" after "read": if there is ordering between a read and a + * later write, then the read will never see the write. + * B.2) "write" after "read traversal": given that there is dependency + * ordering between reads in a "read traversal", if there is + * ordering between the last read of the traversal and a later + * write, then the "read traversal" will never see the write. + * C) "write" while "read traversal": if a write occurs during a "read + * traversal", the traversal may, or may not, see the write. + * D.1) "write" after "write": if there is ordering between a write and + * a later write, then the later write is guaranteed to see the + * effects of the first write. + * D.2) Concurrent "write" pairs: The system will assign an arbitrary + * order to any pair of concurrent conflicting writes. + * Non-conflicting writes (for example, to different keys) are + * unordered. + * E) If a grace period separates a "del" or "replace" operation + * and a subsequent operation, then that subsequent operation is + * guaranteed not to see the removed item. + * F) Uniqueness guarantee: given a hash table that does not contain + * duplicate items for a given key, there will only be one item in + * the hash table after an arbitrary sequence of add_unique and/or + * add_replace operations. Note, however, that a pair of + * concurrent read operations might well access two different items + * with that key. + * G.1) If a pair of lookups for a given key are ordered (e.g. by a + * memory barrier), then the second lookup will return the same + * node as the previous lookup, or some later node. + * G.2) A "read traversal" that starts after the end of a prior "read + * traversal" (ordered by memory barriers) is guaranteed to see the + * same nodes as the previous traversal, or some later nodes. + * G.3) Concurrent "read" pairs: concurrent reads are unordered. For + * example, if a pair of reads to the same key run concurrently + * with an insertion of that same key, the reads remain unordered + * regardless of their return values. In other words, you cannot + * rely on the values returned by the reads to deduce ordering. + * + * Progress guarantees: + * + * * Reads are wait-free. These operations always move forward in the + * hash table linked list, and this list has no loop. + * * Writes are lock-free. Any retry loop performed by a write operation + * is triggered by progress made within another update operation. + * + * Bucket node tables: + * + * hash table hash table the last all bucket node tables + * order size bucket node 0 1 2 3 4 5 6(index) + * table size + * 0 1 1 1 + * 1 2 1 1 1 + * 2 4 2 1 1 2 + * 3 8 4 1 1 2 4 + * 4 16 8 1 1 2 4 8 + * 5 32 16 1 1 2 4 8 16 + * 6 64 32 1 1 2 4 8 16 32 + * + * When growing/shrinking, we only focus on the last bucket node table + * which size is (!order ? 1 : (1 << (order -1))). + * + * Example for growing/shrinking: + * grow hash table from order 5 to 6: init the index=6 bucket node table + * shrink hash table from order 6 to 5: fini the index=6 bucket node table + * + * A bit of ascii art explanation: + * + * The order index is the off-by-one compared to the actual power of 2 + * because we use index 0 to deal with the 0 special-case. + * + * This shows the nodes for a small table ordered by reversed bits: + * + * bits reverse + * 0 000 000 + * 4 100 001 + * 2 010 010 + * 6 110 011 + * 1 001 100 + * 5 101 101 + * 3 011 110 + * 7 111 111 + * + * This shows the nodes in order of non-reversed bits, linked by + * reversed-bit order. + * + * order bits reverse + * 0 0 000 000 + * 1 | 1 001 100 <- + * 2 | | 2 010 010 <- | + * | | | 3 011 110 | <- | + * 3 -> | | | 4 100 001 | | + * -> | | 5 101 101 | + * -> | 6 110 011 + * -> 7 111 111 + */ + +#define _LGPL_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include + +#include "compat-getcpu.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "rculfhash-internal.h" +#include "workqueue.h" +#include "urcu-die.h" +#include "urcu-utils.h" +#include "compat-smp.h" + +/* + * Split-counters lazily update the global counter each 1024 + * addition/removal. It automatically keeps track of resize required. + * We use the bucket length as indicator for need to expand for small + * tables and machines lacking per-cpu data support. + */ +#define COUNT_COMMIT_ORDER 10 +#define DEFAULT_SPLIT_COUNT_MASK 0xFUL +#define CHAIN_LEN_TARGET 1 +#define CHAIN_LEN_RESIZE_THRESHOLD 3 + +/* + * Define the minimum table size. + */ +#define MIN_TABLE_ORDER 0 +#define MIN_TABLE_SIZE (1UL << MIN_TABLE_ORDER) + +/* + * Minimum number of bucket nodes to touch per thread to parallelize grow/shrink. + */ +#define MIN_PARTITION_PER_THREAD_ORDER 12 +#define MIN_PARTITION_PER_THREAD (1UL << MIN_PARTITION_PER_THREAD_ORDER) + +/* + * The removed flag needs to be updated atomically with the pointer. + * It indicates that no node must attach to the node scheduled for + * removal, and that node garbage collection must be performed. + * The bucket flag does not require to be updated atomically with the + * pointer, but it is added as a pointer low bit flag to save space. + * The "removal owner" flag is used to detect which of the "del" + * operation that has set the "removed flag" gets to return the removed + * node to its caller. Note that the replace operation does not need to + * iteract with the "removal owner" flag, because it validates that + * the "removed" flag is not set before performing its cmpxchg. + */ +#define REMOVED_FLAG (1UL << 0) +#define BUCKET_FLAG (1UL << 1) +#define REMOVAL_OWNER_FLAG (1UL << 2) +#define FLAGS_MASK ((1UL << 3) - 1) + +/* Value of the end pointer. Should not interact with flags. */ +#define END_VALUE NULL + +/* + * ht_items_count: Split-counters counting the number of node addition + * and removal in the table. Only used if the CDS_LFHT_ACCOUNTING flag + * is set at hash table creation. + * + * These are free-running counters, never reset to zero. They count the + * number of add/remove, and trigger every (1 << COUNT_COMMIT_ORDER) + * operations to update the global counter. We choose a power-of-2 value + * for the trigger to deal with 32 or 64-bit overflow of the counter. + */ +struct ht_items_count { + unsigned long add, del; +} __attribute__((aligned(CAA_CACHE_LINE_SIZE))); + +/* + * resize_work: Contains arguments passed to worker thread + * responsible for performing lazy resize. + */ +struct resize_work { + struct urcu_work work; + struct cds_lfht *ht; +}; + +/* + * partition_resize_work: Contains arguments passed to worker threads + * executing the hash table resize on partitions of the hash table + * assigned to each processor's worker thread. + */ +struct partition_resize_work { + pthread_t thread_id; + struct cds_lfht *ht; + unsigned long i, start, len; + void (*fct)(struct cds_lfht *ht, unsigned long i, + unsigned long start, unsigned long len); +}; + +enum nr_cpus_mask_state { + NR_CPUS_MASK_INIT_FAILED = -2, + NR_CPUS_MASK_UNINITIALIZED = -1, +}; + +static struct urcu_workqueue *cds_lfht_workqueue; + +/* + * Mutex ensuring mutual exclusion between workqueue initialization and + * fork handlers. cds_lfht_fork_mutex nests inside call_rcu_mutex. + */ +static pthread_mutex_t cds_lfht_fork_mutex = PTHREAD_MUTEX_INITIALIZER; + +static struct urcu_atfork cds_lfht_atfork; + +/* + * atfork handler nesting counters. Handle being registered to many urcu + * flavors, thus being possibly invoked more than once in the + * pthread_atfork list of callbacks. + */ +static int cds_lfht_workqueue_atfork_nesting; + +static void __attribute__((destructor)) cds_lfht_exit(void); +static void cds_lfht_init_worker(const struct rcu_flavor_struct *flavor); + +#ifdef CONFIG_CDS_LFHT_ITER_DEBUG + +static +void cds_lfht_iter_debug_set_ht(struct cds_lfht *ht, struct cds_lfht_iter *iter) +{ + iter->lfht = ht; +} + +#define cds_lfht_iter_debug_assert(...) urcu_posix_assert(__VA_ARGS__) + +#else + +static +void cds_lfht_iter_debug_set_ht(struct cds_lfht *ht __attribute__((unused)), + struct cds_lfht_iter *iter __attribute__((unused))) +{ +} + +#define cds_lfht_iter_debug_assert(...) + +#endif + +/* + * Algorithm to reverse bits in a word by lookup table, extended to + * 64-bit words. + * Source: + * http://graphics.stanford.edu/~seander/bithacks.html#BitReverseTable + * Originally from Public Domain. + */ + +static const uint8_t BitReverseTable256[256] = +{ +#define R2(n) (n), (n) + 2*64, (n) + 1*64, (n) + 3*64 +#define R4(n) R2(n), R2((n) + 2*16), R2((n) + 1*16), R2((n) + 3*16) +#define R6(n) R4(n), R4((n) + 2*4 ), R4((n) + 1*4 ), R4((n) + 3*4 ) + R6(0), R6(2), R6(1), R6(3) +}; +#undef R2 +#undef R4 +#undef R6 + +static +uint8_t bit_reverse_u8(uint8_t v) +{ + return BitReverseTable256[v]; +} + +#if (CAA_BITS_PER_LONG == 32) +static +uint32_t bit_reverse_u32(uint32_t v) +{ + return ((uint32_t) bit_reverse_u8(v) << 24) | + ((uint32_t) bit_reverse_u8(v >> 8) << 16) | + ((uint32_t) bit_reverse_u8(v >> 16) << 8) | + ((uint32_t) bit_reverse_u8(v >> 24)); +} +#else +static +uint64_t bit_reverse_u64(uint64_t v) +{ + return ((uint64_t) bit_reverse_u8(v) << 56) | + ((uint64_t) bit_reverse_u8(v >> 8) << 48) | + ((uint64_t) bit_reverse_u8(v >> 16) << 40) | + ((uint64_t) bit_reverse_u8(v >> 24) << 32) | + ((uint64_t) bit_reverse_u8(v >> 32) << 24) | + ((uint64_t) bit_reverse_u8(v >> 40) << 16) | + ((uint64_t) bit_reverse_u8(v >> 48) << 8) | + ((uint64_t) bit_reverse_u8(v >> 56)); +} +#endif + +static +unsigned long bit_reverse_ulong(unsigned long v) +{ +#if (CAA_BITS_PER_LONG == 32) + return bit_reverse_u32(v); +#else + return bit_reverse_u64(v); +#endif +} + +/* + * fls: returns the position of the most significant bit. + * Returns 0 if no bit is set, else returns the position of the most + * significant bit (from 1 to 32 on 32-bit, from 1 to 64 on 64-bit). + */ +#if defined(URCU_ARCH_X86) +static inline +unsigned int fls_u32(uint32_t x) +{ + int r; + + __asm__ ("bsrl %1,%0\n\t" + "jnz 1f\n\t" + "movl $-1,%0\n\t" + "1:\n\t" + : "=r" (r) : "rm" (x)); + return r + 1; +} +#define HAS_FLS_U32 +#endif + +#if defined(URCU_ARCH_AMD64) +static inline +unsigned int fls_u64(uint64_t x) +{ + long r; + + __asm__ ("bsrq %1,%0\n\t" + "jnz 1f\n\t" + "movq $-1,%0\n\t" + "1:\n\t" + : "=r" (r) : "rm" (x)); + return r + 1; +} +#define HAS_FLS_U64 +#endif + +#ifndef HAS_FLS_U64 +static __attribute__((unused)) +unsigned int fls_u64(uint64_t x) +{ + unsigned int r = 64; + + if (!x) + return 0; + + if (!(x & 0xFFFFFFFF00000000ULL)) { + x <<= 32; + r -= 32; + } + if (!(x & 0xFFFF000000000000ULL)) { + x <<= 16; + r -= 16; + } + if (!(x & 0xFF00000000000000ULL)) { + x <<= 8; + r -= 8; + } + if (!(x & 0xF000000000000000ULL)) { + x <<= 4; + r -= 4; + } + if (!(x & 0xC000000000000000ULL)) { + x <<= 2; + r -= 2; + } + if (!(x & 0x8000000000000000ULL)) { + x <<= 1; + r -= 1; + } + return r; +} +#endif + +#ifndef HAS_FLS_U32 +static __attribute__((unused)) +unsigned int fls_u32(uint32_t x) +{ + unsigned int r = 32; + + if (!x) + return 0; + if (!(x & 0xFFFF0000U)) { + x <<= 16; + r -= 16; + } + if (!(x & 0xFF000000U)) { + x <<= 8; + r -= 8; + } + if (!(x & 0xF0000000U)) { + x <<= 4; + r -= 4; + } + if (!(x & 0xC0000000U)) { + x <<= 2; + r -= 2; + } + if (!(x & 0x80000000U)) { + x <<= 1; + r -= 1; + } + return r; +} +#endif + +unsigned int cds_lfht_fls_ulong(unsigned long x) +{ +#if (CAA_BITS_PER_LONG == 32) + return fls_u32(x); +#else + return fls_u64(x); +#endif +} + +static void *cds_lfht_malloc(void *state __attribute__((unused)), + size_t size) +{ + return malloc(size); +} + +static void *cds_lfht_calloc(void *state __attribute__((unused)), + size_t nmemb, size_t size) +{ + return calloc(nmemb, size); +} + +static void *cds_lfht_realloc(void *state __attribute__((unused)), + void *ptr, size_t size) +{ + return realloc(ptr, size); +} + +static void *cds_lfht_aligned_alloc(void *state __attribute__((unused)), + size_t alignment, size_t size) +{ + void *ptr; + + if (posix_memalign(&ptr, alignment, size)) + return NULL; + return ptr; +} + +static void cds_lfht_free(void *state __attribute__((unused)), void *ptr) +{ + free(ptr); +} + + +/* Default memory allocator */ +static struct cds_lfht_alloc cds_lfht_default_alloc = { + .malloc = cds_lfht_malloc, + .calloc = cds_lfht_calloc, + .realloc = cds_lfht_realloc, + .aligned_alloc = cds_lfht_aligned_alloc, + .free = cds_lfht_free, + .state = NULL, +}; + +/* + * Return the minimum order for which x <= (1UL << order). + * Return -1 if x is 0. + */ +static +int cds_lfht_get_count_order_u32(uint32_t x) +{ + if (!x) + return -1; + + return fls_u32(x - 1); +} + +/* + * Return the minimum order for which x <= (1UL << order). + * Return -1 if x is 0. + */ +int cds_lfht_get_count_order_ulong(unsigned long x) +{ + if (!x) + return -1; + + return cds_lfht_fls_ulong(x - 1); +} + +static +void cds_lfht_resize_lazy_grow(struct cds_lfht *ht, unsigned long size, int growth); + +static +void cds_lfht_resize_lazy_count(struct cds_lfht *ht, unsigned long size, + unsigned long count); + +static void mutex_lock(pthread_mutex_t *mutex) +{ + int ret; + +#ifndef DISTRUST_SIGNALS_EXTREME + ret = pthread_mutex_lock(mutex); + if (ret) + urcu_die(ret); +#else /* #ifndef DISTRUST_SIGNALS_EXTREME */ + while ((ret = pthread_mutex_trylock(mutex)) != 0) { + if (ret != EBUSY && ret != EINTR) + urcu_die(ret); + if (CMM_LOAD_SHARED(URCU_TLS(rcu_reader).need_mb)) { + uatomic_store(&URCU_TLS(rcu_reader).need_mb, 0, CMM_SEQ_CST); + } + (void) poll(NULL, 0, 10); + } +#endif /* #else #ifndef DISTRUST_SIGNALS_EXTREME */ +} + +static void mutex_unlock(pthread_mutex_t *mutex) +{ + int ret; + + ret = pthread_mutex_unlock(mutex); + if (ret) + urcu_die(ret); +} + +static long nr_cpus_mask = NR_CPUS_MASK_UNINITIALIZED; +static long split_count_mask = -1; +static int split_count_order = -1; + +static void ht_init_nr_cpus_mask(void) +{ + long maxcpus; + + maxcpus = get_possible_cpus_array_len(); + if (maxcpus <= 0) { + nr_cpus_mask = NR_CPUS_MASK_INIT_FAILED; + return; + } + /* + * round up number of CPUs to next power of two, so we + * can use & for modulo. + */ + maxcpus = 1UL << cds_lfht_get_count_order_ulong(maxcpus); + nr_cpus_mask = maxcpus - 1; +} + +static +void alloc_split_items_count(struct cds_lfht *ht) +{ + if (nr_cpus_mask == NR_CPUS_MASK_UNINITIALIZED) { + ht_init_nr_cpus_mask(); + if (nr_cpus_mask < 0) + split_count_mask = DEFAULT_SPLIT_COUNT_MASK; + else + split_count_mask = nr_cpus_mask; + split_count_order = + cds_lfht_get_count_order_ulong(split_count_mask + 1); + } + + urcu_posix_assert(split_count_mask >= 0); + + if (ht->flags & CDS_LFHT_ACCOUNTING) { + ht->split_count = ht->alloc->calloc(ht->alloc->state, split_count_mask + 1, + sizeof(struct ht_items_count)); + urcu_posix_assert(ht->split_count); + } else { + ht->split_count = NULL; + } +} + +static +void free_split_items_count(struct cds_lfht *ht) +{ + poison_free(ht->alloc, ht->split_count); +} + +static +int ht_get_split_count_index(unsigned long hash) +{ + int cpu; + + urcu_posix_assert(split_count_mask >= 0); + cpu = urcu_sched_getcpu(); + if (caa_unlikely(cpu < 0)) + return hash & split_count_mask; + else + return cpu & split_count_mask; +} + +static +void ht_count_add(struct cds_lfht *ht, unsigned long size, unsigned long hash) +{ + unsigned long split_count, count; + int index; + + if (caa_unlikely(!ht->split_count)) + return; + index = ht_get_split_count_index(hash); + split_count = uatomic_add_return(&ht->split_count[index].add, 1); + if (caa_likely(split_count & ((1UL << COUNT_COMMIT_ORDER) - 1))) + return; + /* Only if number of add multiple of 1UL << COUNT_COMMIT_ORDER */ + + dbg_printf("add split count %lu\n", split_count); + count = uatomic_add_return(&ht->count, + 1UL << COUNT_COMMIT_ORDER); + if (caa_likely(count & (count - 1))) + return; + /* Only if global count is power of 2 */ + + if ((count >> CHAIN_LEN_RESIZE_THRESHOLD) < size) + return; + dbg_printf("add set global %lu\n", count); + cds_lfht_resize_lazy_count(ht, size, + count >> (CHAIN_LEN_TARGET - 1)); +} + +static +void ht_count_del(struct cds_lfht *ht, unsigned long size, unsigned long hash) +{ + unsigned long split_count, count; + int index; + + if (caa_unlikely(!ht->split_count)) + return; + index = ht_get_split_count_index(hash); + split_count = uatomic_add_return(&ht->split_count[index].del, 1); + if (caa_likely(split_count & ((1UL << COUNT_COMMIT_ORDER) - 1))) + return; + /* Only if number of deletes multiple of 1UL << COUNT_COMMIT_ORDER */ + + dbg_printf("del split count %lu\n", split_count); + count = uatomic_add_return(&ht->count, + -(1UL << COUNT_COMMIT_ORDER)); + if (caa_likely(count & (count - 1))) + return; + /* Only if global count is power of 2 */ + + if ((count >> CHAIN_LEN_RESIZE_THRESHOLD) >= size) + return; + dbg_printf("del set global %lu\n", count); + /* + * Don't shrink table if the number of nodes is below a + * certain threshold. + */ + if (count < (1UL << COUNT_COMMIT_ORDER) * (split_count_mask + 1)) + return; + cds_lfht_resize_lazy_count(ht, size, + count >> (CHAIN_LEN_TARGET - 1)); +} + +static +void check_resize(struct cds_lfht *ht, unsigned long size, uint32_t chain_len) +{ + unsigned long count; + + if (!(ht->flags & CDS_LFHT_AUTO_RESIZE)) + return; + count = uatomic_read(&ht->count); + /* + * Use bucket-local length for small table expand and for + * environments lacking per-cpu data support. + */ + if (count >= (1UL << (COUNT_COMMIT_ORDER + split_count_order))) + return; + if (chain_len > 100) + dbg_printf("WARNING: large chain length: %u.\n", + chain_len); + if (chain_len >= CHAIN_LEN_RESIZE_THRESHOLD) { + int growth; + + /* + * Ideal growth calculated based on chain length. + */ + growth = cds_lfht_get_count_order_u32(chain_len + - (CHAIN_LEN_TARGET - 1)); + if ((ht->flags & CDS_LFHT_ACCOUNTING) + && (size << growth) + >= (1UL << (COUNT_COMMIT_ORDER + + split_count_order))) { + /* + * If ideal growth expands the hash table size + * beyond the "small hash table" sizes, use the + * maximum small hash table size to attempt + * expanding the hash table. This only applies + * when node accounting is available, otherwise + * the chain length is used to expand the hash + * table in every case. + */ + growth = COUNT_COMMIT_ORDER + split_count_order + - cds_lfht_get_count_order_ulong(size); + if (growth <= 0) + return; + } + cds_lfht_resize_lazy_grow(ht, size, growth); + } +} + +static +struct cds_lfht_node *clear_flag(struct cds_lfht_node *node) +{ + return (struct cds_lfht_node *) (((unsigned long) node) & ~FLAGS_MASK); +} + +static +int is_removed(const struct cds_lfht_node *node) +{ + return ((unsigned long) node) & REMOVED_FLAG; +} + +static +int is_bucket(struct cds_lfht_node *node) +{ + return ((unsigned long) node) & BUCKET_FLAG; +} + +static +struct cds_lfht_node *flag_bucket(struct cds_lfht_node *node) +{ + return (struct cds_lfht_node *) (((unsigned long) node) | BUCKET_FLAG); +} + +static +int is_removal_owner(struct cds_lfht_node *node) +{ + return ((unsigned long) node) & REMOVAL_OWNER_FLAG; +} + +static +struct cds_lfht_node *flag_removed(struct cds_lfht_node *node) +{ + return (struct cds_lfht_node *) (((unsigned long) node) | REMOVED_FLAG); +} + +static +struct cds_lfht_node *flag_removal_owner(struct cds_lfht_node *node) +{ + return (struct cds_lfht_node *) (((unsigned long) node) | REMOVAL_OWNER_FLAG); +} + +static +struct cds_lfht_node *flag_removed_or_removal_owner(struct cds_lfht_node *node) +{ + return (struct cds_lfht_node *) (((unsigned long) node) | REMOVED_FLAG | REMOVAL_OWNER_FLAG); +} + +static +struct cds_lfht_node *get_end(void) +{ + return (struct cds_lfht_node *) END_VALUE; +} + +static +int is_end(struct cds_lfht_node *node) +{ + return clear_flag(node) == (struct cds_lfht_node *) END_VALUE; +} + +static +unsigned long _uatomic_xchg_monotonic_increase(unsigned long *ptr, + unsigned long v) +{ + unsigned long old1, old2; + + old1 = uatomic_read(ptr); + do { + old2 = old1; + if (old2 >= v) { + cmm_smp_mb(); + return old2; + } + } while ((old1 = uatomic_cmpxchg(ptr, old2, v)) != old2); + return old2; +} + +static +void cds_lfht_alloc_bucket_table(struct cds_lfht *ht, unsigned long order) +{ + return ht->mm->alloc_bucket_table(ht, order); +} + +/* + * cds_lfht_free_bucket_table() should be called with decreasing order. + * When cds_lfht_free_bucket_table(0) is called, it means the whole + * lfht is destroyed. + */ +static +void cds_lfht_free_bucket_table(struct cds_lfht *ht, unsigned long order) +{ + return ht->mm->free_bucket_table(ht, order); +} + +static inline +struct cds_lfht_node *bucket_at(struct cds_lfht *ht, unsigned long index) +{ + return ht->bucket_at(ht, index); +} + +static inline +struct cds_lfht_node *lookup_bucket(struct cds_lfht *ht, unsigned long size, + unsigned long hash) +{ + urcu_posix_assert(size > 0); + return bucket_at(ht, hash & (size - 1)); +} + +/* + * Remove all logically deleted nodes from a bucket up to a certain node key. + */ +static +void _cds_lfht_gc_bucket(struct cds_lfht_node *bucket, struct cds_lfht_node *node) +{ + struct cds_lfht_node *iter_prev, *iter, *next, *new_next; + + urcu_posix_assert(!is_bucket(bucket)); + urcu_posix_assert(!is_removed(bucket)); + urcu_posix_assert(!is_removal_owner(bucket)); + urcu_posix_assert(!is_bucket(node)); + urcu_posix_assert(!is_removed(node)); + urcu_posix_assert(!is_removal_owner(node)); + for (;;) { + iter_prev = bucket; + /* We can always skip the bucket node initially */ + iter = rcu_dereference(iter_prev->next); + urcu_posix_assert(!is_removed(iter)); + urcu_posix_assert(!is_removal_owner(iter)); + urcu_posix_assert(iter_prev->reverse_hash <= node->reverse_hash); + /* + * We should never be called with bucket (start of chain) + * and logically removed node (end of path compression + * marker) being the actual same node. This would be a + * bug in the algorithm implementation. + */ + urcu_posix_assert(bucket != node); + for (;;) { + if (caa_unlikely(is_end(iter))) + return; + if (caa_likely(clear_flag(iter)->reverse_hash > node->reverse_hash)) + return; + next = rcu_dereference(clear_flag(iter)->next); + if (caa_likely(is_removed(next))) + break; + iter_prev = clear_flag(iter); + iter = next; + } + urcu_posix_assert(!is_removed(iter)); + urcu_posix_assert(!is_removal_owner(iter)); + if (is_bucket(iter)) + new_next = flag_bucket(clear_flag(next)); + else + new_next = clear_flag(next); + (void) uatomic_cmpxchg(&iter_prev->next, iter, new_next); + } +} + +static +int _cds_lfht_replace(struct cds_lfht *ht, unsigned long size, + struct cds_lfht_node *old_node, + struct cds_lfht_node *old_next, + struct cds_lfht_node *new_node) +{ + struct cds_lfht_node *bucket, *ret_next; + + if (!old_node) /* Return -ENOENT if asked to replace NULL node */ + return -ENOENT; + + urcu_posix_assert(!is_removed(old_node)); + urcu_posix_assert(!is_removal_owner(old_node)); + urcu_posix_assert(!is_bucket(old_node)); + urcu_posix_assert(!is_removed(new_node)); + urcu_posix_assert(!is_removal_owner(new_node)); + urcu_posix_assert(!is_bucket(new_node)); + urcu_posix_assert(new_node != old_node); + for (;;) { + /* Insert after node to be replaced */ + if (is_removed(old_next)) { + /* + * Too late, the old node has been removed under us + * between lookup and replace. Fail. + */ + return -ENOENT; + } + urcu_posix_assert(old_next == clear_flag(old_next)); + urcu_posix_assert(new_node != old_next); + /* + * REMOVAL_OWNER flag is _NEVER_ set before the REMOVED + * flag. It is either set atomically at the same time + * (replace) or after (del). + */ + urcu_posix_assert(!is_removal_owner(old_next)); + new_node->next = old_next; + /* + * Here is the whole trick for lock-free replace: we add + * the replacement node _after_ the node we want to + * replace by atomically setting its next pointer at the + * same time we set its removal flag. Given that + * the lookups/get next use an iterator aware of the + * next pointer, they will either skip the old node due + * to the removal flag and see the new node, or use + * the old node, but will not see the new one. + * This is a replacement of a node with another node + * that has the same value: we are therefore not + * removing a value from the hash table. We set both the + * REMOVED and REMOVAL_OWNER flags atomically so we own + * the node after successful cmpxchg. + */ + ret_next = uatomic_cmpxchg(&old_node->next, + old_next, flag_removed_or_removal_owner(new_node)); + if (ret_next == old_next) + break; /* We performed the replacement. */ + old_next = ret_next; + } + + /* + * Ensure that the old node is not visible to readers anymore: + * lookup for the node, and remove it (along with any other + * logically removed node) if found. + */ + bucket = lookup_bucket(ht, size, bit_reverse_ulong(old_node->reverse_hash)); + _cds_lfht_gc_bucket(bucket, new_node); + + urcu_posix_assert(is_removed(CMM_LOAD_SHARED(old_node->next))); + return 0; +} + +/* + * A non-NULL unique_ret pointer uses the "add unique" (or uniquify) add + * mode. A NULL unique_ret allows creation of duplicate keys. + */ +static +void _cds_lfht_add(struct cds_lfht *ht, + unsigned long hash, + cds_lfht_match_fct match, + const void *key, + unsigned long size, + struct cds_lfht_node *node, + struct cds_lfht_iter *unique_ret, + int bucket_flag) +{ + struct cds_lfht_node *iter_prev, *iter, *next, *new_node, *new_next, + *return_node; + struct cds_lfht_node *bucket; + + urcu_posix_assert(!is_bucket(node)); + urcu_posix_assert(!is_removed(node)); + urcu_posix_assert(!is_removal_owner(node)); + bucket = lookup_bucket(ht, size, hash); + for (;;) { + uint32_t chain_len = 0; + + /* + * iter_prev points to the non-removed node prior to the + * insert location. + */ + iter_prev = bucket; + /* We can always skip the bucket node initially */ + iter = rcu_dereference(iter_prev->next); + urcu_posix_assert(iter_prev->reverse_hash <= node->reverse_hash); + for (;;) { + if (caa_unlikely(is_end(iter))) + goto insert; + if (caa_likely(clear_flag(iter)->reverse_hash > node->reverse_hash)) + goto insert; + + /* bucket node is the first node of the identical-hash-value chain */ + if (bucket_flag && clear_flag(iter)->reverse_hash == node->reverse_hash) + goto insert; + + next = rcu_dereference(clear_flag(iter)->next); + if (caa_unlikely(is_removed(next))) + goto gc_node; + + /* uniquely add */ + if (unique_ret + && !is_bucket(next) + && clear_flag(iter)->reverse_hash == node->reverse_hash) { + struct cds_lfht_iter d_iter = { + .node = node, + .next = iter, +#ifdef CONFIG_CDS_LFHT_ITER_DEBUG + .lfht = ht, +#endif + }; + + /* + * uniquely adding inserts the node as the first + * node of the identical-hash-value node chain. + * + * This semantic ensures no duplicated keys + * should ever be observable in the table + * (including traversing the table node by + * node by forward iterations) + */ + cds_lfht_next_duplicate(ht, match, key, &d_iter); + if (!d_iter.node) + goto insert; + + *unique_ret = d_iter; + return; + } + + /* Only account for identical reverse hash once */ + if (iter_prev->reverse_hash != clear_flag(iter)->reverse_hash + && !is_bucket(next)) + check_resize(ht, size, ++chain_len); + iter_prev = clear_flag(iter); + iter = next; + } + + insert: + urcu_posix_assert(node != clear_flag(iter)); + urcu_posix_assert(!is_removed(iter_prev)); + urcu_posix_assert(!is_removal_owner(iter_prev)); + urcu_posix_assert(!is_removed(iter)); + urcu_posix_assert(!is_removal_owner(iter)); + urcu_posix_assert(iter_prev != node); + if (!bucket_flag) + node->next = clear_flag(iter); + else + node->next = flag_bucket(clear_flag(iter)); + if (is_bucket(iter)) + new_node = flag_bucket(node); + else + new_node = node; + if (uatomic_cmpxchg(&iter_prev->next, iter, + new_node) != iter) { + continue; /* retry */ + } else { + return_node = node; + goto end; + } + + gc_node: + urcu_posix_assert(!is_removed(iter)); + urcu_posix_assert(!is_removal_owner(iter)); + if (is_bucket(iter)) + new_next = flag_bucket(clear_flag(next)); + else + new_next = clear_flag(next); + (void) uatomic_cmpxchg(&iter_prev->next, iter, new_next); + /* retry */ + } +end: + if (unique_ret) { + unique_ret->node = return_node; + /* unique_ret->next left unset, never used. */ + } +} + +static +int _cds_lfht_del(struct cds_lfht *ht, unsigned long size, + struct cds_lfht_node *node) +{ + struct cds_lfht_node *bucket, *next; + uintptr_t *node_next; + + if (!node) /* Return -ENOENT if asked to delete NULL node */ + return -ENOENT; + + /* logically delete the node */ + urcu_posix_assert(!is_bucket(node)); + urcu_posix_assert(!is_removed(node)); + urcu_posix_assert(!is_removal_owner(node)); + + /* + * We are first checking if the node had previously been + * logically removed (this check is not atomic with setting the + * logical removal flag). Return -ENOENT if the node had + * previously been removed. + */ + next = CMM_LOAD_SHARED(node->next); /* next is not dereferenced */ + if (caa_unlikely(is_removed(next))) + return -ENOENT; + urcu_posix_assert(!is_bucket(next)); + /* + * The del operation semantic guarantees a full memory barrier + * before the uatomic_or atomic commit of the deletion flag. + * + * We set the REMOVED_FLAG unconditionally. Note that there may + * be more than one concurrent thread setting this flag. + * Knowing which wins the race will be known after the garbage + * collection phase, stay tuned! + * + * NOTE: The node_next variable is present to avoid breaking + * strict-aliasing rules. + */ + node_next = (uintptr_t*)&node->next; + uatomic_or_mo(node_next, REMOVED_FLAG, CMM_RELEASE); + + /* We performed the (logical) deletion. */ + + /* + * Ensure that the node is not visible to readers anymore: lookup for + * the node, and remove it (along with any other logically removed node) + * if found. + */ + bucket = lookup_bucket(ht, size, bit_reverse_ulong(node->reverse_hash)); + _cds_lfht_gc_bucket(bucket, node); + + urcu_posix_assert(is_removed(CMM_LOAD_SHARED(node->next))); + /* + * Last phase: atomically exchange node->next with a version + * having "REMOVAL_OWNER_FLAG" set. If the returned node->next + * pointer did _not_ have "REMOVAL_OWNER_FLAG" set, we now own + * the node and win the removal race. + * It is interesting to note that all "add" paths are forbidden + * to change the next pointer starting from the point where the + * REMOVED_FLAG is set, so here using a read, followed by a + * xchg() suffice to guarantee that the xchg() will ever only + * set the "REMOVAL_OWNER_FLAG" (or change nothing if the flag + * was already set). + */ + if (!is_removal_owner(uatomic_xchg(&node->next, + flag_removal_owner(uatomic_load(&node->next, CMM_RELAXED))))) + return 0; + else + return -ENOENT; +} + +static +void *partition_resize_thread(void *arg) +{ + struct partition_resize_work *work = arg; + + work->ht->flavor->register_thread(); + work->fct(work->ht, work->i, work->start, work->len); + work->ht->flavor->unregister_thread(); + return NULL; +} + +static +void partition_resize_helper(struct cds_lfht *ht, unsigned long i, + unsigned long len, + void (*fct)(struct cds_lfht *ht, unsigned long i, + unsigned long start, unsigned long len)) +{ + unsigned long partition_len, start = 0; + struct partition_resize_work *work; + int ret; + unsigned long thread, nr_threads; + sigset_t newmask, oldmask; + + urcu_posix_assert(nr_cpus_mask != NR_CPUS_MASK_UNINITIALIZED); + if (nr_cpus_mask < 0 || len < 2 * MIN_PARTITION_PER_THREAD) + goto fallback; + + /* + * Note: nr_cpus_mask + 1 is always power of 2. + * We spawn just the number of threads we need to satisfy the minimum + * partition size, up to the number of CPUs in the system. + */ + if (nr_cpus_mask > 0) { + nr_threads = min_t(unsigned long, nr_cpus_mask + 1, + len >> MIN_PARTITION_PER_THREAD_ORDER); + } else { + nr_threads = 1; + } + partition_len = len >> cds_lfht_get_count_order_ulong(nr_threads); + work = ht->alloc->calloc(ht->alloc->state, nr_threads, sizeof(*work)); + if (!work) { + dbg_printf("error allocating for resize, single-threading\n"); + goto fallback; + } + + ret = sigfillset(&newmask); + urcu_posix_assert(!ret); + ret = pthread_sigmask(SIG_BLOCK, &newmask, &oldmask); + urcu_posix_assert(!ret); + + for (thread = 0; thread < nr_threads; thread++) { + work[thread].ht = ht; + work[thread].i = i; + work[thread].len = partition_len; + work[thread].start = thread * partition_len; + work[thread].fct = fct; + ret = pthread_create(&(work[thread].thread_id), + ht->caller_resize_attr ? &ht->resize_attr : NULL, + partition_resize_thread, &work[thread]); + if (ret == EAGAIN) { + /* + * Out of resources: wait and join the threads + * we've created, then handle leftovers. + */ + dbg_printf("error spawning for resize, single-threading\n"); + start = work[thread].start; + len -= start; + nr_threads = thread; + break; + } + urcu_posix_assert(!ret); + } + + ret = pthread_sigmask(SIG_SETMASK, &oldmask, NULL); + urcu_posix_assert(!ret); + + for (thread = 0; thread < nr_threads; thread++) { + ret = pthread_join(work[thread].thread_id, NULL); + urcu_posix_assert(!ret); + } + ht->alloc->free(ht->alloc->state, work); + + /* + * A pthread_create failure above will either lead in us having + * no threads to join or starting at a non-zero offset, + * fallback to single thread processing of leftovers. + */ + if (start == 0 && nr_threads > 0) + return; +fallback: + fct(ht, i, start, len); +} + +/* + * Holding RCU read lock to protect _cds_lfht_add against memory + * reclaim that could be performed by other worker threads (ABA + * problem). + * + * When we reach a certain length, we can split this population phase over + * many worker threads, based on the number of CPUs available in the system. + * This should therefore take care of not having the expand lagging behind too + * many concurrent insertion threads by using the scheduler's ability to + * schedule bucket node population fairly with insertions. + */ +static +void init_table_populate_partition(struct cds_lfht *ht, unsigned long i, + unsigned long start, unsigned long len) +{ + unsigned long j, size = 1UL << (i - 1); + + urcu_posix_assert(i > MIN_TABLE_ORDER); + ht->flavor->read_lock(); + for (j = size + start; j < size + start + len; j++) { + struct cds_lfht_node *new_node = bucket_at(ht, j); + + urcu_posix_assert(j >= size && j < (size << 1)); + dbg_printf("init populate: order %lu index %lu hash %lu\n", + i, j, j); + new_node->reverse_hash = bit_reverse_ulong(j); + _cds_lfht_add(ht, j, NULL, NULL, size, new_node, NULL, 1); + } + ht->flavor->read_unlock(); +} + +static +void init_table_populate(struct cds_lfht *ht, unsigned long i, + unsigned long len) +{ + partition_resize_helper(ht, i, len, init_table_populate_partition); +} + +static +void init_table(struct cds_lfht *ht, + unsigned long first_order, unsigned long last_order) +{ + unsigned long i; + + dbg_printf("init table: first_order %lu last_order %lu\n", + first_order, last_order); + urcu_posix_assert(first_order > MIN_TABLE_ORDER); + for (i = first_order; i <= last_order; i++) { + unsigned long len; + + len = 1UL << (i - 1); + dbg_printf("init order %lu len: %lu\n", i, len); + + /* Stop expand if the resize target changes under us */ + if (CMM_LOAD_SHARED(ht->resize_target) < (1UL << i)) + break; + + cds_lfht_alloc_bucket_table(ht, i); + + /* + * Set all bucket nodes reverse hash values for a level and + * link all bucket nodes into the table. + */ + init_table_populate(ht, i, len); + + /* + * Update table size. + * + * Populate data before RCU size. + */ + uatomic_store(&ht->size, 1UL << i, CMM_RELEASE); + + dbg_printf("init new size: %lu\n", 1UL << i); + if (CMM_LOAD_SHARED(ht->in_progress_destroy)) + break; + } +} + +/* + * Holding RCU read lock to protect _cds_lfht_remove against memory + * reclaim that could be performed by other worker threads (ABA + * problem). + * For a single level, we logically remove and garbage collect each node. + * + * As a design choice, we perform logical removal and garbage collection on a + * node-per-node basis to simplify this algorithm. We also assume keeping good + * cache locality of the operation would overweight possible performance gain + * that could be achieved by batching garbage collection for multiple levels. + * However, this would have to be justified by benchmarks. + * + * Concurrent removal and add operations are helping us perform garbage + * collection of logically removed nodes. We guarantee that all logically + * removed nodes have been garbage-collected (unlinked) before work + * enqueue is invoked to free a hole level of bucket nodes (after a + * grace period). + * + * Logical removal and garbage collection can therefore be done in batch + * or on a node-per-node basis, as long as the guarantee above holds. + * + * When we reach a certain length, we can split this removal over many worker + * threads, based on the number of CPUs available in the system. This should + * take care of not letting resize process lag behind too many concurrent + * updater threads actively inserting into the hash table. + */ +static +void remove_table_partition(struct cds_lfht *ht, unsigned long i, + unsigned long start, unsigned long len) +{ + unsigned long j, size = 1UL << (i - 1); + + urcu_posix_assert(i > MIN_TABLE_ORDER); + ht->flavor->read_lock(); + for (j = size + start; j < size + start + len; j++) { + struct cds_lfht_node *fini_bucket = bucket_at(ht, j); + struct cds_lfht_node *parent_bucket = bucket_at(ht, j - size); + uintptr_t *fini_bucket_next; + + urcu_posix_assert(j >= size && j < (size << 1)); + dbg_printf("remove entry: order %lu index %lu hash %lu\n", + i, j, j); + /* Set the REMOVED_FLAG to freeze the ->next for gc. + * + * NOTE: The fini_bucket_next variable is present to + * avoid breaking strict-aliasing rules. + */ + fini_bucket_next = (uintptr_t*)&fini_bucket->next; + uatomic_or(fini_bucket_next, REMOVED_FLAG); + _cds_lfht_gc_bucket(parent_bucket, fini_bucket); + } + ht->flavor->read_unlock(); +} + +static +void remove_table(struct cds_lfht *ht, unsigned long i, unsigned long len) +{ + partition_resize_helper(ht, i, len, remove_table_partition); +} + +/* + * fini_table() is never called for first_order == 0, which is why + * free_by_rcu_order == 0 can be used as criterion to know if free must + * be called. + */ +static +void fini_table(struct cds_lfht *ht, + unsigned long first_order, unsigned long last_order) +{ + unsigned long free_by_rcu_order = 0, i; + + dbg_printf("fini table: first_order %lu last_order %lu\n", + first_order, last_order); + urcu_posix_assert(first_order > MIN_TABLE_ORDER); + for (i = last_order; i >= first_order; i--) { + unsigned long len; + + len = 1UL << (i - 1); + dbg_printf("fini order %ld len: %lu\n", i, len); + + /* Stop shrink if the resize target changes under us */ + if (CMM_LOAD_SHARED(ht->resize_target) > (1UL << (i - 1))) + break; + + cmm_smp_wmb(); /* populate data before RCU size */ + CMM_STORE_SHARED(ht->size, 1UL << (i - 1)); + + /* + * We need to wait for all add operations to reach Q.S. (and + * thus use the new table for lookups) before we can start + * releasing the old bucket nodes. Otherwise their lookup will + * return a logically removed node as insert position. + */ + ht->flavor->update_synchronize_rcu(); + if (free_by_rcu_order) + cds_lfht_free_bucket_table(ht, free_by_rcu_order); + + /* + * Set "removed" flag in bucket nodes about to be removed. + * Unlink all now-logically-removed bucket node pointers. + * Concurrent add/remove operation are helping us doing + * the gc. + */ + remove_table(ht, i, len); + + free_by_rcu_order = i; + + dbg_printf("fini new size: %lu\n", 1UL << i); + if (CMM_LOAD_SHARED(ht->in_progress_destroy)) + break; + } + + if (free_by_rcu_order) { + ht->flavor->update_synchronize_rcu(); + cds_lfht_free_bucket_table(ht, free_by_rcu_order); + } +} + +/* + * Never called with size < 1. + */ +static +void cds_lfht_create_bucket(struct cds_lfht *ht, unsigned long size) +{ + struct cds_lfht_node *prev, *node; + unsigned long order, len, i; + int bucket_order; + + cds_lfht_alloc_bucket_table(ht, 0); + + dbg_printf("create bucket: order 0 index 0 hash 0\n"); + node = bucket_at(ht, 0); + node->next = flag_bucket(get_end()); + node->reverse_hash = 0; + + bucket_order = cds_lfht_get_count_order_ulong(size); + urcu_posix_assert(bucket_order >= 0); + + for (order = 1; order < (unsigned long) bucket_order + 1; order++) { + len = 1UL << (order - 1); + cds_lfht_alloc_bucket_table(ht, order); + + for (i = 0; i < len; i++) { + /* + * Now, we are trying to init the node with the + * hash=(len+i) (which is also a bucket with the + * index=(len+i)) and insert it into the hash table, + * so this node has to be inserted after the bucket + * with the index=(len+i)&(len-1)=i. And because there + * is no other non-bucket node nor bucket node with + * larger index/hash inserted, so the bucket node + * being inserted should be inserted directly linked + * after the bucket node with index=i. + */ + prev = bucket_at(ht, i); + node = bucket_at(ht, len + i); + + dbg_printf("create bucket: order %lu index %lu hash %lu\n", + order, len + i, len + i); + node->reverse_hash = bit_reverse_ulong(len + i); + + /* insert after prev */ + urcu_posix_assert(is_bucket(prev->next)); + node->next = prev->next; + prev->next = flag_bucket(node); + } + } +} + +#if (CAA_BITS_PER_LONG > 32) +/* + * For 64-bit architectures, with max number of buckets small enough not to + * use the entire 64-bit memory mapping space (and allowing a fair number of + * hash table instances), use the mmap allocator, which is faster. Otherwise, + * fallback to the order allocator. + */ +static +const struct cds_lfht_mm_type *get_mm_type(unsigned long max_nr_buckets) +{ + if (max_nr_buckets && max_nr_buckets <= (1ULL << 32)) + return &cds_lfht_mm_mmap; + else + return &cds_lfht_mm_order; +} +#else +/* + * For 32-bit architectures, use the order allocator. + */ +static +const struct cds_lfht_mm_type *get_mm_type( + unsigned long max_nr_buckets __attribute__((unused))) +{ + return &cds_lfht_mm_order; +} +#endif + +void cds_lfht_node_init_deleted(struct cds_lfht_node *node) +{ + cds_lfht_node_init(node); + node->next = flag_removed(NULL); +} + +struct cds_lfht *_cds_lfht_new_with_alloc(unsigned long init_size, + unsigned long min_nr_alloc_buckets, + unsigned long max_nr_buckets, + int flags, + const struct cds_lfht_mm_type *mm, + const struct rcu_flavor_struct *flavor, + const struct cds_lfht_alloc *alloc, + pthread_attr_t *attr) +{ + struct cds_lfht *ht; + unsigned long order; + + /* min_nr_alloc_buckets must be power of two */ + if (!min_nr_alloc_buckets || (min_nr_alloc_buckets & (min_nr_alloc_buckets - 1))) + return NULL; + + /* init_size must be power of two */ + if (!init_size || (init_size & (init_size - 1))) + return NULL; + + /* + * Memory management plugin default. + */ + if (!mm) + mm = get_mm_type(max_nr_buckets); + + /* max_nr_buckets == 0 for order based mm means infinite */ + if (mm == &cds_lfht_mm_order && !max_nr_buckets) + max_nr_buckets = 1UL << (MAX_TABLE_ORDER - 1); + + /* max_nr_buckets must be power of two */ + if (!max_nr_buckets || (max_nr_buckets & (max_nr_buckets - 1))) + return NULL; + + if (flags & CDS_LFHT_AUTO_RESIZE) + cds_lfht_init_worker(flavor); + + min_nr_alloc_buckets = max(min_nr_alloc_buckets, MIN_TABLE_SIZE); + init_size = max(init_size, MIN_TABLE_SIZE); + max_nr_buckets = max(max_nr_buckets, min_nr_alloc_buckets); + init_size = min(init_size, max_nr_buckets); + + ht = mm->alloc_cds_lfht(min_nr_alloc_buckets, max_nr_buckets, alloc ? : &cds_lfht_default_alloc); + + urcu_posix_assert(ht); + urcu_posix_assert(ht->mm == mm); + urcu_posix_assert(ht->bucket_at == mm->bucket_at); + + ht->flags = flags; + ht->flavor = flavor; + ht->caller_resize_attr = attr; + if (attr) + ht->resize_attr = *attr; + alloc_split_items_count(ht); + /* this mutex should not nest in read-side C.S. */ + pthread_mutex_init(&ht->resize_mutex, NULL); + order = cds_lfht_get_count_order_ulong(init_size); + ht->resize_target = 1UL << order; + cds_lfht_create_bucket(ht, 1UL << order); + ht->size = 1UL << order; + return ht; +} + +struct cds_lfht *_cds_lfht_new(unsigned long init_size, + unsigned long min_nr_alloc_buckets, + unsigned long max_nr_buckets, + int flags, + const struct cds_lfht_mm_type *mm, + const struct rcu_flavor_struct *flavor, + pthread_attr_t *attr) +{ + return _cds_lfht_new_with_alloc(init_size, + min_nr_alloc_buckets, max_nr_buckets, + flags, mm, flavor, NULL, attr); +} + +void cds_lfht_lookup(struct cds_lfht *ht, unsigned long hash, + cds_lfht_match_fct match, const void *key, + struct cds_lfht_iter *iter) +{ + struct cds_lfht_node *node, *next, *bucket; + unsigned long reverse_hash, size; + + cds_lfht_iter_debug_set_ht(ht, iter); + + reverse_hash = bit_reverse_ulong(hash); + + /* + * Use load acquire instead of rcu_dereference because there is no + * dependency between the table size and the dereference of the bucket + * content. + * + * This acquire is paired with the store release in init_table(). + */ + size = uatomic_load(&ht->size, CMM_ACQUIRE); + bucket = lookup_bucket(ht, size, hash); + /* We can always skip the bucket node initially */ + node = rcu_dereference(bucket->next); + node = clear_flag(node); + for (;;) { + if (caa_unlikely(is_end(node))) { + node = next = NULL; + break; + } + if (caa_unlikely(node->reverse_hash > reverse_hash)) { + node = next = NULL; + break; + } + next = rcu_dereference(node->next); + urcu_posix_assert(node == clear_flag(node)); + if (caa_likely(!is_removed(next)) + && !is_bucket(next) + && node->reverse_hash == reverse_hash + && caa_likely(match(node, key))) { + break; + } + node = clear_flag(next); + } + urcu_posix_assert(!node || !is_bucket(CMM_LOAD_SHARED(node->next))); + iter->node = node; + iter->next = next; +} + +void cds_lfht_next_duplicate(struct cds_lfht *ht __attribute__((unused)), + cds_lfht_match_fct match, + const void *key, struct cds_lfht_iter *iter) +{ + struct cds_lfht_node *node, *next; + unsigned long reverse_hash; + + cds_lfht_iter_debug_assert(ht == iter->lfht); + node = iter->node; + reverse_hash = node->reverse_hash; + next = iter->next; + node = clear_flag(next); + + for (;;) { + if (caa_unlikely(is_end(node))) { + node = next = NULL; + break; + } + if (caa_unlikely(node->reverse_hash > reverse_hash)) { + node = next = NULL; + break; + } + next = rcu_dereference(node->next); + if (caa_likely(!is_removed(next)) + && !is_bucket(next) + && caa_likely(match(node, key))) { + break; + } + node = clear_flag(next); + } + urcu_posix_assert(!node || !is_bucket(uatomic_load(&node->next, CMM_RELAXED))); + iter->node = node; + iter->next = next; +} + +void cds_lfht_next(struct cds_lfht *ht __attribute__((unused)), + struct cds_lfht_iter *iter) +{ + struct cds_lfht_node *node, *next; + + cds_lfht_iter_debug_assert(ht == iter->lfht); + node = clear_flag(iter->next); + for (;;) { + if (caa_unlikely(is_end(node))) { + node = next = NULL; + break; + } + next = rcu_dereference(node->next); + if (caa_likely(!is_removed(next)) + && !is_bucket(next)) { + break; + } + node = clear_flag(next); + } + urcu_posix_assert(!node || !is_bucket(uatomic_load(&node->next, CMM_RELAXED))); + iter->node = node; + iter->next = next; +} + +void cds_lfht_first(struct cds_lfht *ht, struct cds_lfht_iter *iter) +{ + cds_lfht_iter_debug_set_ht(ht, iter); + /* + * Get next after first bucket node. The first bucket node is the + * first node of the linked list. + */ + iter->next = uatomic_load(&bucket_at(ht, 0)->next, CMM_CONSUME); + cds_lfht_next(ht, iter); +} + +void cds_lfht_add(struct cds_lfht *ht, unsigned long hash, + struct cds_lfht_node *node) +{ + unsigned long size; + + node->reverse_hash = bit_reverse_ulong(hash); + size = uatomic_load(&ht->size, CMM_ACQUIRE); + _cds_lfht_add(ht, hash, NULL, NULL, size, node, NULL, 0); + ht_count_add(ht, size, hash); +} + +struct cds_lfht_node *cds_lfht_add_unique(struct cds_lfht *ht, + unsigned long hash, + cds_lfht_match_fct match, + const void *key, + struct cds_lfht_node *node) +{ + unsigned long size; + struct cds_lfht_iter iter; + + node->reverse_hash = bit_reverse_ulong(hash); + size = uatomic_load(&ht->size, CMM_ACQUIRE); + _cds_lfht_add(ht, hash, match, key, size, node, &iter, 0); + if (iter.node == node) + ht_count_add(ht, size, hash); + return iter.node; +} + +struct cds_lfht_node *cds_lfht_add_replace(struct cds_lfht *ht, + unsigned long hash, + cds_lfht_match_fct match, + const void *key, + struct cds_lfht_node *node) +{ + unsigned long size; + struct cds_lfht_iter iter; + + node->reverse_hash = bit_reverse_ulong(hash); + size = uatomic_load(&ht->size, CMM_ACQUIRE); + for (;;) { + _cds_lfht_add(ht, hash, match, key, size, node, &iter, 0); + if (iter.node == node) { + ht_count_add(ht, size, hash); + return NULL; + } + + if (!_cds_lfht_replace(ht, size, iter.node, iter.next, node)) + return iter.node; + } +} + +int cds_lfht_replace(struct cds_lfht *ht, + struct cds_lfht_iter *old_iter, + unsigned long hash, + cds_lfht_match_fct match, + const void *key, + struct cds_lfht_node *new_node) +{ + unsigned long size; + + new_node->reverse_hash = bit_reverse_ulong(hash); + if (!old_iter->node) + return -ENOENT; + if (caa_unlikely(old_iter->node->reverse_hash != new_node->reverse_hash)) + return -EINVAL; + if (caa_unlikely(!match(old_iter->node, key))) + return -EINVAL; + size = uatomic_load(&ht->size, CMM_ACQUIRE); + return _cds_lfht_replace(ht, size, old_iter->node, old_iter->next, + new_node); +} + +int cds_lfht_del(struct cds_lfht *ht, struct cds_lfht_node *node) +{ + unsigned long size; + int ret; + + size = uatomic_load(&ht->size, CMM_ACQUIRE); + ret = _cds_lfht_del(ht, size, node); + if (!ret) { + unsigned long hash; + + hash = bit_reverse_ulong(node->reverse_hash); + ht_count_del(ht, size, hash); + } + return ret; +} + +int cds_lfht_is_node_deleted(const struct cds_lfht_node *node) +{ + return is_removed(CMM_LOAD_SHARED(node->next)); +} + +static +bool cds_lfht_is_empty(struct cds_lfht *ht) +{ + struct cds_lfht_node *node, *next; + bool empty = true; + bool was_online; + + was_online = ht->flavor->read_ongoing(); + if (!was_online) { + ht->flavor->thread_online(); + ht->flavor->read_lock(); + } + /* Check that the table is empty */ + node = bucket_at(ht, 0); + do { + next = rcu_dereference(node->next); + if (!is_bucket(next)) { + empty = false; + break; + } + node = clear_flag(next); + } while (!is_end(node)); + if (!was_online) { + ht->flavor->read_unlock(); + ht->flavor->thread_offline(); + } + return empty; +} + +static +int cds_lfht_delete_bucket(struct cds_lfht *ht) +{ + struct cds_lfht_node *node; + unsigned long order, i, size; + + /* Check that the table is empty */ + node = bucket_at(ht, 0); + do { + node = clear_flag(node)->next; + if (!is_bucket(node)) + return -EPERM; + urcu_posix_assert(!is_removed(node)); + urcu_posix_assert(!is_removal_owner(node)); + } while (!is_end(node)); + /* + * size accessed without rcu_dereference because hash table is + * being destroyed. + */ + size = ht->size; + /* Internal sanity check: all nodes left should be buckets */ + for (i = 0; i < size; i++) { + node = bucket_at(ht, i); + dbg_printf("delete bucket: index %lu expected hash %lu hash %lu\n", + i, i, bit_reverse_ulong(node->reverse_hash)); + urcu_posix_assert(is_bucket(node->next)); + } + + for (order = cds_lfht_get_count_order_ulong(size); (long)order >= 0; order--) + cds_lfht_free_bucket_table(ht, order); + + return 0; +} + +static +void do_auto_resize_destroy_cb(struct urcu_work *work) +{ + struct cds_lfht *ht = caa_container_of(work, struct cds_lfht, destroy_work); + int ret; + + ht->flavor->register_thread(); + ret = cds_lfht_delete_bucket(ht); + if (ret) + urcu_die(-ret); + free_split_items_count(ht); + ret = pthread_mutex_destroy(&ht->resize_mutex); + if (ret) + urcu_die(ret); + ht->flavor->unregister_thread(); + poison_free(ht->alloc, ht); +} + +/* + * Should only be called when no more concurrent readers nor writers can + * possibly access the table. + */ +int cds_lfht_destroy(struct cds_lfht *ht, pthread_attr_t **attr) +{ + int ret; + + if (ht->flags & CDS_LFHT_AUTO_RESIZE) { + /* + * Perform error-checking for emptiness before queuing + * work, so we can return error to the caller. This runs + * concurrently with ongoing resize. + */ + if (!cds_lfht_is_empty(ht)) + return -EPERM; + /* Cancel ongoing resize operations. */ + uatomic_store(&ht->in_progress_destroy, 1, CMM_RELAXED); + if (attr) { + *attr = ht->caller_resize_attr; + ht->caller_resize_attr = NULL; + } + /* + * Queue destroy work after prior queued resize + * operations. Given there are no concurrent writers + * accessing the hash table at this point, no resize + * operations can be queued after this destroy work. + */ + urcu_workqueue_queue_work(cds_lfht_workqueue, + &ht->destroy_work, do_auto_resize_destroy_cb); + return 0; + } + ret = cds_lfht_delete_bucket(ht); + if (ret) + return ret; + free_split_items_count(ht); + if (attr) + *attr = ht->caller_resize_attr; + ret = pthread_mutex_destroy(&ht->resize_mutex); + if (ret) + ret = -EBUSY; + poison_free(ht->alloc, ht); + return ret; +} + +void cds_lfht_count_nodes(struct cds_lfht *ht, + long *approx_before, + unsigned long *count, + long *approx_after) +{ + struct cds_lfht_node *node, *next; + unsigned long nr_bucket = 0, nr_removed = 0; + + *approx_before = 0; + if (ht->split_count) { + int i; + + for (i = 0; i < split_count_mask + 1; i++) { + *approx_before += uatomic_read(&ht->split_count[i].add); + *approx_before -= uatomic_read(&ht->split_count[i].del); + } + } + + *count = 0; + + /* Count non-bucket nodes in the table */ + node = bucket_at(ht, 0); + do { + next = rcu_dereference(node->next); + if (is_removed(next)) { + if (!is_bucket(next)) + (nr_removed)++; + else + (nr_bucket)++; + } else if (!is_bucket(next)) + (*count)++; + else + (nr_bucket)++; + node = clear_flag(next); + } while (!is_end(node)); + dbg_printf("number of logically removed nodes: %lu\n", nr_removed); + dbg_printf("number of bucket nodes: %lu\n", nr_bucket); + *approx_after = 0; + if (ht->split_count) { + int i; + + for (i = 0; i < split_count_mask + 1; i++) { + *approx_after += uatomic_read(&ht->split_count[i].add); + *approx_after -= uatomic_read(&ht->split_count[i].del); + } + } +} + +/* called with resize mutex held */ +static +void _do_cds_lfht_grow(struct cds_lfht *ht, + unsigned long old_size, unsigned long new_size) +{ + unsigned long old_order, new_order; + + old_order = cds_lfht_get_count_order_ulong(old_size); + new_order = cds_lfht_get_count_order_ulong(new_size); + dbg_printf("resize from %lu (order %lu) to %lu (order %lu) buckets\n", + old_size, old_order, new_size, new_order); + urcu_posix_assert(new_size > old_size); + init_table(ht, old_order + 1, new_order); +} + +/* called with resize mutex held */ +static +void _do_cds_lfht_shrink(struct cds_lfht *ht, + unsigned long old_size, unsigned long new_size) +{ + unsigned long old_order, new_order; + + new_size = max(new_size, MIN_TABLE_SIZE); + old_order = cds_lfht_get_count_order_ulong(old_size); + new_order = cds_lfht_get_count_order_ulong(new_size); + dbg_printf("resize from %lu (order %lu) to %lu (order %lu) buckets\n", + old_size, old_order, new_size, new_order); + urcu_posix_assert(new_size < old_size); + + /* Remove and unlink all bucket nodes to remove. */ + fini_table(ht, new_order + 1, old_order); +} + + +/* called with resize mutex held */ +static +void _do_cds_lfht_resize(struct cds_lfht *ht) +{ + unsigned long new_size, old_size; + + /* + * Resize table, re-do if the target size has changed under us. + */ + do { + if (uatomic_load(&ht->in_progress_destroy, CMM_RELAXED)) + break; + + uatomic_store(&ht->resize_initiated, 1, CMM_RELAXED); + + old_size = ht->size; + new_size = uatomic_load(&ht->resize_target, CMM_RELAXED); + if (old_size < new_size) + _do_cds_lfht_grow(ht, old_size, new_size); + else if (old_size > new_size) + _do_cds_lfht_shrink(ht, old_size, new_size); + + uatomic_store(&ht->resize_initiated, 0, CMM_RELAXED); + /* write resize_initiated before read resize_target */ + cmm_smp_mb(); + } while (ht->size != uatomic_load(&ht->resize_target, CMM_RELAXED)); +} + +static +unsigned long resize_target_grow(struct cds_lfht *ht, unsigned long new_size) +{ + return _uatomic_xchg_monotonic_increase(&ht->resize_target, new_size); +} + +static +void resize_target_update_count(struct cds_lfht *ht, + unsigned long count) +{ + count = max(count, MIN_TABLE_SIZE); + count = min(count, ht->max_nr_buckets); + uatomic_set(&ht->resize_target, count); +} + +void cds_lfht_resize(struct cds_lfht *ht, unsigned long new_size) +{ + resize_target_update_count(ht, new_size); + + /* + * Set flags has early as possible even in contention case. + */ + uatomic_store(&ht->resize_initiated, 1, CMM_RELAXED); + + mutex_lock(&ht->resize_mutex); + _do_cds_lfht_resize(ht); + mutex_unlock(&ht->resize_mutex); +} + +static +void do_resize_cb(struct urcu_work *work) +{ + struct resize_work *resize_work = + caa_container_of(work, struct resize_work, work); + struct cds_lfht *ht = resize_work->ht; + + ht->flavor->register_thread(); + mutex_lock(&ht->resize_mutex); + _do_cds_lfht_resize(ht); + mutex_unlock(&ht->resize_mutex); + ht->flavor->unregister_thread(); + poison_free(ht->alloc, work); +} + +static +void __cds_lfht_resize_lazy_launch(struct cds_lfht *ht) +{ + struct resize_work *work; + + /* + * Store to resize_target is before read resize_initiated as guaranteed + * by either cmpxchg or _uatomic_xchg_monotonic_increase. + */ + if (!uatomic_load(&ht->resize_initiated, CMM_RELAXED)) { + if (uatomic_load(&ht->in_progress_destroy, CMM_RELAXED)) { + return; + } + work = ht->alloc->malloc(ht->alloc->state, sizeof(*work)); + if (work == NULL) { + dbg_printf("error allocating resize work, bailing out\n"); + return; + } + work->ht = ht; + urcu_workqueue_queue_work(cds_lfht_workqueue, + &work->work, do_resize_cb); + uatomic_store(&ht->resize_initiated, 1, CMM_RELAXED); + } +} + +static +void cds_lfht_resize_lazy_grow(struct cds_lfht *ht, unsigned long size, int growth) +{ + unsigned long target_size = size << growth; + + target_size = min(target_size, ht->max_nr_buckets); + if (resize_target_grow(ht, target_size) >= target_size) + return; + + __cds_lfht_resize_lazy_launch(ht); +} + +/* + * We favor grow operations over shrink. A shrink operation never occurs + * if a grow operation is queued for lazy execution. A grow operation + * cancels any pending shrink lazy execution. + */ +static +void cds_lfht_resize_lazy_count(struct cds_lfht *ht, unsigned long size, + unsigned long count) +{ + if (!(ht->flags & CDS_LFHT_AUTO_RESIZE)) + return; + count = max(count, MIN_TABLE_SIZE); + count = min(count, ht->max_nr_buckets); + if (count == size) + return; /* Already the right size, no resize needed */ + if (count > size) { /* lazy grow */ + if (resize_target_grow(ht, count) >= count) + return; + } else { /* lazy shrink */ + for (;;) { + unsigned long s; + + s = uatomic_cmpxchg(&ht->resize_target, size, count); + if (s == size) + break; /* no resize needed */ + if (s > size) + return; /* growing is/(was just) in progress */ + if (s <= count) + return; /* some other thread do shrink */ + size = s; + } + } + __cds_lfht_resize_lazy_launch(ht); +} + +static void cds_lfht_before_fork(void *priv __attribute__((unused))) +{ + if (cds_lfht_workqueue_atfork_nesting++) + return; + mutex_lock(&cds_lfht_fork_mutex); + if (!cds_lfht_workqueue) + return; + urcu_workqueue_pause_worker(cds_lfht_workqueue); +} + +static void cds_lfht_after_fork_parent(void *priv __attribute__((unused))) +{ + if (--cds_lfht_workqueue_atfork_nesting) + return; + if (!cds_lfht_workqueue) + goto end; + urcu_workqueue_resume_worker(cds_lfht_workqueue); +end: + mutex_unlock(&cds_lfht_fork_mutex); +} + +static void cds_lfht_after_fork_child(void *priv __attribute__((unused))) +{ + if (--cds_lfht_workqueue_atfork_nesting) + return; + if (!cds_lfht_workqueue) + goto end; + urcu_workqueue_create_worker(cds_lfht_workqueue); +end: + mutex_unlock(&cds_lfht_fork_mutex); +} + +static struct urcu_atfork cds_lfht_atfork = { + .before_fork = cds_lfht_before_fork, + .after_fork_parent = cds_lfht_after_fork_parent, + .after_fork_child = cds_lfht_after_fork_child, +}; + +static void cds_lfht_init_worker(const struct rcu_flavor_struct *flavor) +{ + flavor->register_rculfhash_atfork(&cds_lfht_atfork); + + mutex_lock(&cds_lfht_fork_mutex); + if (!cds_lfht_workqueue) + cds_lfht_workqueue = urcu_workqueue_create(0, -1, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL); + mutex_unlock(&cds_lfht_fork_mutex); +} + +static void cds_lfht_exit(void) +{ + mutex_lock(&cds_lfht_fork_mutex); + if (cds_lfht_workqueue) { + urcu_workqueue_flush_queued_work(cds_lfht_workqueue); + urcu_workqueue_destroy(cds_lfht_workqueue); + cds_lfht_workqueue = NULL; + } + mutex_unlock(&cds_lfht_fork_mutex); +} diff --git a/external/lgpl2/userspace-rcu/dist/src/rculfqueue.c b/external/lgpl2/userspace-rcu/dist/src/rculfqueue.c new file mode 100644 index 0000000000000..8b6e0a65baa3d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/rculfqueue.c @@ -0,0 +1,45 @@ +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU library - Lock-Free RCU Queue + */ + +/* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */ +#undef _LGPL_SOURCE +#include "urcu/rculfqueue.h" +#define _LGPL_SOURCE +#include "urcu/static/rculfqueue.h" + +/* + * library wrappers to be used by non-LGPL compatible source code. + */ + +void cds_lfq_node_init_rcu(struct cds_lfq_node_rcu *node) +{ + _cds_lfq_node_init_rcu(node); +} + +void cds_lfq_init_rcu(struct cds_lfq_queue_rcu *q, + void queue_call_rcu(struct rcu_head *head, + void (*func)(struct rcu_head *head))) +{ + _cds_lfq_init_rcu(q, queue_call_rcu); +} + +int cds_lfq_destroy_rcu(struct cds_lfq_queue_rcu *q) +{ + return _cds_lfq_destroy_rcu(q); +} + +void cds_lfq_enqueue_rcu(struct cds_lfq_queue_rcu *q, struct cds_lfq_node_rcu *node) +{ + _cds_lfq_enqueue_rcu(q, node); +} + +struct cds_lfq_node_rcu * +cds_lfq_dequeue_rcu(struct cds_lfq_queue_rcu *q) +{ + return _cds_lfq_dequeue_rcu(q); +} diff --git a/external/lgpl2/userspace-rcu/dist/src/rculfstack.c b/external/lgpl2/userspace-rcu/dist/src/rculfstack.c new file mode 100644 index 0000000000000..d7b00ffcd8876 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/rculfstack.c @@ -0,0 +1,42 @@ +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU library - Lock-Free RCU Stack + */ + +/* Remove deprecation warnings from LGPL wrapper build. */ +#define CDS_LFS_RCU_DEPRECATED + +/* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */ +#undef _LGPL_SOURCE +#include "urcu/rculfstack.h" +#define _LGPL_SOURCE +#include "urcu/static/rculfstack.h" + +/* + * library wrappers to be used by non-LGPL compatible source code. + */ + + +void cds_lfs_node_init_rcu(struct cds_lfs_node_rcu *node) +{ + _cds_lfs_node_init_rcu(node); +} + +void cds_lfs_init_rcu(struct cds_lfs_stack_rcu *s) +{ + _cds_lfs_init_rcu(s); +} + +int cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s, + struct cds_lfs_node_rcu *node) +{ + return _cds_lfs_push_rcu(s, node); +} + +struct cds_lfs_node_rcu *cds_lfs_pop_rcu(struct cds_lfs_stack_rcu *s) +{ + return _cds_lfs_pop_rcu(s); +} diff --git a/external/lgpl2/userspace-rcu/dist/src/urcu-bp.c b/external/lgpl2/userspace-rcu/dist/src/urcu-bp.c new file mode 100644 index 0000000000000..38f867e7b4634 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/urcu-bp.c @@ -0,0 +1,774 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU library, "bulletproof" version. + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#define URCU_NO_COMPAT_IDENTIFIERS +#define _LGPL_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "urcu-die.h" +#include "urcu-utils.h" + +#define URCU_API_MAP +/* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */ +#undef _LGPL_SOURCE +#include +#define _LGPL_SOURCE + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +#ifdef __linux__ +static +void *mremap_wrapper(void *old_address, size_t old_size, + size_t new_size, int flags) +{ + return mremap(old_address, old_size, new_size, flags); +} +#else + +#define MREMAP_MAYMOVE 1 +#define MREMAP_FIXED 2 + +/* + * mremap wrapper for non-Linux systems not allowing MAYMOVE. + * This is not generic. +*/ +static +void *mremap_wrapper(void *old_address __attribute__((unused)), + size_t old_size __attribute__((unused)), + size_t new_size __attribute__((unused)), + int flags) +{ + urcu_posix_assert(!(flags & MREMAP_MAYMOVE)); + + return MAP_FAILED; +} +#endif + +/* Sleep delay in ms */ +#define RCU_SLEEP_DELAY_MS 10 +#define INIT_READER_COUNT 8 + +/* + * Active attempts to check for reader Q.S. before calling sleep(). + */ +#define RCU_QS_ACTIVE_ATTEMPTS 100 + +static +int urcu_bp_refcount; + +/* If the headers do not support membarrier system call, fall back smp_mb. */ +#ifdef __NR_membarrier +# define membarrier(...) syscall(__NR_membarrier, __VA_ARGS__) +#else +# define membarrier(...) -ENOSYS +#endif + +enum membarrier_cmd { + MEMBARRIER_CMD_QUERY = 0, + MEMBARRIER_CMD_SHARED = (1 << 0), + /* reserved for MEMBARRIER_CMD_SHARED_EXPEDITED (1 << 1) */ + /* reserved for MEMBARRIER_CMD_PRIVATE (1 << 2) */ + MEMBARRIER_CMD_PRIVATE_EXPEDITED = (1 << 3), + MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED = (1 << 4), +}; + +static +void __attribute__((constructor)) _urcu_bp_init(void); +static +void urcu_bp_exit(void); +static +void __attribute__((destructor)) urcu_bp_exit_destructor(void); +static void urcu_call_rcu_exit(void); + +#ifndef CONFIG_RCU_FORCE_SYS_MEMBARRIER +int urcu_bp_has_sys_membarrier; +#endif + +/* + * rcu_gp_lock ensures mutual exclusion between threads calling + * synchronize_rcu(). + */ +static pthread_mutex_t rcu_gp_lock = PTHREAD_MUTEX_INITIALIZER; +/* + * rcu_registry_lock ensures mutual exclusion between threads + * registering and unregistering themselves to/from the registry, and + * with threads reading that registry from synchronize_rcu(). However, + * this lock is not held all the way through the completion of awaiting + * for the grace period. It is sporadically released between iterations + * on the registry. + * rcu_registry_lock may nest inside rcu_gp_lock. + */ +static pthread_mutex_t rcu_registry_lock = PTHREAD_MUTEX_INITIALIZER; + +static pthread_mutex_t init_lock = PTHREAD_MUTEX_INITIALIZER; +static int initialized; + +static pthread_key_t urcu_bp_key; + +struct urcu_bp_gp urcu_bp_gp = { .ctr = URCU_BP_GP_COUNT }; + +/* + * Pointer to registry elements. Written to only by each individual reader. Read + * by both the reader and the writers. + */ +DEFINE_URCU_TLS(struct urcu_bp_reader *, urcu_bp_reader); + +static CDS_LIST_HEAD(registry); + +struct registry_chunk { + size_t capacity; /* capacity of this chunk (in elements) */ + size_t used; /* count of elements used */ + struct cds_list_head node; /* chunk_list node */ + struct urcu_bp_reader readers[]; +}; + +struct registry_arena { + struct cds_list_head chunk_list; +}; + +static struct registry_arena registry_arena = { + .chunk_list = CDS_LIST_HEAD_INIT(registry_arena.chunk_list), +}; + +/* Saved fork signal mask, protected by rcu_gp_lock */ +static sigset_t saved_fork_signal_mask; + +static void mutex_lock(pthread_mutex_t *mutex) +{ + int ret; + +#ifndef DISTRUST_SIGNALS_EXTREME + ret = pthread_mutex_lock(mutex); + if (ret) + urcu_die(ret); +#else /* #ifndef DISTRUST_SIGNALS_EXTREME */ + while ((ret = pthread_mutex_trylock(mutex)) != 0) { + if (ret != EBUSY && ret != EINTR) + urcu_die(ret); + poll(NULL,0,10); + } +#endif /* #else #ifndef DISTRUST_SIGNALS_EXTREME */ +} + +static void mutex_unlock(pthread_mutex_t *mutex) +{ + int ret; + + ret = pthread_mutex_unlock(mutex); + if (ret) + urcu_die(ret); +} + +static void smp_mb_master(void) +{ + if (caa_likely(urcu_bp_has_sys_membarrier)) { + if (membarrier(MEMBARRIER_CMD_PRIVATE_EXPEDITED, 0)) + urcu_die(errno); + } else { + cmm_smp_mb(); + } +} + +/* Get the size of a chunk's allocation from its capacity (an element count). */ +static size_t chunk_allocation_size(size_t capacity) +{ + return (capacity * sizeof(struct urcu_bp_reader)) + + sizeof(struct registry_chunk); +} + +/* + * Always called with rcu_registry lock held. Releases this lock between + * iterations and grabs it again. Holds the lock when it returns. + */ +static void wait_for_readers(struct cds_list_head *input_readers, + struct cds_list_head *cur_snap_readers, + struct cds_list_head *qsreaders, + cmm_annotate_t *group) +{ + unsigned int wait_loops = 0; + struct urcu_bp_reader *index, *tmp; + + /* + * Wait for each thread URCU_TLS(urcu_bp_reader).ctr to either + * indicate quiescence (not nested), or observe the current + * rcu_gp.ctr value. + */ + for (;;) { + if (wait_loops < RCU_QS_ACTIVE_ATTEMPTS) + wait_loops++; + + cds_list_for_each_entry_safe(index, tmp, input_readers, node) { + switch (urcu_bp_reader_state(&index->ctr, group)) { + case URCU_BP_READER_ACTIVE_CURRENT: + if (cur_snap_readers) { + cds_list_move(&index->node, + cur_snap_readers); + break; + } + /* Fall-through */ + case URCU_BP_READER_INACTIVE: + cds_list_move(&index->node, qsreaders); + break; + case URCU_BP_READER_ACTIVE_OLD: + /* + * Old snapshot. Leaving node in + * input_readers will make us busy-loop + * until the snapshot becomes current or + * the reader becomes inactive. + */ + break; + } + } + + if (cds_list_empty(input_readers)) { + break; + } else { + /* Temporarily unlock the registry lock. */ + mutex_unlock(&rcu_registry_lock); + if (wait_loops >= RCU_QS_ACTIVE_ATTEMPTS) + (void) poll(NULL, 0, RCU_SLEEP_DELAY_MS); + else + caa_cpu_relax(); + /* Re-lock the registry lock before the next loop. */ + mutex_lock(&rcu_registry_lock); + } + } +} + +void urcu_bp_synchronize_rcu(void) +{ + cmm_annotate_define(acquire_group); + cmm_annotate_define(release_group); + CDS_LIST_HEAD(cur_snap_readers); + CDS_LIST_HEAD(qsreaders); + sigset_t newmask, oldmask; + int ret; + + ret = sigfillset(&newmask); + urcu_posix_assert(!ret); + ret = pthread_sigmask(SIG_BLOCK, &newmask, &oldmask); + urcu_posix_assert(!ret); + + mutex_lock(&rcu_gp_lock); + + mutex_lock(&rcu_registry_lock); + + if (cds_list_empty(®istry)) + goto out; + + /* All threads should read qparity before accessing data structure + * where new ptr points to. */ + /* Write new ptr before changing the qparity */ + smp_mb_master(); + cmm_annotate_group_mb_release(&release_group); + + /* + * Wait for readers to observe original parity or be quiescent. + * wait_for_readers() can release and grab again rcu_registry_lock + * internally. + */ + wait_for_readers(®istry, &cur_snap_readers, &qsreaders, &acquire_group); + + /* + * Adding a cmm_smp_mb() which is _not_ formally required, but makes the + * model easier to understand. It does not have a big performance impact + * anyway, given this is the write-side. + */ + cmm_smp_mb(); + + /* Switch parity: 0 -> 1, 1 -> 0 */ + cmm_annotate_group_mem_release(&release_group, &rcu_gp.ctr); + uatomic_store(&rcu_gp.ctr, rcu_gp.ctr ^ URCU_BP_GP_CTR_PHASE, CMM_RELAXED); + + /* + * Must commit qparity update to memory before waiting for other parity + * quiescent state. Failure to do so could result in the writer waiting + * forever while new readers are always accessing data (no progress). + * Ensured by CMM_STORE_SHARED and CMM_LOAD_SHARED. + */ + + /* + * Adding a cmm_smp_mb() which is _not_ formally required, but makes the + * model easier to understand. It does not have a big performance impact + * anyway, given this is the write-side. + */ + cmm_smp_mb(); + + /* + * Wait for readers to observe new parity or be quiescent. + * wait_for_readers() can release and grab again rcu_registry_lock + * internally. + */ + wait_for_readers(&cur_snap_readers, NULL, &qsreaders, &acquire_group); + + /* + * Put quiescent reader list back into registry. + */ + cds_list_splice(&qsreaders, ®istry); + + /* + * Finish waiting for reader threads before letting the old ptr being + * freed. + */ + smp_mb_master(); + cmm_annotate_group_mb_acquire(&acquire_group); +out: + mutex_unlock(&rcu_registry_lock); + mutex_unlock(&rcu_gp_lock); + ret = pthread_sigmask(SIG_SETMASK, &oldmask, NULL); + urcu_posix_assert(!ret); +} + +/* + * library wrappers to be used by non-LGPL compatible source code. + */ + +void urcu_bp_read_lock(void) +{ + _urcu_bp_read_lock(); +} + +void urcu_bp_read_unlock(void) +{ + _urcu_bp_read_unlock(); +} + +int urcu_bp_read_ongoing(void) +{ + return _urcu_bp_read_ongoing(); +} + +/* + * Only grow for now. If empty, allocate a ARENA_INIT_ALLOC sized chunk. + * Else, try expanding the last chunk. If this fails, allocate a new + * chunk twice as big as the last chunk. + * Memory used by chunks _never_ moves. A chunk could theoretically be + * freed when all "used" slots are released, but we don't do it at this + * point. + */ +static +void expand_arena(struct registry_arena *arena) +{ + struct registry_chunk *new_chunk, *last_chunk; + size_t old_chunk_size_bytes, new_chunk_size_bytes, new_capacity; + + /* No chunk. */ + if (cds_list_empty(&arena->chunk_list)) { + new_chunk_size_bytes = chunk_allocation_size(INIT_READER_COUNT); + new_chunk = (struct registry_chunk *) mmap(NULL, + new_chunk_size_bytes, + PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, + -1, 0); + if (new_chunk == MAP_FAILED) + abort(); + memset(new_chunk, 0, new_chunk_size_bytes); + new_chunk->capacity = INIT_READER_COUNT; + cds_list_add_tail(&new_chunk->node, &arena->chunk_list); + return; /* We're done. */ + } + + /* Try expanding last chunk. */ + last_chunk = cds_list_entry(arena->chunk_list.prev, + struct registry_chunk, node); + old_chunk_size_bytes = chunk_allocation_size(last_chunk->capacity); + new_capacity = last_chunk->capacity << 1; + new_chunk_size_bytes = chunk_allocation_size(new_capacity); + + /* Don't allow memory mapping to move, just expand. */ + new_chunk = mremap_wrapper(last_chunk, old_chunk_size_bytes, + new_chunk_size_bytes, 0); + if (new_chunk != MAP_FAILED) { + /* Should not have moved. */ + assert(new_chunk == last_chunk); + memset((char *) last_chunk + old_chunk_size_bytes, 0, + new_chunk_size_bytes - old_chunk_size_bytes); + last_chunk->capacity = new_capacity; + return; /* We're done. */ + } + + /* Remap did not succeed, we need to add a new chunk. */ + new_chunk = (struct registry_chunk *) mmap(NULL, + new_chunk_size_bytes, + PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, + -1, 0); + if (new_chunk == MAP_FAILED) + abort(); + memset(new_chunk, 0, new_chunk_size_bytes); + new_chunk->capacity = new_capacity; + cds_list_add_tail(&new_chunk->node, &arena->chunk_list); +} + +static +struct rcu_reader *arena_alloc(struct registry_arena *arena) +{ + struct registry_chunk *chunk; + int expand_done = 0; /* Only allow to expand once per alloc */ + +retry: + cds_list_for_each_entry(chunk, &arena->chunk_list, node) { + size_t spot_idx; + + /* Skip fully used chunks. */ + if (chunk->used == chunk->capacity) { + continue; + } + + /* Find a spot. */ + for (spot_idx = 0; spot_idx < chunk->capacity; spot_idx++) { + if (!chunk->readers[spot_idx].alloc) { + chunk->readers[spot_idx].alloc = 1; + chunk->used++; + return &chunk->readers[spot_idx]; + } + } + } + + if (!expand_done) { + expand_arena(arena); + expand_done = 1; + goto retry; + } + + return NULL; +} + +/* Called with signals off and mutex locked */ +static +void add_thread(void) +{ + struct rcu_reader *rcu_reader_reg; + int ret; + + rcu_reader_reg = arena_alloc(®istry_arena); + if (!rcu_reader_reg) + abort(); + ret = pthread_setspecific(urcu_bp_key, rcu_reader_reg); + if (ret) + abort(); + + /* Add to registry */ + rcu_reader_reg->tid = pthread_self(); + urcu_posix_assert(rcu_reader_reg->ctr == 0); + cds_list_add(&rcu_reader_reg->node, ®istry); + /* + * Reader threads are pointing to the reader registry. This is + * why its memory should never be relocated. + */ + URCU_TLS(urcu_bp_reader) = rcu_reader_reg; +} + +/* Called with mutex locked */ +static +void cleanup_thread(struct registry_chunk *chunk, + struct rcu_reader *rcu_reader_reg) +{ + rcu_reader_reg->ctr = 0; + cds_list_del(&rcu_reader_reg->node); + rcu_reader_reg->tid = 0; + rcu_reader_reg->alloc = 0; + chunk->used--; +} + +static +struct registry_chunk *find_chunk(struct rcu_reader *rcu_reader_reg) +{ + struct registry_chunk *chunk; + + cds_list_for_each_entry(chunk, ®istry_arena.chunk_list, node) { + if (rcu_reader_reg < (struct urcu_bp_reader *) &chunk->readers[0]) + continue; + if (rcu_reader_reg >= (struct urcu_bp_reader *) &chunk->readers[chunk->capacity]) + continue; + return chunk; + } + return NULL; +} + +/* Called with signals off and mutex locked */ +static +void remove_thread(struct rcu_reader *rcu_reader_reg) +{ + cleanup_thread(find_chunk(rcu_reader_reg), rcu_reader_reg); + URCU_TLS(urcu_bp_reader) = NULL; +} + +/* Disable signals, take mutex, add to registry */ +void urcu_bp_register(void) +{ + sigset_t newmask, oldmask; + int ret; + + ret = sigfillset(&newmask); + if (ret) + abort(); + ret = pthread_sigmask(SIG_BLOCK, &newmask, &oldmask); + if (ret) + abort(); + + /* + * Check if a signal concurrently registered our thread since + * the check in rcu_read_lock(). + */ + if (URCU_TLS(urcu_bp_reader)) + goto end; + + /* + * Take care of early registration before urcu_bp constructor. + */ + _urcu_bp_init(); + + mutex_lock(&rcu_registry_lock); + add_thread(); + mutex_unlock(&rcu_registry_lock); +end: + ret = pthread_sigmask(SIG_SETMASK, &oldmask, NULL); + if (ret) + abort(); +} + +void urcu_bp_register_thread(void) +{ + if (caa_unlikely(!URCU_TLS(urcu_bp_reader))) + urcu_bp_register(); /* If not yet registered. */ +} + +/* Disable signals, take mutex, remove from registry */ +static +void urcu_bp_unregister(struct rcu_reader *rcu_reader_reg) +{ + sigset_t newmask, oldmask; + int ret; + + ret = sigfillset(&newmask); + if (ret) + abort(); + ret = pthread_sigmask(SIG_BLOCK, &newmask, &oldmask); + if (ret) + abort(); + + mutex_lock(&rcu_registry_lock); + remove_thread(rcu_reader_reg); + mutex_unlock(&rcu_registry_lock); + ret = pthread_sigmask(SIG_SETMASK, &oldmask, NULL); + if (ret) + abort(); + urcu_bp_exit(); +} + +/* + * Remove thread from the registry when it exits, and flag it as + * destroyed so garbage collection can take care of it. + */ +static +void urcu_bp_thread_exit_notifier(void *rcu_key) +{ + urcu_bp_unregister(rcu_key); +} + +#ifdef CONFIG_RCU_FORCE_SYS_MEMBARRIER +static +void urcu_bp_sys_membarrier_status(bool available) +{ + if (!available) + abort(); +} +#else +static +void urcu_bp_sys_membarrier_status(bool available) +{ + if (!available) + return; + urcu_bp_has_sys_membarrier = 1; +} +#endif + +static +void urcu_bp_sys_membarrier_init(void) +{ + bool available = false; + int mask; + + mask = membarrier(MEMBARRIER_CMD_QUERY, 0); + if (mask >= 0) { + if (mask & MEMBARRIER_CMD_PRIVATE_EXPEDITED) { + if (membarrier(MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED, 0)) + urcu_die(errno); + available = true; + } + } + urcu_bp_sys_membarrier_status(available); +} + +static +void _urcu_bp_init(void) +{ + mutex_lock(&init_lock); + if (!urcu_bp_refcount++) { + int ret; + + ret = pthread_key_create(&urcu_bp_key, + urcu_bp_thread_exit_notifier); + if (ret) + abort(); + urcu_bp_sys_membarrier_init(); + initialized = 1; + } + mutex_unlock(&init_lock); +} + +static +void urcu_bp_exit(void) +{ + mutex_lock(&init_lock); + if (!--urcu_bp_refcount) { + struct registry_chunk *chunk, *tmp; + int ret; + + cds_list_for_each_entry_safe(chunk, tmp, + ®istry_arena.chunk_list, node) { + munmap((void *) chunk, chunk_allocation_size(chunk->capacity)); + } + CDS_INIT_LIST_HEAD(®istry_arena.chunk_list); + ret = pthread_key_delete(urcu_bp_key); + if (ret) + abort(); + } + mutex_unlock(&init_lock); +} + +static +void urcu_bp_exit_destructor(void) +{ + urcu_call_rcu_exit(); + urcu_bp_exit(); +} + +/* + * Holding the rcu_gp_lock and rcu_registry_lock across fork will make + * sure we fork() don't race with a concurrent thread executing with + * any of those locks held. This ensures that the registry and data + * protected by rcu_gp_lock are in a coherent state in the child. + */ +void urcu_bp_before_fork(void) +{ + sigset_t newmask, oldmask; + int ret; + + ret = sigfillset(&newmask); + urcu_posix_assert(!ret); + ret = pthread_sigmask(SIG_BLOCK, &newmask, &oldmask); + urcu_posix_assert(!ret); + mutex_lock(&rcu_gp_lock); + mutex_lock(&rcu_registry_lock); + saved_fork_signal_mask = oldmask; +} + +void urcu_bp_after_fork_parent(void) +{ + sigset_t oldmask; + int ret; + + oldmask = saved_fork_signal_mask; + mutex_unlock(&rcu_registry_lock); + mutex_unlock(&rcu_gp_lock); + ret = pthread_sigmask(SIG_SETMASK, &oldmask, NULL); + urcu_posix_assert(!ret); +} + +/* + * Prune all entries from registry except our own thread. Fits the Linux + * fork behavior. Called with rcu_gp_lock and rcu_registry_lock held. + */ +static +void urcu_bp_prune_registry(void) +{ + struct registry_chunk *chunk; + + cds_list_for_each_entry(chunk, ®istry_arena.chunk_list, node) { + size_t spot_idx; + + for (spot_idx = 0; spot_idx < chunk->capacity; spot_idx++) { + struct urcu_bp_reader *reader = &chunk->readers[spot_idx]; + + if (!reader->alloc) + continue; + if (reader->tid == pthread_self()) + continue; + cleanup_thread(chunk, reader); + } + } +} + +void urcu_bp_after_fork_child(void) +{ + sigset_t oldmask; + int ret; + + urcu_bp_prune_registry(); + oldmask = saved_fork_signal_mask; + mutex_unlock(&rcu_registry_lock); + mutex_unlock(&rcu_gp_lock); + ret = pthread_sigmask(SIG_SETMASK, &oldmask, NULL); + urcu_posix_assert(!ret); +} + +void *urcu_bp_dereference_sym(void *p) +{ + return _rcu_dereference(p); +} + +void *urcu_bp_set_pointer_sym(void **p, void *v) +{ + cmm_wmb(); + uatomic_set(p, v); + return v; +} + +void *urcu_bp_xchg_pointer_sym(void **p, void *v) +{ + cmm_wmb(); + return uatomic_xchg(p, v); +} + +void *urcu_bp_cmpxchg_pointer_sym(void **p, void *old, void *_new) +{ + cmm_wmb(); + return uatomic_cmpxchg(p, old, _new); +} + +DEFINE_RCU_FLAVOR(rcu_flavor); + +#include "urcu-call-rcu-impl.h" +#include "urcu-defer-impl.h" +#include "urcu-poll-impl.h" diff --git a/external/lgpl2/userspace-rcu/dist/src/urcu-call-rcu-impl.h b/external/lgpl2/userspace-rcu/dist/src/urcu-call-rcu-impl.h new file mode 100644 index 0000000000000..2ea1efcd19c97 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/urcu-call-rcu-impl.h @@ -0,0 +1,1112 @@ +// SPDX-FileCopyrightText: 2010 Paul E. McKenney +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU library - batch memory reclamation with kernel API + */ + +#define _LGPL_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "compat-getcpu.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "urcu-die.h" +#include "urcu-utils.h" +#include "compat-smp.h" + +#define SET_AFFINITY_CHECK_PERIOD (1U << 8) /* 256 */ +#define SET_AFFINITY_CHECK_PERIOD_MASK (SET_AFFINITY_CHECK_PERIOD - 1) + +/* Data structure that identifies a call_rcu thread. */ + +struct call_rcu_data { + /* + * We do not align head on a different cache-line than tail + * mainly because call_rcu callback-invocation threads use + * batching ("splice") to get an entire list of callbacks, which + * effectively empties the queue, and requires to touch the tail + * anyway. + */ + struct cds_wfcq_tail cbs_tail; + struct cds_wfcq_head cbs_head; + unsigned long flags; + int32_t futex; + unsigned long qlen; /* maintained for debugging. */ + pthread_t tid; + int cpu_affinity; + unsigned long gp_count; + struct cds_list_head list; +} __attribute__((aligned(CAA_CACHE_LINE_SIZE))); + +struct call_rcu_completion { + int barrier_count; + int32_t futex; + struct urcu_ref ref; +}; + +struct call_rcu_completion_work { + struct rcu_head head; + struct call_rcu_completion *completion; +}; + +enum crdf_flags { + CRDF_FLAG_JOIN_THREAD = (1 << 0), +}; + +/* + * List of all call_rcu_data structures to keep valgrind happy. + * Protected by call_rcu_mutex. + */ + +static CDS_LIST_HEAD(call_rcu_data_list); + +/* Link a thread using call_rcu() to its call_rcu thread. */ + +static DEFINE_URCU_TLS(struct call_rcu_data *, thread_call_rcu_data); + +/* + * Guard call_rcu thread creation and atfork handlers. + */ +static pthread_mutex_t call_rcu_mutex = PTHREAD_MUTEX_INITIALIZER; + +/* If a given thread does not have its own call_rcu thread, this is default. */ + +static struct call_rcu_data *default_call_rcu_data; + +static struct urcu_atfork *registered_rculfhash_atfork; + +/* + * If the sched_getcpu() and sysconf(_SC_NPROCESSORS_CONF) calls are + * available, then we can have call_rcu threads assigned to individual + * CPUs rather than only to specific threads. + */ + +#if defined(HAVE_SYSCONF) && (defined(HAVE_SCHED_GETCPU) || defined(HAVE_GETCPUID)) + +/* + * Pointer to array of pointers to per-CPU call_rcu_data structures + * and # CPUs. per_cpu_call_rcu_data is a RCU-protected pointer to an + * array of RCU-protected pointers to call_rcu_data. call_rcu acts as a + * RCU read-side and reads per_cpu_call_rcu_data and the per-cpu pointer + * without mutex. The call_rcu_mutex protects updates. + */ + +static struct call_rcu_data **per_cpu_call_rcu_data; +static long cpus_array_len; + +static void cpus_array_len_reset(void) +{ + cpus_array_len = 0; +} + +/* Allocate the array if it has not already been allocated. */ + +static void alloc_cpu_call_rcu_data(void) +{ + struct call_rcu_data **p; + static int warned = 0; + + if (cpus_array_len != 0) + return; + cpus_array_len = get_possible_cpus_array_len(); + if (cpus_array_len <= 0) { + return; + } + p = malloc(cpus_array_len * sizeof(*per_cpu_call_rcu_data)); + if (p != NULL) { + memset(p, '\0', cpus_array_len * sizeof(*per_cpu_call_rcu_data)); + rcu_set_pointer(&per_cpu_call_rcu_data, p); + } else { + if (!warned) { + fprintf(stderr, "[error] liburcu: unable to allocate per-CPU pointer array\n"); + } + warned = 1; + } +} + +#else /* #if defined(HAVE_SYSCONF) && defined(HAVE_SCHED_GETCPU) */ + +/* + * per_cpu_call_rcu_data should be constant, but some functions below, used both + * for cases where cpu number is available and not available, assume it it not + * constant. + */ +static struct call_rcu_data **per_cpu_call_rcu_data = NULL; +static const long cpus_array_len = -1; + +static void cpus_array_len_reset(void) +{ +} + +static void alloc_cpu_call_rcu_data(void) +{ +} + +#endif /* #else #if defined(HAVE_SYSCONF) && defined(HAVE_SCHED_GETCPU) */ + +/* Acquire the specified pthread mutex. */ + +static void call_rcu_lock(pthread_mutex_t *pmp) +{ + int ret; + + ret = pthread_mutex_lock(pmp); + if (ret) + urcu_die(ret); +} + +/* Release the specified pthread mutex. */ + +static void call_rcu_unlock(pthread_mutex_t *pmp) +{ + int ret; + + ret = pthread_mutex_unlock(pmp); + if (ret) + urcu_die(ret); +} + +/* + * Periodically retry setting CPU affinity if we migrate. + * Losing affinity can be caused by CPU hotunplug/hotplug, or by + * cpuset(7). + */ +#ifdef HAVE_SCHED_SETAFFINITY +static +int set_thread_cpu_affinity(struct call_rcu_data *crdp) +{ + cpu_set_t mask; + int ret; + + if (crdp->cpu_affinity < 0) + return 0; + if (++crdp->gp_count & SET_AFFINITY_CHECK_PERIOD_MASK) + return 0; + if (urcu_sched_getcpu() == crdp->cpu_affinity) + return 0; + + CPU_ZERO(&mask); + CPU_SET(crdp->cpu_affinity, &mask); + ret = sched_setaffinity(0, sizeof(mask), &mask); + + /* + * EINVAL is fine: can be caused by hotunplugged CPUs, or by + * cpuset(7). This is why we should always retry if we detect + * migration. + */ + if (ret && errno == EINVAL) { + ret = 0; + errno = 0; + } + return ret; +} +#else +static +int set_thread_cpu_affinity(struct call_rcu_data *crdp __attribute__((unused))) +{ + return 0; +} +#endif + +static void call_rcu_wait(struct call_rcu_data *crdp) +{ + /* Read call_rcu list before read futex */ + cmm_smp_mb(); + while (uatomic_read(&crdp->futex) == -1) { + if (!futex_async(&crdp->futex, FUTEX_WAIT, -1, NULL, NULL, 0)) { + /* + * Prior queued wakeups queued by unrelated code + * using the same address can cause futex wait to + * return 0 even through the futex value is still + * -1 (spurious wakeups). Check the value again + * in user-space to validate whether it really + * differs from -1. + */ + continue; + } + switch (errno) { + case EAGAIN: + /* Value already changed. */ + return; + case EINTR: + /* Retry if interrupted by signal. */ + break; /* Get out of switch. Check again. */ + default: + /* Unexpected error. */ + urcu_die(errno); + } + } +} + +static void call_rcu_wake_up(struct call_rcu_data *crdp) +{ + /* Write to call_rcu list before reading/writing futex */ + cmm_smp_mb(); + if (caa_unlikely(uatomic_read(&crdp->futex) == -1)) { + uatomic_set(&crdp->futex, 0); + if (futex_async(&crdp->futex, FUTEX_WAKE, 1, + NULL, NULL, 0) < 0) + urcu_die(errno); + } +} + +static void call_rcu_completion_wait(struct call_rcu_completion *completion) +{ + /* Read completion barrier count before read futex */ + cmm_smp_mb(); + while (uatomic_read(&completion->futex) == -1) { + if (!futex_async(&completion->futex, FUTEX_WAIT, -1, NULL, NULL, 0)) { + /* + * Prior queued wakeups queued by unrelated code + * using the same address can cause futex wait to + * return 0 even through the futex value is still + * -1 (spurious wakeups). Check the value again + * in user-space to validate whether it really + * differs from -1. + */ + continue; + } + switch (errno) { + case EAGAIN: + /* Value already changed. */ + return; + case EINTR: + /* Retry if interrupted by signal. */ + break; /* Get out of switch. Check again. */ + default: + /* Unexpected error. */ + urcu_die(errno); + } + } +} + +static void call_rcu_completion_wake_up(struct call_rcu_completion *completion) +{ + /* Write to completion barrier count before reading/writing futex */ + cmm_smp_mb(); + if (caa_unlikely(uatomic_read(&completion->futex) == -1)) { + uatomic_set(&completion->futex, 0); + if (futex_async(&completion->futex, FUTEX_WAKE, 1, + NULL, NULL, 0) < 0) + urcu_die(errno); + } +} + +/* This is the code run by each call_rcu thread. */ + +static void *call_rcu_thread(void *arg) +{ + unsigned long cbcount; + struct call_rcu_data *crdp = (struct call_rcu_data *) arg; + int rt = !!(uatomic_read(&crdp->flags) & URCU_CALL_RCU_RT); + + if (set_thread_cpu_affinity(crdp)) + urcu_die(errno); + + /* + * If callbacks take a read-side lock, we need to be registered. + */ + rcu_register_thread(); + + URCU_TLS(thread_call_rcu_data) = crdp; + if (!rt) { + uatomic_dec(&crdp->futex); + /* Decrement futex before reading call_rcu list */ + cmm_smp_mb(); + } + for (;;) { + struct cds_wfcq_head cbs_tmp_head; + struct cds_wfcq_tail cbs_tmp_tail; + struct cds_wfcq_node *cbs, *cbs_tmp_n; + enum cds_wfcq_ret splice_ret; + + if (set_thread_cpu_affinity(crdp)) + urcu_die(errno); + + if (uatomic_read(&crdp->flags) & URCU_CALL_RCU_PAUSE) { + /* + * Pause requested. Become quiescent: remove + * ourself from all global lists, and don't + * process any callback. The callback lists may + * still be non-empty though. + */ + rcu_unregister_thread(); + cmm_smp_mb__before_uatomic_or(); + uatomic_or(&crdp->flags, URCU_CALL_RCU_PAUSED); + while ((uatomic_read(&crdp->flags) & URCU_CALL_RCU_PAUSE) != 0) + (void) poll(NULL, 0, 1); + uatomic_and(&crdp->flags, ~URCU_CALL_RCU_PAUSED); + cmm_smp_mb__after_uatomic_and(); + rcu_register_thread(); + } + + cds_wfcq_init(&cbs_tmp_head, &cbs_tmp_tail); + splice_ret = __cds_wfcq_splice_blocking(&cbs_tmp_head, + &cbs_tmp_tail, &crdp->cbs_head, &crdp->cbs_tail); + urcu_posix_assert(splice_ret != CDS_WFCQ_RET_WOULDBLOCK); + urcu_posix_assert(splice_ret != CDS_WFCQ_RET_DEST_NON_EMPTY); + if (splice_ret != CDS_WFCQ_RET_SRC_EMPTY) { + synchronize_rcu(); + cbcount = 0; + __cds_wfcq_for_each_blocking_safe(&cbs_tmp_head, + &cbs_tmp_tail, cbs, cbs_tmp_n) { + struct rcu_head *rhp; + + rhp = caa_container_of(cbs, + struct rcu_head, next); + rhp->func(rhp); + cbcount++; + } + uatomic_sub(&crdp->qlen, cbcount); + } + if (uatomic_read(&crdp->flags) & URCU_CALL_RCU_STOP) + break; + rcu_thread_offline(); + if (!rt) { + if (cds_wfcq_empty(&crdp->cbs_head, + &crdp->cbs_tail)) { + call_rcu_wait(crdp); + (void) poll(NULL, 0, 10); + uatomic_dec(&crdp->futex); + /* + * Decrement futex before reading + * call_rcu list. + */ + cmm_smp_mb(); + } else { + (void) poll(NULL, 0, 10); + } + } else { + (void) poll(NULL, 0, 10); + } + rcu_thread_online(); + } + if (!rt) { + /* + * Read call_rcu list before write futex. + */ + cmm_smp_mb(); + uatomic_set(&crdp->futex, 0); + } + uatomic_or(&crdp->flags, URCU_CALL_RCU_STOPPED); + rcu_unregister_thread(); + return NULL; +} + +/* + * Create both a call_rcu thread and the corresponding call_rcu_data + * structure, linking the structure in as specified. Caller must hold + * call_rcu_mutex. + */ + +static void call_rcu_data_init(struct call_rcu_data **crdpp, + unsigned long flags, + int cpu_affinity) +{ + struct call_rcu_data *crdp; + int ret; + sigset_t newmask, oldmask; + + crdp = malloc(sizeof(*crdp)); + if (crdp == NULL) + urcu_die(errno); + memset(crdp, '\0', sizeof(*crdp)); + cds_wfcq_init(&crdp->cbs_head, &crdp->cbs_tail); + crdp->qlen = 0; + crdp->futex = 0; + crdp->flags = flags; + cds_list_add(&crdp->list, &call_rcu_data_list); + crdp->cpu_affinity = cpu_affinity; + crdp->gp_count = 0; + rcu_set_pointer(crdpp, crdp); + + ret = sigfillset(&newmask); + urcu_posix_assert(!ret); + ret = pthread_sigmask(SIG_BLOCK, &newmask, &oldmask); + urcu_posix_assert(!ret); + + ret = pthread_create(&crdp->tid, NULL, call_rcu_thread, crdp); + if (ret) + urcu_die(ret); + + ret = pthread_sigmask(SIG_SETMASK, &oldmask, NULL); + urcu_posix_assert(!ret); +} + +/* + * Return a pointer to the call_rcu_data structure for the specified + * CPU, returning NULL if there is none. We cannot automatically + * created it because the platform we are running on might not define + * urcu_sched_getcpu(). + * + * The call to this function and use of the returned call_rcu_data + * should be protected by RCU read-side lock. + */ + +struct call_rcu_data *get_cpu_call_rcu_data(int cpu) +{ + static int warned = 0; + struct call_rcu_data **pcpu_crdp; + + pcpu_crdp = rcu_dereference(per_cpu_call_rcu_data); + if (pcpu_crdp == NULL) + return NULL; + if (!warned && cpus_array_len > 0 && (cpu < 0 || cpus_array_len <= cpu)) { + fprintf(stderr, "[error] liburcu: get CPU # out of range\n"); + warned = 1; + } + if (cpu < 0 || cpus_array_len <= cpu) + return NULL; + return rcu_dereference(pcpu_crdp[cpu]); +} + +/* + * Return the tid corresponding to the call_rcu thread whose + * call_rcu_data structure is specified. + */ + +pthread_t get_call_rcu_thread(struct call_rcu_data *crdp) +{ + return crdp->tid; +} + +/* + * Create a call_rcu_data structure (with thread) and return a pointer. + */ + +static struct call_rcu_data *__create_call_rcu_data(unsigned long flags, + int cpu_affinity) +{ + struct call_rcu_data *crdp; + + call_rcu_data_init(&crdp, flags, cpu_affinity); + return crdp; +} + +struct call_rcu_data *create_call_rcu_data(unsigned long flags, + int cpu_affinity) +{ + struct call_rcu_data *crdp; + + call_rcu_lock(&call_rcu_mutex); + crdp = __create_call_rcu_data(flags, cpu_affinity); + call_rcu_unlock(&call_rcu_mutex); + return crdp; +} + +/* + * Set the specified CPU to use the specified call_rcu_data structure. + * + * Use NULL to remove a CPU's call_rcu_data structure, but it is + * the caller's responsibility to dispose of the removed structure. + * Use get_cpu_call_rcu_data() to obtain a pointer to the old structure + * (prior to NULLing it out, of course). + * + * The caller must wait for a grace-period to pass between return from + * set_cpu_call_rcu_data() and call to call_rcu_data_free() passing the + * previous call rcu data as argument. + */ + +int set_cpu_call_rcu_data(int cpu, struct call_rcu_data *crdp) +{ + static int warned = 0; + + call_rcu_lock(&call_rcu_mutex); + alloc_cpu_call_rcu_data(); + if (cpu < 0 || cpus_array_len <= cpu) { + if (!warned) { + fprintf(stderr, "[error] liburcu: set CPU # out of range\n"); + warned = 1; + } + call_rcu_unlock(&call_rcu_mutex); + errno = EINVAL; + return -EINVAL; + } + + if (per_cpu_call_rcu_data == NULL) { + call_rcu_unlock(&call_rcu_mutex); + errno = ENOMEM; + return -ENOMEM; + } + + if (per_cpu_call_rcu_data[cpu] != NULL && crdp != NULL) { + call_rcu_unlock(&call_rcu_mutex); + errno = EEXIST; + return -EEXIST; + } + + rcu_set_pointer(&per_cpu_call_rcu_data[cpu], crdp); + call_rcu_unlock(&call_rcu_mutex); + return 0; +} + +/* + * Return a pointer to the default call_rcu_data structure, creating + * one if need be. + * + * The call to this function with intent to use the returned + * call_rcu_data should be protected by RCU read-side lock. + */ + +struct call_rcu_data *get_default_call_rcu_data(void) +{ + struct call_rcu_data *crdp; + + crdp = rcu_dereference(default_call_rcu_data); + if (crdp != NULL) + return crdp; + + call_rcu_lock(&call_rcu_mutex); + if (default_call_rcu_data == NULL) + call_rcu_data_init(&default_call_rcu_data, 0, -1); + crdp = default_call_rcu_data; + call_rcu_unlock(&call_rcu_mutex); + + return crdp; +} + +/* + * Return the call_rcu_data structure that applies to the currently + * running thread. Any call_rcu_data structure assigned specifically + * to this thread has first priority, followed by any call_rcu_data + * structure assigned to the CPU on which the thread is running, + * followed by the default call_rcu_data structure. If there is not + * yet a default call_rcu_data structure, one will be created. + * + * Calls to this function and use of the returned call_rcu_data should + * be protected by RCU read-side lock. + */ +struct call_rcu_data *get_call_rcu_data(void) +{ + struct call_rcu_data *crd; + + if (URCU_TLS(thread_call_rcu_data) != NULL) + return URCU_TLS(thread_call_rcu_data); + + if (cpus_array_len > 0) { + crd = get_cpu_call_rcu_data(urcu_sched_getcpu()); + if (crd) + return crd; + } + + return get_default_call_rcu_data(); +} + +/* + * Return a pointer to this task's call_rcu_data if there is one. + */ + +struct call_rcu_data *get_thread_call_rcu_data(void) +{ + return URCU_TLS(thread_call_rcu_data); +} + +/* + * Set this task's call_rcu_data structure as specified, regardless + * of whether or not this task already had one. (This allows switching + * to and from real-time call_rcu threads, for example.) + * + * Use NULL to remove a thread's call_rcu_data structure, but it is + * the caller's responsibility to dispose of the removed structure. + * Use get_thread_call_rcu_data() to obtain a pointer to the old structure + * (prior to NULLing it out, of course). + */ + +void set_thread_call_rcu_data(struct call_rcu_data *crdp) +{ + URCU_TLS(thread_call_rcu_data) = crdp; +} + +/* + * Create a separate call_rcu thread for each CPU. This does not + * replace a pre-existing call_rcu thread -- use the set_cpu_call_rcu_data() + * function if you want that behavior. Should be paired with + * free_all_cpu_call_rcu_data() to teardown these call_rcu worker + * threads. + */ + +int create_all_cpu_call_rcu_data(unsigned long flags) +{ + int i; + struct call_rcu_data *crdp; + int ret; + + call_rcu_lock(&call_rcu_mutex); + alloc_cpu_call_rcu_data(); + call_rcu_unlock(&call_rcu_mutex); + if (cpus_array_len <= 0) { + errno = EINVAL; + return -EINVAL; + } + if (per_cpu_call_rcu_data == NULL) { + errno = ENOMEM; + return -ENOMEM; + } + for (i = 0; i < cpus_array_len; i++) { + call_rcu_lock(&call_rcu_mutex); + if (get_cpu_call_rcu_data(i)) { + call_rcu_unlock(&call_rcu_mutex); + continue; + } + crdp = __create_call_rcu_data(flags, i); + if (crdp == NULL) { + call_rcu_unlock(&call_rcu_mutex); + errno = ENOMEM; + return -ENOMEM; + } + call_rcu_unlock(&call_rcu_mutex); + if ((ret = set_cpu_call_rcu_data(i, crdp)) != 0) { + call_rcu_data_free(crdp); + + /* it has been created by other thread */ + if (ret == -EEXIST) + continue; + + return ret; + } + } + return 0; +} + +/* + * Wake up the call_rcu thread corresponding to the specified + * call_rcu_data structure. + */ +static void wake_call_rcu_thread(struct call_rcu_data *crdp) +{ + if (!(_CMM_LOAD_SHARED(crdp->flags) & URCU_CALL_RCU_RT)) + call_rcu_wake_up(crdp); +} + +static void _call_rcu(struct rcu_head *head, + void (*func)(struct rcu_head *head), + struct call_rcu_data *crdp) +{ + cds_wfcq_node_init(&head->next); + head->func = func; + cds_wfcq_enqueue(&crdp->cbs_head, &crdp->cbs_tail, &head->next); + uatomic_inc(&crdp->qlen); + wake_call_rcu_thread(crdp); +} + +/* + * Schedule a function to be invoked after a following grace period. + * This is the only function that must be called -- the others are + * only present to allow applications to tune their use of RCU for + * maximum performance. + * + * Note that unless a call_rcu thread has not already been created, + * the first invocation of call_rcu() will create one. So, if you + * need the first invocation of call_rcu() to be fast, make sure + * to create a call_rcu thread first. One way to accomplish this is + * "get_call_rcu_data();", and another is create_all_cpu_call_rcu_data(). + * + * call_rcu must be called by registered RCU read-side threads. + */ +void call_rcu(struct rcu_head *head, + void (*func)(struct rcu_head *head)) +{ + struct call_rcu_data *crdp; + + /* Holding rcu read-side lock across use of per-cpu crdp */ + _rcu_read_lock(); + crdp = get_call_rcu_data(); + _call_rcu(head, func, crdp); + _rcu_read_unlock(); +} + +/* + * Free up the specified call_rcu_data structure, terminating the + * associated call_rcu thread. The caller must have previously + * removed the call_rcu_data structure from per-thread or per-CPU + * usage. For example, set_cpu_call_rcu_data(cpu, NULL) for per-CPU + * call_rcu_data structures or set_thread_call_rcu_data(NULL) for + * per-thread call_rcu_data structures. + * + * We silently refuse to free up the default call_rcu_data structure + * because that is where we put any leftover callbacks. Note that + * the possibility of self-spawning callbacks makes it impossible + * to execute all the callbacks in finite time without putting any + * newly spawned callbacks somewhere else. The "somewhere else" of + * last resort is the default call_rcu_data structure. + * + * We also silently refuse to free NULL pointers. This simplifies + * the calling code. + * + * The caller must wait for a grace-period to pass between return from + * set_cpu_call_rcu_data() and call to call_rcu_data_free() passing the + * previous call rcu data as argument. + * + * Note: introducing __cds_wfcq_splice_blocking() in this function fixed + * a list corruption bug in the 0.7.x series. The equivalent fix + * appeared in 0.6.8 for the stable-0.6 branch. + */ +static +void _call_rcu_data_free(struct call_rcu_data *crdp, unsigned int flags) +{ + if (crdp == NULL || crdp == default_call_rcu_data) { + return; + } + if ((uatomic_read(&crdp->flags) & URCU_CALL_RCU_STOPPED) == 0) { + uatomic_or(&crdp->flags, URCU_CALL_RCU_STOP); + wake_call_rcu_thread(crdp); + while ((uatomic_read(&crdp->flags) & URCU_CALL_RCU_STOPPED) == 0) + (void) poll(NULL, 0, 1); + } + call_rcu_lock(&call_rcu_mutex); + if (!cds_wfcq_empty(&crdp->cbs_head, &crdp->cbs_tail)) { + call_rcu_unlock(&call_rcu_mutex); + /* Create default call rcu data if need be. */ + /* CBs queued here will be handed to the default list. */ + (void) get_default_call_rcu_data(); + call_rcu_lock(&call_rcu_mutex); + __cds_wfcq_splice_blocking(&default_call_rcu_data->cbs_head, + &default_call_rcu_data->cbs_tail, + &crdp->cbs_head, &crdp->cbs_tail); + uatomic_add(&default_call_rcu_data->qlen, + uatomic_read(&crdp->qlen)); + wake_call_rcu_thread(default_call_rcu_data); + } + + cds_list_del(&crdp->list); + call_rcu_unlock(&call_rcu_mutex); + + if (flags & CRDF_FLAG_JOIN_THREAD) { + int ret; + + ret = pthread_join(get_call_rcu_thread(crdp), NULL); + if (ret) + urcu_die(ret); + } + free(crdp); +} + +void call_rcu_data_free(struct call_rcu_data *crdp) +{ + _call_rcu_data_free(crdp, CRDF_FLAG_JOIN_THREAD); +} + +/* + * Clean up all the per-CPU call_rcu threads. + */ +void free_all_cpu_call_rcu_data(void) +{ + int cpu; + struct call_rcu_data **crdp; + static int warned = 0; + + if (cpus_array_len <= 0) + return; + + crdp = malloc(sizeof(*crdp) * cpus_array_len); + if (!crdp) { + if (!warned) { + fprintf(stderr, "[error] liburcu: unable to allocate per-CPU pointer array\n"); + } + warned = 1; + return; + } + + for (cpu = 0; cpu < cpus_array_len; cpu++) { + crdp[cpu] = get_cpu_call_rcu_data(cpu); + if (crdp[cpu] == NULL) + continue; + set_cpu_call_rcu_data(cpu, NULL); + } + /* + * Wait for call_rcu sites acting as RCU readers of the + * call_rcu_data to become quiescent. + */ + synchronize_rcu(); + for (cpu = 0; cpu < cpus_array_len; cpu++) { + if (crdp[cpu] == NULL) + continue; + call_rcu_data_free(crdp[cpu]); + } + free(crdp); +} + +static +void free_completion(struct urcu_ref *ref) +{ + struct call_rcu_completion *completion; + + completion = caa_container_of(ref, struct call_rcu_completion, ref); + free(completion); +} + +static +void _rcu_barrier_complete(struct rcu_head *head) +{ + struct call_rcu_completion_work *work; + struct call_rcu_completion *completion; + + work = caa_container_of(head, struct call_rcu_completion_work, head); + completion = work->completion; + if (!uatomic_sub_return(&completion->barrier_count, 1)) + call_rcu_completion_wake_up(completion); + urcu_ref_put(&completion->ref, free_completion); + free(work); +} + +/* + * Wait for all in-flight call_rcu callbacks to complete execution. + */ +void rcu_barrier(void) +{ + struct call_rcu_data *crdp; + struct call_rcu_completion *completion; + int count = 0; + int was_online; + + /* Put in offline state in QSBR. */ + was_online = _rcu_read_ongoing(); + if (was_online) + rcu_thread_offline(); + /* + * Calling a rcu_barrier() within a RCU read-side critical + * section is an error. + */ + if (_rcu_read_ongoing()) { + static int warned = 0; + + if (!warned) { + fprintf(stderr, "[error] liburcu: rcu_barrier() called from within RCU read-side critical section.\n"); + } + warned = 1; + goto online; + } + + completion = calloc(1, sizeof(*completion)); + if (!completion) + urcu_die(errno); + + call_rcu_lock(&call_rcu_mutex); + cds_list_for_each_entry(crdp, &call_rcu_data_list, list) + count++; + + /* Referenced by rcu_barrier() and each call_rcu thread. */ + urcu_ref_set(&completion->ref, count + 1); + completion->barrier_count = count; + + cds_list_for_each_entry(crdp, &call_rcu_data_list, list) { + struct call_rcu_completion_work *work; + + work = calloc(1, sizeof(*work)); + if (!work) + urcu_die(errno); + work->completion = completion; + _call_rcu(&work->head, _rcu_barrier_complete, crdp); + } + call_rcu_unlock(&call_rcu_mutex); + + /* Wait for them */ + for (;;) { + uatomic_dec(&completion->futex); + /* Decrement futex before reading barrier_count */ + cmm_smp_mb(); + if (!uatomic_read(&completion->barrier_count)) + break; + call_rcu_completion_wait(completion); + } + + urcu_ref_put(&completion->ref, free_completion); + +online: + if (was_online) + rcu_thread_online(); +} + +/* + * Acquire the call_rcu_mutex in order to ensure that the child sees + * all of the call_rcu() data structures in a consistent state. Ensure + * that all call_rcu threads are in a quiescent state across fork. + * Suitable for pthread_atfork() and friends. + */ +void call_rcu_before_fork(void) +{ + struct call_rcu_data *crdp; + struct urcu_atfork *atfork; + + call_rcu_lock(&call_rcu_mutex); + + atfork = registered_rculfhash_atfork; + if (atfork) + atfork->before_fork(atfork->priv); + + cds_list_for_each_entry(crdp, &call_rcu_data_list, list) { + uatomic_or(&crdp->flags, URCU_CALL_RCU_PAUSE); + cmm_smp_mb__after_uatomic_or(); + wake_call_rcu_thread(crdp); + } + cds_list_for_each_entry(crdp, &call_rcu_data_list, list) { + while ((uatomic_read(&crdp->flags) & URCU_CALL_RCU_PAUSED) == 0) + (void) poll(NULL, 0, 1); + } +} + +/* + * Clean up call_rcu data structures in the parent of a successful fork() + * that is not followed by exec() in the child. Suitable for + * pthread_atfork() and friends. + */ +void call_rcu_after_fork_parent(void) +{ + struct call_rcu_data *crdp; + struct urcu_atfork *atfork; + + cds_list_for_each_entry(crdp, &call_rcu_data_list, list) + uatomic_and(&crdp->flags, ~URCU_CALL_RCU_PAUSE); + cds_list_for_each_entry(crdp, &call_rcu_data_list, list) { + while ((uatomic_read(&crdp->flags) & URCU_CALL_RCU_PAUSED) != 0) + (void) poll(NULL, 0, 1); + } + atfork = registered_rculfhash_atfork; + if (atfork) + atfork->after_fork_parent(atfork->priv); + call_rcu_unlock(&call_rcu_mutex); +} + +/* + * Clean up call_rcu data structures in the child of a successful fork() + * that is not followed by exec(). Suitable for pthread_atfork() and + * friends. + */ +void call_rcu_after_fork_child(void) +{ + struct call_rcu_data *crdp, *next; + struct urcu_atfork *atfork; + + /* Release the mutex. */ + call_rcu_unlock(&call_rcu_mutex); + + atfork = registered_rculfhash_atfork; + if (atfork) + atfork->after_fork_child(atfork->priv); + + /* Do nothing when call_rcu() has not been used */ + if (cds_list_empty(&call_rcu_data_list)) + return; + + /* + * Allocate a new default call_rcu_data structure in order + * to get a working call_rcu thread to go with it. + */ + default_call_rcu_data = NULL; + (void)get_default_call_rcu_data(); + + /* Cleanup call_rcu_data pointers before use */ + cpus_array_len_reset(); + free(per_cpu_call_rcu_data); + rcu_set_pointer(&per_cpu_call_rcu_data, NULL); + URCU_TLS(thread_call_rcu_data) = NULL; + + /* + * Dispose of all of the rest of the call_rcu_data structures. + * Leftover call_rcu callbacks will be merged into the new + * default call_rcu thread queue. + */ + cds_list_for_each_entry_safe(crdp, next, &call_rcu_data_list, list) { + if (crdp == default_call_rcu_data) + continue; + uatomic_set(&crdp->flags, URCU_CALL_RCU_STOPPED); + /* + * Do not join the thread because it does not exist in + * the child. + */ + _call_rcu_data_free(crdp, 0); + } +} + +void urcu_register_rculfhash_atfork(struct urcu_atfork *atfork) +{ + if (CMM_LOAD_SHARED(registered_rculfhash_atfork)) + return; + call_rcu_lock(&call_rcu_mutex); + if (!registered_rculfhash_atfork) + registered_rculfhash_atfork = atfork; + call_rcu_unlock(&call_rcu_mutex); +} + +/* + * This unregistration function is deprecated, meant only for internal + * use by rculfhash. + */ +__attribute__((__noreturn__)) +void urcu_unregister_rculfhash_atfork(struct urcu_atfork *atfork __attribute__((unused))) +{ + urcu_die(EPERM); +} + +/* + * Teardown the default call_rcu worker thread if there are no queued + * callbacks on process exit. This prevents leaking memory. + * + * Here is how an application can ensure graceful teardown of this + * worker thread: + * + * - An application queuing call_rcu callbacks should invoke + * rcu_barrier() before it exits. + * - When chaining call_rcu callbacks, the number of calls to + * rcu_barrier() on application exit must match at least the maximum + * number of chained callbacks. + * - If an application chains callbacks endlessly, it would have to be + * modified to stop chaining callbacks when it detects an application + * exit (e.g. with a flag), and wait for quiescence with rcu_barrier() + * after setting that flag. + * - The statements above apply to a library which queues call_rcu + * callbacks, only it needs to invoke rcu_barrier in its library + * destructor. + * + * Note that this function does not presume it is being called when the + * application is single-threaded even though this is invoked from a + * destructor: this function synchronizes against concurrent calls to + * get_default_call_rcu_data(). + */ +static void urcu_call_rcu_exit(void) +{ + struct call_rcu_data *crdp; + bool teardown = true; + + if (default_call_rcu_data == NULL) + return; + call_rcu_lock(&call_rcu_mutex); + /* + * If the application leaves callbacks in the default call_rcu + * worker queue, keep the default worker in place. + */ + crdp = default_call_rcu_data; + if (!crdp) { + teardown = false; + goto unlock; + } + if (!cds_wfcq_empty(&crdp->cbs_head, &crdp->cbs_tail)) { + teardown = false; + goto unlock; + } + rcu_set_pointer(&default_call_rcu_data, NULL); +unlock: + call_rcu_unlock(&call_rcu_mutex); + if (teardown) { + synchronize_rcu(); + call_rcu_data_free(crdp); + } +} diff --git a/external/lgpl2/userspace-rcu/dist/src/urcu-defer-impl.h b/external/lgpl2/userspace-rcu/dist/src/urcu-defer-impl.h new file mode 100644 index 0000000000000..a180c4875bf17 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/urcu-defer-impl.h @@ -0,0 +1,476 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_DEFER_IMPL_H +#define _URCU_DEFER_IMPL_H + +/* + * Userspace RCU header - memory reclamation. + * + * TO BE INCLUDED ONLY FROM URCU LIBRARY CODE. See urcu-defer.h for linking + * dynamically with the userspace rcu reclamation library. + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "urcu/futex.h" + +#include +#include +#include +#include +#include +#include +#include +#include "urcu-die.h" +#include "urcu-utils.h" + +/* + * Number of entries in the per-thread defer queue. Must be power of 2. + */ +#define DEFER_QUEUE_SIZE (1 << 12) +#define DEFER_QUEUE_MASK (DEFER_QUEUE_SIZE - 1) + +/* + * Typically, data is aligned at least on the architecture size. + * Use lowest bit to indicate that the current callback is changing. + * Assumes that (void *)-2L is not used often. Used to encode non-aligned + * functions and non-aligned data using extra space. + * We encode the (void *)-2L fct as: -2L, fct, data. + * We encode the (void *)-2L data as either: + * fct | DQ_FCT_BIT, data (if fct is aligned), or + * -2L, fct, data (if fct is not aligned). + * Here, DQ_FCT_MARK == ~DQ_FCT_BIT. Required for the test order. + */ +#define DQ_FCT_BIT (1 << 0) +#define DQ_IS_FCT_BIT(x) ((unsigned long)(x) & DQ_FCT_BIT) +#define DQ_SET_FCT_BIT(x) \ + (x = (void *)((unsigned long)(x) | DQ_FCT_BIT)) +#define DQ_CLEAR_FCT_BIT(x) \ + (x = (void *)((unsigned long)(x) & ~DQ_FCT_BIT)) +#define DQ_FCT_MARK ((void *)(~DQ_FCT_BIT)) + +/* + * This code section can only be included in LGPL 2.1 compatible source code. + * See below for the function call wrappers which can be used in code meant to + * be only linked with the Userspace RCU library. This comes with a small + * performance degradation on the read-side due to the added function calls. + * This is required to permit relinking with newer versions of the library. + */ + +/* + * defer queue. + * Contains pointers. Encoded to save space when same callback is often used. + * When looking up the next item: + * - if DQ_FCT_BIT is set, set the current callback to DQ_CLEAR_FCT_BIT(ptr) + * - next element contains pointer to data. + * - else if item == DQ_FCT_MARK + * - set the current callback to next element ptr + * - following next element contains pointer to data. + * - else current element contains data + */ +struct defer_queue { + unsigned long head; /* add element at head */ + void *last_fct_in; /* last fct pointer encoded */ + unsigned long tail; /* next element to remove at tail */ + void *last_fct_out; /* last fct pointer encoded */ + void **q; + /* registry information */ + unsigned long last_head; + struct cds_list_head list; /* list of thread queues */ +}; + +/* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */ +#include + +void __attribute__((destructor)) rcu_defer_exit(void); + +extern void synchronize_rcu(void); + +/* + * rcu_defer_mutex nests inside defer_thread_mutex. + */ +static pthread_mutex_t rcu_defer_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t defer_thread_mutex = PTHREAD_MUTEX_INITIALIZER; + +static int32_t defer_thread_futex; +static int32_t defer_thread_stop; + +/* + * Written to only by each individual deferer. Read by both the deferer and + * the reclamation tread. + */ +static DEFINE_URCU_TLS(struct defer_queue, defer_queue); +static CDS_LIST_HEAD(registry_defer); +static pthread_t tid_defer; + +static void mutex_lock_defer(pthread_mutex_t *mutex) +{ + int ret; + +#ifndef DISTRUST_SIGNALS_EXTREME + ret = pthread_mutex_lock(mutex); + if (ret) + urcu_die(ret); +#else /* #ifndef DISTRUST_SIGNALS_EXTREME */ + while ((ret = pthread_mutex_trylock(mutex)) != 0) { + if (ret != EBUSY && ret != EINTR) + urcu_die(ret); + (void) poll(NULL,0,10); + } +#endif /* #else #ifndef DISTRUST_SIGNALS_EXTREME */ +} + +/* + * Wake-up any waiting defer thread. Called from many concurrent threads. + */ +static void wake_up_defer(void) +{ + if (caa_unlikely(uatomic_read(&defer_thread_futex) == -1)) { + uatomic_set(&defer_thread_futex, 0); + if (futex_noasync(&defer_thread_futex, FUTEX_WAKE, 1, + NULL, NULL, 0) < 0) + urcu_die(errno); + } +} + +static unsigned long rcu_defer_num_callbacks(void) +{ + unsigned long num_items = 0, head; + struct defer_queue *index; + + mutex_lock_defer(&rcu_defer_mutex); + cds_list_for_each_entry(index, ®istry_defer, list) { + head = CMM_LOAD_SHARED(index->head); + num_items += head - index->tail; + } + mutex_unlock(&rcu_defer_mutex); + return num_items; +} + +/* + * Defer thread waiting. Single thread. + */ +static void wait_defer(void) +{ + uatomic_dec(&defer_thread_futex); + /* Write futex before read queue */ + /* Write futex before read defer_thread_stop */ + cmm_smp_mb(); + if (_CMM_LOAD_SHARED(defer_thread_stop)) { + uatomic_set(&defer_thread_futex, 0); + pthread_exit(0); + } + if (rcu_defer_num_callbacks()) { + cmm_smp_mb(); /* Read queue before write futex */ + /* Callbacks are queued, don't wait. */ + uatomic_set(&defer_thread_futex, 0); + } else { + cmm_smp_rmb(); /* Read queue before read futex */ + while (uatomic_read(&defer_thread_futex) == -1) { + if (!futex_noasync(&defer_thread_futex, FUTEX_WAIT, -1, NULL, NULL, 0)) { + /* + * Prior queued wakeups queued by unrelated code + * using the same address can cause futex wait to + * return 0 even through the futex value is still + * -1 (spurious wakeups). Check the value again + * in user-space to validate whether it really + * differs from -1. + */ + continue; + } + switch (errno) { + case EAGAIN: + /* Value already changed. */ + return; + case EINTR: + /* Retry if interrupted by signal. */ + break; /* Get out of switch. Check again. */ + default: + /* Unexpected error. */ + urcu_die(errno); + } + } + } +} + +/* + * Must be called after Q.S. is reached. + */ +static void rcu_defer_barrier_queue(struct defer_queue *queue, + unsigned long head) +{ + unsigned long i; + void (*fct)(void *p); + void *p; + + /* + * Tail is only modified when lock is held. + * Head is only modified by owner thread. + */ + + for (i = queue->tail; i != head;) { + cmm_smp_rmb(); /* read head before q[]. */ + p = CMM_LOAD_SHARED(queue->q[i++ & DEFER_QUEUE_MASK]); + if (caa_unlikely(DQ_IS_FCT_BIT(p))) { + DQ_CLEAR_FCT_BIT(p); + queue->last_fct_out = p; + p = CMM_LOAD_SHARED(queue->q[i++ & DEFER_QUEUE_MASK]); + } else if (caa_unlikely(p == DQ_FCT_MARK)) { + p = CMM_LOAD_SHARED(queue->q[i++ & DEFER_QUEUE_MASK]); + queue->last_fct_out = p; + p = CMM_LOAD_SHARED(queue->q[i++ & DEFER_QUEUE_MASK]); + } + fct = queue->last_fct_out; + fct(p); + } + cmm_smp_mb(); /* push tail after having used q[] */ + CMM_STORE_SHARED(queue->tail, i); +} + +static void _rcu_defer_barrier_thread(void) +{ + unsigned long head, num_items; + + head = URCU_TLS(defer_queue).head; + num_items = head - URCU_TLS(defer_queue).tail; + if (caa_unlikely(!num_items)) + return; + synchronize_rcu(); + rcu_defer_barrier_queue(&URCU_TLS(defer_queue), head); +} + +void rcu_defer_barrier_thread(void) +{ + mutex_lock_defer(&rcu_defer_mutex); + _rcu_defer_barrier_thread(); + mutex_unlock(&rcu_defer_mutex); +} + +/* + * rcu_defer_barrier - Execute all queued rcu callbacks. + * + * Execute all RCU callbacks queued before rcu_defer_barrier() execution. + * All callbacks queued on the local thread prior to a rcu_defer_barrier() call + * are guaranteed to be executed. + * Callbacks queued by other threads concurrently with rcu_defer_barrier() + * execution are not guaranteed to be executed in the current batch (could + * be left for the next batch). These callbacks queued by other threads are only + * guaranteed to be executed if there is explicit synchronization between + * the thread adding to the queue and the thread issuing the defer_barrier call. + */ + +void rcu_defer_barrier(void) +{ + struct defer_queue *index; + unsigned long num_items = 0; + + if (cds_list_empty(®istry_defer)) + return; + + mutex_lock_defer(&rcu_defer_mutex); + cds_list_for_each_entry(index, ®istry_defer, list) { + index->last_head = CMM_LOAD_SHARED(index->head); + num_items += index->last_head - index->tail; + } + if (caa_likely(!num_items)) { + /* + * We skip the grace period because there are no queued + * callbacks to execute. + */ + goto end; + } + synchronize_rcu(); + cds_list_for_each_entry(index, ®istry_defer, list) + rcu_defer_barrier_queue(index, index->last_head); +end: + mutex_unlock(&rcu_defer_mutex); +} + +/* + * _defer_rcu - Queue a RCU callback. + */ +static void _defer_rcu(void (*fct)(void *p), void *p) +{ + unsigned long head, tail; + + /* + * Head is only modified by ourself. Tail can be modified by reclamation + * thread. + */ + head = URCU_TLS(defer_queue).head; + tail = CMM_LOAD_SHARED(URCU_TLS(defer_queue).tail); + + /* + * If queue is full, or reached threshold. Empty queue ourself. + * Worse-case: must allow 2 supplementary entries for fct pointer. + */ + if (caa_unlikely(head - tail >= DEFER_QUEUE_SIZE - 2)) { + urcu_posix_assert(head - tail <= DEFER_QUEUE_SIZE); + rcu_defer_barrier_thread(); + urcu_posix_assert(head - CMM_LOAD_SHARED(URCU_TLS(defer_queue).tail) == 0); + } + + /* + * Encode: + * if the function is not changed and the data is aligned and it is + * not the marker: + * store the data + * otherwise if the function is aligned and its not the marker: + * store the function with DQ_FCT_BIT + * store the data + * otherwise: + * store the marker (DQ_FCT_MARK) + * store the function + * store the data + * + * Decode: see the comments before 'struct defer_queue' + * or the code in rcu_defer_barrier_queue(). + */ + if (caa_unlikely(URCU_TLS(defer_queue).last_fct_in != fct + || DQ_IS_FCT_BIT(p) + || p == DQ_FCT_MARK)) { + URCU_TLS(defer_queue).last_fct_in = fct; + if (caa_unlikely(DQ_IS_FCT_BIT(fct) || fct == DQ_FCT_MARK)) { + _CMM_STORE_SHARED(URCU_TLS(defer_queue).q[head++ & DEFER_QUEUE_MASK], + DQ_FCT_MARK); + _CMM_STORE_SHARED(URCU_TLS(defer_queue).q[head++ & DEFER_QUEUE_MASK], + fct); + } else { + DQ_SET_FCT_BIT(fct); + _CMM_STORE_SHARED(URCU_TLS(defer_queue).q[head++ & DEFER_QUEUE_MASK], + fct); + } + } + _CMM_STORE_SHARED(URCU_TLS(defer_queue).q[head++ & DEFER_QUEUE_MASK], p); + cmm_smp_wmb(); /* Publish new pointer before head */ + /* Write q[] before head. */ + CMM_STORE_SHARED(URCU_TLS(defer_queue).head, head); + cmm_smp_mb(); /* Write queue head before read futex */ + /* + * Wake-up any waiting defer thread. + */ + wake_up_defer(); +} + +static void *thr_defer(void *args __attribute__((unused))) +{ + for (;;) { + /* + * "Be green". Don't wake up the CPU if there is no RCU work + * to perform whatsoever. Aims at saving laptop battery life by + * leaving the processor in sleep state when idle. + */ + wait_defer(); + /* Sleeping after wait_defer to let many callbacks enqueue */ + (void) poll(NULL,0,100); /* wait for 100ms */ + rcu_defer_barrier(); + } + + return NULL; +} + +/* + * library wrappers to be used by non-LGPL compatible source code. + */ + +void defer_rcu(void (*fct)(void *p), void *p) +{ + _defer_rcu(fct, p); +} + +static void start_defer_thread(void) +{ + int ret; + sigset_t newmask, oldmask; + + ret = sigfillset(&newmask); + urcu_posix_assert(!ret); + ret = pthread_sigmask(SIG_BLOCK, &newmask, &oldmask); + urcu_posix_assert(!ret); + + ret = pthread_create(&tid_defer, NULL, thr_defer, NULL); + if (ret) + urcu_die(ret); + + ret = pthread_sigmask(SIG_SETMASK, &oldmask, NULL); + urcu_posix_assert(!ret); +} + +static void stop_defer_thread(void) +{ + int ret; + void *tret; + + _CMM_STORE_SHARED(defer_thread_stop, 1); + /* Store defer_thread_stop before testing futex */ + cmm_smp_mb(); + wake_up_defer(); + + ret = pthread_join(tid_defer, &tret); + urcu_posix_assert(!ret); + + CMM_STORE_SHARED(defer_thread_stop, 0); + /* defer thread should always exit when futex value is 0 */ + urcu_posix_assert(uatomic_read(&defer_thread_futex) == 0); +} + +int rcu_defer_register_thread(void) +{ + int was_empty; + + urcu_posix_assert(URCU_TLS(defer_queue).last_head == 0); + urcu_posix_assert(URCU_TLS(defer_queue).q == NULL); + URCU_TLS(defer_queue).q = malloc(sizeof(void *) * DEFER_QUEUE_SIZE); + if (!URCU_TLS(defer_queue).q) + return -ENOMEM; + + mutex_lock_defer(&defer_thread_mutex); + mutex_lock_defer(&rcu_defer_mutex); + was_empty = cds_list_empty(®istry_defer); + cds_list_add(&URCU_TLS(defer_queue).list, ®istry_defer); + mutex_unlock(&rcu_defer_mutex); + + if (was_empty) + start_defer_thread(); + mutex_unlock(&defer_thread_mutex); + return 0; +} + +void rcu_defer_unregister_thread(void) +{ + int is_empty; + + mutex_lock_defer(&defer_thread_mutex); + mutex_lock_defer(&rcu_defer_mutex); + cds_list_del(&URCU_TLS(defer_queue).list); + _rcu_defer_barrier_thread(); + free(URCU_TLS(defer_queue).q); + URCU_TLS(defer_queue).q = NULL; + is_empty = cds_list_empty(®istry_defer); + mutex_unlock(&rcu_defer_mutex); + + if (is_empty) + stop_defer_thread(); + mutex_unlock(&defer_thread_mutex); +} + +void rcu_defer_exit(void) +{ + urcu_posix_assert(cds_list_empty(®istry_defer)); +} + +#endif /* _URCU_DEFER_IMPL_H */ diff --git a/external/lgpl2/userspace-rcu/dist/src/urcu-die.h b/external/lgpl2/userspace-rcu/dist/src/urcu-die.h new file mode 100644 index 0000000000000..d6b0b16a821f0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/urcu-die.h @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_DIE_H +#define _URCU_DIE_H + +/* + * Userspace RCU library unrecoverable error handling + */ + +#include +#include +#include + +#define urcu_die(cause) \ +do { \ + fprintf(stderr, "(" __FILE__ ":%s@%u) Unrecoverable error: %s\n", \ + __func__, __LINE__, strerror(cause)); \ + abort(); \ +} while (0) + +#endif /* _URCU_DIE_H */ diff --git a/external/lgpl2/userspace-rcu/dist/src/urcu-pointer.c b/external/lgpl2/userspace-rcu/dist/src/urcu-pointer.c new file mode 100644 index 0000000000000..a42fe87be47c0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/urcu-pointer.c @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * library wrappers to be used by non-LGPL compatible source code. + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#include + +#include +/* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */ +#include + +extern void synchronize_rcu(void); + +void *rcu_dereference_sym(void *p) +{ + return _rcu_dereference(p); +} + +void *rcu_set_pointer_sym(void **p, void *v) +{ + uatomic_store(p, v, CMM_RELEASE); + return v; +} + +void *rcu_xchg_pointer_sym(void **p, void *v) +{ + return uatomic_xchg_mo(p, v, CMM_SEQ_CST); +} + +void *rcu_cmpxchg_pointer_sym(void **p, void *old, void *_new) +{ + return uatomic_cmpxchg_mo(p, old, _new, CMM_SEQ_CST, CMM_RELAXED); +} diff --git a/external/lgpl2/userspace-rcu/dist/src/urcu-poll-impl.h b/external/lgpl2/userspace-rcu/dist/src/urcu-poll-impl.h new file mode 100644 index 0000000000000..9aaf5eb564bd5 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/urcu-poll-impl.h @@ -0,0 +1,86 @@ +// SPDX-FileCopyrightText: 2023 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU library - Grace period polling API + */ + +#include +#include + +#include +#include + +struct urcu_poll_worker_state { + struct urcu_gp_poll_state current_state; + struct urcu_gp_poll_state latest_target; /* Most recent snapshot taken */ + struct rcu_head rcu_head; + pthread_mutex_t lock; + bool active; +}; + +static struct urcu_poll_worker_state poll_worker_gp_state = { + .lock = PTHREAD_MUTEX_INITIALIZER, +}; + +static +void urcu_poll_worker_cb(struct rcu_head *head __attribute__((unused))) +{ + mutex_lock(&poll_worker_gp_state.lock); + /* A new grace period has been reached. */ + poll_worker_gp_state.current_state.grace_period_id++; + if ((long)(poll_worker_gp_state.latest_target.grace_period_id - poll_worker_gp_state.current_state.grace_period_id) >= 0) { + /* Need to re-queue. */ + call_rcu(&poll_worker_gp_state.rcu_head, urcu_poll_worker_cb); + } else { + /* No user waiting for a target grace period. */ + poll_worker_gp_state.active = false; + } + mutex_unlock(&poll_worker_gp_state.lock); +} + +/* + * Start polling on grace period. If no worker is currently active, + * snapshot the current value and start a worker callback. If the worker + * is currently active, snapshot the current value + 1, and set this + * value as the latest snapshot, which will cause the worker to re-queue + * itself with call_rcu to issue one more grace period. + * + * Because it uses call_rcu, it needs to be called from a registered RCU + * thread. + */ +struct urcu_gp_poll_state start_poll_synchronize_rcu(void) +{ + struct urcu_gp_poll_state new_target_gp_state; + bool was_active = false; + + mutex_lock(&poll_worker_gp_state.lock); + new_target_gp_state.grace_period_id = poll_worker_gp_state.current_state.grace_period_id; + was_active = poll_worker_gp_state.active; + if (!was_active) + poll_worker_gp_state.active = true; + else + new_target_gp_state.grace_period_id++; + poll_worker_gp_state.latest_target.grace_period_id = new_target_gp_state.grace_period_id; + if (!was_active) + call_rcu(&poll_worker_gp_state.rcu_head, urcu_poll_worker_cb); + mutex_unlock(&poll_worker_gp_state.lock); + return new_target_gp_state; +} + +/* + * Poll the grace period state. Return true if quiescence was reached + * since the snapshot was taken, return false if quiescence was not + * reached since snapshot. + */ +bool poll_state_synchronize_rcu(struct urcu_gp_poll_state target_gp_state) +{ + bool target_gp_reached = false; + + mutex_lock(&poll_worker_gp_state.lock); + if ((long)(target_gp_state.grace_period_id - poll_worker_gp_state.current_state.grace_period_id) < 0) + target_gp_reached = true; + mutex_unlock(&poll_worker_gp_state.lock); + return target_gp_reached; +} diff --git a/external/lgpl2/userspace-rcu/dist/src/urcu-qsbr.c b/external/lgpl2/userspace-rcu/dist/src/urcu-qsbr.c new file mode 100644 index 0000000000000..e7ee180a9f811 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/urcu-qsbr.c @@ -0,0 +1,519 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU QSBR library + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#define URCU_NO_COMPAT_IDENTIFIERS +#define _LGPL_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#define BUILD_QSBR_LIB +#include +#include +#include + +#include "urcu-die.h" +#include "urcu-wait.h" +#include "urcu-utils.h" + +#define URCU_API_MAP +/* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */ +#undef _LGPL_SOURCE +#include +#define _LGPL_SOURCE + +void __attribute__((destructor)) urcu_qsbr_exit(void); +static void urcu_call_rcu_exit(void); + +/* + * rcu_gp_lock ensures mutual exclusion between threads calling + * synchronize_rcu(). + */ +static pthread_mutex_t rcu_gp_lock = PTHREAD_MUTEX_INITIALIZER; +/* + * rcu_registry_lock ensures mutual exclusion between threads + * registering and unregistering themselves to/from the registry, and + * with threads reading that registry from synchronize_rcu(). However, + * this lock is not held all the way through the completion of awaiting + * for the grace period. It is sporadically released between iterations + * on the registry. + * rcu_registry_lock may nest inside rcu_gp_lock. + */ +static pthread_mutex_t rcu_registry_lock = PTHREAD_MUTEX_INITIALIZER; +struct urcu_gp urcu_qsbr_gp = { .ctr = URCU_QSBR_GP_ONLINE }; + +/* + * Active attempts to check for reader Q.S. before calling futex(). + */ +#define RCU_QS_ACTIVE_ATTEMPTS 100 + +/* + * Written to only by each individual reader. Read by both the reader and the + * writers. + */ +DEFINE_URCU_TLS(struct urcu_qsbr_reader, urcu_qsbr_reader); + +static CDS_LIST_HEAD(registry); + +/* + * Queue keeping threads awaiting to wait for a grace period. Contains + * struct gp_waiters_thread objects. + */ +static DEFINE_URCU_WAIT_QUEUE(gp_waiters); + +static void mutex_lock(pthread_mutex_t *mutex) +{ + int ret; + +#ifndef DISTRUST_SIGNALS_EXTREME + ret = pthread_mutex_lock(mutex); + if (ret) + urcu_die(ret); +#else /* #ifndef DISTRUST_SIGNALS_EXTREME */ + while ((ret = pthread_mutex_trylock(mutex)) != 0) { + if (ret != EBUSY && ret != EINTR) + urcu_die(ret); + poll(NULL,0,10); + } +#endif /* #else #ifndef DISTRUST_SIGNALS_EXTREME */ +} + +static void mutex_unlock(pthread_mutex_t *mutex) +{ + int ret; + + ret = pthread_mutex_unlock(mutex); + if (ret) + urcu_die(ret); +} + +/* + * synchronize_rcu() waiting. Single thread. + */ +static void wait_gp(void) +{ + /* Read reader_gp before read futex */ + cmm_smp_rmb(); + while (uatomic_read(&urcu_qsbr_gp.futex) == -1) { + if (!futex_noasync(&urcu_qsbr_gp.futex, FUTEX_WAIT, -1, NULL, NULL, 0)) { + /* + * Prior queued wakeups queued by unrelated code + * using the same address can cause futex wait to + * return 0 even through the futex value is still + * -1 (spurious wakeups). Check the value again + * in user-space to validate whether it really + * differs from -1. + */ + continue; + } + switch (errno) { + case EAGAIN: + /* Value already changed. */ + return; + case EINTR: + /* Retry if interrupted by signal. */ + break; /* Get out of switch. Check again. */ + default: + /* Unexpected error. */ + urcu_die(errno); + } + } +} + +/* + * Always called with rcu_registry lock held. Releases this lock between + * iterations and grabs it again. Holds the lock when it returns. + */ +static void wait_for_readers(struct cds_list_head *input_readers, + struct cds_list_head *cur_snap_readers, + struct cds_list_head *qsreaders, + cmm_annotate_t *group) +{ + unsigned int wait_loops = 0; + struct urcu_qsbr_reader *index, *tmp; + + /* + * Wait for each thread URCU_TLS(urcu_qsbr_reader).ctr to either + * indicate quiescence (offline), or for them to observe the + * current urcu_qsbr_gp.ctr value. + */ + for (;;) { + if (wait_loops < RCU_QS_ACTIVE_ATTEMPTS) + wait_loops++; + if (wait_loops >= RCU_QS_ACTIVE_ATTEMPTS) { + uatomic_set(&urcu_qsbr_gp.futex, -1); + /* + * Write futex before write waiting (the other side + * reads them in the opposite order). + */ + cmm_smp_wmb(); + cds_list_for_each_entry(index, input_readers, node) { + _CMM_STORE_SHARED(index->waiting, 1); + } + /* Write futex before read reader_gp */ + cmm_smp_mb(); + } + cds_list_for_each_entry_safe(index, tmp, input_readers, node) { + switch (urcu_qsbr_reader_state(&index->ctr, group)) { + case URCU_READER_ACTIVE_CURRENT: + if (cur_snap_readers) { + cds_list_move(&index->node, + cur_snap_readers); + break; + } + /* Fall-through */ + case URCU_READER_INACTIVE: + cds_list_move(&index->node, qsreaders); + break; + case URCU_READER_ACTIVE_OLD: + /* + * Old snapshot. Leaving node in + * input_readers will make us busy-loop + * until the snapshot becomes current or + * the reader becomes inactive. + */ + break; + } + } + + if (cds_list_empty(input_readers)) { + if (wait_loops >= RCU_QS_ACTIVE_ATTEMPTS) { + /* Read reader_gp before write futex */ + uatomic_store(&urcu_qsbr_gp.futex, 0, CMM_RELEASE); + } + break; + } else { + /* Temporarily unlock the registry lock. */ + mutex_unlock(&rcu_registry_lock); + if (wait_loops >= RCU_QS_ACTIVE_ATTEMPTS) { + wait_gp(); + } else { +#ifndef HAS_INCOHERENT_CACHES + caa_cpu_relax(); +#else /* #ifndef HAS_INCOHERENT_CACHES */ + cmm_smp_mb(); +#endif /* #else #ifndef HAS_INCOHERENT_CACHES */ + } + /* Re-lock the registry lock before the next loop. */ + mutex_lock(&rcu_registry_lock); + } + } +} + +/* + * Using a two-subphases algorithm for architectures with smaller than 64-bit + * long-size to ensure we do not encounter an overflow bug. + */ + +#if (CAA_BITS_PER_LONG < 64) +void urcu_qsbr_synchronize_rcu(void) +{ + cmm_annotate_define(acquire_group); + cmm_annotate_define(release_group); + CDS_LIST_HEAD(cur_snap_readers); + CDS_LIST_HEAD(qsreaders); + unsigned long was_online; + DEFINE_URCU_WAIT_NODE(wait, URCU_WAIT_WAITING); + struct urcu_waiters waiters; + + was_online = urcu_qsbr_read_ongoing(); + + /* All threads should read qparity before accessing data structure + * where new ptr points to. In the "then" case, rcu_thread_offline + * includes a memory barrier. + * + * Mark the writer thread offline to make sure we don't wait for + * our own quiescent state. This allows using synchronize_rcu() + * in threads registered as readers. + */ + if (was_online) + urcu_qsbr_thread_offline(); + else + cmm_smp_mb(); + cmm_annotate_group_mb_release(&release_group); + + /* + * Add ourself to gp_waiters queue of threads awaiting to wait + * for a grace period. Proceed to perform the grace period only + * if we are the first thread added into the queue. + */ + if (urcu_wait_add(&gp_waiters, &wait) != 0) { + /* Not first in queue: will be awakened by another thread. */ + urcu_adaptative_busy_wait(&wait); + goto gp_end; + } + /* We won't need to wake ourself up */ + urcu_wait_set_state(&wait, URCU_WAIT_RUNNING); + + mutex_lock(&rcu_gp_lock); + + /* + * Move all waiters into our local queue. + */ + urcu_move_waiters(&waiters, &gp_waiters); + + mutex_lock(&rcu_registry_lock); + + if (cds_list_empty(®istry)) + goto out; + + /* + * Wait for readers to observe original parity or be quiescent. + * wait_for_readers() can release and grab again rcu_registry_lock + * internally. + */ + wait_for_readers(®istry, &cur_snap_readers, &qsreaders, &acquire_group); + + /* + * Must finish waiting for quiescent state for original parity + * before committing next urcu_qsbr_gp.ctr update to memory. Failure + * to do so could result in the writer waiting forever while new + * readers are always accessing data (no progress). Enforce + * compiler-order of load URCU_TLS(urcu_qsbr_reader).ctr before store + * to urcu_qsbr_gp.ctr. + */ + cmm_barrier(); + + /* + * Adding a cmm_smp_mb() which is _not_ formally required, but makes the + * model easier to understand. It does not have a big performance impact + * anyway, given this is the write-side. + */ + cmm_smp_mb(); + + /* Switch parity: 0 -> 1, 1 -> 0 */ + cmm_annotate_group_mem_release(&release_group, &urcu_qsbr_gp.ctr); + uatomic_store(&urcu_qsbr_gp.ctr, urcu_qsbr_gp.ctr ^ URCU_QSBR_GP_CTR, CMM_RELAXED); + + /* + * Must commit urcu_qsbr_gp.ctr update to memory before waiting for + * quiescent state. Failure to do so could result in the writer + * waiting forever while new readers are always accessing data + * (no progress). Enforce compiler-order of store to urcu_qsbr_gp.ctr + * before load URCU_TLS(urcu_qsbr_reader).ctr. + */ + cmm_barrier(); + + /* + * Adding a cmm_smp_mb() which is _not_ formally required, but makes the + * model easier to understand. It does not have a big performance impact + * anyway, given this is the write-side. + */ + cmm_smp_mb(); + + /* + * Wait for readers to observe new parity or be quiescent. + * wait_for_readers() can release and grab again rcu_registry_lock + * internally. + */ + wait_for_readers(&cur_snap_readers, NULL, &qsreaders, &acquire_group); + + /* + * Put quiescent reader list back into registry. + */ + cds_list_splice(&qsreaders, ®istry); +out: + mutex_unlock(&rcu_registry_lock); + mutex_unlock(&rcu_gp_lock); + urcu_wake_all_waiters(&waiters); +gp_end: + /* + * Finish waiting for reader threads before letting the old ptr being + * freed. + */ + cmm_annotate_group_mb_acquire(&acquire_group); + + if (was_online) + urcu_qsbr_thread_online(); + else + cmm_smp_mb(); +} +#else /* !(CAA_BITS_PER_LONG < 64) */ +void urcu_qsbr_synchronize_rcu(void) +{ + cmm_annotate_define(acquire_group); + cmm_annotate_define(release_group); + CDS_LIST_HEAD(qsreaders); + unsigned long was_online; + DEFINE_URCU_WAIT_NODE(wait, URCU_WAIT_WAITING); + struct urcu_waiters waiters; + + was_online = urcu_qsbr_read_ongoing(); + + /* + * Mark the writer thread offline to make sure we don't wait for + * our own quiescent state. This allows using synchronize_rcu() + * in threads registered as readers. + */ + if (was_online) + urcu_qsbr_thread_offline(); + else + cmm_smp_mb(); + cmm_annotate_group_mb_release(&release_group); + + /* + * Add ourself to gp_waiters queue of threads awaiting to wait + * for a grace period. Proceed to perform the grace period only + * if we are the first thread added into the queue. + */ + if (urcu_wait_add(&gp_waiters, &wait) != 0) { + /* Not first in queue: will be awakened by another thread. */ + urcu_adaptative_busy_wait(&wait); + goto gp_end; + } + /* We won't need to wake ourself up */ + urcu_wait_set_state(&wait, URCU_WAIT_RUNNING); + + mutex_lock(&rcu_gp_lock); + + /* + * Move all waiters into our local queue. + */ + urcu_move_waiters(&waiters, &gp_waiters); + + mutex_lock(&rcu_registry_lock); + + if (cds_list_empty(®istry)) + goto out; + + /* Increment current G.P. */ + cmm_annotate_group_mem_release(&release_group, &urcu_qsbr_gp.ctr); + uatomic_store(&urcu_qsbr_gp.ctr, urcu_qsbr_gp.ctr + URCU_QSBR_GP_CTR, CMM_RELAXED); + + /* + * Must commit urcu_qsbr_gp.ctr update to memory before waiting for + * quiescent state. Failure to do so could result in the writer + * waiting forever while new readers are always accessing data + * (no progress). Enforce compiler-order of store to urcu_qsbr_gp.ctr + * before load URCU_TLS(urcu_qsbr_reader).ctr. + */ + cmm_barrier(); + + /* + * Adding a cmm_smp_mb() which is _not_ formally required, but makes the + * model easier to understand. It does not have a big performance impact + * anyway, given this is the write-side. + */ + cmm_smp_mb(); + + /* + * Wait for readers to observe new count of be quiescent. + * wait_for_readers() can release and grab again rcu_registry_lock + * internally. + */ + wait_for_readers(®istry, NULL, &qsreaders, &acquire_group); + + /* + * Put quiescent reader list back into registry. + */ + cds_list_splice(&qsreaders, ®istry); +out: + mutex_unlock(&rcu_registry_lock); + mutex_unlock(&rcu_gp_lock); + urcu_wake_all_waiters(&waiters); +gp_end: + if (was_online) + urcu_qsbr_thread_online(); + else + cmm_smp_mb(); + + cmm_annotate_group_mb_acquire(&acquire_group); +} +#endif /* !(CAA_BITS_PER_LONG < 64) */ + +/* + * library wrappers to be used by non-LGPL compatible source code. + */ + +void urcu_qsbr_read_lock(void) +{ + _urcu_qsbr_read_lock(); +} + +void urcu_qsbr_read_unlock(void) +{ + _urcu_qsbr_read_unlock(); +} + +int urcu_qsbr_read_ongoing(void) +{ + return _urcu_qsbr_read_ongoing(); +} +void rcu_read_ongoing_qsbr(); + +void urcu_qsbr_quiescent_state(void) +{ + _urcu_qsbr_quiescent_state(); +} +void rcu_quiescent_state_qsbr(); + +void urcu_qsbr_thread_offline(void) +{ + _urcu_qsbr_thread_offline(); +} +void rcu_thread_offline_qsbr(); + +void urcu_qsbr_thread_online(void) +{ + _urcu_qsbr_thread_online(); +} + +void urcu_qsbr_register_thread(void) +{ + URCU_TLS(urcu_qsbr_reader).tid = pthread_self(); + urcu_posix_assert(URCU_TLS(urcu_qsbr_reader).ctr == 0); + + mutex_lock(&rcu_registry_lock); + urcu_posix_assert(!URCU_TLS(urcu_qsbr_reader).registered); + URCU_TLS(urcu_qsbr_reader).registered = 1; + cds_list_add(&URCU_TLS(urcu_qsbr_reader).node, ®istry); + mutex_unlock(&rcu_registry_lock); + _urcu_qsbr_thread_online(); +} + +void urcu_qsbr_unregister_thread(void) +{ + /* + * We have to make the thread offline otherwise we end up dealocking + * with a waiting writer. + */ + _urcu_qsbr_thread_offline(); + urcu_posix_assert(URCU_TLS(urcu_qsbr_reader).registered); + URCU_TLS(urcu_qsbr_reader).registered = 0; + mutex_lock(&rcu_registry_lock); + cds_list_del(&URCU_TLS(urcu_qsbr_reader).node); + mutex_unlock(&rcu_registry_lock); +} + +void urcu_qsbr_exit(void) +{ + /* + * Assertion disabled because call_rcu threads are now rcu + * readers, and left running at exit. + * urcu_posix_assert(cds_list_empty(®istry)); + */ + urcu_call_rcu_exit(); +} + +DEFINE_RCU_FLAVOR(rcu_flavor); + +#include "urcu-call-rcu-impl.h" +#include "urcu-defer-impl.h" +#include "urcu-poll-impl.h" diff --git a/external/lgpl2/userspace-rcu/dist/src/urcu-utils.h b/external/lgpl2/userspace-rcu/dist/src/urcu-utils.h new file mode 100644 index 0000000000000..face655221554 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/urcu-utils.h @@ -0,0 +1,31 @@ +// SPDX-FileCopyrightText: 2018 Michael Jeanson +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_UTILS_H +#define _URCU_UTILS_H + +/* + * Userspace RCU library internal utils + */ + +#include + +#define urcu_stringify(a) _urcu_stringify(a) +#define _urcu_stringify(a) #a + +#define max_t(type, x, y) \ + ({ \ + type __max1 = (x); \ + type __max2 = (y); \ + __max1 > __max2 ? __max1: __max2; \ + }) + +#define min_t(type, x, y) \ + ({ \ + type __min1 = (x); \ + type __min2 = (y); \ + __min1 <= __min2 ? __min1: __min2; \ + }) + +#endif /* _URCU_UTILS_H */ diff --git a/external/lgpl2/userspace-rcu/dist/src/urcu-wait.h b/external/lgpl2/userspace-rcu/dist/src/urcu-wait.h new file mode 100644 index 0000000000000..d77282bd55def --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/urcu-wait.h @@ -0,0 +1,204 @@ +// SPDX-FileCopyrightText: 2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_WAIT_H +#define _URCU_WAIT_H + +/* + * Userspace RCU library wait/wakeup management + */ + +#include +#include +#include +#include +#include "urcu-die.h" + +/* + * Number of busy-loop attempts before waiting on futex for grace period + * batching. + */ +#define URCU_WAIT_ATTEMPTS 1000 + +enum urcu_wait_state { + /* URCU_WAIT_WAITING is compared directly (futex compares it). */ + URCU_WAIT_WAITING = 0, + /* non-zero are used as masks. */ + URCU_WAIT_WAKEUP = (1 << 0), + URCU_WAIT_RUNNING = (1 << 1), + URCU_WAIT_TEARDOWN = (1 << 2), +}; + +struct urcu_wait_node { + struct cds_wfs_node node; + int32_t state; /* enum urcu_wait_state */ +}; + +#define URCU_WAIT_NODE_INIT(name, _state) \ + { .node = { .next = NULL }, .state = _state } + +#define DEFINE_URCU_WAIT_NODE(name, state) \ + struct urcu_wait_node name = URCU_WAIT_NODE_INIT(name, state) + +#define DECLARE_URCU_WAIT_NODE(name) \ + struct urcu_wait_node name + +struct urcu_wait_queue { + struct cds_wfs_stack stack; +}; + +#define URCU_WAIT_QUEUE_HEAD_INIT(name) \ + { \ + .stack = { \ + .head = CDS_WFS_END, \ + .lock = PTHREAD_MUTEX_INITIALIZER, \ + }, \ + } + +#define DECLARE_URCU_WAIT_QUEUE(name) \ + struct urcu_wait_queue name + +#define DEFINE_URCU_WAIT_QUEUE(name) \ + struct urcu_wait_queue name = URCU_WAIT_QUEUE_HEAD_INIT(name) + +struct urcu_waiters { + struct cds_wfs_head *head; +}; + +/* + * Add ourself atomically to a wait queue. Return 0 if queue was + * previously empty, else return 1. + * A full memory barrier is issued before being added to the wait queue. + */ +static inline +bool urcu_wait_add(struct urcu_wait_queue *queue, + struct urcu_wait_node *node) +{ + return cds_wfs_push(&queue->stack, &node->node); +} + +/* + * Atomically move all waiters from wait queue into our local struct + * urcu_waiters. + */ +static inline +void urcu_move_waiters(struct urcu_waiters *waiters, + struct urcu_wait_queue *queue) +{ + waiters->head = __cds_wfs_pop_all(&queue->stack); +} + +static inline +void urcu_wait_set_state(struct urcu_wait_node *node, + enum urcu_wait_state state) +{ + node->state = state; +} + +static inline +void urcu_wait_node_init(struct urcu_wait_node *node, + enum urcu_wait_state state) +{ + urcu_wait_set_state(node, state); + cds_wfs_node_init(&node->node); +} + +/* + * Note: urcu_adaptative_wake_up needs "value" to stay allocated + * throughout its execution. In this scheme, the waiter owns the node + * memory, and we only allow it to free this memory when it receives the + * URCU_WAIT_TEARDOWN flag. + */ +static inline +void urcu_adaptative_wake_up(struct urcu_wait_node *wait) +{ + urcu_posix_assert(uatomic_read(&wait->state) == URCU_WAIT_WAITING); + uatomic_store(&wait->state, URCU_WAIT_WAKEUP, CMM_RELEASE); + if (!(uatomic_read(&wait->state) & URCU_WAIT_RUNNING)) { + if (futex_noasync(&wait->state, FUTEX_WAKE, 1, + NULL, NULL, 0) < 0) + urcu_die(errno); + } + /* Allow teardown of struct urcu_wait memory. */ + uatomic_or_mo(&wait->state, URCU_WAIT_TEARDOWN, CMM_RELEASE); +} + +/* + * Caller must initialize "value" to URCU_WAIT_WAITING before passing its + * memory to waker thread. + */ +static inline +void urcu_adaptative_busy_wait(struct urcu_wait_node *wait) +{ + unsigned int i; + + /* Load and test condition before read state */ + cmm_smp_rmb(); + for (i = 0; i < URCU_WAIT_ATTEMPTS; i++) { + if (uatomic_load(&wait->state, CMM_ACQUIRE) != URCU_WAIT_WAITING) + goto skip_futex_wait; + caa_cpu_relax(); + } + while (uatomic_load(&wait->state, CMM_ACQUIRE) == URCU_WAIT_WAITING) { + if (!futex_noasync(&wait->state, FUTEX_WAIT, URCU_WAIT_WAITING, NULL, NULL, 0)) { + /* + * Prior queued wakeups queued by unrelated code + * using the same address can cause futex wait to + * return 0 even through the futex value is still + * URCU_WAIT_WAITING (spurious wakeups). Check + * the value again in user-space to validate + * whether it really differs from + * URCU_WAIT_WAITING. + */ + continue; + } + switch (errno) { + case EAGAIN: + /* Value already changed. */ + goto skip_futex_wait; + case EINTR: + /* Retry if interrupted by signal. */ + break; /* Get out of switch. Check again. */ + default: + /* Unexpected error. */ + urcu_die(errno); + } + } +skip_futex_wait: + + /* Tell waker thread than we are running. */ + uatomic_or(&wait->state, URCU_WAIT_RUNNING); + + /* + * Wait until waker thread lets us know it's ok to tear down + * memory allocated for struct urcu_wait. + */ + for (i = 0; i < URCU_WAIT_ATTEMPTS; i++) { + if (uatomic_load(&wait->state, CMM_RELAXED) & URCU_WAIT_TEARDOWN) + break; + caa_cpu_relax(); + } + while (!(uatomic_load(&wait->state, CMM_ACQUIRE) & URCU_WAIT_TEARDOWN)) + poll(NULL, 0, 10); + urcu_posix_assert(uatomic_read(&wait->state) & URCU_WAIT_TEARDOWN); +} + +static inline +void urcu_wake_all_waiters(struct urcu_waiters *waiters) +{ + struct cds_wfs_node *iter, *iter_n; + + /* Wake all waiters in our stack head */ + cds_wfs_for_each_blocking_safe(waiters->head, iter, iter_n) { + struct urcu_wait_node *wait_node = + caa_container_of(iter, struct urcu_wait_node, node); + + /* Don't wake already running threads */ + if (uatomic_load(&wait_node->state, CMM_RELAXED) & URCU_WAIT_RUNNING) + continue; + urcu_adaptative_wake_up(wait_node); + } +} + +#endif /* _URCU_WAIT_H */ diff --git a/external/lgpl2/userspace-rcu/dist/src/urcu.c b/external/lgpl2/userspace-rcu/dist/src/urcu.c new file mode 100644 index 0000000000000..5f4a7d71c2fad --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/urcu.c @@ -0,0 +1,559 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU library + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#define URCU_NO_COMPAT_IDENTIFIERS +#define _BSD_SOURCE +#define _LGPL_SOURCE +#define _DEFAULT_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "urcu-die.h" +#include "urcu-wait.h" +#include "urcu-utils.h" + +#define URCU_API_MAP +/* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */ +#undef _LGPL_SOURCE +#include +#define _LGPL_SOURCE + +/* + * If a reader is really non-cooperative and refuses to commit its + * rcu_active_readers count to memory (there is no barrier in the reader + * per-se), kick it after 10 loops waiting for it. + */ +#define KICK_READER_LOOPS 10 + +/* + * Active attempts to check for reader Q.S. before calling futex(). + */ +#define RCU_QS_ACTIVE_ATTEMPTS 100 + +/* If the headers do not support membarrier system call, fall back on RCU_MB */ +#ifdef __NR_membarrier +# define membarrier(...) syscall(__NR_membarrier, __VA_ARGS__) +#else +# define membarrier(...) -ENOSYS +#endif + +enum membarrier_cmd { + MEMBARRIER_CMD_QUERY = 0, + MEMBARRIER_CMD_SHARED = (1 << 0), + /* reserved for MEMBARRIER_CMD_SHARED_EXPEDITED (1 << 1) */ + /* reserved for MEMBARRIER_CMD_PRIVATE (1 << 2) */ + MEMBARRIER_CMD_PRIVATE_EXPEDITED = (1 << 3), + MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED = (1 << 4), +}; + +#ifdef RCU_MEMBARRIER +static int init_done; +static int urcu_memb_has_sys_membarrier_private_expedited; + +#ifndef CONFIG_RCU_FORCE_SYS_MEMBARRIER +/* + * Explicitly initialize to zero because we can't alias a non-static + * uninitialized variable. + */ +int urcu_memb_has_sys_membarrier = 0; +#endif + +void __attribute__((constructor)) rcu_init(void); +#endif + +#if defined(RCU_MB) +void rcu_init(void) +{ +} +#endif + +void __attribute__((destructor)) rcu_exit(void); +static void urcu_call_rcu_exit(void); + +/* + * rcu_gp_lock ensures mutual exclusion between threads calling + * synchronize_rcu(). + */ +static pthread_mutex_t rcu_gp_lock = PTHREAD_MUTEX_INITIALIZER; +/* + * rcu_registry_lock ensures mutual exclusion between threads + * registering and unregistering themselves to/from the registry, and + * with threads reading that registry from synchronize_rcu(). However, + * this lock is not held all the way through the completion of awaiting + * for the grace period. It is sporadically released between iterations + * on the registry. + * rcu_registry_lock may nest inside rcu_gp_lock. + */ +static pthread_mutex_t rcu_registry_lock = PTHREAD_MUTEX_INITIALIZER; +struct urcu_gp rcu_gp = { .ctr = URCU_GP_COUNT }; + +/* + * Written to only by each individual reader. Read by both the reader and the + * writers. + */ +DEFINE_URCU_TLS(struct urcu_reader, rcu_reader); + +static CDS_LIST_HEAD(registry); + +/* + * Queue keeping threads awaiting to wait for a grace period. Contains + * struct gp_waiters_thread objects. + */ +static DEFINE_URCU_WAIT_QUEUE(gp_waiters); + +static void mutex_lock(pthread_mutex_t *mutex) +{ + int ret; + +#ifndef DISTRUST_SIGNALS_EXTREME + ret = pthread_mutex_lock(mutex); + if (ret) + urcu_die(ret); +#else /* #ifndef DISTRUST_SIGNALS_EXTREME */ + while ((ret = pthread_mutex_trylock(mutex)) != 0) { + if (ret != EBUSY && ret != EINTR) + urcu_die(ret); + if (CMM_LOAD_SHARED(URCU_TLS(rcu_reader).need_mb)) { + cmm_smp_mb(); + _CMM_STORE_SHARED(URCU_TLS(rcu_reader).need_mb, 0); + cmm_smp_mb(); + } + (void) poll(NULL, 0, 10); + } +#endif /* #else #ifndef DISTRUST_SIGNALS_EXTREME */ +} + +static void mutex_unlock(pthread_mutex_t *mutex) +{ + int ret; + + ret = pthread_mutex_unlock(mutex); + if (ret) + urcu_die(ret); +} + +#ifdef RCU_MEMBARRIER +static void smp_mb_master(void) +{ + if (caa_likely(urcu_memb_has_sys_membarrier)) { + if (membarrier(urcu_memb_has_sys_membarrier_private_expedited ? + MEMBARRIER_CMD_PRIVATE_EXPEDITED : + MEMBARRIER_CMD_SHARED, 0)) + urcu_die(errno); + } else { + cmm_smp_mb(); + } +} +#endif + +#if defined(RCU_MB) +static void smp_mb_master(void) +{ + cmm_smp_mb(); +} +#endif + +/* + * synchronize_rcu() waiting. Single thread. + * Always called with rcu_registry lock held. Releases this lock and + * grabs it again. Holds the lock when it returns. + */ +static void wait_gp(void) +{ + /* + * Read reader_gp before read futex. + */ + smp_mb_master(); + /* Temporarily unlock the registry lock. */ + mutex_unlock(&rcu_registry_lock); + while (uatomic_read(&rcu_gp.futex) == -1) { + if (!futex_async(&rcu_gp.futex, FUTEX_WAIT, -1, NULL, NULL, 0)) { + /* + * Prior queued wakeups queued by unrelated code + * using the same address can cause futex wait to + * return 0 even through the futex value is still + * -1 (spurious wakeups). Check the value again + * in user-space to validate whether it really + * differs from -1. + */ + continue; + } + switch (errno) { + case EAGAIN: + /* Value already changed. */ + goto end; + case EINTR: + /* Retry if interrupted by signal. */ + break; /* Get out of switch. Check again. */ + default: + /* Unexpected error. */ + urcu_die(errno); + } + } +end: + /* + * Re-lock the registry lock before the next loop. + */ + mutex_lock(&rcu_registry_lock); +} + +/* + * Always called with rcu_registry lock held. Releases this lock between + * iterations and grabs it again. Holds the lock when it returns. + */ +static void wait_for_readers(struct cds_list_head *input_readers, + struct cds_list_head *cur_snap_readers, + struct cds_list_head *qsreaders, + cmm_annotate_t *group) +{ + unsigned int wait_loops = 0; + struct urcu_reader *index, *tmp; +#ifdef HAS_INCOHERENT_CACHES + unsigned int wait_gp_loops = 0; +#endif /* HAS_INCOHERENT_CACHES */ + + /* + * Wait for each thread URCU_TLS(rcu_reader).ctr to either + * indicate quiescence (not nested), or observe the current + * rcu_gp.ctr value. + */ + for (;;) { + if (wait_loops < RCU_QS_ACTIVE_ATTEMPTS) + wait_loops++; + if (wait_loops >= RCU_QS_ACTIVE_ATTEMPTS) { + uatomic_dec(&rcu_gp.futex); + /* Write futex before read reader_gp */ + smp_mb_master(); + } + + cds_list_for_each_entry_safe(index, tmp, input_readers, node) { + switch (urcu_common_reader_state(&rcu_gp, &index->ctr, group)) { + case URCU_READER_ACTIVE_CURRENT: + if (cur_snap_readers) { + cds_list_move(&index->node, + cur_snap_readers); + break; + } + /* Fall-through */ + case URCU_READER_INACTIVE: + cds_list_move(&index->node, qsreaders); + break; + case URCU_READER_ACTIVE_OLD: + /* + * Old snapshot. Leaving node in + * input_readers will make us busy-loop + * until the snapshot becomes current or + * the reader becomes inactive. + */ + break; + } + } + +#ifndef HAS_INCOHERENT_CACHES + if (cds_list_empty(input_readers)) { + if (wait_loops >= RCU_QS_ACTIVE_ATTEMPTS) { + /* Read reader_gp before write futex */ + smp_mb_master(); + uatomic_set(&rcu_gp.futex, 0); + } + break; + } else { + if (wait_loops >= RCU_QS_ACTIVE_ATTEMPTS) { + /* wait_gp unlocks/locks registry lock. */ + wait_gp(); + } else { + /* Temporarily unlock the registry lock. */ + mutex_unlock(&rcu_registry_lock); + caa_cpu_relax(); + /* + * Re-lock the registry lock before the + * next loop. + */ + mutex_lock(&rcu_registry_lock); + } + } +#else /* #ifndef HAS_INCOHERENT_CACHES */ + /* + * BUSY-LOOP. Force the reader thread to commit its + * URCU_TLS(rcu_reader).ctr update to memory if we wait + * for too long. + */ + if (cds_list_empty(input_readers)) { + if (wait_loops >= RCU_QS_ACTIVE_ATTEMPTS) { + /* Read reader_gp before write futex */ + smp_mb_master(); + uatomic_set(&rcu_gp.futex, 0); + } + break; + } else { + if (wait_gp_loops == KICK_READER_LOOPS) { + smp_mb_master(); + wait_gp_loops = 0; + } + if (wait_loops >= RCU_QS_ACTIVE_ATTEMPTS) { + /* wait_gp unlocks/locks registry lock. */ + wait_gp(); + wait_gp_loops++; + } else { + /* Temporarily unlock the registry lock. */ + mutex_unlock(&rcu_registry_lock); + caa_cpu_relax(); + /* + * Re-lock the registry lock before the + * next loop. + */ + mutex_lock(&rcu_registry_lock); + } + } +#endif /* #else #ifndef HAS_INCOHERENT_CACHES */ + } +} + +void synchronize_rcu(void) +{ + cmm_annotate_define(acquire_group); + cmm_annotate_define(release_group); + CDS_LIST_HEAD(cur_snap_readers); + CDS_LIST_HEAD(qsreaders); + DEFINE_URCU_WAIT_NODE(wait, URCU_WAIT_WAITING); + struct urcu_waiters waiters; + + /* + * Add ourself to gp_waiters queue of threads awaiting to wait + * for a grace period. Proceed to perform the grace period only + * if we are the first thread added into the queue. + * The implicit memory barrier before urcu_wait_add() + * orders prior memory accesses of threads put into the wait + * queue before their insertion into the wait queue. + */ + if (urcu_wait_add(&gp_waiters, &wait) != 0) { + /* + * Not first in queue: will be awakened by another thread. + * Implies a memory barrier after grace period. + */ + urcu_adaptative_busy_wait(&wait); + return; + } + /* We won't need to wake ourself up */ + urcu_wait_set_state(&wait, URCU_WAIT_RUNNING); + + mutex_lock(&rcu_gp_lock); + + /* + * Move all waiters into our local queue. + */ + urcu_move_waiters(&waiters, &gp_waiters); + + mutex_lock(&rcu_registry_lock); + + if (cds_list_empty(®istry)) + goto out; + + /* + * All threads should read qparity before accessing data structure + * where new ptr points to. Must be done within rcu_registry_lock + * because it iterates on reader threads. + */ + /* Write new ptr before changing the qparity */ + smp_mb_master(); + cmm_annotate_group_mb_release(&release_group); + + /* + * Wait for readers to observe original parity or be quiescent. + * wait_for_readers() can release and grab again rcu_registry_lock + * internally. + */ + wait_for_readers(®istry, &cur_snap_readers, &qsreaders, &acquire_group); + + /* + * Must finish waiting for quiescent state for original parity before + * committing next rcu_gp.ctr update to memory. Failure to do so could + * result in the writer waiting forever while new readers are always + * accessing data (no progress). Enforce compiler-order of load + * URCU_TLS(rcu_reader).ctr before store to rcu_gp.ctr. + */ + cmm_barrier(); + + /* + * Adding a cmm_smp_mb() which is _not_ formally required, but makes the + * model easier to understand. It does not have a big performance impact + * anyway, given this is the write-side. + */ + cmm_smp_mb(); + + /* Switch parity: 0 -> 1, 1 -> 0 */ + cmm_annotate_group_mem_release(&release_group, &rcu_gp.ctr); + uatomic_store(&rcu_gp.ctr, rcu_gp.ctr ^ URCU_GP_CTR_PHASE, CMM_RELAXED); + + /* + * Must commit rcu_gp.ctr update to memory before waiting for quiescent + * state. Failure to do so could result in the writer waiting forever + * while new readers are always accessing data (no progress). Enforce + * compiler-order of store to rcu_gp.ctr before load rcu_reader ctr. + */ + cmm_barrier(); + + /* + * + * Adding a cmm_smp_mb() which is _not_ formally required, but makes the + * model easier to understand. It does not have a big performance impact + * anyway, given this is the write-side. + */ + cmm_smp_mb(); + + /* + * Wait for readers to observe new parity or be quiescent. + * wait_for_readers() can release and grab again rcu_registry_lock + * internally. + */ + wait_for_readers(&cur_snap_readers, NULL, &qsreaders, &acquire_group); + + /* + * Put quiescent reader list back into registry. + */ + cds_list_splice(&qsreaders, ®istry); + + /* + * Finish waiting for reader threads before letting the old ptr + * being freed. Must be done within rcu_registry_lock because it + * iterates on reader threads. + */ + smp_mb_master(); + cmm_annotate_group_mb_acquire(&acquire_group); +out: + mutex_unlock(&rcu_registry_lock); + mutex_unlock(&rcu_gp_lock); + + /* + * Wakeup waiters only after we have completed the grace period + * and have ensured the memory barriers at the end of the grace + * period have been issued. + */ + urcu_wake_all_waiters(&waiters); +} + +/* + * library wrappers to be used by non-LGPL compatible source code. + */ + +void rcu_read_lock(void) +{ + _rcu_read_lock(); +} + +void rcu_read_unlock(void) +{ + _rcu_read_unlock(); +} + +int rcu_read_ongoing(void) +{ + return _rcu_read_ongoing(); +} + +void rcu_register_thread(void) +{ + URCU_TLS(rcu_reader).tid = pthread_self(); + urcu_posix_assert(URCU_TLS(rcu_reader).need_mb == 0); + urcu_posix_assert(!(URCU_TLS(rcu_reader).ctr & URCU_GP_CTR_NEST_MASK)); + + mutex_lock(&rcu_registry_lock); + urcu_posix_assert(!URCU_TLS(rcu_reader).registered); + URCU_TLS(rcu_reader).registered = 1; + rcu_init(); /* In case gcc does not support constructor attribute */ + cds_list_add(&URCU_TLS(rcu_reader).node, ®istry); + mutex_unlock(&rcu_registry_lock); +} + +void rcu_unregister_thread(void) +{ + mutex_lock(&rcu_registry_lock); + urcu_posix_assert(URCU_TLS(rcu_reader).registered); + URCU_TLS(rcu_reader).registered = 0; + cds_list_del(&URCU_TLS(rcu_reader).node); + mutex_unlock(&rcu_registry_lock); +} + +#ifdef RCU_MEMBARRIER + +#ifdef CONFIG_RCU_FORCE_SYS_MEMBARRIER +static +void rcu_sys_membarrier_status(bool available) +{ + if (!available) + abort(); +} +#else +static +void rcu_sys_membarrier_status(bool available) +{ + if (!available) + return; + urcu_memb_has_sys_membarrier = 1; +} +#endif + +static +void rcu_sys_membarrier_init(void) +{ + bool available = false; + int mask; + + mask = membarrier(MEMBARRIER_CMD_QUERY, 0); + if (mask >= 0) { + if (mask & MEMBARRIER_CMD_PRIVATE_EXPEDITED) { + if (membarrier(MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED, 0)) + urcu_die(errno); + urcu_memb_has_sys_membarrier_private_expedited = 1; + available = true; + } else if (mask & MEMBARRIER_CMD_SHARED) { + available = true; + } + } + rcu_sys_membarrier_status(available); +} + +void rcu_init(void) +{ + if (init_done) + return; + init_done = 1; + rcu_sys_membarrier_init(); +} +#endif + +void rcu_exit(void) +{ + urcu_call_rcu_exit(); +} + +DEFINE_RCU_FLAVOR(rcu_flavor); + +#include "urcu-call-rcu-impl.h" +#include "urcu-defer-impl.h" +#include "urcu-poll-impl.h" diff --git a/external/lgpl2/userspace-rcu/dist/src/wfcqueue.c b/external/lgpl2/userspace-rcu/dist/src/wfcqueue.c new file mode 100644 index 0000000000000..294b2662ba023 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/wfcqueue.c @@ -0,0 +1,170 @@ +// SPDX-FileCopyrightText: 2010-2012 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2011-2012 Lai Jiangshan +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU library - Concurrent Queue with Wait-Free Enqueue/Blocking Dequeue + */ + +/* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */ +#include "urcu/wfcqueue.h" +#include "urcu/static/wfcqueue.h" + +/* + * library wrappers to be used by non-LGPL compatible source code. + */ + +void cds_wfcq_node_init(struct cds_wfcq_node *node) +{ + _cds_wfcq_node_init(node); +} + +void cds_wfcq_init(struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail) +{ + _cds_wfcq_init(head, tail); +} + +void cds_wfcq_destroy(struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail) +{ + _cds_wfcq_destroy(head, tail); +} + +void __cds_wfcq_init(struct __cds_wfcq_head *head, + struct cds_wfcq_tail *tail) +{ + ___cds_wfcq_init(head, tail); +} + +bool cds_wfcq_empty(cds_wfcq_head_const_ptr_t head, + const struct cds_wfcq_tail *tail) + +{ + return _cds_wfcq_empty(head, tail); +} + +bool cds_wfcq_enqueue(cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail, + struct cds_wfcq_node *node) +{ + return _cds_wfcq_enqueue(head, tail, node); +} + +void cds_wfcq_dequeue_lock(struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail) +{ + _cds_wfcq_dequeue_lock(head, tail); +} + +void cds_wfcq_dequeue_unlock(struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail) +{ + _cds_wfcq_dequeue_unlock(head, tail); +} + +struct cds_wfcq_node *cds_wfcq_dequeue_blocking( + struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail) +{ + return _cds_wfcq_dequeue_blocking(head, tail); +} + +struct cds_wfcq_node *cds_wfcq_dequeue_with_state_blocking( + struct cds_wfcq_head *head, + struct cds_wfcq_tail *tail, + int *state) +{ + return _cds_wfcq_dequeue_with_state_blocking(head, tail, state); +} + +enum cds_wfcq_ret cds_wfcq_splice_blocking( + struct cds_wfcq_head *dest_q_head, + struct cds_wfcq_tail *dest_q_tail, + struct cds_wfcq_head *src_q_head, + struct cds_wfcq_tail *src_q_tail) +{ + return _cds_wfcq_splice_blocking(dest_q_head, dest_q_tail, + src_q_head, src_q_tail); +} + +struct cds_wfcq_node *__cds_wfcq_dequeue_blocking( + cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail) +{ + return ___cds_wfcq_dequeue_blocking(head, tail); +} + +struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_blocking( + cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail, + int *state) +{ + return ___cds_wfcq_dequeue_with_state_blocking(head, tail, state); +} + +struct cds_wfcq_node *__cds_wfcq_dequeue_nonblocking( + cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail) +{ + return ___cds_wfcq_dequeue_nonblocking(head, tail); +} + +struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_nonblocking( + cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail, + int *state) +{ + return ___cds_wfcq_dequeue_with_state_nonblocking(head, tail, state); +} + +enum cds_wfcq_ret __cds_wfcq_splice_blocking( + cds_wfcq_head_ptr_t dest_q_head, + struct cds_wfcq_tail *dest_q_tail, + cds_wfcq_head_ptr_t src_q_head, + struct cds_wfcq_tail *src_q_tail) +{ + return ___cds_wfcq_splice_blocking(dest_q_head, dest_q_tail, + src_q_head, src_q_tail); +} + +enum cds_wfcq_ret __cds_wfcq_splice_nonblocking( + cds_wfcq_head_ptr_t dest_q_head, + struct cds_wfcq_tail *dest_q_tail, + cds_wfcq_head_ptr_t src_q_head, + struct cds_wfcq_tail *src_q_tail) +{ + return ___cds_wfcq_splice_nonblocking(dest_q_head, dest_q_tail, + src_q_head, src_q_tail); +} + +struct cds_wfcq_node *__cds_wfcq_first_blocking( + cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail) +{ + return ___cds_wfcq_first_blocking(head, tail); +} + +struct cds_wfcq_node *__cds_wfcq_first_nonblocking( + cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail) +{ + return ___cds_wfcq_first_nonblocking(head, tail); +} + +struct cds_wfcq_node *__cds_wfcq_next_blocking( + cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail, + struct cds_wfcq_node *node) +{ + return ___cds_wfcq_next_blocking(head, tail, node); +} + +struct cds_wfcq_node *__cds_wfcq_next_nonblocking( + cds_wfcq_head_ptr_t head, + struct cds_wfcq_tail *tail, + struct cds_wfcq_node *node) +{ + return ___cds_wfcq_next_nonblocking(head, tail, node); +} diff --git a/external/lgpl2/userspace-rcu/dist/src/wfqueue.c b/external/lgpl2/userspace-rcu/dist/src/wfqueue.c new file mode 100644 index 0000000000000..062f8017ea9dd --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/wfqueue.c @@ -0,0 +1,48 @@ +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU library - Queue with Wait-Free Enqueue/Blocking Dequeue + */ + +/* Remove deprecation warnings from LGPL wrapper build. */ +#define CDS_WFQ_DEPRECATED + +/* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */ +#include "urcu/wfqueue.h" +#include "urcu/static/wfqueue.h" + +/* + * library wrappers to be used by non-LGPL compatible source code. + */ + +void cds_wfq_node_init(struct cds_wfq_node *node) +{ + _cds_wfq_node_init(node); +} + +void cds_wfq_init(struct cds_wfq_queue *q) +{ + _cds_wfq_init(q); +} + +void cds_wfq_destroy(struct cds_wfq_queue *q) +{ + _cds_wfq_destroy(q); +} + +void cds_wfq_enqueue(struct cds_wfq_queue *q, struct cds_wfq_node *node) +{ + _cds_wfq_enqueue(q, node); +} + +struct cds_wfq_node *__cds_wfq_dequeue_blocking(struct cds_wfq_queue *q) +{ + return ___cds_wfq_dequeue_blocking(q); +} + +struct cds_wfq_node *cds_wfq_dequeue_blocking(struct cds_wfq_queue *q) +{ + return _cds_wfq_dequeue_blocking(q); +} diff --git a/external/lgpl2/userspace-rcu/dist/src/wfstack.c b/external/lgpl2/userspace-rcu/dist/src/wfstack.c new file mode 100644 index 0000000000000..6308a94b9876f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/wfstack.c @@ -0,0 +1,115 @@ +// SPDX-FileCopyrightText: 2010-2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU library - Stack with wait-free push, blocking traversal. + */ + +/* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */ +#include "urcu/wfstack.h" +#include "urcu/static/wfstack.h" + +/* + * library wrappers to be used by non-LGPL compatible source code. + */ + +void cds_wfs_node_init(struct cds_wfs_node *node) +{ + _cds_wfs_node_init(node); +} + +void cds_wfs_init(struct cds_wfs_stack *s) +{ + _cds_wfs_init(s); +} + +void cds_wfs_destroy(struct cds_wfs_stack *s) +{ + _cds_wfs_destroy(s); +} + +void __cds_wfs_init(struct __cds_wfs_stack *s) +{ + ___cds_wfs_init(s); +} + +bool cds_wfs_empty(cds_wfs_stack_const_ptr_t u_stack) +{ + return _cds_wfs_empty(u_stack); +} + +int cds_wfs_push(cds_wfs_stack_ptr_t u_stack, struct cds_wfs_node *node) +{ + return _cds_wfs_push(u_stack, node); +} + +struct cds_wfs_node *cds_wfs_pop_blocking(struct cds_wfs_stack *s) +{ + return _cds_wfs_pop_blocking(s); +} + +struct cds_wfs_node * + cds_wfs_pop_with_state_blocking(struct cds_wfs_stack *s, int *state) +{ + return _cds_wfs_pop_with_state_blocking(s, state); +} + +struct cds_wfs_head *cds_wfs_pop_all_blocking(struct cds_wfs_stack *s) +{ + return _cds_wfs_pop_all_blocking(s); +} + +struct cds_wfs_node *cds_wfs_first(struct cds_wfs_head *head) +{ + return _cds_wfs_first(head); +} + +struct cds_wfs_node *cds_wfs_next_blocking(struct cds_wfs_node *node) +{ + return _cds_wfs_next_blocking(node); +} + +struct cds_wfs_node *cds_wfs_next_nonblocking(struct cds_wfs_node *node) +{ + return _cds_wfs_next_nonblocking(node); +} + +void cds_wfs_pop_lock(struct cds_wfs_stack *s) +{ + _cds_wfs_pop_lock(s); +} + +void cds_wfs_pop_unlock(struct cds_wfs_stack *s) +{ + _cds_wfs_pop_unlock(s); +} + +struct cds_wfs_node *__cds_wfs_pop_blocking(cds_wfs_stack_ptr_t u_stack) +{ + return ___cds_wfs_pop_blocking(u_stack); +} + +struct cds_wfs_node * + __cds_wfs_pop_with_state_blocking(cds_wfs_stack_ptr_t u_stack, + int *state) +{ + return ___cds_wfs_pop_with_state_blocking(u_stack, state); +} + +struct cds_wfs_node *__cds_wfs_pop_nonblocking(cds_wfs_stack_ptr_t u_stack) +{ + return ___cds_wfs_pop_nonblocking(u_stack); +} + +struct cds_wfs_node * + __cds_wfs_pop_with_state_nonblocking(cds_wfs_stack_ptr_t u_stack, + int *state) +{ + return ___cds_wfs_pop_with_state_nonblocking(u_stack, state); +} + +struct cds_wfs_head *__cds_wfs_pop_all(cds_wfs_stack_ptr_t u_stack) +{ + return ___cds_wfs_pop_all(u_stack); +} diff --git a/external/lgpl2/userspace-rcu/dist/src/workqueue.c b/external/lgpl2/userspace-rcu/dist/src/workqueue.c new file mode 100644 index 0000000000000..10b9fdee5df22 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/workqueue.c @@ -0,0 +1,483 @@ +// SPDX-FileCopyrightText: 2010 Paul E. McKenney +// SPDX-FileCopyrightText: 2017 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU library - Userspace workqeues + */ + +#define _LGPL_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "compat-getcpu.h" +#include +#include +#include +#include +#include +#include +#include +#include "urcu-die.h" + +#include "workqueue.h" + +#define SET_AFFINITY_CHECK_PERIOD (1U << 8) /* 256 */ +#define SET_AFFINITY_CHECK_PERIOD_MASK (SET_AFFINITY_CHECK_PERIOD - 1) + +/* Data structure that identifies a workqueue. */ + +struct urcu_workqueue { + /* + * We do not align head on a different cache-line than tail + * mainly because workqueue threads use batching ("splice") to + * get an entire list of callbacks, which effectively empties + * the queue, and requires to touch the tail anyway. + */ + struct cds_wfcq_tail cbs_tail; + struct cds_wfcq_head cbs_head; + unsigned long flags; + int32_t futex; + unsigned long qlen; /* maintained for debugging. */ + pthread_t tid; + int cpu_affinity; + unsigned long loop_count; + void *priv; + void (*grace_period_fct)(struct urcu_workqueue *workqueue, void *priv); + void (*initialize_worker_fct)(struct urcu_workqueue *workqueue, void *priv); + void (*finalize_worker_fct)(struct urcu_workqueue *workqueue, void *priv); + void (*worker_before_pause_fct)(struct urcu_workqueue *workqueue, void *priv); + void (*worker_after_resume_fct)(struct urcu_workqueue *workqueue, void *priv); + void (*worker_before_wait_fct)(struct urcu_workqueue *workqueue, void *priv); + void (*worker_after_wake_up_fct)(struct urcu_workqueue *workqueue, void *priv); +} __attribute__((aligned(CAA_CACHE_LINE_SIZE))); + +struct urcu_workqueue_completion { + int barrier_count; + int32_t futex; + struct urcu_ref ref; +}; + +struct urcu_workqueue_completion_work { + struct urcu_work work; + struct urcu_workqueue_completion *completion; +}; + +/* + * Periodically retry setting CPU affinity if we migrate. + * Losing affinity can be caused by CPU hotunplug/hotplug, or by + * cpuset(7). + */ +#ifdef HAVE_SCHED_SETAFFINITY +static int set_thread_cpu_affinity(struct urcu_workqueue *workqueue) +{ + cpu_set_t mask; + int ret; + + if (workqueue->cpu_affinity < 0) + return 0; + if (++workqueue->loop_count & SET_AFFINITY_CHECK_PERIOD_MASK) + return 0; + if (urcu_sched_getcpu() == workqueue->cpu_affinity) + return 0; + + CPU_ZERO(&mask); + CPU_SET(workqueue->cpu_affinity, &mask); + ret = sched_setaffinity(0, sizeof(mask), &mask); + + /* + * EINVAL is fine: can be caused by hotunplugged CPUs, or by + * cpuset(7). This is why we should always retry if we detect + * migration. + */ + if (ret && errno == EINVAL) { + ret = 0; + errno = 0; + } + return ret; +} +#else +static int set_thread_cpu_affinity(struct urcu_workqueue *workqueue __attribute__((unused))) +{ + return 0; +} +#endif + +static void futex_wait(int32_t *futex) +{ + /* Read condition before read futex */ + cmm_smp_mb(); + while (uatomic_read(futex) == -1) { + if (!futex_async(futex, FUTEX_WAIT, -1, NULL, NULL, 0)) { + /* + * Prior queued wakeups queued by unrelated code + * using the same address can cause futex wait to + * return 0 even through the futex value is still + * -1 (spurious wakeups). Check the value again + * in user-space to validate whether it really + * differs from -1. + */ + continue; + } + switch (errno) { + case EAGAIN: + /* Value already changed. */ + return; + case EINTR: + /* Retry if interrupted by signal. */ + break; /* Get out of switch. Check again. */ + default: + /* Unexpected error. */ + urcu_die(errno); + } + } +} + +static void futex_wake_up(int32_t *futex) +{ + /* Write to condition before reading/writing futex */ + cmm_smp_mb(); + if (caa_unlikely(uatomic_read(futex) == -1)) { + uatomic_set(futex, 0); + if (futex_async(futex, FUTEX_WAKE, 1, + NULL, NULL, 0) < 0) + urcu_die(errno); + } +} + +/* This is the code run by each worker thread. */ + +static void *workqueue_thread(void *arg) +{ + unsigned long cbcount; + struct urcu_workqueue *workqueue = (struct urcu_workqueue *) arg; + int rt = !!(uatomic_read(&workqueue->flags) & URCU_WORKQUEUE_RT); + + if (set_thread_cpu_affinity(workqueue)) + urcu_die(errno); + + if (workqueue->initialize_worker_fct) + workqueue->initialize_worker_fct(workqueue, workqueue->priv); + + if (!rt) { + uatomic_dec(&workqueue->futex); + /* Decrement futex before reading workqueue */ + cmm_smp_mb(); + } + for (;;) { + struct cds_wfcq_head cbs_tmp_head; + struct cds_wfcq_tail cbs_tmp_tail; + struct cds_wfcq_node *cbs, *cbs_tmp_n; + enum cds_wfcq_ret splice_ret; + + if (set_thread_cpu_affinity(workqueue)) + urcu_die(errno); + + if (uatomic_read(&workqueue->flags) & URCU_WORKQUEUE_PAUSE) { + /* + * Pause requested. Become quiescent: remove + * ourself from all global lists, and don't + * process any callback. The callback lists may + * still be non-empty though. + */ + if (workqueue->worker_before_pause_fct) + workqueue->worker_before_pause_fct(workqueue, workqueue->priv); + cmm_smp_mb__before_uatomic_or(); + uatomic_or(&workqueue->flags, URCU_WORKQUEUE_PAUSED); + while ((uatomic_read(&workqueue->flags) & URCU_WORKQUEUE_PAUSE) != 0) + (void) poll(NULL, 0, 1); + uatomic_and(&workqueue->flags, ~URCU_WORKQUEUE_PAUSED); + cmm_smp_mb__after_uatomic_and(); + if (workqueue->worker_after_resume_fct) + workqueue->worker_after_resume_fct(workqueue, workqueue->priv); + } + + cds_wfcq_init(&cbs_tmp_head, &cbs_tmp_tail); + splice_ret = __cds_wfcq_splice_blocking(&cbs_tmp_head, + &cbs_tmp_tail, &workqueue->cbs_head, &workqueue->cbs_tail); + urcu_posix_assert(splice_ret != CDS_WFCQ_RET_WOULDBLOCK); + urcu_posix_assert(splice_ret != CDS_WFCQ_RET_DEST_NON_EMPTY); + if (splice_ret != CDS_WFCQ_RET_SRC_EMPTY) { + if (workqueue->grace_period_fct) + workqueue->grace_period_fct(workqueue, workqueue->priv); + cbcount = 0; + __cds_wfcq_for_each_blocking_safe(&cbs_tmp_head, + &cbs_tmp_tail, cbs, cbs_tmp_n) { + struct urcu_work *uwp; + + uwp = caa_container_of(cbs, + struct urcu_work, next); + uwp->func(uwp); + cbcount++; + } + uatomic_sub(&workqueue->qlen, cbcount); + } + if (uatomic_read(&workqueue->flags) & URCU_WORKQUEUE_STOP) + break; + if (workqueue->worker_before_wait_fct) + workqueue->worker_before_wait_fct(workqueue, workqueue->priv); + if (!rt) { + if (cds_wfcq_empty(&workqueue->cbs_head, + &workqueue->cbs_tail)) { + futex_wait(&workqueue->futex); + uatomic_dec(&workqueue->futex); + /* + * Decrement futex before reading + * urcu_work list. + */ + cmm_smp_mb(); + } + } else { + if (cds_wfcq_empty(&workqueue->cbs_head, + &workqueue->cbs_tail)) { + (void) poll(NULL, 0, 10); + } + } + if (workqueue->worker_after_wake_up_fct) + workqueue->worker_after_wake_up_fct(workqueue, workqueue->priv); + } + if (!rt) { + /* + * Read urcu_work list before write futex. + */ + cmm_smp_mb(); + uatomic_set(&workqueue->futex, 0); + } + if (workqueue->finalize_worker_fct) + workqueue->finalize_worker_fct(workqueue, workqueue->priv); + return NULL; +} + +struct urcu_workqueue *urcu_workqueue_create(unsigned long flags, + int cpu_affinity, void *priv, + void (*grace_period_fct)(struct urcu_workqueue *workqueue, void *priv), + void (*initialize_worker_fct)(struct urcu_workqueue *workqueue, void *priv), + void (*finalize_worker_fct)(struct urcu_workqueue *workqueue, void *priv), + void (*worker_before_wait_fct)(struct urcu_workqueue *workqueue, void *priv), + void (*worker_after_wake_up_fct)(struct urcu_workqueue *workqueue, void *priv), + void (*worker_before_pause_fct)(struct urcu_workqueue *workqueue, void *priv), + void (*worker_after_resume_fct)(struct urcu_workqueue *workqueue, void *priv)) +{ + struct urcu_workqueue *workqueue; + int ret; + sigset_t newmask, oldmask; + + workqueue = malloc(sizeof(*workqueue)); + if (workqueue == NULL) + urcu_die(errno); + memset(workqueue, '\0', sizeof(*workqueue)); + cds_wfcq_init(&workqueue->cbs_head, &workqueue->cbs_tail); + workqueue->qlen = 0; + workqueue->futex = 0; + workqueue->flags = flags; + workqueue->priv = priv; + workqueue->grace_period_fct = grace_period_fct; + workqueue->initialize_worker_fct = initialize_worker_fct; + workqueue->finalize_worker_fct = finalize_worker_fct; + workqueue->worker_before_wait_fct = worker_before_wait_fct; + workqueue->worker_after_wake_up_fct = worker_after_wake_up_fct; + workqueue->worker_before_pause_fct = worker_before_pause_fct; + workqueue->worker_after_resume_fct = worker_after_resume_fct; + workqueue->cpu_affinity = cpu_affinity; + workqueue->loop_count = 0; + cmm_smp_mb(); /* Structure initialized before pointer is planted. */ + + ret = sigfillset(&newmask); + urcu_posix_assert(!ret); + ret = pthread_sigmask(SIG_BLOCK, &newmask, &oldmask); + urcu_posix_assert(!ret); + + ret = pthread_create(&workqueue->tid, NULL, workqueue_thread, workqueue); + if (ret) { + urcu_die(ret); + } + + ret = pthread_sigmask(SIG_SETMASK, &oldmask, NULL); + urcu_posix_assert(!ret); + + return workqueue; +} + +static void wake_worker_thread(struct urcu_workqueue *workqueue) +{ + if (!(_CMM_LOAD_SHARED(workqueue->flags) & URCU_WORKQUEUE_RT)) + futex_wake_up(&workqueue->futex); +} + +static int urcu_workqueue_destroy_worker(struct urcu_workqueue *workqueue) +{ + int ret; + void *retval; + + uatomic_or(&workqueue->flags, URCU_WORKQUEUE_STOP); + wake_worker_thread(workqueue); + + ret = pthread_join(workqueue->tid, &retval); + if (ret) { + urcu_die(ret); + } + if (retval != NULL) { + urcu_die(EINVAL); + } + workqueue->flags &= ~URCU_WORKQUEUE_STOP; + workqueue->tid = 0; + return 0; +} + +void urcu_workqueue_destroy(struct urcu_workqueue *workqueue) +{ + if (workqueue == NULL) { + return; + } + if (urcu_workqueue_destroy_worker(workqueue)) { + urcu_die(errno); + } + urcu_posix_assert(cds_wfcq_empty(&workqueue->cbs_head, &workqueue->cbs_tail)); + free(workqueue); +} + +void urcu_workqueue_queue_work(struct urcu_workqueue *workqueue, + struct urcu_work *work, + void (*func)(struct urcu_work *work)) +{ + cds_wfcq_node_init(&work->next); + work->func = func; + cds_wfcq_enqueue(&workqueue->cbs_head, &workqueue->cbs_tail, &work->next); + uatomic_inc(&workqueue->qlen); + wake_worker_thread(workqueue); +} + +static +void free_completion(struct urcu_ref *ref) +{ + struct urcu_workqueue_completion *completion; + + completion = caa_container_of(ref, struct urcu_workqueue_completion, ref); + free(completion); +} + +static +void _urcu_workqueue_wait_complete(struct urcu_work *work) +{ + struct urcu_workqueue_completion_work *completion_work; + struct urcu_workqueue_completion *completion; + + completion_work = caa_container_of(work, struct urcu_workqueue_completion_work, work); + completion = completion_work->completion; + if (!uatomic_sub_return(&completion->barrier_count, 1)) + futex_wake_up(&completion->futex); + urcu_ref_put(&completion->ref, free_completion); + free(completion_work); +} + +struct urcu_workqueue_completion *urcu_workqueue_create_completion(void) +{ + struct urcu_workqueue_completion *completion; + + completion = calloc(1, sizeof(*completion)); + if (!completion) + urcu_die(errno); + urcu_ref_set(&completion->ref, 1); + completion->barrier_count = 0; + return completion; +} + +void urcu_workqueue_destroy_completion(struct urcu_workqueue_completion *completion) +{ + urcu_ref_put(&completion->ref, free_completion); +} + +void urcu_workqueue_wait_completion(struct urcu_workqueue_completion *completion) +{ + /* Wait for them */ + for (;;) { + uatomic_dec(&completion->futex); + /* Decrement futex before reading barrier_count */ + cmm_smp_mb(); + if (!uatomic_read(&completion->barrier_count)) + break; + futex_wait(&completion->futex); + } +} + +void urcu_workqueue_queue_completion(struct urcu_workqueue *workqueue, + struct urcu_workqueue_completion *completion) +{ + struct urcu_workqueue_completion_work *work; + + work = calloc(1, sizeof(*work)); + if (!work) + urcu_die(errno); + work->completion = completion; + urcu_ref_get(&completion->ref); + uatomic_inc(&completion->barrier_count); + urcu_workqueue_queue_work(workqueue, &work->work, _urcu_workqueue_wait_complete); +} + +/* + * Wait for all in-flight work to complete execution. + */ +void urcu_workqueue_flush_queued_work(struct urcu_workqueue *workqueue) +{ + struct urcu_workqueue_completion *completion; + + completion = urcu_workqueue_create_completion(); + if (!completion) + urcu_die(ENOMEM); + urcu_workqueue_queue_completion(workqueue, completion); + urcu_workqueue_wait_completion(completion); + urcu_workqueue_destroy_completion(completion); +} + +/* To be used in before fork handler. */ +void urcu_workqueue_pause_worker(struct urcu_workqueue *workqueue) +{ + uatomic_or(&workqueue->flags, URCU_WORKQUEUE_PAUSE); + cmm_smp_mb__after_uatomic_or(); + wake_worker_thread(workqueue); + + while ((uatomic_read(&workqueue->flags) & URCU_WORKQUEUE_PAUSED) == 0) + (void) poll(NULL, 0, 1); +} + +/* To be used in after fork parent handler. */ +void urcu_workqueue_resume_worker(struct urcu_workqueue *workqueue) +{ + uatomic_and(&workqueue->flags, ~URCU_WORKQUEUE_PAUSE); + while ((uatomic_read(&workqueue->flags) & URCU_WORKQUEUE_PAUSED) != 0) + (void) poll(NULL, 0, 1); +} + +void urcu_workqueue_create_worker(struct urcu_workqueue *workqueue) +{ + int ret; + sigset_t newmask, oldmask; + + /* Clear workqueue state from parent. */ + workqueue->flags &= ~URCU_WORKQUEUE_PAUSED; + workqueue->flags &= ~URCU_WORKQUEUE_PAUSE; + workqueue->tid = 0; + + ret = sigfillset(&newmask); + urcu_posix_assert(!ret); + ret = pthread_sigmask(SIG_BLOCK, &newmask, &oldmask); + urcu_posix_assert(!ret); + + ret = pthread_create(&workqueue->tid, NULL, workqueue_thread, workqueue); + if (ret) { + urcu_die(ret); + } + + ret = pthread_sigmask(SIG_SETMASK, &oldmask, NULL); + urcu_posix_assert(!ret); +} diff --git a/external/lgpl2/userspace-rcu/dist/src/workqueue.h b/external/lgpl2/userspace-rcu/dist/src/workqueue.h new file mode 100644 index 0000000000000..ed391da7743d0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/src/workqueue.h @@ -0,0 +1,90 @@ +// SPDX-FileCopyrightText: 2009,2017 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _URCU_WORKQUEUE_H +#define _URCU_WORKQUEUE_H + +/* + * Userspace RCU header - Userspace workqueues + */ + +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Note that struct urcu_workqueue is opaque to callers. */ + +struct urcu_workqueue; +struct urcu_workqueue_completion; + +/* Flag values. */ + +#define URCU_WORKQUEUE_RT (1U << 0) +#define URCU_WORKQUEUE_STOP (1U << 1) +#define URCU_WORKQUEUE_PAUSE (1U << 2) +#define URCU_WORKQUEUE_PAUSED (1U << 3) + +/* + * The urcu_work data structure is placed in the structure to be acted + * upon via urcu_workqueue_queue_work(). + */ + +struct urcu_work { + struct cds_wfcq_node next; + void (*func)(struct urcu_work *head); +}; + +/* + * Exported functions + */ + +struct urcu_workqueue *urcu_workqueue_create(unsigned long flags, + int cpu_affinity, void *priv, + void (*grace_period_fct)(struct urcu_workqueue *workqueue, void *priv), + void (*initialize_worker_fct)(struct urcu_workqueue *workqueue, void *priv), + void (*finalize_worker_fct)(struct urcu_workqueue *workqueue, void *priv), + void (*worker_before_wait_fct)(struct urcu_workqueue *workqueue, void *priv), + void (*worker_after_wake_up_fct)(struct urcu_workqueue *workqueue, void *priv), + void (*worker_before_pause_fct)(struct urcu_workqueue *workqueue, void *priv), + void (*worker_after_resume_fct)(struct urcu_workqueue *workqueue, void *priv)); +void urcu_workqueue_destroy(struct urcu_workqueue *workqueue); + +/* + * Never fails. Should not be used to enqueue work from worker threads + * after the application invokes urcu_workqueue_free. + */ +void urcu_workqueue_queue_work(struct urcu_workqueue *workqueue, + struct urcu_work *work, + void (*func)(struct urcu_work *work)); + +struct urcu_workqueue_completion *urcu_workqueue_create_completion(void); +void urcu_workqueue_destroy_completion(struct urcu_workqueue_completion *completion); + +void urcu_workqueue_queue_completion(struct urcu_workqueue *workqueue, + struct urcu_workqueue_completion *completion); +void urcu_workqueue_wait_completion(struct urcu_workqueue_completion *completion); + +void urcu_workqueue_flush_queued_work(struct urcu_workqueue *workqueue); + +/* + * pause/resume/create worker threads. Can be used to pause worker + * threads across fork/clone while keeping the workqueue in place. + * Pause is used in parent pre-fork, resume in parent post-fork, create + * in child after-fork. + */ +void urcu_workqueue_pause_worker(struct urcu_workqueue *workqueue); +void urcu_workqueue_resume_worker(struct urcu_workqueue *workqueue); +void urcu_workqueue_create_worker(struct urcu_workqueue *workqueue); + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_WORKQUEUE_H */ diff --git a/external/lgpl2/userspace-rcu/dist/tests/Makefile.am b/external/lgpl2/userspace-rcu/dist/tests/Makefile.am new file mode 100644 index 0000000000000..c4f4afa11a73c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/Makefile.am @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +SUBDIRS = utils common unit benchmark regression + +.PHONY: short_bench long_bench regtest check-loop + +short_bench: + cd benchmark && $(MAKE) $(AM_MAKEFLAGS) short_bench +long_bench: + cd benchmark && $(MAKE) $(AM_MAKEFLAGS) long_bench +regtest: + cd regression && $(MAKE) $(AM_MAKEFLAGS) regtest + cd benchmark && $(MAKE) $(AM_MAKEFLAGS) regtest + +check-loop: + while [ 0 ]; do \ + $(MAKE) $(AM_MAKEFLAGS) check; \ + if [ "$$?" != "0" ]; then \ + break; \ + fi \ + done diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/Makefile.am b/external/lgpl2/userspace-rcu/dist/tests/benchmark/Makefile.am new file mode 100644 index 0000000000000..e5ce2e9860bb6 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/Makefile.am @@ -0,0 +1,235 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +AM_CPPFLAGS += -I$(top_srcdir)/src -I$(top_srcdir)/tests/common +AM_CPPFLAGS += -include $(top_srcdir)/tests/benchmark/common-states.h + +TEST_EXTENSIONS = .tap +TAP_LOG_DRIVER_FLAGS = --merge --comments +TAP_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' \ + URCU_TESTS_SRCDIR='$(abs_top_srcdir)/tests' \ + URCU_TESTS_BUILDDIR='$(abs_top_builddir)/tests' \ + $(SHELL) $(top_srcdir)/tests/utils/tap-driver.sh + +noinst_HEADERS = common-states.h + +SCRIPT_LIST = \ + runpaul-phase1.sh \ + runpaul-phase2.sh \ + runpaul-phase3.sh \ + runpaul-phase4.sh \ + runpaul-phase5.sh \ + runpaul-phase6.sh \ + runpaul-phase7.sh \ + subphase4.sh + +dist_noinst_SCRIPTS = \ + runhash.sh \ + runtests-batch.sh \ + runtests.sh \ + run-urcu-tests.sh \ + $(SCRIPT_LIST) + +dist_noinst_DATA = \ + hashtable_1_seconds.tap \ + urcu_1_seconds.tap + hashtable_3_seconds.tap \ + urcu_3_seconds.tap + hashtable_30_seconds.tap \ + urcu_30_seconds.tap + +noinst_PROGRAMS = test_urcu test_urcu_dynamic_link test_urcu_timing \ + test_rwlock_timing test_rwlock test_perthreadlock_timing \ + test_perthreadlock test_urcu_yield test_urcu_mb \ + test_urcu_qsbr_timing test_urcu_qsbr \ + test_mutex test_looplen test_urcu_gc \ + test_urcu_lgc \ + test_urcu_mb_gc test_urcu_qsbr_gc test_urcu_qsbr_lgc \ + test_urcu_mb_lgc test_urcu_qsbr_dynamic_link test_urcu_defer \ + test_urcu_assign test_urcu_assign_dynamic_link \ + test_urcu_bp test_urcu_bp_dynamic_link test_cycles_per_loop \ + test_urcu_lfq test_urcu_wfq test_urcu_lfs test_urcu_wfs \ + test_urcu_lfs_rcu \ + test_urcu_wfcq \ + test_urcu_wfq_dynlink test_urcu_wfs_dynlink \ + test_urcu_wfcq_dynlink \ + test_urcu_lfq_dynlink test_urcu_lfs_dynlink test_urcu_hash \ + test_urcu_lfs_rcu_dynlink + +URCU_COMMON_LIB=$(top_builddir)/src/liburcu-common.la +URCU_LIB=$(top_builddir)/src/liburcu.la +URCU_QSBR_LIB=$(top_builddir)/src/liburcu-qsbr.la +URCU_MB_LIB=$(top_builddir)/src/liburcu-mb.la +URCU_BP_LIB=$(top_builddir)/src/liburcu-bp.la +URCU_CDS_LIB=$(top_builddir)/src/liburcu-cds.la + +DEBUG_YIELD_LIB=$(builddir)/../common/libdebug-yield.la + +test_urcu_SOURCES = test_urcu.c common-states.c +test_urcu_LDADD = $(URCU_LIB) + +test_urcu_dynamic_link_SOURCES = test_urcu.c common-states.c +test_urcu_dynamic_link_LDADD = $(URCU_LIB) +test_urcu_dynamic_link_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS) + +test_urcu_timing_SOURCES = test_urcu_timing.c common-states.c +test_urcu_timing_LDADD = $(URCU_LIB) + +test_urcu_yield_SOURCES = test_urcu.c common-states.c +test_urcu_yield_LDADD = $(URCU_LIB) $(DEBUG_YIELD_LIB) +test_urcu_yield_CFLAGS = -DDEBUG_YIELD $(AM_CFLAGS) + + +test_urcu_qsbr_SOURCES = test_urcu_qsbr.c common-states.c +test_urcu_qsbr_LDADD = $(URCU_QSBR_LIB) + +test_urcu_qsbr_timing_SOURCES = test_urcu_qsbr_timing.c common-states.c +test_urcu_qsbr_timing_LDADD = $(URCU_QSBR_LIB) + + +test_urcu_mb_SOURCES = test_urcu.c common-states.c +test_urcu_mb_LDADD = $(URCU_MB_LIB) +test_urcu_mb_CFLAGS = -DRCU_MB $(AM_CFLAGS) + + +test_rwlock_timing_SOURCES = test_rwlock_timing.c common-states.c +test_rwlock_timing_LDADD = $(URCU_LIB) + +test_rwlock_SOURCES = test_rwlock.c common-states.c +test_rwlock_LDADD = $(URCU_LIB) + +test_perthreadlock_timing_SOURCES = test_perthreadlock_timing.c common-states.c +test_perthreadlock_timing_LDADD = $(URCU_LIB) + +test_perthreadlock_SOURCES = test_perthreadlock.c common-states.c +test_perthreadlock_LDADD = $(URCU_LIB) + +test_mutex_SOURCES = test_mutex.c common-states.c + +test_looplen_SOURCES = test_looplen.c common-states.c + +test_urcu_gc_SOURCES = test_urcu_gc.c common-states.c +test_urcu_gc_LDADD = $(URCU_LIB) + +test_urcu_mb_gc_SOURCES = test_urcu_gc.c common-states.c +test_urcu_mb_gc_LDADD = $(URCU_MB_LIB) +test_urcu_mb_gc_CFLAGS = -DRCU_MB $(AM_CFLAGS) + +test_urcu_qsbr_gc_SOURCES = test_urcu_qsbr_gc.c common-states.c +test_urcu_qsbr_gc_LDADD = $(URCU_QSBR_LIB) + +test_urcu_qsbr_lgc_SOURCES = test_urcu_qsbr_gc.c common-states.c +test_urcu_qsbr_lgc_LDADD = $(URCU_QSBR_LIB) +test_urcu_qsbr_lgc_CFLAGS = -DTEST_LOCAL_GC $(AM_CFLAGS) + +test_urcu_lgc_SOURCES = test_urcu_gc.c common-states.c +test_urcu_lgc_LDADD = $(URCU_LIB) +test_urcu_lgc_CFLAGS = -DTEST_LOCAL_GC $(AM_CFLAGS) + +test_urcu_mb_lgc_SOURCES = test_urcu_gc.c common-states.c +test_urcu_mb_lgc_LDADD = $(URCU_MB_LIB) +test_urcu_mb_lgc_CFLAGS = -DTEST_LOCAL_GC -DRCU_MB $(AM_CFLAGS) + +test_urcu_qsbr_dynamic_link_SOURCES = test_urcu_qsbr.c common-states.c +test_urcu_qsbr_dynamic_link_LDADD = $(URCU_QSBR_LIB) +test_urcu_qsbr_dynamic_link_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS) + +test_urcu_defer_SOURCES = test_urcu_defer.c common-states.c +test_urcu_defer_LDADD = $(URCU_LIB) + +test_cycles_per_loop_SOURCES = test_cycles_per_loop.c + +test_urcu_assign_SOURCES = test_urcu_assign.c common-states.c +test_urcu_assign_LDADD = $(URCU_LIB) + +test_urcu_assign_dynamic_link_SOURCES = test_urcu_assign.c common-states.c +test_urcu_assign_dynamic_link_LDADD = $(URCU_LIB) +test_urcu_assign_dynamic_link_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS) + +test_urcu_bp_SOURCES = test_urcu_bp.c common-states.c +test_urcu_bp_LDADD = $(URCU_BP_LIB) + +test_urcu_bp_dynamic_link_SOURCES = test_urcu_bp.c common-states.c +test_urcu_bp_dynamic_link_LDADD = $(URCU_BP_LIB) +test_urcu_bp_dynamic_link_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS) + +test_urcu_lfq_SOURCES = test_urcu_lfq.c common-states.c +test_urcu_lfq_LDADD = $(URCU_LIB) $(URCU_CDS_LIB) + +test_urcu_lfq_dynlink_SOURCES = test_urcu_lfq.c common-states.c +test_urcu_lfq_dynlink_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS) +test_urcu_lfq_dynlink_LDADD = $(URCU_LIB) $(URCU_CDS_LIB) + +test_urcu_wfq_SOURCES = test_urcu_wfq.c common-states.c +test_urcu_wfq_LDADD = $(URCU_COMMON_LIB) + +test_urcu_wfq_dynlink_SOURCES = test_urcu_wfq.c common-states.c +test_urcu_wfq_dynlink_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS) +test_urcu_wfq_dynlink_LDADD = $(URCU_COMMON_LIB) + +test_urcu_wfcq_SOURCES = test_urcu_wfcq.c common-states.c +test_urcu_wfcq_LDADD = $(URCU_COMMON_LIB) + +test_urcu_wfcq_dynlink_SOURCES = test_urcu_wfcq.c common-states.c +test_urcu_wfcq_dynlink_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS) +test_urcu_wfcq_dynlink_LDADD = $(URCU_COMMON_LIB) + +test_urcu_lfs_SOURCES = test_urcu_lfs.c common-states.c +test_urcu_lfs_LDADD = $(URCU_LIB) $(URCU_CDS_LIB) + +test_urcu_lfs_rcu_SOURCES = test_urcu_lfs_rcu.c common-states.c +test_urcu_lfs_rcu_LDADD = $(URCU_LIB) $(URCU_CDS_LIB) + +test_urcu_lfs_dynlink_SOURCES = test_urcu_lfs.c common-states.c +test_urcu_lfs_dynlink_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS) +test_urcu_lfs_dynlink_LDADD = $(URCU_LIB) $(URCU_CDS_LIB) + +test_urcu_lfs_rcu_dynlink_SOURCES = test_urcu_lfs_rcu.c common-states.c +test_urcu_lfs_rcu_dynlink_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS) +test_urcu_lfs_rcu_dynlink_LDADD = $(URCU_LIB) $(URCU_CDS_LIB) + +test_urcu_wfs_SOURCES = test_urcu_wfs.c common-states.c +test_urcu_wfs_LDADD = $(URCU_COMMON_LIB) + +test_urcu_wfs_dynlink_SOURCES = test_urcu_wfs.c common-states.c +test_urcu_wfs_dynlink_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS) +test_urcu_wfs_dynlink_LDADD = $(URCU_COMMON_LIB) + +test_urcu_hash_SOURCES = test_urcu_hash.c test_urcu_hash.h \ + test_urcu_hash_rw.c test_urcu_hash_unique.c common-states.c +test_urcu_hash_CFLAGS = -DRCU_QSBR $(AM_CFLAGS) +test_urcu_hash_LDADD = $(URCU_QSBR_LIB) $(URCU_COMMON_LIB) $(URCU_CDS_LIB) + +all-local: + @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + for script in $(SCRIPT_LIST); do \ + cp -f $(srcdir)/$$script $(builddir); \ + done; \ + fi + +clean-local: + @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + for script in $(SCRIPT_LIST); do \ + rm -f $(builddir)/$$script; \ + done; \ + fi + +.PHONY: short_bench long_bench regtest + +# This empty variable is required to enable the TAP test suite for custom +# targets like 'regtest' while keeping the default 'check' a noop. +TESTS = + +SHORT_BENCH_TESTS = urcu_3_seconds.tap hashtable_3_seconds.tap +LONG_BENCH_TESTS = urcu_30_seconds.tap hashtable_30_seconds.tap +REGTEST_TESTS = urcu_1_seconds.tap hashtable_1_seconds.tap + +short_bench: + $(MAKE) $(AM_MAKEFLAGS) check TESTS="$(SHORT_BENCH_TESTS)" + +long_bench: + $(MAKE) $(AM_MAKEFLAGS) check TESTS="$(LONG_BENCH_TESTS)" + +regtest: + $(MAKE) $(AM_MAKEFLAGS) check TESTS="$(REGTEST_TESTS)" diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/common-states.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/common-states.c new file mode 100644 index 0000000000000..4a7f71905e35b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/common-states.c @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 Olivier Dion +// +// SPDX-License-Identifier: GPL-2.0-or-later + +volatile int _test_go = 0, _test_stop = 0; diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/common-states.h b/external/lgpl2/userspace-rcu/dist/tests/benchmark/common-states.h new file mode 100644 index 0000000000000..d46fd38a80a80 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/common-states.h @@ -0,0 +1,55 @@ +// SPDX-FileCopyrightText: 2023 Olivier Dion +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* Common states for benchmarks. */ + +#include + +#include + +extern volatile int _test_go, _test_stop; + +static inline void complete_sleep(unsigned int seconds) +{ + while (seconds != 0) { + seconds = sleep(seconds); + } +} + +static inline void begin_test(void) +{ + uatomic_store(&_test_go, 1, CMM_RELEASE); +} + +static inline void end_test(void) +{ + uatomic_store(&_test_stop, 1, CMM_RELAXED); +} + +static inline void test_for(unsigned int duration) +{ + begin_test(); + complete_sleep(duration); + end_test(); +} + +static inline void wait_until_go(void) +{ + while (!uatomic_load(&_test_go, CMM_ACQUIRE)) + { + } +} + +/* + * returns 0 if test should end. + */ +static inline int test_duration_write(void) +{ + return !uatomic_load(&_test_stop, CMM_RELAXED); +} + +static inline int test_duration_read(void) +{ + return !uatomic_load(&_test_stop, CMM_RELAXED); +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/hashtable_1_seconds.tap b/external/lgpl2/userspace-rcu/dist/tests/benchmark/hashtable_1_seconds.tap new file mode 100755 index 0000000000000..d71cc3f43877a --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/hashtable_1_seconds.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"$URCU_TESTS_SRCDIR/benchmark/runhash.sh" 1 diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/hashtable_30_seconds.tap b/external/lgpl2/userspace-rcu/dist/tests/benchmark/hashtable_30_seconds.tap new file mode 100755 index 0000000000000..49ad0e6a8755f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/hashtable_30_seconds.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"$URCU_TESTS_SRCDIR/benchmark/runhash.sh" 30 diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/hashtable_3_seconds.tap b/external/lgpl2/userspace-rcu/dist/tests/benchmark/hashtable_3_seconds.tap new file mode 100755 index 0000000000000..c63618b3705d8 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/hashtable_3_seconds.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"$URCU_TESTS_SRCDIR/benchmark/runhash.sh" 3 diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/run-urcu-tests.sh b/external/lgpl2/userspace-rcu/dist/tests/benchmark/run-urcu-tests.sh new file mode 100755 index 0000000000000..13347ee1ce159 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/run-urcu-tests.sh @@ -0,0 +1,159 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# Enable TAP +SH_TAP=1 + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +# First parameter: seconds per test +DURATION=$1 + +if [ "x${DURATION}" = "x" ]; then + echo "usage: $0 [DURATION]" + exit 1 +fi + +# Create a temporary file for tests output +TMPFILE=$(mktemp) + +# Set trap to delete the temporary file on exit and call tap.sh '_exit' +trap 'rm -f "$TMPFILE"; _exit' EXIT + +# Set to number of active CPUS +NUM_CPUS="$(urcu_nproc)" +if [[ ${NUM_CPUS} -lt 4 ]]; then + NUM_CPUS=4 # Floor at 4 due to following assumptions. +fi + +# batch: 19 * 1 = 19 +# fraction: 12 * 29 = +# scalabilit NUM_CPUS * 12 +# reader 12 * 23 = +NUM_TESTS=$(( 19 + 348 + ( NUM_CPUS * 12 ) + 276 )) + +plan_tests ${NUM_TESTS} + +#run all tests +diag "Executing URCU tests" + + +#extra options, e.g. for setting affinity on even CPUs : +#EXTRA_OPTS=$(for a in $(seq 0 2 127); do echo -n "-a ${a} "; done) + +#ppc64 striding, use with NUM_CPUS=8 + +#stride 1 +#EXTRA_OPTS=$(for a in $(seq 0 2 15); do echo -n "-a ${a} "; done) +#stride 2 +#EXTRA_OPTS=$(for a in $(seq 0 4 31); do echo -n "-a ${a} "; done) +#stride 4 +#EXTRA_OPTS=$(for a in $(seq 0 8 63); do echo -n "-a ${a} "; done) +#stride 8 +#EXTRA_OPTS=$(for a in $(seq 0 16 127); do echo -n "-a ${a} "; done) + +#Vary update fraction +#x: vary update fraction from 0 to 0.0001 + #fix number of readers and reader C.S. length, vary delay between updates +#y: ops/s +EXTRA_OPTS="" + + +diag "Executing batch RCU test" + +BATCH_ARRAY="1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 + 131072 262144" +BATCH_TEST_ARRAY="test_urcu_gc" + +NR_WRITERS=$((NUM_CPUS / 2)) +NR_READERS=$((NUM_CPUS - NR_WRITERS)) + +for BATCH_SIZE in ${BATCH_ARRAY}; do + for TEST in ${BATCH_TEST_ARRAY}; do + okx ${URCU_TESTS_TIME_BIN} "${URCU_TESTS_BUILDDIR}/benchmark/${TEST}" "${NR_READERS}" "${NR_WRITERS}" "${DURATION}" \ + -d 0 -b "${BATCH_SIZE}" ${EXTRA_OPTS} 2>"${TMPFILE}" + while read -r line; do + echo "## $line" + done <"${TMPFILE}" + done +done + +TEST_ARRAY="test_urcu_gc test_urcu_mb_gc test_urcu_qsbr_gc + test_urcu_lgc test_urcu_mb_lgc test_urcu_qsbr_lgc + test_urcu test_urcu_mb test_urcu_qsbr + test_rwlock test_perthreadlock test_mutex" + +#setting gc each 32768. ** UPDATE FOR YOUR ARCHITECTURE BASED ON TEST ABOVE ** +EXTRA_OPTS="${EXTRA_OPTS} -b 32768" + +diag "Executing update fraction test" + +WDELAY_ARRAY="0 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 + 65536 131072 262144 524288 1048576 2097152 4194304 8388608 + 16777216 33554432 67108864 134217728" +NR_WRITERS=$((NUM_CPUS / 2)) +NR_READERS=$((NUM_CPUS - NR_WRITERS)) + +for WDELAY in ${WDELAY_ARRAY}; do + for TEST in ${TEST_ARRAY}; do + okx ${URCU_TESTS_TIME_BIN} "${URCU_TESTS_BUILDDIR}/benchmark/${TEST}" "${NR_READERS}" "${NR_WRITERS}" "${DURATION}" \ + -d "${WDELAY}" ${EXTRA_OPTS} 2>"${TMPFILE}" + while read -r line; do + echo "## $line" + done <"${TMPFILE}" + done +done + +#Test scalability : +# x: vary number of readers from 0 to num cpus +# y: ops/s +# 0 writer. + +diag "Executing scalability test" + +NR_WRITERS=0 + +for NR_READERS in $(urcu_xseq 1 ${NUM_CPUS}); do + for TEST in ${TEST_ARRAY}; do + okx ${URCU_TESTS_TIME_BIN} "${URCU_TESTS_BUILDDIR}/benchmark/${TEST}" "${NR_READERS}" "${NR_WRITERS}" "${DURATION}" \ + ${EXTRA_OPTS} 2>"${TMPFILE}" + while read -r line; do + echo "## $line" + done <"${TMPFILE}" + done +done + + +# x: Vary reader C.S. length from 0 to 100 us +# y: ops/s +# 8 readers +# 0 writers + +diag "Executing reader C.S. length test" + +NR_READERS=${NUM_CPUS} +NR_WRITERS=0 +#in loops. +READERCSLEN_ARRAY="0 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152" + +for READERCSLEN in ${READERCSLEN_ARRAY}; do + for TEST in ${TEST_ARRAY}; do + okx ${URCU_TESTS_TIME_BIN} "${URCU_TESTS_BUILDDIR}/benchmark/${TEST}" "${NR_READERS}" "${NR_WRITERS}" "${DURATION}" \ + -c "${READERCSLEN}" ${EXTRA_OPTS} 2>"${TMPFILE}" + while read -r line; do + echo "## $line" + done <"${TMPFILE}" + done +done diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/runhash.sh b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runhash.sh new file mode 100755 index 0000000000000..c3f42ebe327bb --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runhash.sh @@ -0,0 +1,170 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# Enable TAP +SH_TAP=1 + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +# 1st parameter: seconds per test +DURATION=$1 + +if [ "x${DURATION}" = "x" ]; then + echo "usage: $0 [DURATION]" + exit 1 +fi + +NUM_TESTS=17 + +plan_tests ${NUM_TESTS} + +diag "Executing Hash table test" + +# TODO: missing tests: +# - send kill signals during tests to change the behavior between +# add/remove/random +# - validate that "nr_leaked" is always 0 in SUMMARY for all tests + +TESTPROG="${URCU_TESTS_BUILDDIR}/benchmark/test_urcu_hash" + +#thread multiplier: number of processors divided by 4. +NUM_CPUS="$(urcu_nproc)" +if [[ ${NUM_CPUS} -lt 4 ]]; then + NUM_CPUS=4 # Floor at 4 due to following assumptions. +fi + +THREAD_MUL=$((NUM_CPUS / 4)) + +EXTRA_PARAMS=-v + +# ** test update coherency with single-value table + +# rw test, single key, replace and del randomly, 4 threads, auto resize. +# key range: init, lookup, and update: 0 to 0 +okx "${TESTPROG}" 0 $((4*THREAD_MUL)) "${DURATION}" -A -s -M 1 -N 1 -O 1 ${EXTRA_PARAMS} + +# rw test, single key, add unique and del randomly, 4 threads, auto resize. +# key range: init, lookup, and update: 0 to 0 +okx "${TESTPROG}" 0 $((4*THREAD_MUL)) "${DURATION}" -A -u -M 1 -N 1 -O 1 ${EXTRA_PARAMS} + +# rw test, single key, replace and del randomly, 2 lookup threads, 2 update threads, auto resize. +# key range: init, lookup, and update: 0 to 0 +okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -s -M 1 -N 1 -O 1 ${EXTRA_PARAMS} + +# rw test, single key, add and del randomly, 2 lookup threads, 2 update threads, auto resize. +# key range: init, lookup, and update: 0 to 0 +okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -M 1 -N 1 -O 1 ${EXTRA_PARAMS} + + +# ** test updates vs lookups with default table + +# rw test, 2 lookup, 2 update threads, add and del randomly, auto resize. +# max 1048576 buckets +# key range: init, lookup, and update: 0 to 999999 +okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A ${EXTRA_PARAMS} + +# rw test, 2 lookup, 2 update threads, add_replace and del randomly, auto resize. +# max 1048576 buckets +# key range: init, lookup, and update: 0 to 999999 +okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -s ${EXTRA_PARAMS} + +# rw test, 2 lookup, 2 update threads, add_unique and del randomly, auto resize. +# max 1048576 buckets +# key range: init, lookup, and update: 0 to 999999 +okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -u ${EXTRA_PARAMS} + + +# test memory management backends + +# rw test, 2 lookup, 2 update threads, add only, auto resize. +# max buckets: 1048576 +# key range: init, lookup, and update: 0 to 99999999 +# mm backend: "order" +okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -m 1 -n 1048576 -i \ + -M 100000000 -N 100000000 -O 100000000 -B order ${EXTRA_PARAMS} + +# rw test, 2 lookup, 2 update threads, add only, auto resize. +# max buckets: 1048576 +# key range: init, lookup, and update: 0 to 99999999 +# mm backend: "chunk" +okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -m 1 -n 1048576 -i \ + -M 100000000 -N 100000000 -O 100000000 -B chunk ${EXTRA_PARAMS} + +# rw test, 2 lookup, 2 update threads, add only, auto resize. +# max buckets: 1048576 +# key range: init, lookup, and update: 0 to 99999999 +# mm backend: "mmap" +okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -m 1 -n 1048576 -i \ + -M 100000000 -N 100000000 -O 100000000 -B mmap ${EXTRA_PARAMS} + + +# ** key range tests + +# rw test, 2 lookup, 2 update threads, add and del randomly, auto resize. +# max 1048576 buckets +# key range: init, and update: 0 to 999999 +# key range: lookup: 1000000 to 1999999 +# NOTE: reader threads in this test should never have a successful +# lookup. TODO +okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ + -R 1000000 ${EXTRA_PARAMS} + +# ** small key range + +# rw test, 2 lookup, 2 update threads, add and del randomly, auto resize. +# max 1048576 buckets +# key range: init, update, and lookups: 0 to 9 +okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ + -M 10 -N 10 -O 10 ${EXTRA_PARAMS} + +# rw test, 2 lookup, 2 update threads, add_unique and del randomly, auto resize. +# max 1048576 buckets +# key range: init, update, and lookups: 0 to 9 +okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ + -M 10 -N 10 -O 10 -u ${EXTRA_PARAMS} + +# rw test, 2 lookup, 2 update threads, add_replace and del randomly, auto resize. +# max 1048576 buckets +# key range: init, update, and lookups: 0 to 9 +okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ + -M 10 -N 10 -O 10 -s ${EXTRA_PARAMS} + +# ** lookup for known keys + +# rw test, 2 lookup, 2 update threads, add_replace and del randomly, auto resize. +# max 1048576 buckets +# lookup range is entirely populated. +# key range: init, and lookups: 0 to 9 +# key range: updates: 10 to 19 +# NOTE: reader threads in this test should always have successful +# lookups. TODO +okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ + -M 10 -N 10 -O 10 -R 0 -T 0 -S 10 -k 10 -s ${EXTRA_PARAMS} + +# ** Uniqueness test + +# rw test, 2 lookup, 2 update threads, add_unique, add_replace and del randomly, auto resize. +# max 1048576 buckets +# asserts that no duplicates are observed by reader threads +# standard length hash chains +okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ + -U ${EXTRA_PARAMS} + +# rw test, 2 lookup, 2 update threads, add_unique, add_replace and del randomly, auto resize. +# max 1048576 buckets +# asserts that no duplicates are observed by reader threads +# create long hash chains: using modulo 4 on keys as hash +okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ + -U -C 4 ${EXTRA_PARAMS} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase1.sh b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase1.sh new file mode 100755 index 0000000000000..4ebea56ec5254 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase1.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +# +# SPDX-License-Identifier: GPL-2.0-only + +#run all tests + +#set to number of active CPUS +NUM_CPUS=64 + +#extra options, e.g. for setting affinity on even CPUs : +EXTRA_OPTS=$(for a in $(seq 0 2 127); do echo -n "-a ${a} "; done) + +#ppc64 striding, use with NUM_CPUS=8 + +#stride 1 +#EXTRA_OPTS=$(for a in $(seq 0 2 15); do echo -n "-a ${a} "; done) +#stride 2 +#EXTRA_OPTS=$(for a in $(seq 0 4 31); do echo -n "-a ${a} "; done) +#stride 4 +#EXTRA_OPTS=$(for a in $(seq 0 8 63); do echo -n "-a ${a} "; done) +#stride 8 +#EXTRA_OPTS=$(for a in $(seq 0 16 127); do echo -n "-a ${a} "; done) + +#Vary update fraction +#x: vary update fraction from 0 to 0.0001 + #fix number of readers and reader C.S. length, vary delay between updates +#y: ops/s + +rm -f runall.log +rm -fr runall.detail.log + + +echo Executing batch RCU test + +DURATION=10 +BATCH_ARRAY="1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 + 131072 262144" +NR_WRITERS=$((${NUM_CPUS} / 2)) + +rm -f batch-rcu.log + +NR_READERS=$((${NUM_CPUS} - ${NR_WRITERS})) +for BATCH_SIZE in ${BATCH_ARRAY}; do + echo "./runtests-batch.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} -d 0 -b ${BATCH_SIZE} ${EXTRA_OPTS} | tee -a batch-rcu.log" >> runall.log + ./runtests-batch.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} -d 0 -b ${BATCH_SIZE} ${EXTRA_OPTS} | tee -a batch-rcu.log +done diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase2.sh b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase2.sh new file mode 100755 index 0000000000000..74fbd5b3f5245 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase2.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +# SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +# +# SPDX-License-Identifier: GPL-2.0-only + +#run all tests + +#set to number of active CPUS +NUM_CPUS=64 + +#extra options, e.g. for setting affinity on even CPUs : +EXTRA_OPTS=$(for a in $(seq 0 2 127); do echo -n "-a ${a} "; done) + +#ppc64 striding, use with NUM_CPUS=8 + +#stride 1 +#EXTRA_OPTS=$(for a in $(seq 0 2 15); do echo -n "-a ${a} "; done) +#stride 2 +#EXTRA_OPTS=$(for a in $(seq 0 4 31); do echo -n "-a ${a} "; done) +#stride 4 +#EXTRA_OPTS=$(for a in $(seq 0 8 63); do echo -n "-a ${a} "; done) +#stride 8 +#EXTRA_OPTS=$(for a in $(seq 0 16 127); do echo -n "-a ${a} "; done) + +#Vary update fraction +#x: vary update fraction from 0 to 0.0001 + #fix number of readers and reader C.S. length, vary delay between updates +#y: ops/s + +rm -f runall.log +rm -fr runall.detail.log + +#setting gc each 32768. ** UPDATE FOR YOUR ARCHITECTURE BASED ON PHASE 1 RESULT ** +EXTRA_OPTS="${EXTRA_OPTS} -b 32768" + +echo Executing update fraction test + +DURATION=10 +WDELAY_ARRAY="0 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 + 65536 131072 262144 524288 1048576 2097152 4194304 8388608 + 16777216 33554432 67108864 134217728" +NR_WRITERS=$((${NUM_CPUS} / 2)) + +rm -f update-fraction.log + +NR_READERS=$((${NUM_CPUS} - ${NR_WRITERS})) +for WDELAY in ${WDELAY_ARRAY}; do + echo "./runtests.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} -d ${WDELAY} ${EXTRA_OPTS} | tee -a update-fraction.log" >> runall.log + ./runtests.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} -d ${WDELAY} ${EXTRA_OPTS} | tee -a update-fraction.log +done diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase3.sh b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase3.sh new file mode 100755 index 0000000000000..4618c3c53642f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase3.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +# SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +# +# SPDX-License-Identifier: GPL-2.0-only + +#run all tests + +#set to number of active CPUS +NUM_CPUS=64 + +#extra options, e.g. for setting affinity on even CPUs : +EXTRA_OPTS=$(for a in $(seq 0 2 127); do echo -n "-a ${a} "; done) + +#ppc64 striding, use with NUM_CPUS=8 + +#stride 1 +#EXTRA_OPTS=$(for a in $(seq 0 2 15); do echo -n "-a ${a} "; done) +#stride 2 +#EXTRA_OPTS=$(for a in $(seq 0 4 31); do echo -n "-a ${a} "; done) +#stride 4 +#EXTRA_OPTS=$(for a in $(seq 0 8 63); do echo -n "-a ${a} "; done) +#stride 8 +#EXTRA_OPTS=$(for a in $(seq 0 16 127); do echo -n "-a ${a} "; done) + +#Vary update fraction +#x: vary update fraction from 0 to 0.0001 + #fix number of readers and reader C.S. length, vary delay between updates +#y: ops/s + +rm -f runall.log +rm -fr runall.detail.log + +#setting gc each 32768. ** UPDATE FOR YOUR ARCHITECTURE BASED ON PHASE 1 RESULT ** +EXTRA_OPTS="${EXTRA_OPTS} -b 32768" + +#Test scalability : +# x: vary number of readers from 0 to num cpus +# y: ops/s +# 0 writer. + +echo Executing scalability test + +NR_WRITERS=0 +DURATION=10 + +rm -f scalability.log + +for NR_READERS in $(seq 1 ${NUM_CPUS}); do + echo "./runtests.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} ${EXTRA_OPTS}| tee -a scalability.log" >> runall.log + ./runtests.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} ${EXTRA_OPTS}| tee -a scalability.log +done + + diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase4.sh b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase4.sh new file mode 100755 index 0000000000000..4edddc469152b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase4.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +# SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +# +# SPDX-License-Identifier: GPL-2.0-only + +#run all tests + +#set to number of active CPUS +export NUM_CPUS=8 + +#extra options, e.g. for setting affinity on even CPUs : +#EXTRA_OPTS=$(for a in $(seq 0 2 127); do echo -n "-a ${a} "; done) + +#ppc64 striding, use with NUM_CPUS=8 + +rm -f *.log + +#stride 1 +export EXTRA_OPTS=$(for a in $(seq 0 2 15); do echo -n "-a ${a} "; done) +sh subphase4.sh $* +mkdir ppc64-8cores-stride1 +mv *.log ppc64-8cores-stride1/ + + +#stride 2 +export EXTRA_OPTS=$(for a in $(seq 0 4 31); do echo -n "-a ${a} "; done) +sh subphase4.sh $* +mkdir ppc64-8cores-stride2 +mv *.log ppc64-8cores-stride2/ + + +#stride 4 +export EXTRA_OPTS=$(for a in $(seq 0 8 63); do echo -n "-a ${a} "; done) +sh subphase4.sh $* +mkdir ppc64-8cores-stride4 +mv *.log ppc64-8cores-stride4/ + + +#stride 8 +export EXTRA_OPTS=$(for a in $(seq 0 16 127); do echo -n "-a ${a} "; done) +sh subphase4.sh $* +mkdir ppc64-8cores-stride8 +mv *.log ppc64-8cores-stride8/ diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase5.sh b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase5.sh new file mode 100755 index 0000000000000..5d462ec543068 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase5.sh @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +# +# SPDX-License-Identifier: GPL-2.0-only + +# test run after write-size update + +sh runpaul-phase1.sh +mkdir runpaul-phase1 +mv *.log runpaul-phase1/ + +sh runpaul-phase2.sh +mkdir runpaul-phase2 +mv *.log runpaul-phase2/ + +sh runpaul-phase4.sh diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase6.sh b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase6.sh new file mode 100755 index 0000000000000..647749b3db8a6 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase6.sh @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +# +# SPDX-License-Identifier: GPL-2.0-only + +sh runpaul-phase1.sh +mkdir runpaul-phase1 +mv *.log runpaul-phase1/ + +sh runpaul-phase2.sh +mkdir runpaul-phase2 +mv *.log runpaul-phase2/ diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase7.sh b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase7.sh new file mode 100755 index 0000000000000..83afd50bc9b25 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runpaul-phase7.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +# SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +# +# SPDX-License-Identifier: GPL-2.0-only + +#run all tests + +#set to number of active CPUS +export NUM_CPUS=64 +#export NUM_CPUS=8 + +#extra options, e.g. for setting affinity on even CPUs : +EXTRA_OPTS=$(for a in $(seq 0 2 127); do echo -n "-a ${a} "; done) +#EXTRA_OPTS=$(for a in $(seq 0 1 7); do echo -n "-a ${a} "; done) + +rm -f *.log + +# x: Vary writer C.S. length from 0 to 100 us +# y: reads/s +# 4 readers +# 4 writers + +echo Executing writer C.S. length test + +NR_READERS=$((${NUM_CPUS} / 2)) +NR_WRITERS=$((${NUM_CPUS} / 2)) +DURATION=10 +WDELAY=10 +#in loops. +WRITERCSLEN_ARRAY="0 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152" + +rm -f writercslen.log + +for WRITERCSLEN in ${WRITERCSLEN_ARRAY}; do + echo "./runtests.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} ${EXTRA_OPTS} -d ${WDELAY} -e ${WRITERCSLEN} | tee -a writercslen.log" >> runall.log + ./runtests.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} ${EXTRA_OPTS} -d ${WDELAY} -e ${WRITERCSLEN} | tee -a writercslen.log +done + + + +mkdir ppc64-writercslen +mv *.log ppc64-writercslen/ +#mkdir xeon-writercslen +#mv *.log xeon-writercslen/ diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/runtests-batch.sh b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runtests-batch.sh new file mode 100755 index 0000000000000..93af6d4596d05 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runtests-batch.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# Enable TAP +SH_TAP=1 + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +# Create a temporary file for tests output +TMPFILE=$(mktemp) + +# Set trap to delete the temporary file on exit and call tap.sh '_exit' +trap 'rm -f "$TMPFILE"; _exit' EXIT + + +NUM_TESTS=1 + +plan_tests ${NUM_TESTS} + +#for a in test_urcu_gc test_urcu_gc_mb test_urcu_qsbr_gc; do +for a in test_urcu_gc; do + okx "${URCU_TESTS_TIME_BIN}" "${URCU_TESTS_BUILDDIR}/benchmark/${a}" "$@" 2>"${TMPFILE}" + diag "time: $(cat "${TMPFILE}")" +done diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/runtests.sh b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runtests.sh new file mode 100755 index 0000000000000..761a5476b5c0f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/runtests.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# Enable TAP +SH_TAP=1 + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +# Create a temporary file for tests output +TMPFILE=$(mktemp) + +# Set trap to delete the temporary file on exit and call tap.sh '_exit' +trap 'rm -f "$TMPFILE"; _exit' EXIT + + +NUM_TESTS=12 + +plan_tests ${NUM_TESTS} + +for a in test_urcu_gc test_urcu_mb_gc test_urcu_qsbr_gc \ + test_urcu_lgc test_urcu_mb_lgc test_urcu_qsbr_lgc \ + test_urcu test_urcu_mb test_urcu_qsbr \ + test_rwlock test_perthreadlock test_mutex; do + okx ${URCU_TESTS_TIME_BIN} "$URCU_TESTS_BUILDDIR/benchmark/${a}" "$@" 2>"${TMPFILE}" + diag "time: $(cat "${TMPFILE}")" +done diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/subphase4.sh b/external/lgpl2/userspace-rcu/dist/tests/benchmark/subphase4.sh new file mode 100755 index 0000000000000..95f39e1542f5a --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/subphase4.sh @@ -0,0 +1,105 @@ +#!/bin/sh + +# SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +# +# SPDX-License-Identifier: GPL-2.0-only + +#run all tests + +#set to number of active CPUS +#NUM_CPUS=8 + +#extra options, e.g. for setting affinity on even CPUs : +#EXTRA_OPTS=$(for a in $(seq 0 2 127); do echo -n "-a ${a} "; done) + +#ppc64 striding, use with NUM_CPUS=8 + +#stride 1 +#EXTRA_OPTS=$(for a in $(seq 0 2 15); do echo -n "-a ${a} "; done) +#stride 2 +#EXTRA_OPTS=$(for a in $(seq 0 4 31); do echo -n "-a ${a} "; done) +#stride 4 +#EXTRA_OPTS=$(for a in $(seq 0 8 63); do echo -n "-a ${a} "; done) +#stride 8 +#EXTRA_OPTS=$(for a in $(seq 0 16 127); do echo -n "-a ${a} "; done) + +#Vary update fraction +#x: vary update fraction from 0 to 0.0001 + #fix number of readers and reader C.S. length, vary delay between updates +#y: ops/s + +rm -f runall.log +rm -fr runall.detail.log + + +echo Executing batch RCU test + +DURATION=10 +BATCH_ARRAY="1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 + 131072 262144" +NR_WRITERS=$((${NUM_CPUS} / 2)) + +rm -f batch-rcu.log + +NR_READERS=$((${NUM_CPUS} - ${NR_WRITERS})) +for BATCH_SIZE in ${BATCH_ARRAY}; do + echo "./runtests-batch.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} -d 0 -b ${BATCH_SIZE} ${EXTRA_OPTS} | tee -a batch-rcu.log" >> runall.log + ./runtests-batch.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} -d 0 -b ${BATCH_SIZE} ${EXTRA_OPTS} | tee -a batch-rcu.log +done + +#setting gc each 4096. ** UPDATE FOR YOUR ARCHITECTURE BASED ON TEST ABOVE ** +EXTRA_OPTS="${EXTRA_OPTS} -b 32768" + +echo Executing update fraction test + +DURATION=10 +WDELAY_ARRAY="0 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 + 65536 131072 262144 524288 1048576 2097152 4194304 8388608 + 16777216 33554432 67108864 134217728" +NR_WRITERS=$((${NUM_CPUS} / 2)) + +rm -f update-fraction.log + +NR_READERS=$((${NUM_CPUS} - ${NR_WRITERS})) +for WDELAY in ${WDELAY_ARRAY}; do + echo "./runtests.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} -d ${WDELAY} ${EXTRA_OPTS} | tee -a update-fraction.log" >> runall.log + ./runtests.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} -d ${WDELAY} ${EXTRA_OPTS} | tee -a update-fraction.log +done + +#Test scalability : +# x: vary number of readers from 0 to num cpus +# y: ops/s +# 0 writer. + +echo Executing scalability test + +NR_WRITERS=0 +DURATION=10 + +rm -f scalability.log + +for NR_READERS in $(seq 1 ${NUM_CPUS}); do + echo "./runtests.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} ${EXTRA_OPTS}| tee -a scalability.log" >> runall.log + ./runtests.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} ${EXTRA_OPTS}| tee -a scalability.log +done + + +# x: Vary reader C.S. length from 0 to 100 us +# y: ops/s +# 8 readers +# 0 writers + +echo Executing reader C.S. length test + +NR_READERS=${NUM_CPUS} +NR_WRITERS=0 +DURATION=10 +#in loops. +READERCSLEN_ARRAY="0 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152" + +rm -f readercslen.log + +for READERCSLEN in ${READERCSLEN_ARRAY}; do + echo "./runtests.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} ${EXTRA_OPTS} -c ${READERCSLEN} | tee -a readercslen.log" >> runall.log + ./runtests.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} ${EXTRA_OPTS} -c ${READERCSLEN} | tee -a readercslen.log +done diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_cycles_per_loop.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_cycles_per_loop.c new file mode 100644 index 0000000000000..7fec92cb8af50 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_cycles_per_loop.c @@ -0,0 +1,30 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test cycles per loop + */ + +#include +#include + +#define NR_LOOPS 1000000UL + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +int main() +{ + caa_cycles_t time1, time2; + + time1 = caa_get_cycles(); + loop_sleep(NR_LOOPS); + time2 = caa_get_cycles(); + printf("CPU clock cycles per loop: %g\n", (time2 - time1) / + (double)NR_LOOPS); + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_looplen.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_looplen.c new file mode 100644 index 0000000000000..b743828979f13 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_looplen.c @@ -0,0 +1,59 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test program + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#else +#define debug_yield_read() +#endif +#include + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +#define LOOPS 1048576 +#define TESTS 10 + +int main(void) +{ + unsigned long i; + caa_cycles_t time1, time2; + caa_cycles_t time_tot = 0; + double cpl; + + for (i = 0; i < TESTS; i++) { + time1 = caa_get_cycles(); + loop_sleep(LOOPS); + time2 = caa_get_cycles(); + time_tot += time2 - time1; + } + cpl = ((double)time_tot) / (double)TESTS / (double)LOOPS; + + printf("CALIBRATION : %g cycles per loop\n", cpl); + printf("time_tot = %llu, LOOPS = %d, TESTS = %d\n", + (unsigned long long) time_tot, LOOPS, TESTS); + + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_mutex.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_mutex.c new file mode 100644 index 0000000000000..6254e15c4cf0d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_mutex.c @@ -0,0 +1,325 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test program + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "thread-id.h" + +/* hardcoded number of CPUs */ +#define NR_CPUS 16384 + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif +#include + +struct test_array { + int a; +}; + +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; + +static unsigned long wdelay; + +static volatile struct test_array test_array = { 8 }; + +static unsigned long duration; + +/* read-side C.S. duration, in loops */ +static unsigned long rduration; + +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +static int verbose_mode; + +#define printf_verbose(fmt, args...) \ + do { \ + if (verbose_mode) \ + printf(fmt, args); \ + } while (0) + +static unsigned int cpu_affinities[NR_CPUS]; +static unsigned int next_aff = 0; +static int use_affinity = 0; + +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void set_affinity(void) +{ +#ifdef HAVE_SCHED_SETAFFINITY + cpu_set_t mask; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ + + if (!use_affinity) + return; + +#ifdef HAVE_SCHED_SETAFFINITY + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +#endif /* HAVE_SCHED_SETAFFINITY */ +} + +static DEFINE_URCU_TLS(unsigned long long, nr_writes); +static DEFINE_URCU_TLS(unsigned long long, nr_reads); + +static +unsigned long long __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *tot_nr_writes; +static +unsigned long long __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *tot_nr_reads; + +static unsigned int nr_readers; +static unsigned int nr_writers; + +pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER; + +static +void *thr_reader(void *data) +{ + unsigned long tidx = (unsigned long)data; + + printf_verbose("thread_begin %s, tid %lu\n", + "reader", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + for (;;) { + int v; + + pthread_mutex_lock(&lock); + v = test_array.a; + urcu_posix_assert(v == 8); + if (caa_unlikely(rduration)) + loop_sleep(rduration); + pthread_mutex_unlock(&lock); + URCU_TLS(nr_reads)++; + if (caa_unlikely(!test_duration_read())) + break; + } + + tot_nr_reads[tidx] = URCU_TLS(nr_reads); + printf_verbose("thread_end %s, tid %lu\n", + "reader", urcu_get_thread_id()); + return ((void*)1); + +} + +static +void *thr_writer(void *data) +{ + unsigned long wtidx = (unsigned long)data; + + printf_verbose("thread_begin %s, tid %lu\n", + "writer", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + for (;;) { + pthread_mutex_lock(&lock); + test_array.a = 0; + test_array.a = 8; + if (caa_unlikely(wduration)) + loop_sleep(wduration); + pthread_mutex_unlock(&lock); + URCU_TLS(nr_writes)++; + if (caa_unlikely(!test_duration_write())) + break; + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); + } + + printf_verbose("thread_end %s, tid %lu\n", + "writer", urcu_get_thread_id()); + tot_nr_writes[wtidx] = URCU_TLS(nr_writes); + return ((void*)2); +} + +static +void show_usage(char **argv) +{ + printf("Usage : %s nr_readers nr_writers duration (s) \n", + argv[0]); + printf("OPTIONS:\n"); + printf(" [-d delay] (writer period (us))\n"); + printf(" [-c duration] (reader C.S. duration (in loops))\n"); + printf(" [-e duration] (writer C.S. duration (in loops))\n"); + printf(" [-v] (verbose output)\n"); + printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); + printf("\n"); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_reader, *tid_writer; + void *tret; + unsigned long long *count_reader, *count_writer; + unsigned long long tot_reads = 0, tot_writes = 0; + int i, a; + unsigned int i_thr; + + if (argc < 4) { + show_usage(argv); + return -1; + } + cmm_smp_mb(); + + err = sscanf(argv[1], "%u", &nr_readers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[2], "%u", &nr_writers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[3], "%lu", &duration); + if (err != 1) { + show_usage(argv); + return -1; + } + + for (i = 4; i < argc; i++) { + if (argv[i][0] != '-') + continue; + switch (argv[i][1]) { + case 'a': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + a = atoi(argv[++i]); + cpu_affinities[next_aff++] = a; + use_affinity = 1; + printf_verbose("Adding CPU %d affinity\n", a); + break; + case 'c': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + rduration = atol(argv[++i]); + break; + case 'd': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wdelay = atol(argv[++i]); + break; + case 'e': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wduration = atol(argv[++i]); + break; + case 'v': + verbose_mode = 1; + break; + } + } + + printf_verbose("running test for %lu seconds, %u readers, %u writers.\n", + duration, nr_readers, nr_writers); + printf_verbose("Writer delay : %lu loops.\n", wdelay); + printf_verbose("Reader duration : %lu loops.\n", rduration); + printf_verbose("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + tid_reader = calloc(nr_readers, sizeof(*tid_reader)); + tid_writer = calloc(nr_writers, sizeof(*tid_writer)); + count_reader = calloc(nr_readers, sizeof(*count_reader)); + count_writer = calloc(nr_writers, sizeof(*count_writer)); + tot_nr_reads = calloc(nr_readers, sizeof(*tot_nr_reads)); + tot_nr_writes = calloc(nr_writers, sizeof(*tot_nr_writes)); + + next_aff = 0; + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_create(&tid_reader[i_thr], NULL, thr_reader, + (void *)(long)i_thr); + if (err != 0) + exit(1); + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_create(&tid_writer[i_thr], NULL, thr_writer, + (void *)(long)i_thr); + if (err != 0) + exit(1); + } + + test_for(duration); + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_join(tid_reader[i_thr], &tret); + if (err != 0) + exit(1); + tot_reads += tot_nr_reads[i_thr]; + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_join(tid_writer[i_thr], &tret); + if (err != 0) + exit(1); + tot_writes += tot_nr_writes[i_thr]; + } + + printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads, + tot_writes); + printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu " + "nr_writers %3u " + "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", + argv[0], duration, nr_readers, rduration, wduration, + nr_writers, wdelay, tot_reads, tot_writes, + tot_reads + tot_writes); + + free(tid_reader); + free(tid_writer); + free(count_reader); + free(count_writer); + free(tot_nr_reads); + free(tot_nr_writes); + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_perthreadlock.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_perthreadlock.c new file mode 100644 index 0000000000000..2cc50d1d13b29 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_perthreadlock.c @@ -0,0 +1,358 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test program + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "thread-id.h" + +/* hardcoded number of CPUs */ +#define NR_CPUS 16384 + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif +#include + +struct test_array { + int a; +}; + +struct per_thread_lock { + pthread_mutex_t lock; +} __attribute__((aligned(CAA_CACHE_LINE_SIZE))); /* cache-line aligned */ + +static struct per_thread_lock *per_thread_lock; + +static unsigned long wdelay; + +static volatile struct test_array test_array = { 8 }; + +static unsigned long duration; + +/* read-side C.S. duration, in loops */ +static unsigned long rduration; + +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +static int verbose_mode; + +#define printf_verbose(fmt, args...) \ + do { \ + if (verbose_mode) \ + printf(fmt, args); \ + } while (0) + +static unsigned int cpu_affinities[NR_CPUS]; +static unsigned int next_aff = 0; +static int use_affinity = 0; + +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void set_affinity(void) +{ +#ifdef HAVE_SCHED_SETAFFINITY + cpu_set_t mask; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ + + if (!use_affinity) + return; + +#ifdef HAVE_SCHED_SETAFFINITY + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + errno = ret; + perror("Error in pthread mutex lock"); + abort(); + } + cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + errno = ret; + perror("Error in pthread mutex unlock"); + abort(); + } + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +#endif /* HAVE_SCHED_SETAFFINITY */ +} + +static DEFINE_URCU_TLS(unsigned long long, nr_writes); +static DEFINE_URCU_TLS(unsigned long long, nr_reads); + +static +unsigned long long __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *tot_nr_writes; +static +unsigned long long __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *tot_nr_reads; + +static unsigned int nr_readers; +static unsigned int nr_writers; + +static void urcu_mutex_lock(pthread_mutex_t *lock) +{ + int ret; + + ret = pthread_mutex_lock(lock); + if (ret) { + errno = ret; + perror("Error in pthread mutex lock"); + abort(); + } +} + +static void urcu_mutex_unlock(pthread_mutex_t *lock) +{ + int ret; + + ret = pthread_mutex_unlock(lock); + if (ret) { + errno = ret; + perror("Error in pthread mutex unlock"); + abort(); + } +} + +static +void *thr_reader(void *data) +{ + unsigned long tidx = (unsigned long)data; + + printf_verbose("thread_begin %s, tid %lu\n", + "reader", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + for (;;) { + int v; + + urcu_mutex_lock(&per_thread_lock[tidx].lock); + v = test_array.a; + urcu_posix_assert(v == 8); + if (caa_unlikely(rduration)) + loop_sleep(rduration); + urcu_mutex_unlock(&per_thread_lock[tidx].lock); + URCU_TLS(nr_reads)++; + if (caa_unlikely(!test_duration_read())) + break; + } + + tot_nr_reads[tidx] = URCU_TLS(nr_reads); + printf_verbose("thread_end %s, tid %lu\n", + "reader", urcu_get_thread_id()); + return ((void*)1); + +} + +static +void *thr_writer(void *data) +{ + unsigned long wtidx = (unsigned long)data; + long tidx; + + printf_verbose("thread_begin %s, tid %lu\n", + "writer", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + for (;;) { + for (tidx = 0; tidx < (long)nr_readers; tidx++) { + urcu_mutex_lock(&per_thread_lock[tidx].lock); + } + test_array.a = 0; + test_array.a = 8; + if (caa_unlikely(wduration)) + loop_sleep(wduration); + for (tidx = (long)nr_readers - 1; tidx >= 0; tidx--) { + urcu_mutex_unlock(&per_thread_lock[tidx].lock); + } + URCU_TLS(nr_writes)++; + if (caa_unlikely(!test_duration_write())) + break; + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); + } + + printf_verbose("thread_end %s, tid %lu\n", + "writer", urcu_get_thread_id()); + tot_nr_writes[wtidx] = URCU_TLS(nr_writes); + return ((void*)2); +} + +static +void show_usage(char **argv) +{ + printf("Usage : %s nr_readers nr_writers duration (s) \n", + argv[0]); + printf("OPTIONS:\n"); + printf(" [-d delay] (writer period (us))\n"); + printf(" [-c duration] (reader C.S. duration (in loops))\n"); + printf(" [-e duration] (writer C.S. duration (in loops))\n"); + printf(" [-v] (verbose output)\n"); + printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); + printf("\n"); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_reader, *tid_writer; + void *tret; + unsigned long long tot_reads = 0, tot_writes = 0; + int i, a; + unsigned int i_thr; + + if (argc < 4) { + show_usage(argv); + return -1; + } + cmm_smp_mb(); + + err = sscanf(argv[1], "%u", &nr_readers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[2], "%u", &nr_writers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[3], "%lu", &duration); + if (err != 1) { + show_usage(argv); + return -1; + } + + for (i = 4; i < argc; i++) { + if (argv[i][0] != '-') + continue; + switch (argv[i][1]) { + case 'a': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + a = atoi(argv[++i]); + cpu_affinities[next_aff++] = a; + use_affinity = 1; + printf_verbose("Adding CPU %d affinity\n", a); + break; + case 'c': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + rduration = atol(argv[++i]); + break; + case 'd': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wdelay = atol(argv[++i]); + break; + case 'e': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wduration = atol(argv[++i]); + break; + case 'v': + verbose_mode = 1; + break; + } + } + + printf_verbose("running test for %lu seconds, %u readers, %u writers.\n", + duration, nr_readers, nr_writers); + printf_verbose("Writer delay : %lu loops.\n", wdelay); + printf_verbose("Reader duration : %lu loops.\n", rduration); + printf_verbose("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + tid_reader = calloc(nr_readers, sizeof(*tid_reader)); + tid_writer = calloc(nr_writers, sizeof(*tid_writer)); + tot_nr_reads = calloc(nr_readers, sizeof(*tot_nr_reads)); + tot_nr_writes = calloc(nr_writers, sizeof(*tot_nr_writes)); + per_thread_lock = calloc(nr_readers, sizeof(*per_thread_lock)); + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + pthread_mutex_init(&per_thread_lock[i_thr].lock, NULL); + } + + next_aff = 0; + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_create(&tid_reader[i_thr], NULL, thr_reader, + (void *)(long)i_thr); + if (err != 0) + exit(1); + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_create(&tid_writer[i_thr], NULL, thr_writer, + (void *)(long)i_thr); + if (err != 0) + exit(1); + } + + test_for(duration); + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_join(tid_reader[i_thr], &tret); + if (err != 0) + exit(1); + tot_reads += tot_nr_reads[i_thr]; + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_join(tid_writer[i_thr], &tret); + if (err != 0) + exit(1); + tot_writes += tot_nr_writes[i_thr]; + } + + printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads, + tot_writes); + printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu " + "nr_writers %3u " + "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", + argv[0], duration, nr_readers, rduration, wduration, + nr_writers, wdelay, tot_reads, tot_writes, + tot_reads + tot_writes); + + free(tid_reader); + free(tid_writer); + free(tot_nr_reads); + free(tot_nr_writes); + free(per_thread_lock); + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_perthreadlock_timing.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_perthreadlock_timing.c new file mode 100644 index 0000000000000..78222750302dd --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_perthreadlock_timing.c @@ -0,0 +1,204 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Per thread locks - test program + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "thread-id.h" + +#include + +struct test_array { + int a; +}; + +static struct test_array test_array = { 8 }; + +struct per_thread_lock { + pthread_mutex_t lock; +} __attribute__((aligned(CAA_CACHE_LINE_SIZE))); /* cache-line aligned */ + +static struct per_thread_lock *per_thread_lock; + +#define OUTER_READ_LOOP 200U +#define INNER_READ_LOOP 100000U +#define READ_LOOP ((unsigned long long)OUTER_READ_LOOP * INNER_READ_LOOP) + +#define OUTER_WRITE_LOOP 10U +#define INNER_WRITE_LOOP 200U +#define WRITE_LOOP ((unsigned long long)OUTER_WRITE_LOOP * INNER_WRITE_LOOP) + +static int num_read; +static int num_write; + +#define NR_READ num_read +#define NR_WRITE num_write + +static caa_cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *reader_time; +static caa_cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *writer_time; + +static +void *thr_reader(void *arg) +{ + caa_cycles_t time1, time2; + long tidx = (long)arg; + unsigned int i, j; + int ret; + + printf("thread_begin %s, tid %lu\n", + "reader", urcu_get_thread_id()); + sleep(2); + + time1 = caa_get_cycles(); + for (i = 0; i < OUTER_READ_LOOP; i++) { + for (j = 0; j < INNER_READ_LOOP; j++) { + ret = pthread_mutex_lock(&per_thread_lock[tidx].lock); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + urcu_posix_assert(test_array.a == 8); + ret = pthread_mutex_unlock(&per_thread_lock[tidx].lock); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + } + } + time2 = caa_get_cycles(); + + reader_time[tidx] = time2 - time1; + + sleep(2); + printf("thread_end %s, tid %lu\n", + "reader", urcu_get_thread_id()); + return ((void*)1); + +} + +static +void *thr_writer(void *arg) +{ + caa_cycles_t time1, time2; + unsigned int i, j; + long tidx; + int ret; + + printf("thread_begin %s, tid %lu\n", + "writer", urcu_get_thread_id()); + sleep(2); + + for (i = 0; i < OUTER_WRITE_LOOP; i++) { + for (j = 0; j < INNER_WRITE_LOOP; j++) { + time1 = caa_get_cycles(); + for (tidx = 0; tidx < NR_READ; tidx++) { + ret = pthread_mutex_lock(&per_thread_lock[tidx].lock); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + } + test_array.a = 8; + for (tidx = NR_READ - 1; tidx >= 0; tidx--) { + ret = pthread_mutex_unlock(&per_thread_lock[tidx].lock); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + } + time2 = caa_get_cycles(); + writer_time[(unsigned long)arg] += time2 - time1; + usleep(1); + } + } + + printf("thread_end %s, tid %lu\n", + "writer", urcu_get_thread_id()); + return ((void*)2); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_reader, *tid_writer; + void *tret; + int i; + caa_cycles_t tot_rtime = 0; + caa_cycles_t tot_wtime = 0; + + if (argc < 2) { + printf("Usage : %s nr_readers nr_writers\n", argv[0]); + exit(-1); + } + num_read = atoi(argv[1]); + num_write = atoi(argv[2]); + + reader_time = calloc(num_read, sizeof(*reader_time)); + writer_time = calloc(num_write, sizeof(*writer_time)); + tid_reader = calloc(num_read, sizeof(*tid_reader)); + tid_writer = calloc(num_write, sizeof(*tid_writer)); + + printf("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + per_thread_lock = malloc(sizeof(struct per_thread_lock) * NR_READ); + + for (i = 0; i < NR_READ; i++) { + pthread_mutex_init(&per_thread_lock[i].lock, NULL); + } + for (i = 0; i < NR_READ; i++) { + err = pthread_create(&tid_reader[i], NULL, thr_reader, + (void *)(long)i); + if (err != 0) + exit(1); + } + for (i = 0; i < NR_WRITE; i++) { + err = pthread_create(&tid_writer[i], NULL, thr_writer, + (void *)(long)i); + if (err != 0) + exit(1); + } + + sleep(10); + + for (i = 0; i < NR_READ; i++) { + err = pthread_join(tid_reader[i], &tret); + if (err != 0) + exit(1); + tot_rtime += reader_time[i]; + } + for (i = 0; i < NR_WRITE; i++) { + err = pthread_join(tid_writer[i], &tret); + if (err != 0) + exit(1); + tot_wtime += writer_time[i]; + } + printf("Time per read : %g cycles\n", + (double)tot_rtime / ((double)NR_READ * (double)READ_LOOP)); + printf("Time per write : %g cycles\n", + (double)tot_wtime / ((double)NR_WRITE * (double)WRITE_LOOP)); + free(per_thread_lock); + + free(reader_time); + free(writer_time); + free(tid_reader); + free(tid_writer); + + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_rwlock.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_rwlock.c new file mode 100644 index 0000000000000..b275f78a51deb --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_rwlock.c @@ -0,0 +1,358 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test program + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "thread-id.h" + +/* hardcoded number of CPUs */ +#define NR_CPUS 16384 + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif +#include + +struct test_array { + int a; +}; + +/* + * static rwlock initializer is broken on Cygwin. Use runtime + * initialization. + */ +pthread_rwlock_t lock; + +static unsigned long wdelay; + +static volatile struct test_array test_array = { 8 }; + +static unsigned long duration; + +/* read-side C.S. duration, in loops */ +static unsigned long rduration; + +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +static int verbose_mode; + +#define printf_verbose(fmt, args...) \ + do { \ + if (verbose_mode) \ + printf(fmt, args); \ + } while (0) + +static unsigned int cpu_affinities[NR_CPUS]; +static unsigned int next_aff = 0; +static int use_affinity = 0; + +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void set_affinity(void) +{ +#ifdef HAVE_SCHED_SETAFFINITY + cpu_set_t mask; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ + + if (!use_affinity) + return; + +#ifdef HAVE_SCHED_SETAFFINITY + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +#endif /* HAVE_SCHED_SETAFFINITY */ +} + +static DEFINE_URCU_TLS(unsigned long long, nr_writes); +static DEFINE_URCU_TLS(unsigned long long, nr_reads); + +static unsigned int nr_readers; +static unsigned int nr_writers; + +pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER; + +static +void *thr_reader(void *_count) +{ + unsigned long long *count = _count; + + printf_verbose("thread_begin %s, tid %lu\n", + "reader", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + for (;;) { + int a, ret; + + ret = pthread_rwlock_rdlock(&lock); + if (ret) { + fprintf(stderr, "reader pthread_rwlock_rdlock: %s\n", strerror(ret)); + abort(); + } + + a = test_array.a; + urcu_posix_assert(a == 8); + if (caa_unlikely(rduration)) + loop_sleep(rduration); + + ret = pthread_rwlock_unlock(&lock); + if (ret) { + fprintf(stderr, "reader pthread_rwlock_unlock: %s\n", strerror(ret)); + abort(); + } + + URCU_TLS(nr_reads)++; + if (caa_unlikely(!test_duration_read())) + break; + } + + *count = URCU_TLS(nr_reads); + + printf_verbose("thread_end %s, tid %lu, count %llu\n", + "reader", urcu_get_thread_id(), *count); + return ((void*)1); + +} + +static +void *thr_writer(void *_count) +{ + unsigned long long *count = _count; + + printf_verbose("thread_begin %s, tid %lu\n", + "writer", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + for (;;) { + int ret; + + ret = pthread_rwlock_wrlock(&lock); + if (ret) { + fprintf(stderr, "writer pthread_rwlock_wrlock: %s\n", strerror(ret)); + abort(); + } + + test_array.a = 0; + test_array.a = 8; + if (caa_unlikely(wduration)) + loop_sleep(wduration); + + ret = pthread_rwlock_unlock(&lock); + if (ret) { + fprintf(stderr, "writer pthread_rwlock_unlock: %s\n", strerror(ret)); + abort(); + } + + URCU_TLS(nr_writes)++; + if (caa_unlikely(!test_duration_write())) + break; + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); + } + *count = URCU_TLS(nr_writes); + + printf_verbose("thread_end %s, tid %lu, count %llu\n", + "writer", urcu_get_thread_id(), *count); + return ((void*)2); +} + +static +void show_usage(char **argv) +{ + printf("Usage : %s nr_readers nr_writers duration (s) \n", + argv[0]); + printf("OPTIONS:\n"); + printf(" [-d delay] (writer period (us))\n"); + printf(" [-c duration] (reader C.S. duration (in loops))\n"); + printf(" [-e duration] (writer C.S. duration (in loops))\n"); + printf(" [-v] (verbose output)\n"); + printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); + printf("\n"); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_reader, *tid_writer; + void *tret; + unsigned long long *count_reader, *count_writer; + unsigned long long tot_reads = 0, tot_writes = 0; + int i, a; + unsigned int i_thr; + + if (argc < 4) { + show_usage(argv); + return -1; + } + cmm_smp_mb(); + + err = sscanf(argv[1], "%u", &nr_readers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[2], "%u", &nr_writers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[3], "%lu", &duration); + if (err != 1) { + show_usage(argv); + return -1; + } + + for (i = 4; i < argc; i++) { + if (argv[i][0] != '-') + continue; + switch (argv[i][1]) { + case 'a': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + a = atoi(argv[++i]); + cpu_affinities[next_aff++] = a; + use_affinity = 1; + printf_verbose("Adding CPU %d affinity\n", a); + break; + case 'c': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + rduration = atol(argv[++i]); + break; + case 'd': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wdelay = atol(argv[++i]); + break; + case 'e': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wduration = atol(argv[++i]); + break; + case 'v': + verbose_mode = 1; + break; + } + } + + printf_verbose("running test for %lu seconds, %u readers, %u writers.\n", + duration, nr_readers, nr_writers); + printf_verbose("Writer delay : %lu loops.\n", wdelay); + printf_verbose("Writer duration : %lu loops.\n", wduration); + printf_verbose("Reader duration : %lu loops.\n", rduration); + printf_verbose("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + err = pthread_rwlock_init(&lock, NULL); + if (err != 0) { + fprintf(stderr, "pthread_rwlock_init: (%d) %s\n", err, strerror(err)); + exit(1); + } + + tid_reader = calloc(nr_readers, sizeof(*tid_reader)); + tid_writer = calloc(nr_writers, sizeof(*tid_writer)); + count_reader = calloc(nr_readers, sizeof(*count_reader)); + count_writer = calloc(nr_writers, sizeof(*count_writer)); + + next_aff = 0; + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_create(&tid_reader[i_thr], NULL, thr_reader, + &count_reader[i_thr]); + if (err != 0) + exit(1); + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_create(&tid_writer[i_thr], NULL, thr_writer, + &count_writer[i_thr]); + if (err != 0) + exit(1); + } + + test_for(duration); + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_join(tid_reader[i_thr], &tret); + if (err != 0) + exit(1); + tot_reads += count_reader[i_thr]; + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_join(tid_writer[i_thr], &tret); + if (err != 0) + exit(1); + tot_writes += count_writer[i_thr]; + } + + printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads, + tot_writes); + printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu " + "nr_writers %3u " + "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", + argv[0], duration, nr_readers, rduration, wduration, + nr_writers, wdelay, tot_reads, tot_writes, + tot_reads + tot_writes); + + err = pthread_rwlock_destroy(&lock); + if (err != 0) { + fprintf(stderr, "pthread_rwlock_destroy: (%d) %s\n", err, strerror(err)); + exit(1); + } + free(tid_reader); + free(tid_writer); + free(count_reader); + free(count_writer); + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_rwlock_timing.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_rwlock_timing.c new file mode 100644 index 0000000000000..2bae56ca275b6 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_rwlock_timing.c @@ -0,0 +1,208 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test program + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "thread-id.h" + +#include + +struct test_array { + int a; +}; + +/* + * static rwlock initializer is broken on Cygwin. Use runtime + * initialization. + */ +pthread_rwlock_t lock; + +static struct test_array test_array = { 8 }; + +#define OUTER_READ_LOOP 200U +#define INNER_READ_LOOP 100000U +#define READ_LOOP ((unsigned long long)OUTER_READ_LOOP * INNER_READ_LOOP) + +#define OUTER_WRITE_LOOP 10U +#define INNER_WRITE_LOOP 200U +#define WRITE_LOOP ((unsigned long long)OUTER_WRITE_LOOP * INNER_WRITE_LOOP) + +static int num_read; +static int num_write; + +#define NR_READ num_read +#define NR_WRITE num_write + +static caa_cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *reader_time; +static caa_cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *writer_time; + +static +void *thr_reader(void *arg) +{ + unsigned int i, j; + int ret; + caa_cycles_t time1, time2; + + printf("thread_begin %s, tid %lu\n", + "reader", urcu_get_thread_id()); + sleep(2); + + time1 = caa_get_cycles(); + for (i = 0; i < OUTER_READ_LOOP; i++) { + for (j = 0; j < INNER_READ_LOOP; j++) { + ret = pthread_rwlock_rdlock(&lock); + if (ret) { + fprintf(stderr, "reader pthread_rwlock_rdlock: %s\n", strerror(ret)); + abort(); + } + + urcu_posix_assert(test_array.a == 8); + + ret = pthread_rwlock_unlock(&lock); + if (ret) { + fprintf(stderr, "reader pthread_rwlock_unlock: %s\n", strerror(ret)); + abort(); + } + } + } + time2 = caa_get_cycles(); + + reader_time[(unsigned long)arg] = time2 - time1; + + sleep(2); + printf("thread_end %s, tid %lu\n", + "reader", urcu_get_thread_id()); + return ((void*)1); + +} + +static +void *thr_writer(void *arg) +{ + unsigned int i, j; + int ret; + caa_cycles_t time1, time2; + + printf("thread_begin %s, tid %lu\n", + "writer", urcu_get_thread_id()); + sleep(2); + + for (i = 0; i < OUTER_WRITE_LOOP; i++) { + for (j = 0; j < INNER_WRITE_LOOP; j++) { + time1 = caa_get_cycles(); + ret = pthread_rwlock_wrlock(&lock); + if (ret) { + fprintf(stderr, "writer pthread_rwlock_wrlock: %s\n", strerror(ret)); + abort(); + } + + test_array.a = 8; + + ret = pthread_rwlock_unlock(&lock); + if (ret) { + fprintf(stderr, "writer pthread_rwlock_unlock: %s\n", strerror(ret)); + abort(); + } + + time2 = caa_get_cycles(); + writer_time[(unsigned long)arg] += time2 - time1; + usleep(1); + } + } + + printf("thread_end %s, tid %lu\n", + "writer", urcu_get_thread_id()); + return ((void*)2); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_reader, *tid_writer; + void *tret; + int i; + caa_cycles_t tot_rtime = 0; + caa_cycles_t tot_wtime = 0; + + if (argc < 2) { + printf("Usage : %s nr_readers nr_writers\n", argv[0]); + exit(-1); + } + num_read = atoi(argv[1]); + num_write = atoi(argv[2]); + + err = pthread_rwlock_init(&lock, NULL); + if (err != 0) { + fprintf(stderr, "pthread_rwlock_init: (%d) %s\n", err, strerror(err)); + exit(1); + } + + reader_time = calloc(num_read, sizeof(*reader_time)); + writer_time = calloc(num_write, sizeof(*writer_time)); + tid_reader = calloc(num_read, sizeof(*tid_reader)); + tid_writer = calloc(num_write, sizeof(*tid_writer)); + + printf("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + for (i = 0; i < NR_READ; i++) { + err = pthread_create(&tid_reader[i], NULL, thr_reader, + (void *)(long)i); + if (err != 0) + exit(1); + } + for (i = 0; i < NR_WRITE; i++) { + err = pthread_create(&tid_writer[i], NULL, thr_writer, + (void *)(long)i); + if (err != 0) + exit(1); + } + + sleep(10); + + for (i = 0; i < NR_READ; i++) { + err = pthread_join(tid_reader[i], &tret); + if (err != 0) + exit(1); + tot_rtime += reader_time[i]; + } + for (i = 0; i < NR_WRITE; i++) { + err = pthread_join(tid_writer[i], &tret); + if (err != 0) + exit(1); + tot_wtime += writer_time[i]; + } + printf("Time per read : %g cycles\n", + (double)tot_rtime / ((double)NR_READ * (double)READ_LOOP)); + printf("Time per write : %g cycles\n", + (double)tot_wtime / ((double)NR_WRITE * (double)WRITE_LOOP)); + + err = pthread_rwlock_destroy(&lock); + if (err != 0) { + fprintf(stderr, "pthread_rwlock_destroy: (%d) %s\n", err, strerror(err)); + exit(1); + } + free(reader_time); + free(writer_time); + free(tid_reader); + free(tid_writer); + + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu.c new file mode 100644 index 0000000000000..053993ae94034 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu.c @@ -0,0 +1,334 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test program + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "thread-id.h" +#include <../common/debug-yield.h> + +/* hardcoded number of CPUs */ +#define NR_CPUS 16384 + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif +#include + +static unsigned long wdelay; + +static int *test_rcu_pointer; + +static unsigned long duration; + +/* read-side C.S. duration, in loops */ +static unsigned long rduration; + +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +static int verbose_mode; + +#define printf_verbose(fmt, args...) \ + do { \ + if (verbose_mode) \ + printf(fmt, args); \ + } while (0) + +static unsigned int cpu_affinities[NR_CPUS]; +static unsigned int next_aff = 0; +static int use_affinity = 0; + +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void set_affinity(void) +{ +#ifdef HAVE_SCHED_SETAFFINITY + cpu_set_t mask; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ + + if (!use_affinity) + return; + +#ifdef HAVE_SCHED_SETAFFINITY + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +#endif /* HAVE_SCHED_SETAFFINITY */ +} + +static DEFINE_URCU_TLS(unsigned long long, nr_writes); +static DEFINE_URCU_TLS(unsigned long long, nr_reads); + +static unsigned int nr_readers; +static unsigned int nr_writers; + +pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER; + +static +void *thr_reader(void *_count) +{ + unsigned long long *count = _count; + int *local_ptr; + + printf_verbose("thread_begin %s, tid %lu\n", + "reader", urcu_get_thread_id()); + + set_affinity(); + + rcu_register_thread(); + urcu_posix_assert(!rcu_read_ongoing()); + + wait_until_go(); + + for (;;) { + rcu_read_lock(); + urcu_posix_assert(rcu_read_ongoing()); + local_ptr = rcu_dereference(test_rcu_pointer); + rcu_debug_yield_read(); + if (local_ptr) + urcu_posix_assert(*local_ptr == 8); + if (caa_unlikely(rduration)) + loop_sleep(rduration); + rcu_read_unlock(); + URCU_TLS(nr_reads)++; + if (caa_unlikely(!test_duration_read())) + break; + } + + rcu_unregister_thread(); + + /* test extra thread registration */ + rcu_register_thread(); + rcu_unregister_thread(); + + *count = URCU_TLS(nr_reads); + printf_verbose("thread_end %s, tid %lu\n", + "reader", urcu_get_thread_id()); + return ((void*)1); + +} + +static +void *thr_writer(void *_count) +{ + unsigned long long *count = _count; + int *new, *old; + + printf_verbose("thread_begin %s, tid %lu\n", + "writer", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + for (;;) { + new = malloc(sizeof(int)); + urcu_posix_assert(new); + *new = 8; + old = rcu_xchg_pointer(&test_rcu_pointer, new); + if (caa_unlikely(wduration)) + loop_sleep(wduration); + synchronize_rcu(); + if (old) + *old = 0; + free(old); + URCU_TLS(nr_writes)++; + if (caa_unlikely(!test_duration_write())) + break; + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); + } + + printf_verbose("thread_end %s, tid %lu\n", + "writer", urcu_get_thread_id()); + *count = URCU_TLS(nr_writes); + return ((void*)2); +} + +static +void show_usage(char **argv) +{ + printf("Usage : %s nr_readers nr_writers duration (s) \n", + argv[0]); + printf("OPTIONS:\n"); + printf(" [-r] [-w] (yield reader and/or writer)\n"); + printf(" [-d delay] (writer period (us))\n"); + printf(" [-c duration] (reader C.S. duration (in loops))\n"); + printf(" [-e duration] (writer C.S. duration (in loops))\n"); + printf(" [-v] (verbose output)\n"); + printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); + printf("\n"); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_reader, *tid_writer; + void *tret; + unsigned long long *count_reader, *count_writer; + unsigned long long tot_reads = 0, tot_writes = 0; + int i, a; + unsigned int i_thr; + + if (argc < 4) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[1], "%u", &nr_readers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[2], "%u", &nr_writers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[3], "%lu", &duration); + if (err != 1) { + show_usage(argv); + return -1; + } + + for (i = 4; i < argc; i++) { + if (argv[i][0] != '-') + continue; + switch (argv[i][1]) { + case 'r': + rcu_debug_yield_enable(RCU_YIELD_READ); + break; + case 'w': + rcu_debug_yield_enable(RCU_YIELD_WRITE); + break; + case 'a': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + a = atoi(argv[++i]); + cpu_affinities[next_aff++] = a; + use_affinity = 1; + printf_verbose("Adding CPU %d affinity\n", a); + break; + case 'c': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + rduration = atol(argv[++i]); + break; + case 'd': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wdelay = atol(argv[++i]); + break; + case 'e': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wduration = atol(argv[++i]); + break; + case 'v': + verbose_mode = 1; + break; + } + } + + printf_verbose("running test for %lu seconds, %u readers, %u writers.\n", + duration, nr_readers, nr_writers); + printf_verbose("Writer delay : %lu loops.\n", wdelay); + printf_verbose("Reader duration : %lu loops.\n", rduration); + printf_verbose("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + tid_reader = calloc(nr_readers, sizeof(*tid_reader)); + tid_writer = calloc(nr_writers, sizeof(*tid_writer)); + count_reader = calloc(nr_readers, sizeof(*count_reader)); + count_writer = calloc(nr_writers, sizeof(*count_writer)); + + next_aff = 0; + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_create(&tid_reader[i_thr], NULL, thr_reader, + &count_reader[i_thr]); + if (err != 0) + exit(1); + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_create(&tid_writer[i_thr], NULL, thr_writer, + &count_writer[i_thr]); + if (err != 0) + exit(1); + } + + test_for(duration); + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_join(tid_reader[i_thr], &tret); + if (err != 0) + exit(1); + tot_reads += count_reader[i_thr]; + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_join(tid_writer[i_thr], &tret); + if (err != 0) + exit(1); + tot_writes += count_writer[i_thr]; + } + + printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads, + tot_writes); + printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu " + "nr_writers %3u " + "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", + argv[0], duration, nr_readers, rduration, wduration, + nr_writers, wdelay, tot_reads, tot_writes, + tot_reads + tot_writes); + free(test_rcu_pointer); + free(tid_reader); + free(tid_writer); + free(count_reader); + free(count_writer); + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_assign.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_assign.c new file mode 100644 index 0000000000000..d0272a7b2bf07 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_assign.c @@ -0,0 +1,394 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test program + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "thread-id.h" +#include "../common/debug-yield.h" + +/* hardcoded number of CPUs */ +#define NR_CPUS 16384 + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif +#include + +struct test_array { + int a; +}; + +static unsigned long wdelay; + +static struct test_array *test_rcu_pointer; + +static unsigned long duration; + +/* read-side C.S. duration, in loops */ +static unsigned long rduration; + +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +static int verbose_mode; + +#define printf_verbose(fmt, args...) \ + do { \ + if (verbose_mode) \ + printf(fmt, args); \ + } while (0) + +static unsigned int cpu_affinities[NR_CPUS]; +static unsigned int next_aff = 0; +static int use_affinity = 0; + +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void set_affinity(void) +{ +#ifdef HAVE_SCHED_SETAFFINITY + cpu_set_t mask; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ + + if (!use_affinity) + return; + +#ifdef HAVE_SCHED_SETAFFINITY + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +#endif /* HAVE_SCHED_SETAFFINITY */ +} + +static DEFINE_URCU_TLS(unsigned long long, nr_writes); +static DEFINE_URCU_TLS(unsigned long long, nr_reads); + +static unsigned int nr_readers; +static unsigned int nr_writers; + +pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER; + +static +void rcu_copy_mutex_lock(void) +{ + int ret; + ret = pthread_mutex_lock(&rcu_copy_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } +} + +static +void rcu_copy_mutex_unlock(void) +{ + int ret; + + ret = pthread_mutex_unlock(&rcu_copy_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } +} + +/* + * malloc/free are reusing memory areas too quickly, which does not let us + * test races appropriately. Use a large circular array for allocations. + * ARRAY_SIZE is larger than nr_writers, and we keep the mutex across + * both alloc and free, which insures we never run over our tail. + */ +#define ARRAY_SIZE (1048576 * nr_writers) +#define ARRAY_POISON (int) 0xDEADBEEF +static unsigned int array_index; +static struct test_array *test_array; + +static struct test_array *test_array_alloc(void) +{ + struct test_array *ret; + int index; + + index = array_index % ARRAY_SIZE; + urcu_posix_assert(test_array[index].a == ARRAY_POISON || + test_array[index].a == 0); + ret = &test_array[index]; + array_index++; + if (array_index == ARRAY_SIZE) + array_index = 0; + return ret; +} + +static void test_array_free(struct test_array *ptr) +{ + if (!ptr) + return; + ptr->a = ARRAY_POISON; +} + +static +void *thr_reader(void *_count) +{ + unsigned long long *count = _count; + struct test_array *local_ptr; + + printf_verbose("thread_begin %s, tid %lu\n", + "reader", urcu_get_thread_id()); + + set_affinity(); + + rcu_register_thread(); + + wait_until_go(); + + for (;;) { + rcu_read_lock(); + local_ptr = rcu_dereference(test_rcu_pointer); + rcu_debug_yield_read(); + if (local_ptr) + urcu_posix_assert(local_ptr->a == 8); + if (caa_unlikely(rduration)) + loop_sleep(rduration); + rcu_read_unlock(); + URCU_TLS(nr_reads)++; + if (caa_unlikely(!test_duration_read())) + break; + } + + rcu_unregister_thread(); + + *count = URCU_TLS(nr_reads); + printf_verbose("thread_end %s, tid %lu\n", + "reader", urcu_get_thread_id()); + return ((void*)1); + +} + +static +void *thr_writer(void *_count) +{ + unsigned long long *count = _count; + struct test_array *new, *old; + + printf_verbose("thread_begin %s, tid %lu\n", + "writer", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + for (;;) { + rcu_copy_mutex_lock(); + new = test_array_alloc(); + new->a = 8; + old = test_rcu_pointer; + rcu_assign_pointer(test_rcu_pointer, new); + if (caa_unlikely(wduration)) + loop_sleep(wduration); + synchronize_rcu(); + if (old) + old->a = 0; + test_array_free(old); + rcu_copy_mutex_unlock(); + URCU_TLS(nr_writes)++; + if (caa_unlikely(!test_duration_write())) + break; + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); + } + + printf_verbose("thread_end %s, tid %lu\n", + "writer", urcu_get_thread_id()); + *count = URCU_TLS(nr_writes); + return ((void*)2); +} + +static +void show_usage(char **argv) +{ + printf("Usage : %s nr_readers nr_writers duration (s) \n", + argv[0]); + printf("OPTIONS:\n"); + printf(" [-r] [-w] (yield reader and/or writer)\n"); + printf(" [-d delay] (writer period (us))\n"); + printf(" [-c duration] (reader C.S. duration (in loops))\n"); + printf(" [-e duration] (writer C.S. duration (in loops))\n"); + printf(" [-v] (verbose output)\n"); + printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); + printf("\n"); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_reader, *tid_writer; + void *tret; + unsigned long long *count_reader, *count_writer; + unsigned long long tot_reads = 0, tot_writes = 0; + int i, a; + unsigned int i_thr; + + if (argc < 4) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[1], "%u", &nr_readers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[2], "%u", &nr_writers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[3], "%lu", &duration); + if (err != 1) { + show_usage(argv); + return -1; + } + + for (i = 4; i < argc; i++) { + if (argv[i][0] != '-') + continue; + switch (argv[i][1]) { + case 'r': + rcu_debug_yield_enable(RCU_YIELD_READ); + break; + case 'w': + rcu_debug_yield_enable(RCU_YIELD_WRITE); + break; + case 'a': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + a = atoi(argv[++i]); + cpu_affinities[next_aff++] = a; + use_affinity = 1; + printf_verbose("Adding CPU %d affinity\n", a); + break; + case 'c': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + rduration = atol(argv[++i]); + break; + case 'd': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wdelay = atol(argv[++i]); + break; + case 'e': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wduration = atol(argv[++i]); + break; + case 'v': + verbose_mode = 1; + break; + } + } + + printf_verbose("running test for %lu seconds, %u readers, %u writers.\n", + duration, nr_readers, nr_writers); + printf_verbose("Writer delay : %lu loops.\n", wdelay); + printf_verbose("Reader duration : %lu loops.\n", rduration); + printf_verbose("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + test_array = calloc(1, sizeof(*test_array) * ARRAY_SIZE); + tid_reader = calloc(nr_readers, sizeof(*tid_reader)); + tid_writer = calloc(nr_writers, sizeof(*tid_writer)); + count_reader = calloc(nr_readers, sizeof(*count_reader)); + count_writer = calloc(nr_writers, sizeof(*count_writer)); + + next_aff = 0; + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_create(&tid_reader[i_thr], NULL, thr_reader, + &count_reader[i_thr]); + if (err != 0) + exit(1); + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_create(&tid_writer[i_thr], NULL, thr_writer, + &count_writer[i_thr]); + if (err != 0) + exit(1); + } + + test_for(duration); + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_join(tid_reader[i_thr], &tret); + if (err != 0) + exit(1); + tot_reads += count_reader[i_thr]; + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_join(tid_writer[i_thr], &tret); + if (err != 0) + exit(1); + tot_writes += count_writer[i_thr]; + } + + printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads, + tot_writes); + printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu " + "nr_writers %3u " + "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", + argv[0], duration, nr_readers, rduration, wduration, + nr_writers, wdelay, tot_reads, tot_writes, + tot_reads + tot_writes); + + test_array_free(test_rcu_pointer); + free(test_array); + free(tid_reader); + free(tid_writer); + free(count_reader); + free(count_writer); + + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_bp.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_bp.c new file mode 100644 index 0000000000000..5da71320db369 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_bp.c @@ -0,0 +1,331 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test program + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "thread-id.h" +#include "../common/debug-yield.h" + +/* hardcoded number of CPUs */ +#define NR_CPUS 16384 + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif +#include + +static unsigned long wdelay; + +static int *test_rcu_pointer; + +static unsigned long duration; + +/* read-side C.S. duration, in loops */ +static unsigned long rduration; + +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +static int verbose_mode; + +#define printf_verbose(fmt, args...) \ + do { \ + if (verbose_mode) \ + printf(fmt, args); \ + } while (0) + +static unsigned int cpu_affinities[NR_CPUS]; +static unsigned int next_aff = 0; +static int use_affinity = 0; + +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void set_affinity(void) +{ +#ifdef HAVE_SCHED_SETAFFINITY + cpu_set_t mask; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ + + if (!use_affinity) + return; + +#ifdef HAVE_SCHED_SETAFFINITY + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +#endif /* HAVE_SCHED_SETAFFINITY */ +} + +static DEFINE_URCU_TLS(unsigned long long, nr_writes); +static DEFINE_URCU_TLS(unsigned long long, nr_reads); + +static unsigned int nr_readers; +static unsigned int nr_writers; + +pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER; + +static +void *thr_reader(void *_count) +{ + unsigned long long *count = _count; + int *local_ptr; + + printf_verbose("thread_begin %s, tid %lu\n", + "reader", urcu_get_thread_id()); + + set_affinity(); + + rcu_register_thread(); + urcu_posix_assert(!rcu_read_ongoing()); + + wait_until_go(); + + for (;;) { + rcu_read_lock(); + urcu_posix_assert(rcu_read_ongoing()); + local_ptr = rcu_dereference(test_rcu_pointer); + rcu_debug_yield_read(); + if (local_ptr) + urcu_posix_assert(*local_ptr == 8); + if (caa_unlikely(rduration)) + loop_sleep(rduration); + rcu_read_unlock(); + URCU_TLS(nr_reads)++; + if (caa_unlikely(!test_duration_read())) + break; + } + + rcu_unregister_thread(); + + *count = URCU_TLS(nr_reads); + printf_verbose("thread_end %s, tid %lu\n", + "reader", urcu_get_thread_id()); + return ((void*)1); + +} + +static +void *thr_writer(void *_count) +{ + unsigned long long *count = _count; + int *new, *old; + + printf_verbose("thread_begin %s, tid %lu\n", + "writer", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + for (;;) { + new = malloc(sizeof(int)); + *new = 8; + old = rcu_xchg_pointer(&test_rcu_pointer, new); + if (caa_unlikely(wduration)) + loop_sleep(wduration); + synchronize_rcu(); + if (old) + *old = 0; + free(old); + URCU_TLS(nr_writes)++; + if (caa_unlikely(!test_duration_write())) + break; + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); + } + + printf_verbose("thread_end %s, tid %lu\n", + "writer", urcu_get_thread_id()); + *count = URCU_TLS(nr_writes); + return ((void*)2); +} + +static +void show_usage(char **argv) +{ + printf("Usage : %s nr_readers nr_writers duration (s) \n", + argv[0]); + printf("OPTIONS:\n"); + printf(" [-r] [-w] (yield reader and/or writer)\n"); + printf(" [-d delay] (writer period (us))\n"); + printf(" [-c duration] (reader C.S. duration (in loops))\n"); + printf(" [-e duration] (writer C.S. duration (in loops))\n"); + printf(" [-v] (verbose output)\n"); + printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); + printf("\n"); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_reader, *tid_writer; + void *tret; + unsigned long long *count_reader, *count_writer; + unsigned long long tot_reads = 0, tot_writes = 0; + int i, a; + unsigned int i_thr; + + if (argc < 4) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[1], "%u", &nr_readers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[2], "%u", &nr_writers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[3], "%lu", &duration); + if (err != 1) { + show_usage(argv); + return -1; + } + + for (i = 4; i < argc; i++) { + if (argv[i][0] != '-') + continue; + switch (argv[i][1]) { + case 'r': + rcu_debug_yield_enable(RCU_YIELD_READ); + break; + case 'w': + rcu_debug_yield_enable(RCU_YIELD_WRITE); + break; + case 'a': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + a = atoi(argv[++i]); + cpu_affinities[next_aff++] = a; + use_affinity = 1; + printf_verbose("Adding CPU %d affinity\n", a); + break; + case 'c': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + rduration = atol(argv[++i]); + break; + case 'd': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wdelay = atol(argv[++i]); + break; + case 'e': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wduration = atol(argv[++i]); + break; + case 'v': + verbose_mode = 1; + break; + } + } + + printf_verbose("running test for %lu seconds, %u readers, %u writers.\n", + duration, nr_readers, nr_writers); + printf_verbose("Writer delay : %lu loops.\n", wdelay); + printf_verbose("Reader duration : %lu loops.\n", rduration); + printf_verbose("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + tid_reader = calloc(nr_readers, sizeof(*tid_reader)); + tid_writer = calloc(nr_writers, sizeof(*tid_writer)); + count_reader = calloc(nr_readers, sizeof(*count_reader)); + count_writer = calloc(nr_writers, sizeof(*count_writer)); + + next_aff = 0; + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_create(&tid_reader[i_thr], NULL, thr_reader, + &count_reader[i_thr]); + if (err != 0) + exit(1); + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_create(&tid_writer[i_thr], NULL, thr_writer, + &count_writer[i_thr]); + if (err != 0) + exit(1); + } + + test_for(duration); + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_join(tid_reader[i_thr], &tret); + if (err != 0) + exit(1); + tot_reads += count_reader[i_thr]; + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_join(tid_writer[i_thr], &tret); + if (err != 0) + exit(1); + tot_writes += count_writer[i_thr]; + } + + printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads, + tot_writes); + printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu " + "nr_writers %3u " + "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", + argv[0], duration, nr_readers, rduration, wduration, + nr_writers, wdelay, tot_reads, tot_writes, + tot_reads + tot_writes); + + free(test_rcu_pointer); + free(tid_reader); + free(tid_writer); + free(count_reader); + free(count_writer); + + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_defer.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_defer.c new file mode 100644 index 0000000000000..56ac28d419d2b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_defer.c @@ -0,0 +1,356 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test program (with automatic reclamation) + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "thread-id.h" +#include "../common/debug-yield.h" + +/* hardcoded number of CPUs */ +#define NR_CPUS 16384 + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif +#include +#include + +struct test_array { + int a; +}; + +static unsigned long wdelay; + +static struct test_array *test_rcu_pointer; + +static unsigned long duration; + +/* read-side C.S. duration, in loops */ +static unsigned long rduration; + +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +static int verbose_mode; + +#define printf_verbose(fmt, args...) \ + do { \ + if (verbose_mode) \ + printf(fmt, args); \ + } while (0) + +static unsigned int cpu_affinities[NR_CPUS]; +static unsigned int next_aff = 0; +static int use_affinity = 0; + +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void set_affinity(void) +{ +#ifdef HAVE_SCHED_SETAFFINITY + cpu_set_t mask; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ + + if (!use_affinity) + return; + +#ifdef HAVE_SCHED_SETAFFINITY + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +#endif /* HAVE_SCHED_SETAFFINITY */ +} + +static DEFINE_URCU_TLS(unsigned long long, nr_writes); +static DEFINE_URCU_TLS(unsigned long long, nr_reads); + +static +unsigned long long __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *tot_nr_writes; + +static unsigned int nr_readers; +static unsigned int nr_writers; + +pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER; + +static +void *thr_reader(void *_count) +{ + unsigned long long *count = _count; + struct test_array *local_ptr; + + printf_verbose("thread_begin %s, tid %lu\n", + "reader", urcu_get_thread_id()); + + set_affinity(); + + rcu_register_thread(); + + wait_until_go(); + + for (;;) { + rcu_read_lock(); + local_ptr = rcu_dereference(test_rcu_pointer); + rcu_debug_yield_read(); + if (local_ptr) + urcu_posix_assert(local_ptr->a == 8); + if (caa_unlikely(rduration)) + loop_sleep(rduration); + rcu_read_unlock(); + URCU_TLS(nr_reads)++; + if (caa_unlikely(!test_duration_read())) + break; + } + + rcu_unregister_thread(); + + *count = URCU_TLS(nr_reads); + printf_verbose("thread_end %s, tid %lu\n", + "reader", urcu_get_thread_id()); + return ((void*)1); + +} + +static void test_cb2(void *data __attribute__((unused))) +{ +} + +static void test_cb1(void *data __attribute__((unused))) +{ +} + +static +void *thr_writer(void *data) +{ + unsigned long wtidx = (unsigned long)data; + struct test_array *new, *old = NULL; + int ret; + + printf_verbose("thread_begin %s, tid %lu\n", + "writer", urcu_get_thread_id()); + + set_affinity(); + + ret = rcu_defer_register_thread(); + if (ret) { + printf("Error in rcu_defer_register_thread\n"); + exit(-1); + } + + wait_until_go(); + + for (;;) { + new = malloc(sizeof(*new)); + new->a = 8; + old = rcu_xchg_pointer(&test_rcu_pointer, new); + if (caa_unlikely(wduration)) + loop_sleep(wduration); + defer_rcu(free, old); + defer_rcu(test_cb1, old); + defer_rcu(test_cb1, (void *)-2L); + defer_rcu(test_cb1, (void *)-2L); + defer_rcu(test_cb1, old); + defer_rcu(test_cb2, (void *)-2L); + defer_rcu(test_cb2, (void *)-4L); + defer_rcu(test_cb2, (void *)-2L); + URCU_TLS(nr_writes)++; + if (caa_unlikely(!test_duration_write())) + break; + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); + } + + rcu_defer_unregister_thread(); + + printf_verbose("thread_end %s, tid %lu\n", + "writer", urcu_get_thread_id()); + tot_nr_writes[wtidx] = URCU_TLS(nr_writes); + return ((void*)2); +} + +static +void show_usage(char **argv) +{ + printf("Usage : %s nr_readers nr_writers duration (s) \n", + argv[0]); + printf("OPTIONS:\n"); + printf(" [-r] [-w] (yield reader and/or writer)\n"); + printf(" [-d delay] (writer period (us))\n"); + printf(" [-c duration] (reader C.S. duration (in loops))\n"); + printf(" [-e duration] (writer C.S. duration (in loops))\n"); + printf(" [-v] (verbose output)\n"); + printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); + printf("\n"); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_reader, *tid_writer; + void *tret; + unsigned long long *count_reader; + unsigned long long tot_reads = 0, tot_writes = 0; + int i, a; + unsigned int i_thr; + + if (argc < 4) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[1], "%u", &nr_readers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[2], "%u", &nr_writers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[3], "%lu", &duration); + if (err != 1) { + show_usage(argv); + return -1; + } + + for (i = 4; i < argc; i++) { + if (argv[i][0] != '-') + continue; + switch (argv[i][1]) { + case 'r': + rcu_debug_yield_enable(RCU_YIELD_READ); + break; + case 'w': + rcu_debug_yield_enable(RCU_YIELD_WRITE); + break; + case 'a': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + a = atoi(argv[++i]); + cpu_affinities[next_aff++] = a; + use_affinity = 1; + printf_verbose("Adding CPU %d affinity\n", a); + break; + case 'c': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + rduration = atol(argv[++i]); + break; + case 'd': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wdelay = atol(argv[++i]); + break; + case 'e': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wduration = atol(argv[++i]); + break; + case 'v': + verbose_mode = 1; + break; + } + } + + printf_verbose("running test for %lu seconds, %u readers, %u writers.\n", + duration, nr_readers, nr_writers); + printf_verbose("Writer delay : %lu loops.\n", wdelay); + printf_verbose("Reader duration : %lu loops.\n", rduration); + printf_verbose("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + tid_reader = calloc(nr_readers, sizeof(*tid_reader)); + tid_writer = calloc(nr_writers, sizeof(*tid_writer)); + count_reader = calloc(nr_readers, sizeof(*count_reader)); + tot_nr_writes = calloc(nr_writers, sizeof(*tot_nr_writes)); + + next_aff = 0; + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_create(&tid_reader[i_thr], NULL, thr_reader, + &count_reader[i_thr]); + if (err != 0) + exit(1); + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_create(&tid_writer[i_thr], NULL, thr_writer, + (void *)(long)i_thr); + if (err != 0) + exit(1); + } + + test_for(duration); + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_join(tid_reader[i_thr], &tret); + if (err != 0) + exit(1); + tot_reads += count_reader[i_thr]; + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_join(tid_writer[i_thr], &tret); + if (err != 0) + exit(1); + tot_writes += tot_nr_writes[i_thr]; + } + + printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads, + tot_writes); + printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu " + "nr_writers %3u " + "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", + argv[0], duration, nr_readers, rduration, wduration, + nr_writers, wdelay, tot_reads, tot_writes, + tot_reads + tot_writes); + free(tid_reader); + free(tid_writer); + free(count_reader); + free(tot_nr_writes); + + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_gc.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_gc.c new file mode 100644 index 0000000000000..d52a51df87278 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_gc.c @@ -0,0 +1,404 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test program (with batch reclamation) + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include "thread-id.h" +#include "../common/debug-yield.h" + +/* hardcoded number of CPUs */ +#define NR_CPUS 16384 + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif +#include + +struct test_array { + int a; +}; + +static unsigned long wdelay; + +static struct test_array *test_rcu_pointer; + +static long reclaim_batch = 1; + +struct reclaim_queue { + void **queue; /* Beginning of queue */ + void **head; /* Insert position */ +}; + +static struct reclaim_queue *pending_reclaims; + +static unsigned long duration; + +/* read-side C.S. duration, in loops */ +static unsigned long rduration; + +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +static int verbose_mode; + +#define printf_verbose(fmt, args...) \ + do { \ + if (verbose_mode) \ + printf(fmt, args); \ + } while (0) + +static unsigned int cpu_affinities[NR_CPUS]; +static unsigned int next_aff = 0; +static int use_affinity = 0; + +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void set_affinity(void) +{ +#ifdef HAVE_SCHED_SETAFFINITY + cpu_set_t mask; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ + + if (!use_affinity) + return; + +#ifdef HAVE_SCHED_SETAFFINITY + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +#endif /* HAVE_SCHED_SETAFFINITY */ +} + +static DEFINE_URCU_TLS(unsigned long long, nr_writes); +static DEFINE_URCU_TLS(unsigned long long, nr_reads); + +static +unsigned long long __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *tot_nr_writes; + +static unsigned int nr_readers; +static unsigned int nr_writers; + +pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER; + +static +void *thr_reader(void *_count) +{ + unsigned long long *count = _count; + struct test_array *local_ptr; + + printf_verbose("thread_begin %s, tid %lu\n", + "reader", urcu_get_thread_id()); + + set_affinity(); + + rcu_register_thread(); + + wait_until_go(); + + for (;;) { + rcu_read_lock(); + local_ptr = rcu_dereference(test_rcu_pointer); + rcu_debug_yield_read(); + if (local_ptr) + urcu_posix_assert(local_ptr->a == 8); + if (caa_unlikely(rduration)) + loop_sleep(rduration); + rcu_read_unlock(); + URCU_TLS(nr_reads)++; + if (caa_unlikely(!test_duration_read())) + break; + } + + rcu_unregister_thread(); + + *count = URCU_TLS(nr_reads); + printf_verbose("thread_end %s, tid %lu\n", + "reader", urcu_get_thread_id()); + return ((void*)1); + +} + +static void rcu_gc_clear_queue(unsigned long wtidx) +{ + void **p; + + /* Wait for Q.S and empty queue */ + synchronize_rcu(); + + for (p = pending_reclaims[wtidx].queue; + p < pending_reclaims[wtidx].head; p++) { + /* poison */ + if (*p) + ((struct test_array *)*p)->a = 0; + free(*p); + } + pending_reclaims[wtidx].head = pending_reclaims[wtidx].queue; +} + +/* Using per-thread queue */ +static void rcu_gc_reclaim(unsigned long wtidx, void *old) +{ + /* Queue pointer */ + *pending_reclaims[wtidx].head = old; + pending_reclaims[wtidx].head++; + + if (caa_likely(pending_reclaims[wtidx].head - pending_reclaims[wtidx].queue + < reclaim_batch)) + return; + + rcu_gc_clear_queue(wtidx); +} + +static +void *thr_writer(void *data) +{ + unsigned long wtidx = (unsigned long)data; +#ifdef TEST_LOCAL_GC + struct test_array *old = NULL; +#else + struct test_array *new, *old; +#endif + + printf_verbose("thread_begin %s, tid %lu\n", + "writer", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + for (;;) { +#ifndef TEST_LOCAL_GC + new = malloc(sizeof(*new)); + new->a = 8; + old = rcu_xchg_pointer(&test_rcu_pointer, new); +#endif + if (caa_unlikely(wduration)) + loop_sleep(wduration); + rcu_gc_reclaim(wtidx, old); + URCU_TLS(nr_writes)++; + if (caa_unlikely(!test_duration_write())) + break; + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); + } + + printf_verbose("thread_end %s, tid %lu\n", + "writer", urcu_get_thread_id()); + tot_nr_writes[wtidx] = URCU_TLS(nr_writes); + return ((void*)2); +} + +static +void show_usage(char **argv) +{ + printf("Usage : %s nr_readers nr_writers duration (s) \n", + argv[0]); + printf("OPTIONS:\n"); + printf(" [-r] [-w] (yield reader and/or writer)\n"); + printf(" [-d delay] (writer period (us))\n"); + printf(" [-c duration] (reader C.S. duration (in loops))\n"); + printf(" [-e duration] (writer C.S. duration (in loops))\n"); + printf(" [-v] (verbose output)\n"); + printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); + printf("\n"); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_reader, *tid_writer; + void *tret; + unsigned long long *count_reader; + unsigned long long tot_reads = 0, tot_writes = 0; + int i, a; + unsigned int i_thr; + + if (argc < 4) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[1], "%u", &nr_readers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[2], "%u", &nr_writers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[3], "%lu", &duration); + if (err != 1) { + show_usage(argv); + return -1; + } + + for (i = 4; i < argc; i++) { + if (argv[i][0] != '-') + continue; + switch (argv[i][1]) { + case 'r': + rcu_debug_yield_enable(RCU_YIELD_READ); + break; + case 'w': + rcu_debug_yield_enable(RCU_YIELD_WRITE); + break; + case 'a': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + a = atoi(argv[++i]); + cpu_affinities[next_aff++] = a; + use_affinity = 1; + printf_verbose("Adding CPU %d affinity\n", a); + break; + case 'b': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + reclaim_batch = atol(argv[++i]); + break; + case 'c': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + rduration = atol(argv[++i]); + break; + case 'd': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wdelay = atol(argv[++i]); + break; + case 'e': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wduration = atol(argv[++i]); + break; + case 'v': + verbose_mode = 1; + break; + } + } + + printf_verbose("running test for %lu seconds, %u readers, %u writers.\n", + duration, nr_readers, nr_writers); + printf_verbose("Writer delay : %lu loops.\n", wdelay); + printf_verbose("Reader duration : %lu loops.\n", rduration); + printf_verbose("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + tid_reader = calloc(nr_readers, sizeof(*tid_reader)); + tid_writer = calloc(nr_writers, sizeof(*tid_writer)); + count_reader = calloc(nr_readers, sizeof(*count_reader)); + tot_nr_writes = calloc(nr_writers, sizeof(*tot_nr_writes)); + pending_reclaims = calloc(nr_writers, sizeof(*pending_reclaims)); + + if (reclaim_batch * sizeof(*pending_reclaims[0].queue) + < CAA_CACHE_LINE_SIZE) + for (i_thr = 0; i_thr < nr_writers; i_thr++) + pending_reclaims[i_thr].queue = calloc(1, CAA_CACHE_LINE_SIZE); + else + for (i_thr = 0; i_thr < nr_writers; i_thr++) + pending_reclaims[i_thr].queue = calloc(reclaim_batch, + sizeof(*pending_reclaims[i_thr].queue)); + for (i_thr = 0; i_thr < nr_writers; i_thr++) + pending_reclaims[i_thr].head = pending_reclaims[i_thr].queue; + + next_aff = 0; + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_create(&tid_reader[i_thr], NULL, thr_reader, + &count_reader[i_thr]); + if (err != 0) + exit(1); + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_create(&tid_writer[i_thr], NULL, thr_writer, + (void *)(long)i_thr); + if (err != 0) + exit(1); + } + + test_for(duration); + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_join(tid_reader[i_thr], &tret); + if (err != 0) + exit(1); + tot_reads += count_reader[i_thr]; + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_join(tid_writer[i_thr], &tret); + if (err != 0) + exit(1); + tot_writes += tot_nr_writes[i_thr]; + rcu_gc_clear_queue(i_thr); + } + + printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads, + tot_writes); + printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu " + "nr_writers %3u " + "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu " + "batch %ld\n", + argv[0], duration, nr_readers, rduration, wduration, + nr_writers, wdelay, tot_reads, tot_writes, + tot_reads + tot_writes, reclaim_batch); + + free(tid_reader); + free(tid_writer); + free(count_reader); + free(tot_nr_writes); + + for (i_thr = 0; i_thr < nr_writers; i_thr++) + free(pending_reclaims[i_thr].queue); + free(pending_reclaims); + + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_hash.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_hash.c new file mode 100644 index 0000000000000..606851baf37ee --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_hash.c @@ -0,0 +1,757 @@ +// SPDX-FileCopyrightText: 2009-2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test program + */ + +#include "test_urcu_hash.h" + +enum test_hash { + TEST_HASH_RW, + TEST_HASH_UNIQUE, +}; + +struct test_hash_cb { + void (*sigusr1)(int signo); + void (*sigusr2)(int signo); + void *(*thr_reader)(void *_count); + void *(*thr_writer)(void *_count); + int (*populate_hash)(void); +}; + +static +struct test_hash_cb test_hash_cb[] = { + [TEST_HASH_RW] = { + test_hash_rw_sigusr1_handler, + test_hash_rw_sigusr2_handler, + test_hash_rw_thr_reader, + test_hash_rw_thr_writer, + test_hash_rw_populate_hash, + }, + [TEST_HASH_UNIQUE] = { + test_hash_unique_sigusr1_handler, + test_hash_unique_sigusr2_handler, + test_hash_unique_thr_reader, + test_hash_unique_thr_writer, + test_hash_unique_populate_hash, + }, + +}; + +static enum test_hash test_choice = TEST_HASH_RW; + +static +void (*get_sigusr1_cb(void))(int) +{ + return test_hash_cb[test_choice].sigusr1; +} + +static +void (*get_sigusr2_cb(void))(int) +{ + return test_hash_cb[test_choice].sigusr2; +} + +static +void *(*get_thr_reader_cb(void))(void *) +{ + return test_hash_cb[test_choice].thr_reader; +} + +static +void *(*get_thr_writer_cb(void))(void *) +{ + return test_hash_cb[test_choice].thr_writer; +} + +static +int (*get_populate_hash_cb(void))(void) +{ + return test_hash_cb[test_choice].populate_hash; +} + +DEFINE_URCU_TLS(unsigned int, rand_lookup); +DEFINE_URCU_TLS(unsigned long, nr_add); +DEFINE_URCU_TLS(unsigned long, nr_addexist); +DEFINE_URCU_TLS(unsigned long, nr_del); +DEFINE_URCU_TLS(unsigned long, nr_delnoent); +DEFINE_URCU_TLS(unsigned long, lookup_fail); +DEFINE_URCU_TLS(unsigned long, lookup_ok); + +struct cds_lfht *test_ht; + +unsigned long wdelay; + +unsigned long duration; + +/* read-side C.S. duration, in loops */ +unsigned long rduration; + +unsigned long init_hash_size = DEFAULT_HASH_SIZE; +unsigned long min_hash_alloc_size = DEFAULT_MIN_ALLOC_SIZE; +unsigned long max_hash_buckets_size = (1UL << 20); +unsigned long init_populate; +int opt_auto_resize; +int add_only, add_unique, add_replace; +const struct cds_lfht_mm_type *memory_backend; + +unsigned long init_pool_offset, lookup_pool_offset, write_pool_offset; +unsigned long init_pool_size = DEFAULT_RAND_POOL, + lookup_pool_size = DEFAULT_RAND_POOL, + write_pool_size = DEFAULT_RAND_POOL; +int validate_lookup; +unsigned long nr_hash_chains; /* 0: normal table, other: number of hash chains */ + +int count_pipe[2]; + +int verbose_mode; + +unsigned int cpu_affinities[NR_CPUS]; +unsigned int next_aff = 0; +int use_affinity = 0; + +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + +DEFINE_URCU_TLS(unsigned long long, nr_writes); +DEFINE_URCU_TLS(unsigned long long, nr_reads); + +unsigned int nr_readers; +unsigned int nr_writers; + +static pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER; + +void set_affinity(void) +{ +#ifdef HAVE_SCHED_SETAFFINITY + cpu_set_t mask; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ + + if (!use_affinity) + return; + +#ifdef HAVE_SCHED_SETAFFINITY + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +#endif /* HAVE_SCHED_SETAFFINITY */ +} + +void rcu_copy_mutex_lock(void) +{ + int ret; + ret = pthread_mutex_lock(&rcu_copy_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } +} + +void rcu_copy_mutex_unlock(void) +{ + int ret; + + ret = pthread_mutex_unlock(&rcu_copy_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } +} + +unsigned long test_compare(const void *key1, size_t key1_len, + const void *key2, size_t key2_len) +{ + if (caa_unlikely(key1_len != key2_len)) + return -1; + urcu_posix_assert(key1_len == sizeof(unsigned long)); + if (key1 == key2) + return 0; + else + return 1; +} + +static +void *thr_count(void *arg __attribute__((unused))) +{ + printf_verbose("thread_begin %s, tid %lu\n", + "counter", urcu_get_thread_id()); + + rcu_register_thread(); + + for (;;) { + unsigned long count; + long approx_before, approx_after; + ssize_t len; + char buf[1]; + + rcu_thread_offline(); + len = read(count_pipe[0], buf, 1); + rcu_thread_online(); + if (caa_unlikely(!test_duration_read())) + break; + if (len != 1) + continue; + /* Accounting */ + printf("Counting nodes... "); + fflush(stdout); + rcu_read_lock(); + cds_lfht_count_nodes(test_ht, &approx_before, &count, + &approx_after); + rcu_read_unlock(); + printf("done.\n"); + printf("Approximation before node accounting: %ld nodes.\n", + approx_before); + printf("Accounting of nodes in the hash table: " + "%lu nodes.\n", + count); + printf("Approximation after node accounting: %ld nodes.\n", + approx_after); + } + rcu_unregister_thread(); + return NULL; +} + +void free_node_cb(struct rcu_head *head) +{ + struct lfht_test_node *node = + caa_container_of(head, struct lfht_test_node, head); + free(node); +} + +static +void test_delete_all_nodes(struct cds_lfht *ht) +{ + struct cds_lfht_iter iter; + struct lfht_test_node *node; + unsigned long count = 0; + + cds_lfht_for_each_entry(ht, &iter, node, node) { + int ret; + + ret = cds_lfht_del(test_ht, cds_lfht_iter_get_node(&iter)); + urcu_posix_assert(!ret); + call_rcu(&node->head, free_node_cb); + count++; + } + printf("deleted %lu nodes.\n", count); +} + +static +void show_usage(char **argv) +{ + printf("Usage : %s nr_readers nr_writers duration (s) \n", + argv[0]); + printf("OPTIONS:\n"); + printf(" [-r] [-w] (yield reader and/or writer)\n"); + printf(" [-d delay] (writer period (us))\n"); + printf(" [-c duration] (reader C.S. duration (in loops))\n"); + printf(" [-v] (verbose output)\n"); + printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); + printf(" [-h size] (initial number of buckets)\n"); + printf(" [-m size] (minimum number of allocated buckets)\n"); + printf(" [-n size] (maximum number of buckets)\n"); +printf(" [not -u nor -s] Add entries (supports redundant keys).\n"); + printf(" [-u] Uniquify add (no redundant keys).\n"); + printf(" [-s] Replace (swap) entries.\n"); + printf(" [-i] Add only (no removal).\n"); + printf(" [-k nr_nodes] Number of nodes to insert initially.\n"); + printf(" [-A] Automatically resize hash table.\n"); + printf(" [-B order|chunk|mmap] Specify the memory backend.\n"); + printf(" [-R offset] Lookup pool offset.\n"); + printf(" [-S offset] Write pool offset.\n"); + printf(" [-T offset] Init pool offset.\n"); + printf(" [-M size] Lookup pool size.\n"); + printf(" [-N size] Write pool size.\n"); + printf(" [-O size] Init pool size.\n"); + printf(" [-V] Validate lookups of init values.\n"); + printf(" (use with filled init pool, same lookup range,\n"); + printf(" with different write range)\n"); + printf(" [-U] Uniqueness test.\n"); + printf(" [-C] Number of hash chains.\n"); + printf("\n"); +} + +int main(int argc, char **argv) +{ + pthread_t *tid_reader, *tid_writer; + pthread_t tid_count; + void *tret; + unsigned long long *count_reader; + struct wr_count *count_writer; + unsigned long long tot_reads = 0, tot_writes = 0, + tot_add = 0, tot_add_exist = 0, tot_remove = 0; + unsigned long count; + long approx_before, approx_after; + int i, a, ret, err, mainret = 0; + unsigned int i_thr; + struct sigaction act; + unsigned int remain; + unsigned int nr_readers_created = 0, nr_writers_created = 0; + long long nr_leaked; + + if (argc < 4) { + show_usage(argv); + mainret = 1; + goto end; + } + + err = sscanf(argv[1], "%u", &nr_readers); + if (err != 1) { + show_usage(argv); + mainret = 1; + goto end; + } + + err = sscanf(argv[2], "%u", &nr_writers); + if (err != 1) { + show_usage(argv); + mainret = 1; + goto end; + } + + err = sscanf(argv[3], "%lu", &duration); + if (err != 1) { + show_usage(argv); + mainret = 1; + goto end; + } + + for (i = 4; i < argc; i++) { + if (argv[i][0] != '-') + continue; + switch (argv[i][1]) { + case 'r': + rcu_debug_yield_enable(RCU_YIELD_READ); + break; + case 'w': + rcu_debug_yield_enable(RCU_YIELD_WRITE); + break; + case 'a': + if (argc < i + 2) { + show_usage(argv); + mainret = 1; + goto end; + } + a = atoi(argv[++i]); + cpu_affinities[next_aff++] = a; + use_affinity = 1; + printf_verbose("Adding CPU %d affinity\n", a); + break; + case 'c': + if (argc < i + 2) { + show_usage(argv); + mainret = 1; + goto end; + } + rduration = atol(argv[++i]); + break; + case 'd': + if (argc < i + 2) { + show_usage(argv); + mainret = 1; + goto end; + } + wdelay = atol(argv[++i]); + break; + case 'v': + verbose_mode = 1; + break; + case 'h': + if (argc < i + 2) { + show_usage(argv); + mainret = 1; + goto end; + } + init_hash_size = atol(argv[++i]); + break; + case 'm': + if (argc < i + 2) { + show_usage(argv); + mainret = 1; + goto end; + } + min_hash_alloc_size = atol(argv[++i]); + break; + case 'n': + if (argc < i + 2) { + show_usage(argv); + mainret = 1; + goto end; + } + max_hash_buckets_size = atol(argv[++i]); + break; + case 'u': + if (add_replace) { + printf("Please specify at most one of -s or -u.\n"); + exit(-1); + } + add_unique = 1; + break; + case 's': + if (add_unique) { + printf("Please specify at most one of -s or -u.\n"); + exit(-1); + } + add_replace = 1; + break; + case 'i': + add_only = 1; + break; + case 'k': + init_populate = atol(argv[++i]); + break; + case 'A': + opt_auto_resize = 1; + break; + case 'B': + if (argc < i + 2) { + show_usage(argv); + mainret = 1; + goto end; + } + i++; + if (!strcmp("order", argv[i])) + memory_backend = &cds_lfht_mm_order; + else if (!strcmp("chunk", argv[i])) + memory_backend = &cds_lfht_mm_chunk; + else if (!strcmp("mmap", argv[i])) + memory_backend = &cds_lfht_mm_mmap; + else { + printf("Please specify memory backend with order|chunk|mmap.\n"); + mainret = 1; + goto end; + } + break; + case 'R': + lookup_pool_offset = atol(argv[++i]); + break; + case 'S': + write_pool_offset = atol(argv[++i]); + break; + case 'T': + init_pool_offset = atol(argv[++i]); + break; + case 'M': + lookup_pool_size = atol(argv[++i]); + break; + case 'N': + write_pool_size = atol(argv[++i]); + break; + case 'O': + init_pool_size = atol(argv[++i]); + break; + case 'V': + validate_lookup = 1; + break; + case 'U': + test_choice = TEST_HASH_UNIQUE; + break; + case 'C': + nr_hash_chains = atol(argv[++i]); + break; + } + } + + /* Check if hash size is power of 2 */ + if (init_hash_size && init_hash_size & (init_hash_size - 1)) { + printf("Error: Initial number of buckets (%lu) is not a power of 2.\n", + init_hash_size); + mainret = 1; + goto end; + } + + if (min_hash_alloc_size && min_hash_alloc_size & (min_hash_alloc_size - 1)) { + printf("Error: Minimum number of allocated buckets (%lu) is not a power of 2.\n", + min_hash_alloc_size); + mainret = 1; + goto end; + } + + if (max_hash_buckets_size && max_hash_buckets_size & (max_hash_buckets_size - 1)) { + printf("Error: Maximum number of buckets (%lu) is not a power of 2.\n", + max_hash_buckets_size); + mainret = 1; + goto end; + } + + memset(&act, 0, sizeof(act)); + ret = sigemptyset(&act.sa_mask); + if (ret == -1) { + perror("sigemptyset"); + mainret = 1; + goto end; + } + act.sa_handler = get_sigusr1_cb(); + act.sa_flags = SA_RESTART; + ret = sigaction(SIGUSR1, &act, NULL); + if (ret == -1) { + perror("sigaction"); + mainret = 1; + goto end; + } + + act.sa_handler = get_sigusr2_cb(); + act.sa_flags = SA_RESTART; + ret = sigaction(SIGUSR2, &act, NULL); + if (ret == -1) { + perror("sigaction"); + mainret = 1; + goto end; + } + + printf_verbose("running test for %lu seconds, %u readers, %u writers.\n", + duration, nr_readers, nr_writers); + printf_verbose("Writer delay : %lu loops.\n", wdelay); + printf_verbose("Reader duration : %lu loops.\n", rduration); + printf_verbose("Mode:%s%s.\n", + add_only ? " add only" : " add/remove", + add_unique ? " uniquify" : ( add_replace ? " replace" : " insert")); + printf_verbose("Initial number of buckets: %lu buckets.\n", init_hash_size); + printf_verbose("Minimum number of allocated buckets: %lu buckets.\n", min_hash_alloc_size); + printf_verbose("Maximum number of buckets: %lu buckets.\n", max_hash_buckets_size); + printf_verbose("Init pool size offset %lu size %lu.\n", + init_pool_offset, init_pool_size); + printf_verbose("Lookup pool size offset %lu size %lu.\n", + lookup_pool_offset, lookup_pool_size); + printf_verbose("Update pool size offset %lu size %lu.\n", + write_pool_offset, write_pool_size); + printf_verbose("Number of hash chains: %lu.\n", + nr_hash_chains); + printf_verbose("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + tid_reader = calloc(nr_readers, sizeof(*tid_reader)); + if (!tid_reader) { + mainret = 1; + goto end; + } + tid_writer = calloc(nr_writers, sizeof(*tid_writer)); + if (!tid_writer) { + mainret = 1; + goto end_free_tid_reader; + } + count_reader = calloc(nr_readers, sizeof(*count_reader)); + if (!count_reader) { + mainret = 1; + goto end_free_tid_writer; + } + count_writer = calloc(nr_writers, sizeof(*count_writer)); + if (!count_writer) { + mainret = 1; + goto end_free_count_reader; + } + + err = create_all_cpu_call_rcu_data(0); + if (err) { + printf("Per-CPU call_rcu() worker threads unavailable. Using default global worker thread.\n"); + } + + if (memory_backend) { + test_ht = _cds_lfht_new(init_hash_size, min_hash_alloc_size, + max_hash_buckets_size, + (opt_auto_resize ? CDS_LFHT_AUTO_RESIZE : 0) | + CDS_LFHT_ACCOUNTING, memory_backend, + &rcu_flavor, NULL); + } else { + test_ht = cds_lfht_new(init_hash_size, min_hash_alloc_size, + max_hash_buckets_size, + (opt_auto_resize ? CDS_LFHT_AUTO_RESIZE : 0) | + CDS_LFHT_ACCOUNTING, NULL); + } + if (!test_ht) { + printf("Error allocating hash table.\n"); + mainret = 1; + goto end_free_call_rcu_data; + } + + /* + * Hash Population needs to be seen as a RCU reader + * thread from the point of view of resize. + */ + rcu_register_thread(); + ret = (get_populate_hash_cb())(); + urcu_posix_assert(!ret); + + rcu_thread_offline(); + + next_aff = 0; + + ret = pipe(count_pipe); + if (ret == -1) { + perror("pipe"); + mainret = 1; + goto end_online; + } + + /* spawn counter thread */ + err = pthread_create(&tid_count, NULL, thr_count, + NULL); + if (err != 0) { + errno = err; + mainret = 1; + perror("pthread_create"); + goto end_close_pipe; + } + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_create(&tid_reader[i_thr], + NULL, get_thr_reader_cb(), + &count_reader[i_thr]); + if (err != 0) { + errno = err; + mainret = 1; + perror("pthread_create"); + goto end_pthread_join; + } + nr_readers_created++; + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_create(&tid_writer[i_thr], + NULL, get_thr_writer_cb(), + &count_writer[i_thr]); + if (err != 0) { + errno = err; + mainret = 1; + perror("pthread_create"); + goto end_pthread_join; + } + nr_writers_created++; + } + + cmm_smp_mb(); + + begin_test(); + + remain = duration; + do { + remain = sleep(remain); + } while (remain > 0); + + end_test(); + +end_pthread_join: + for (i_thr = 0; i_thr < nr_readers_created; i_thr++) { + err = pthread_join(tid_reader[i_thr], &tret); + if (err != 0) { + errno = err; + mainret = 1; + perror("pthread_join"); + } + tot_reads += count_reader[i_thr]; + } + for (i_thr = 0; i_thr < nr_writers_created; i_thr++) { + err = pthread_join(tid_writer[i_thr], &tret); + if (err != 0) { + errno = err; + mainret = 1; + perror("pthread_join"); + } + tot_writes += count_writer[i_thr].update_ops; + tot_add += count_writer[i_thr].add; + tot_add_exist += count_writer[i_thr].add_exist; + tot_remove += count_writer[i_thr].remove; + } + + /* teardown counter thread */ + act.sa_handler = SIG_IGN; + act.sa_flags = SA_RESTART; + ret = sigaction(SIGUSR2, &act, NULL); + if (ret == -1) { + mainret = 1; + perror("sigaction"); + } + { + char msg[1] = { 0x42 }; + ssize_t sret; + + do { + sret = write(count_pipe[1], msg, 1); /* wakeup thread */ + } while (sret == -1L && errno == EINTR); + } + err = pthread_join(tid_count, &tret); + if (err != 0) { + errno = err; + mainret = 1; + perror("pthread_join"); + } + +end_close_pipe: + for (i = 0; i < 2; i++) { + err = close(count_pipe[i]); + if (err) { + mainret = 1; + perror("close pipe"); + } + } + fflush(stdout); +end_online: + rcu_thread_online(); + rcu_read_lock(); + printf("Counting nodes... "); + cds_lfht_count_nodes(test_ht, &approx_before, &count, &approx_after); + printf("done.\n"); + test_delete_all_nodes(test_ht); + rcu_read_unlock(); + rcu_thread_offline(); + if (count) { + printf("Approximation before node accounting: %ld nodes.\n", + approx_before); + printf("Nodes deleted from hash table before destroy: " + "%lu nodes.\n", + count); + printf("Approximation after node accounting: %ld nodes.\n", + approx_after); + } + + ret = cds_lfht_destroy(test_ht, NULL); + if (ret) { + printf_verbose("final delete aborted\n"); + mainret = 1; + } else { + printf_verbose("final delete success\n"); + } + printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads, + tot_writes); + nr_leaked = (long long) tot_add + init_populate - tot_remove - count; + printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu " + "nr_writers %3u " + "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu " + "nr_add %12llu nr_add_fail %12llu nr_remove %12llu nr_leaked %12lld\n", + argv[0], duration, nr_readers, rduration, + nr_writers, wdelay, tot_reads, tot_writes, + tot_reads + tot_writes, tot_add, tot_add_exist, tot_remove, + nr_leaked); + if (nr_leaked != 0) { + mainret = 1; + printf("WARNING: %lld nodes were leaked!\n", nr_leaked); + } + + rcu_unregister_thread(); +end_free_call_rcu_data: + free_all_cpu_call_rcu_data(); + free(count_writer); +end_free_count_reader: + free(count_reader); +end_free_tid_writer: + free(tid_writer); +end_free_tid_reader: + free(tid_reader); +end: + if (!mainret) + exit(EXIT_SUCCESS); + else + exit(EXIT_FAILURE); +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_hash.h b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_hash.h new file mode 100644 index 0000000000000..0ecb781a129b2 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_hash.h @@ -0,0 +1,363 @@ +// SPDX-FileCopyrightText: 2009-2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#ifndef _TEST_URCU_HASH_H +#define _TEST_URCU_HASH_H + +/* + * Userspace RCU library - test program + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "thread-id.h" +#include "../common/debug-yield.h" + +#define DEFAULT_HASH_SIZE 32 +#define DEFAULT_MIN_ALLOC_SIZE 1 +#define DEFAULT_RAND_POOL 1000000 + +/* + * Note: the hash seed should be a random value for hash tables + * targeting production environments to provide protection against + * denial of service attacks. We keep it a static value within this test + * program to compare identical benchmark runs. + */ +#define TEST_HASH_SEED 0x42UL + +/* hardcoded number of CPUs */ +#define NR_CPUS 16384 + +#ifdef POISON_FREE +#define poison_free(ptr) \ + do { \ + memset(ptr, 0x42, sizeof(*(ptr))); \ + free(ptr); \ + } while (0) +#else +#define poison_free(ptr) free(ptr) +#endif + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#else +#define debug_yield_read() +#endif +#include +#include +#include + +struct wr_count { + unsigned long update_ops; + unsigned long add; + unsigned long add_exist; + unsigned long remove; +}; + +extern DECLARE_URCU_TLS(unsigned int, rand_lookup); +extern DECLARE_URCU_TLS(unsigned long, nr_add); +extern DECLARE_URCU_TLS(unsigned long, nr_addexist); +extern DECLARE_URCU_TLS(unsigned long, nr_del); +extern DECLARE_URCU_TLS(unsigned long, nr_delnoent); +extern DECLARE_URCU_TLS(unsigned long, lookup_fail); +extern DECLARE_URCU_TLS(unsigned long, lookup_ok); + +extern struct cds_lfht *test_ht; + +struct test_data { + int a; + int b; +}; + +struct lfht_test_node { + struct cds_lfht_node node; + void *key; + unsigned int key_len; + /* cache-cold for iteration */ + struct rcu_head head; +}; + +static inline struct lfht_test_node * +to_test_node(struct cds_lfht_node *node) +{ + return caa_container_of(node, struct lfht_test_node, node); +} + +static inline +void lfht_test_node_init(struct lfht_test_node *node, void *key, + size_t key_len) +{ + cds_lfht_node_init(&node->node); + node->key = key; + node->key_len = key_len; +} + +static inline struct lfht_test_node * +cds_lfht_iter_get_test_node(struct cds_lfht_iter *iter) +{ + return to_test_node(cds_lfht_iter_get_node(iter)); +} + +extern unsigned long wdelay; + +extern unsigned long duration; + +/* read-side C.S. duration, in loops */ +extern unsigned long rduration; + +extern unsigned long init_hash_size; +extern unsigned long min_hash_alloc_size; +extern unsigned long max_hash_buckets_size; +extern unsigned long init_populate; +extern int opt_auto_resize; +extern int add_only, add_unique, add_replace; +extern const struct cds_lfht_mm_type *memory_backend; + +extern unsigned long init_pool_offset, lookup_pool_offset, write_pool_offset; +extern unsigned long init_pool_size, + lookup_pool_size, + write_pool_size; +extern int validate_lookup; + +extern unsigned long nr_hash_chains; + +extern int count_pipe[2]; + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +extern int verbose_mode; + +#define printf_verbose(fmt, args...) \ + do { \ + if (verbose_mode) \ + printf(fmt, ## args); \ + } while (0) + +extern unsigned int cpu_affinities[NR_CPUS]; +extern unsigned int next_aff; +extern int use_affinity; + +extern pthread_mutex_t affinity_mutex; + +void set_affinity(void); + +extern DECLARE_URCU_TLS(unsigned long long, nr_writes); +extern DECLARE_URCU_TLS(unsigned long long, nr_reads); + +extern unsigned int nr_readers; +extern unsigned int nr_writers; + +void rcu_copy_mutex_lock(void); +void rcu_copy_mutex_unlock(void); + +/* + * Hash function + * Source: http://burtleburtle.net/bob/c/lookup3.c + * Originally Public Domain + */ + +#define rot(x, k) (((x) << (k)) | ((x) >> (32 - (k)))) + +#define mix(a, b, c) \ +do { \ + a -= c; a ^= rot(c, 4); c += b; \ + b -= a; b ^= rot(a, 6); a += c; \ + c -= b; c ^= rot(b, 8); b += a; \ + a -= c; a ^= rot(c, 16); c += b; \ + b -= a; b ^= rot(a, 19); a += c; \ + c -= b; c ^= rot(b, 4); b += a; \ +} while (0) + +#define final(a, b, c) \ +{ \ + c ^= b; c -= rot(b, 14); \ + a ^= c; a -= rot(c, 11); \ + b ^= a; b -= rot(a, 25); \ + c ^= b; c -= rot(b, 16); \ + a ^= c; a -= rot(c, 4);\ + b ^= a; b -= rot(a, 14); \ + c ^= b; c -= rot(b, 24); \ +} + +static inline __attribute__((unused)) +uint32_t hash_u32( + const uint32_t *k, /* the key, an array of uint32_t values */ + size_t length, /* the length of the key, in uint32_ts */ + uint32_t initval) /* the previous hash, or an arbitrary value */ +{ + uint32_t a, b, c; + + /* Set up the internal state */ + a = b = c = 0xdeadbeef + (((uint32_t) length) << 2) + initval; + + /*----------------------------------------- handle most of the key */ + while (length > 3) { + a += k[0]; + b += k[1]; + c += k[2]; + mix(a, b, c); + length -= 3; + k += 3; + } + + /*----------------------------------- handle the last 3 uint32_t's */ + switch (length) { /* all the case statements fall through */ + case 3: c += k[2]; /* fall through */ + case 2: b += k[1]; /* fall through */ + case 1: a += k[0]; + final(a, b, c); + /* fall through */ + case 0: /* case 0: nothing left to add */ + break; + } + /*---------------------------------------------- report the result */ + return c; +} + +static inline +void hashword2( + const uint32_t *k, /* the key, an array of uint32_t values */ + size_t length, /* the length of the key, in uint32_ts */ + uint32_t *pc, /* IN: seed OUT: primary hash value */ + uint32_t *pb) /* IN: more seed OUT: secondary hash value */ +{ + uint32_t a, b, c; + + /* Set up the internal state */ + a = b = c = 0xdeadbeef + ((uint32_t) (length << 2)) + *pc; + c += *pb; + + /*----------------------------------------- handle most of the key */ + while (length > 3) { + a += k[0]; + b += k[1]; + c += k[2]; + mix(a, b, c); + length -= 3; + k += 3; + } + + /*----------------------------------- handle the last 3 uint32_t's */ + switch (length) { /* all the case statements fall through */ + case 3: c += k[2]; /* fall through */ + case 2: b += k[1]; /* fall through */ + case 1: a += k[0]; + final(a, b, c); + /* fall through */ + case 0: /* case 0: nothing left to add */ + break; + } + /*---------------------------------------------- report the result */ + *pc = c; + *pb = b; +} + +#if (CAA_BITS_PER_LONG == 32) +static inline +unsigned long test_hash_mix(const void *_key, size_t length, unsigned long seed) +{ + unsigned int key = (unsigned int) _key; + + urcu_posix_assert(length == sizeof(unsigned int)); + return hash_u32(&key, 1, seed); +} +#else +static inline +unsigned long test_hash_mix(const void *_key, size_t length, unsigned long seed) +{ + union { + uint64_t v64; + uint32_t v32[2]; + } v; + union { + uint64_t v64; + uint32_t v32[2]; + } key; + + urcu_posix_assert(length == sizeof(unsigned long)); + v.v64 = (uint64_t) seed; + key.v64 = (uint64_t) _key; + hashword2(key.v32, 2, &v.v32[0], &v.v32[1]); + return v.v64; +} +#endif + +/* + * Hash function with nr_hash_chains != 0 for testing purpose only! + * Creates very long hash chains, deteriorating the hash table into a + * few linked lists, depending on the nr_hash_chains value. The purpose + * of this test is to check how the hash table behaves with hash chains + * containing different values, which is a rare case in a normal hash + * table. + */ +static inline +unsigned long test_hash(const void *_key, size_t length, + unsigned long seed) +{ + if (nr_hash_chains == 0) { + return test_hash_mix(_key, length, seed); + } else { + unsigned long v; + + urcu_posix_assert(length == sizeof(unsigned long)); + v = (unsigned long) _key; + return v % nr_hash_chains; + } +} + +unsigned long test_compare(const void *key1, size_t key1_len, + const void *key2, size_t key2_len); + +static inline +int test_match(struct cds_lfht_node *node, const void *key) +{ + struct lfht_test_node *test_node = to_test_node(node); + + return !test_compare(test_node->key, test_node->key_len, + key, sizeof(unsigned long)); +} + +static inline +void cds_lfht_test_lookup(struct cds_lfht *ht, void *key, size_t key_len, + struct cds_lfht_iter *iter) +{ + urcu_posix_assert(key_len == sizeof(unsigned long)); + + cds_lfht_lookup(ht, test_hash(key, key_len, TEST_HASH_SEED), + test_match, key, iter); +} + +void free_node_cb(struct rcu_head *head); + +/* rw test */ +void test_hash_rw_sigusr1_handler(int signo); +void test_hash_rw_sigusr2_handler(int signo); +void *test_hash_rw_thr_reader(void *_count); +void *test_hash_rw_thr_writer(void *_count); +int test_hash_rw_populate_hash(void); + +/* unique test */ +void test_hash_unique_sigusr1_handler(int signo); +void test_hash_unique_sigusr2_handler(int signo); +void *test_hash_unique_thr_reader(void *_count); +void *test_hash_unique_thr_writer(void *_count); +int test_hash_unique_populate_hash(void); + +#endif /* _TEST_URCU_HASH_H */ diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_hash_rw.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_hash_rw.c new file mode 100644 index 0000000000000..b76603e6742db --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_hash_rw.c @@ -0,0 +1,265 @@ +// SPDX-FileCopyrightText: 2009-2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test program + */ + +#include "test_urcu_hash.h" + +enum urcu_hash_addremove { + AR_RANDOM = 0, + AR_ADD = 1, + AR_REMOVE = -1, +}; /* 1: add, -1 remove, 0: random */ + +static enum urcu_hash_addremove addremove; /* 1: add, -1 remove, 0: random */ + +void test_hash_rw_sigusr1_handler(int signo __attribute__((unused))) +{ + switch (addremove) { + case AR_ADD: + printf("Add/Remove: random.\n"); + addremove = AR_RANDOM; + break; + case AR_RANDOM: + printf("Add/Remove: remove only.\n"); + addremove = AR_REMOVE; + break; + case AR_REMOVE: + printf("Add/Remove: add only.\n"); + addremove = AR_ADD; + break; + } +} + +void test_hash_rw_sigusr2_handler(int signo __attribute__((unused))) +{ + char msg[1] = { 0x42 }; + ssize_t ret; + + do { + ret = write(count_pipe[1], msg, 1); /* wakeup thread */ + } while (ret == -1L && errno == EINTR); +} + +void *test_hash_rw_thr_reader(void *_count) +{ + unsigned long long *count = _count; + struct lfht_test_node *node; + struct cds_lfht_iter iter; + + printf_verbose("thread_begin %s, tid %lu\n", + "reader", urcu_get_thread_id()); + + URCU_TLS(rand_lookup) = urcu_get_thread_id() ^ time(NULL); + + set_affinity(); + + rcu_register_thread(); + + wait_until_go(); + + for (;;) { + rcu_read_lock(); + cds_lfht_test_lookup(test_ht, + (void *)(((unsigned long) rand_r(&URCU_TLS(rand_lookup)) % lookup_pool_size) + lookup_pool_offset), + sizeof(void *), &iter); + node = cds_lfht_iter_get_test_node(&iter); + if (node == NULL) { + if (validate_lookup) { + printf("[ERROR] Lookup cannot find initial node.\n"); + exit(-1); + } + URCU_TLS(lookup_fail)++; + } else { + URCU_TLS(lookup_ok)++; + } + rcu_debug_yield_read(); + if (caa_unlikely(rduration)) + loop_sleep(rduration); + rcu_read_unlock(); + URCU_TLS(nr_reads)++; + if (caa_unlikely(!test_duration_read())) + break; + if (caa_unlikely((URCU_TLS(nr_reads) & ((1 << 10) - 1)) == 0)) + rcu_quiescent_state(); + } + + rcu_unregister_thread(); + + *count = URCU_TLS(nr_reads); + printf_verbose("thread_end %s, tid %lu\n", + "reader", urcu_get_thread_id()); + printf_verbose("read tid : %lx, lookupfail %lu, lookupok %lu\n", + urcu_get_thread_id(), + URCU_TLS(lookup_fail), + URCU_TLS(lookup_ok)); + return ((void*)1); + +} + +void *test_hash_rw_thr_writer(void *_count) +{ + struct lfht_test_node *node; + struct cds_lfht_iter iter; + struct wr_count *count = _count; + int ret; + + printf_verbose("thread_begin %s, tid %lu\n", + "writer", urcu_get_thread_id()); + + URCU_TLS(rand_lookup) = urcu_get_thread_id() ^ time(NULL); + + set_affinity(); + + rcu_register_thread(); + + wait_until_go(); + + for (;;) { + struct cds_lfht_node *ret_node = NULL; + + if ((addremove == AR_ADD || add_only) + || (addremove == AR_RANDOM && rand_r(&URCU_TLS(rand_lookup)) & 1)) { + node = malloc(sizeof(struct lfht_test_node)); + lfht_test_node_init(node, + (void *)(((unsigned long) rand_r(&URCU_TLS(rand_lookup)) % write_pool_size) + write_pool_offset), + sizeof(void *)); + rcu_read_lock(); + if (add_unique) { + ret_node = cds_lfht_add_unique(test_ht, + test_hash(node->key, node->key_len, TEST_HASH_SEED), + test_match, node->key, &node->node); + } else { + if (add_replace) + ret_node = cds_lfht_add_replace(test_ht, + test_hash(node->key, node->key_len, TEST_HASH_SEED), + test_match, node->key, &node->node); + else + cds_lfht_add(test_ht, + test_hash(node->key, node->key_len, TEST_HASH_SEED), + &node->node); + } + rcu_read_unlock(); + if (add_unique && ret_node != &node->node) { + free(node); + URCU_TLS(nr_addexist)++; + } else { + if (add_replace && ret_node) { + call_rcu(&to_test_node(ret_node)->head, + free_node_cb); + URCU_TLS(nr_addexist)++; + } else { + URCU_TLS(nr_add)++; + } + } + } else { + /* May delete */ + rcu_read_lock(); + cds_lfht_test_lookup(test_ht, + (void *)(((unsigned long) rand_r(&URCU_TLS(rand_lookup)) % write_pool_size) + write_pool_offset), + sizeof(void *), &iter); + ret = cds_lfht_del(test_ht, cds_lfht_iter_get_node(&iter)); + rcu_read_unlock(); + if (ret == 0) { + node = cds_lfht_iter_get_test_node(&iter); + call_rcu(&node->head, free_node_cb); + URCU_TLS(nr_del)++; + } else + URCU_TLS(nr_delnoent)++; + } +#if 0 + //if (URCU_TLS(nr_writes) % 100000 == 0) { + if (URCU_TLS(nr_writes) % 1000 == 0) { + rcu_read_lock(); + if (rand_r(&URCU_TLS(rand_lookup)) & 1) { + ht_resize(test_ht, 1); + } else { + ht_resize(test_ht, -1); + } + rcu_read_unlock(); + } +#endif //0 + URCU_TLS(nr_writes)++; + if (caa_unlikely(!test_duration_write())) + break; + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); + if (caa_unlikely((URCU_TLS(nr_writes) & ((1 << 10) - 1)) == 0)) + rcu_quiescent_state(); + } + + rcu_unregister_thread(); + + printf_verbose("thread_end %s, tid %lu\n", + "writer", urcu_get_thread_id()); + printf_verbose("info tid %lu: nr_add %lu, nr_addexist %lu, nr_del %lu, " + "nr_delnoent %lu\n", urcu_get_thread_id(), + URCU_TLS(nr_add), + URCU_TLS(nr_addexist), + URCU_TLS(nr_del), + URCU_TLS(nr_delnoent)); + count->update_ops = URCU_TLS(nr_writes); + count->add = URCU_TLS(nr_add); + count->add_exist = URCU_TLS(nr_addexist); + count->remove = URCU_TLS(nr_del); + return ((void*)2); +} + +int test_hash_rw_populate_hash(void) +{ + struct lfht_test_node *node; + + if (!init_populate) + return 0; + + printf("Starting rw test\n"); + + URCU_TLS(rand_lookup) = urcu_get_thread_id() ^ time(NULL); + + if ((add_unique || add_replace) && init_populate * 10 > init_pool_size) { + printf("WARNING: required to populate %lu nodes (-k), but random " +"pool is quite small (%lu values) and we are in add_unique (-u) or add_replace (-s) mode. Try with a " +"larger random pool (-p option). This may take a while...\n", init_populate, init_pool_size); + } + + while (URCU_TLS(nr_add) < init_populate) { + struct cds_lfht_node *ret_node = NULL; + + node = malloc(sizeof(struct lfht_test_node)); + lfht_test_node_init(node, + (void *)(((unsigned long) rand_r(&URCU_TLS(rand_lookup)) % init_pool_size) + init_pool_offset), + sizeof(void *)); + rcu_read_lock(); + if (add_unique) { + ret_node = cds_lfht_add_unique(test_ht, + test_hash(node->key, node->key_len, TEST_HASH_SEED), + test_match, node->key, &node->node); + } else { + if (add_replace) + ret_node = cds_lfht_add_replace(test_ht, + test_hash(node->key, node->key_len, TEST_HASH_SEED), + test_match, node->key, &node->node); + else + cds_lfht_add(test_ht, + test_hash(node->key, node->key_len, TEST_HASH_SEED), + &node->node); + } + rcu_read_unlock(); + if (add_unique && ret_node != &node->node) { + free(node); + URCU_TLS(nr_addexist)++; + } else { + if (add_replace && ret_node) { + call_rcu(&to_test_node(ret_node)->head, free_node_cb); + URCU_TLS(nr_addexist)++; + } else { + URCU_TLS(nr_add)++; + } + } + URCU_TLS(nr_writes)++; + } + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_hash_unique.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_hash_unique.c new file mode 100644 index 0000000000000..487baa878e698 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_hash_unique.c @@ -0,0 +1,258 @@ +// SPDX-FileCopyrightText: 2009-2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test program + */ + +#include "test_urcu_hash.h" + +enum urcu_hash_addremove { + AR_RANDOM = 0, + AR_ADD = 1, + AR_REMOVE = -1, +}; /* 1: add, -1 remove, 0: random */ + +static enum urcu_hash_addremove addremove; /* 1: add, -1 remove, 0: random */ + +void test_hash_unique_sigusr1_handler(int signo __attribute__((unused))) +{ + switch (addremove) { + case AR_ADD: + printf("Add/Remove: random.\n"); + addremove = AR_RANDOM; + break; + case AR_RANDOM: + printf("Add/Remove: remove only.\n"); + addremove = AR_REMOVE; + break; + case AR_REMOVE: + printf("Add/Remove: add only.\n"); + addremove = AR_ADD; + break; + } +} + +void test_hash_unique_sigusr2_handler(int signo __attribute__((unused))) +{ + char msg[1] = { 0x42 }; + ssize_t ret; + + do { + ret = write(count_pipe[1], msg, 1); /* wakeup thread */ + } while (ret == -1L && errno == EINTR); +} + +void *test_hash_unique_thr_reader(void *_count) +{ + unsigned long long *count = _count; + + printf_verbose("thread_begin %s, tid %lu\n", + "reader", urcu_get_thread_id()); + + URCU_TLS(rand_lookup) = urcu_get_thread_id() ^ time(NULL); + + set_affinity(); + + rcu_register_thread(); + + wait_until_go(); + + for (;;) { + struct lfht_test_node *node; + struct cds_lfht_iter iter; + /* + * iterate on whole table, ensuring that no duplicate is + * found. + */ + rcu_read_lock(); + cds_lfht_for_each_entry(test_ht, &iter, node, node) { + struct cds_lfht_iter dup_iter; + + dup_iter = iter; + cds_lfht_next_duplicate(test_ht, test_match, + node->key, &dup_iter); + if (dup_iter.node != NULL) { + printf("[ERROR] Duplicate key %p found\n", node->key); + } + } + rcu_read_unlock(); + + rcu_debug_yield_read(); + if (caa_unlikely(rduration)) + loop_sleep(rduration); + URCU_TLS(nr_reads)++; + if (caa_unlikely(!test_duration_read())) + break; + if (caa_unlikely((URCU_TLS(nr_reads) & ((1 << 10) - 1)) == 0)) + rcu_quiescent_state(); + } + + rcu_unregister_thread(); + + *count = URCU_TLS(nr_reads); + printf_verbose("thread_end %s, tid %lu\n", + "reader", urcu_get_thread_id()); + printf_verbose("read tid : %lu, lookupfail %lu, lookupok %lu\n", + urcu_get_thread_id(), URCU_TLS(lookup_fail), + URCU_TLS(lookup_ok)); + return ((void*)1); + +} + +void *test_hash_unique_thr_writer(void *_count) +{ + struct lfht_test_node *node; + struct cds_lfht_node *ret_node; + struct cds_lfht_iter iter; + struct wr_count *count = _count; + int ret; + int loc_add_unique; + + printf_verbose("thread_begin %s, tid %lu\n", + "writer", urcu_get_thread_id()); + + URCU_TLS(rand_lookup) = urcu_get_thread_id() ^ time(NULL); + + set_affinity(); + + rcu_register_thread(); + + wait_until_go(); + + for (;;) { + /* + * add unique/add replace with new node key from range. + */ + if (1 || (addremove == AR_ADD || add_only) + || (addremove == AR_RANDOM && rand_r(&URCU_TLS(rand_lookup)) & 1)) { + node = malloc(sizeof(struct lfht_test_node)); + lfht_test_node_init(node, + (void *)(((unsigned long) rand_r(&URCU_TLS(rand_lookup)) % write_pool_size) + write_pool_offset), + sizeof(void *)); + rcu_read_lock(); + loc_add_unique = rand_r(&URCU_TLS(rand_lookup)) & 1; + if (loc_add_unique) { + ret_node = cds_lfht_add_unique(test_ht, + test_hash(node->key, node->key_len, TEST_HASH_SEED), + test_match, node->key, &node->node); + } else { + ret_node = cds_lfht_add_replace(test_ht, + test_hash(node->key, node->key_len, TEST_HASH_SEED), + test_match, node->key, &node->node); +#if 0 //generate an error on purpose + cds_lfht_add(test_ht, + test_hash(node->key, node->key_len, TEST_HASH_SEED), + &node->node); + ret_node = NULL; +#endif //0 + } + rcu_read_unlock(); + if (loc_add_unique) { + if (ret_node != &node->node) { + free(node); + URCU_TLS(nr_addexist)++; + } else { + URCU_TLS(nr_add)++; + } + } else { + if (ret_node) { + call_rcu(&to_test_node(ret_node)->head, + free_node_cb); + URCU_TLS(nr_addexist)++; + } else { + URCU_TLS(nr_add)++; + } + } + } else { + /* May delete */ + rcu_read_lock(); + cds_lfht_test_lookup(test_ht, + (void *)(((unsigned long) rand_r(&URCU_TLS(rand_lookup)) % write_pool_size) + write_pool_offset), + sizeof(void *), &iter); + ret = cds_lfht_del(test_ht, cds_lfht_iter_get_node(&iter)); + rcu_read_unlock(); + if (ret == 0) { + node = cds_lfht_iter_get_test_node(&iter); + call_rcu(&node->head, free_node_cb); + URCU_TLS(nr_del)++; + } else + URCU_TLS(nr_delnoent)++; + } +#if 0 + //if (URCU_TLS(nr_writes) % 100000 == 0) { + if (URCU_TLS(nr_writes) % 1000 == 0) { + rcu_read_lock(); + if (rand_r(&URCU_TLS(rand_lookup)) & 1) { + ht_resize(test_ht, 1); + } else { + ht_resize(test_ht, -1); + } + rcu_read_unlock(); + } +#endif //0 + URCU_TLS(nr_writes)++; + if (caa_unlikely(!test_duration_write())) + break; + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); + if (caa_unlikely((URCU_TLS(nr_writes) & ((1 << 10) - 1)) == 0)) + rcu_quiescent_state(); + } + + rcu_unregister_thread(); + + printf_verbose("thread_end %s, tid %lu\n", + "writer", urcu_get_thread_id()); + printf_verbose("info tid %lu: nr_add %lu, nr_addexist %lu, nr_del %lu, " + "nr_delnoent %lu\n", urcu_get_thread_id(), + URCU_TLS(nr_add), + URCU_TLS(nr_addexist), + URCU_TLS(nr_del), + URCU_TLS(nr_delnoent)); + count->update_ops = URCU_TLS(nr_writes); + count->add = URCU_TLS(nr_add); + count->add_exist = URCU_TLS(nr_addexist); + count->remove = URCU_TLS(nr_del); + return ((void*)2); +} + +int test_hash_unique_populate_hash(void) +{ + struct lfht_test_node *node; + struct cds_lfht_node *ret_node; + + printf("Starting uniqueness test.\n"); + + URCU_TLS(rand_lookup) = urcu_get_thread_id() ^ time(NULL); + + if (!init_populate) + return 0; + + if (init_populate * 10 > init_pool_size) { + printf("WARNING: required to populate %lu nodes (-k), but random " +"pool is quite small (%lu values) and we are in add_unique (-u) or add_replace (-s) mode. Try with a " +"larger random pool (-p option). This may take a while...\n", init_populate, init_pool_size); + } + + while (URCU_TLS(nr_add) < init_populate) { + node = malloc(sizeof(struct lfht_test_node)); + lfht_test_node_init(node, + (void *)(((unsigned long) rand_r(&URCU_TLS(rand_lookup)) % init_pool_size) + init_pool_offset), + sizeof(void *)); + rcu_read_lock(); + ret_node = cds_lfht_add_replace(test_ht, + test_hash(node->key, node->key_len, TEST_HASH_SEED), + test_match, node->key, &node->node); + rcu_read_unlock(); + if (ret_node) { + call_rcu(&to_test_node(ret_node)->head, free_node_cb); + URCU_TLS(nr_addexist)++; + } else { + URCU_TLS(nr_add)++; + } + URCU_TLS(nr_writes)++; + } + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_lfq.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_lfq.c new file mode 100644 index 0000000000000..66cf78ca36aa0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_lfq.c @@ -0,0 +1,415 @@ +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2010 Paolo Bonzini +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - example RCU-based lock-free queue + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "thread-id.h" + +/* hardcoded number of CPUs */ +#define NR_CPUS 16384 + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif +#include +#include + +static unsigned long rduration; + +static unsigned long duration; + +/* read-side C.S. duration, in loops */ +static unsigned long wdelay; + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +static int verbose_mode; + +#define printf_verbose(fmt, args...) \ + do { \ + if (verbose_mode) \ + printf(fmt, args); \ + } while (0) + +static unsigned int cpu_affinities[NR_CPUS]; +static unsigned int next_aff = 0; +static int use_affinity = 0; + +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void set_affinity(void) +{ +#ifdef HAVE_SCHED_SETAFFINITY + cpu_set_t mask; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ + + if (!use_affinity) + return; + +#ifdef HAVE_SCHED_SETAFFINITY + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +#endif /* HAVE_SCHED_SETAFFINITY */ +} + +/* + * returns 0 if test should end. + */ +static int test_duration_dequeue(void) +{ + return test_duration_read(); +} + +static int test_duration_enqueue(void) +{ + return test_duration_write(); +} + +static DEFINE_URCU_TLS(unsigned long long, nr_dequeues); +static DEFINE_URCU_TLS(unsigned long long, nr_enqueues); + +static DEFINE_URCU_TLS(unsigned long long, nr_successful_dequeues); +static DEFINE_URCU_TLS(unsigned long long, nr_successful_enqueues); + +static unsigned int nr_enqueuers; +static unsigned int nr_dequeuers; + +struct test { + struct cds_lfq_node_rcu list; + struct rcu_head rcu; +}; + +static struct cds_lfq_queue_rcu q; + +static +void *thr_enqueuer(void *_count) +{ + unsigned long long *count = _count; + + printf_verbose("thread_begin %s, tid %lu\n", + "enqueuer", urcu_get_thread_id()); + + set_affinity(); + + rcu_register_thread(); + + wait_until_go(); + + for (;;) { + struct test *node = malloc(sizeof(*node)); + if (!node) + goto fail; + cds_lfq_node_init_rcu(&node->list); + rcu_read_lock(); + cds_lfq_enqueue_rcu(&q, &node->list); + rcu_read_unlock(); + URCU_TLS(nr_successful_enqueues)++; + + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); +fail: + URCU_TLS(nr_enqueues)++; + if (caa_unlikely(!test_duration_enqueue())) + break; + } + + rcu_unregister_thread(); + + count[0] = URCU_TLS(nr_enqueues); + count[1] = URCU_TLS(nr_successful_enqueues); + printf_verbose("enqueuer thread_end, tid %lu, " + "enqueues %llu successful_enqueues %llu\n", + urcu_get_thread_id(), + URCU_TLS(nr_enqueues), + URCU_TLS(nr_successful_enqueues)); + return ((void*)1); + +} + +static +void free_node_cb(struct rcu_head *head) +{ + struct test *node = + caa_container_of(head, struct test, rcu); + free(node); +} + +static +void *thr_dequeuer(void *_count) +{ + unsigned long long *count = _count; + + printf_verbose("thread_begin %s, tid %lu\n", + "dequeuer", urcu_get_thread_id()); + + set_affinity(); + + rcu_register_thread(); + + wait_until_go(); + + for (;;) { + struct cds_lfq_node_rcu *qnode; + + rcu_read_lock(); + qnode = cds_lfq_dequeue_rcu(&q); + rcu_read_unlock(); + + if (qnode) { + struct test *node; + + node = caa_container_of(qnode, struct test, list); + call_rcu(&node->rcu, free_node_cb); + URCU_TLS(nr_successful_dequeues)++; + } + + URCU_TLS(nr_dequeues)++; + if (caa_unlikely(!test_duration_dequeue())) + break; + if (caa_unlikely(rduration)) + loop_sleep(rduration); + } + + rcu_unregister_thread(); + printf_verbose("dequeuer thread_end, tid %lu, " + "dequeues %llu, successful_dequeues %llu\n", + urcu_get_thread_id(), + URCU_TLS(nr_dequeues), + URCU_TLS(nr_successful_dequeues)); + count[0] = URCU_TLS(nr_dequeues); + count[1] = URCU_TLS(nr_successful_dequeues); + return ((void*)2); +} + +static +void test_end(unsigned long long *nr_dequeues_l) +{ + struct cds_lfq_node_rcu *snode; + + do { + snode = cds_lfq_dequeue_rcu(&q); + if (snode) { + struct test *node; + + node = caa_container_of(snode, struct test, list); + free(node); /* no more concurrent access */ + (*nr_dequeues_l)++; + } + } while (snode); +} + +static +void show_usage(char **argv) +{ + printf("Usage : %s nr_dequeuers nr_enqueuers duration (s) \n", + argv[0]); + printf("OPTIONS:\n"); + printf(" [-d delay] (enqueuer period (in loops))\n"); + printf(" [-c duration] (dequeuer period (in loops))\n"); + printf(" [-v] (verbose output)\n"); + printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); + printf("\n"); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_enqueuer, *tid_dequeuer; + void *tret; + unsigned long long *count_enqueuer, *count_dequeuer; + unsigned long long tot_enqueues = 0, tot_dequeues = 0; + unsigned long long tot_successful_enqueues = 0, + tot_successful_dequeues = 0; + unsigned long long end_dequeues = 0; + int i, a; + unsigned int i_thr; + + if (argc < 4) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[1], "%u", &nr_dequeuers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[2], "%u", &nr_enqueuers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[3], "%lu", &duration); + if (err != 1) { + show_usage(argv); + return -1; + } + + for (i = 4; i < argc; i++) { + if (argv[i][0] != '-') + continue; + switch (argv[i][1]) { + case 'a': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + a = atoi(argv[++i]); + cpu_affinities[next_aff++] = a; + use_affinity = 1; + printf_verbose("Adding CPU %d affinity\n", a); + break; + case 'c': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + rduration = atol(argv[++i]); + break; + case 'd': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wdelay = atol(argv[++i]); + break; + case 'v': + verbose_mode = 1; + break; + } + } + + printf_verbose("running test for %lu seconds, %u enqueuers, " + "%u dequeuers.\n", + duration, nr_enqueuers, nr_dequeuers); + printf_verbose("Writer delay : %lu loops.\n", rduration); + printf_verbose("Reader duration : %lu loops.\n", wdelay); + printf_verbose("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + tid_enqueuer = calloc(nr_enqueuers, sizeof(*tid_enqueuer)); + tid_dequeuer = calloc(nr_dequeuers, sizeof(*tid_dequeuer)); + count_enqueuer = calloc(nr_enqueuers, 2 * sizeof(*count_enqueuer)); + count_dequeuer = calloc(nr_dequeuers, 2 * sizeof(*count_dequeuer)); + cds_lfq_init_rcu(&q, call_rcu); + err = create_all_cpu_call_rcu_data(0); + if (err) { + printf("Per-CPU call_rcu() worker threads unavailable. Using default global worker thread.\n"); + } + + next_aff = 0; + + for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) { + err = pthread_create(&tid_enqueuer[i_thr], NULL, thr_enqueuer, + &count_enqueuer[2 * i_thr]); + if (err != 0) + exit(1); + } + for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) { + err = pthread_create(&tid_dequeuer[i_thr], NULL, thr_dequeuer, + &count_dequeuer[2 * i_thr]); + if (err != 0) + exit(1); + } + + cmm_smp_mb(); + + begin_test(); + + for (i_thr = 0; i_thr < duration; i_thr++) { + sleep(1); + if (verbose_mode) { + fwrite(".", sizeof(char), 1, stdout); + fflush(stdout); + } + } + + end_test(); + + for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) { + err = pthread_join(tid_enqueuer[i_thr], &tret); + if (err != 0) + exit(1); + tot_enqueues += count_enqueuer[2 * i_thr]; + tot_successful_enqueues += count_enqueuer[2 * i_thr + 1]; + } + for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) { + err = pthread_join(tid_dequeuer[i_thr], &tret); + if (err != 0) + exit(1); + tot_dequeues += count_dequeuer[2 * i_thr]; + tot_successful_dequeues += count_dequeuer[2 * i_thr + 1]; + } + + test_end(&end_dequeues); + err = cds_lfq_destroy_rcu(&q); + urcu_posix_assert(!err); + + printf_verbose("total number of enqueues : %llu, dequeues %llu\n", + tot_enqueues, tot_dequeues); + printf_verbose("total number of successful enqueues : %llu, " + "successful dequeues %llu\n", + tot_successful_enqueues, tot_successful_dequeues); + printf("SUMMARY %-25s testdur %4lu nr_enqueuers %3u wdelay %6lu " + "nr_dequeuers %3u " + "rdur %6lu nr_enqueues %12llu nr_dequeues %12llu " + "successful enqueues %12llu successful dequeues %12llu " + "end_dequeues %llu nr_ops %12llu\n", + argv[0], duration, nr_enqueuers, wdelay, + nr_dequeuers, rduration, tot_enqueues, tot_dequeues, + tot_successful_enqueues, + tot_successful_dequeues, end_dequeues, + tot_enqueues + tot_dequeues); + if (tot_successful_enqueues != tot_successful_dequeues + end_dequeues) + printf("WARNING! Discrepancy between nr succ. enqueues %llu vs " + "succ. dequeues + end dequeues %llu.\n", + tot_successful_enqueues, + tot_successful_dequeues + end_dequeues); + + free_all_cpu_call_rcu_data(); + free(count_enqueuer); + free(count_dequeuer); + free(tid_enqueuer); + free(tid_dequeuer); + + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_lfs.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_lfs.c new file mode 100644 index 0000000000000..933f0b37bfdb0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_lfs.c @@ -0,0 +1,498 @@ +// SPDX-FileCopyrightText: 2010-2012 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2010 Paolo Bonzini +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - example lock-free stack + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "thread-id.h" + +/* hardcoded number of CPUs */ +#define NR_CPUS 16384 + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif +#include +#include + +#define POISON_PTR ((void *) 0x42UL) + +/* + * External synchronization used. + */ +enum test_sync { + TEST_SYNC_NONE = 0, + TEST_SYNC_RCU, +}; + +static enum test_sync test_sync; + +static unsigned long rduration; + +static unsigned long duration; + +/* read-side C.S. duration, in loops */ +static unsigned long wdelay; + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +static int verbose_mode; + +static int test_pop, test_pop_all; + +#define printf_verbose(fmt, args...) \ + do { \ + if (verbose_mode) \ + printf(fmt, ## args); \ + } while (0) + +static unsigned int cpu_affinities[NR_CPUS]; +static unsigned int next_aff = 0; +static int use_affinity = 0; + +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void set_affinity(void) +{ +#ifdef HAVE_SCHED_SETAFFINITY + cpu_set_t mask; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ + + if (!use_affinity) + return; + +#ifdef HAVE_SCHED_SETAFFINITY + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +#endif /* HAVE_SCHED_SETAFFINITY */ +} + +/* + * returns 0 if test should end. + */ +static int test_duration_dequeue(void) +{ + return test_duration_read(); +} + +static int test_duration_enqueue(void) +{ + return test_duration_write(); +} + +static DEFINE_URCU_TLS(unsigned long long, nr_dequeues); +static DEFINE_URCU_TLS(unsigned long long, nr_enqueues); + +static DEFINE_URCU_TLS(unsigned long long, nr_successful_dequeues); +static DEFINE_URCU_TLS(unsigned long long, nr_successful_enqueues); + +static unsigned int nr_enqueuers; +static unsigned int nr_dequeuers; + +struct test { + struct cds_lfs_node list; + struct rcu_head rcu; +}; + +static struct cds_lfs_stack s; + +static void *thr_enqueuer(void *_count) +{ + unsigned long long *count = _count; + + printf_verbose("thread_begin %s, tid %lu\n", + "enqueuer", urcu_get_thread_id()); + + set_affinity(); + + rcu_register_thread(); + + wait_until_go(); + + for (;;) { + struct test *node = malloc(sizeof(*node)); + if (!node) + goto fail; + cds_lfs_node_init(&node->list); + cds_lfs_push(&s, &node->list); + URCU_TLS(nr_successful_enqueues)++; + + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); +fail: + URCU_TLS(nr_enqueues)++; + if (caa_unlikely(!test_duration_enqueue())) + break; + } + + rcu_unregister_thread(); + + count[0] = URCU_TLS(nr_enqueues); + count[1] = URCU_TLS(nr_successful_enqueues); + printf_verbose("enqueuer thread_end, tid %lu, " + "enqueues %llu successful_enqueues %llu\n", + urcu_get_thread_id(), + URCU_TLS(nr_enqueues), + URCU_TLS(nr_successful_enqueues)); + return ((void*)1); + +} + +static +void free_node_cb(struct rcu_head *head) +{ + struct test *node = + caa_container_of(head, struct test, rcu); + free(node); +} + +static +void do_test_pop(enum test_sync sync) +{ + struct cds_lfs_node *snode; + + if (sync == TEST_SYNC_RCU) + rcu_read_lock(); + snode = __cds_lfs_pop(&s); + if (sync == TEST_SYNC_RCU) + rcu_read_unlock(); + if (snode) { + struct test *node; + + snode->next = POISON_PTR; + node = caa_container_of(snode, + struct test, list); + if (sync == TEST_SYNC_RCU) + call_rcu(&node->rcu, free_node_cb); + else + free(node); + URCU_TLS(nr_successful_dequeues)++; + } + URCU_TLS(nr_dequeues)++; +} + +static +void do_test_pop_all(enum test_sync sync) +{ + struct cds_lfs_node *snode; + struct cds_lfs_head *head; + struct cds_lfs_node *n; + + head = __cds_lfs_pop_all(&s); + cds_lfs_for_each_safe(head, snode, n) { + struct test *node; + + snode->next = POISON_PTR; + node = caa_container_of(snode, struct test, list); + if (sync == TEST_SYNC_RCU) + call_rcu(&node->rcu, free_node_cb); + else + free(node); + URCU_TLS(nr_successful_dequeues)++; + URCU_TLS(nr_dequeues)++; + } + +} + +static void *thr_dequeuer(void *_count) +{ + unsigned long long *count = _count; + unsigned int counter = 0; + + printf_verbose("thread_begin %s, tid %lu\n", + "dequeuer", urcu_get_thread_id()); + + set_affinity(); + + rcu_register_thread(); + + wait_until_go(); + + urcu_posix_assert(test_pop || test_pop_all); + + for (;;) { + if (test_pop && test_pop_all) { + /* both pop and pop all */ + if (counter & 1) + do_test_pop(test_sync); + else + do_test_pop_all(test_sync); + counter++; + } else { + if (test_pop) + do_test_pop(test_sync); + else + do_test_pop_all(test_sync); + } + + if (caa_unlikely(!test_duration_dequeue())) + break; + if (caa_unlikely(rduration)) + loop_sleep(rduration); + } + + rcu_unregister_thread(); + + printf_verbose("dequeuer thread_end, tid %lu, " + "dequeues %llu, successful_dequeues %llu\n", + urcu_get_thread_id(), + URCU_TLS(nr_dequeues), + URCU_TLS(nr_successful_dequeues)); + count[0] = URCU_TLS(nr_dequeues); + count[1] = URCU_TLS(nr_successful_dequeues); + return ((void*)2); +} + +static void test_end(unsigned long long *nr_dequeues_l) +{ + struct cds_lfs_node *snode; + + do { + snode = __cds_lfs_pop(&s); + if (snode) { + struct test *node; + + node = caa_container_of(snode, struct test, list); + free(node); + (*nr_dequeues_l)++; + } + } while (snode); +} + +static void show_usage(char **argv) +{ + printf("Usage : %s nr_dequeuers nr_enqueuers duration (s) \n", + argv[0]); + printf("OPTIONS:\n"); + printf(" [-d delay] (enqueuer period (in loops))\n"); + printf(" [-c duration] (dequeuer period (in loops))\n"); + printf(" [-v] (verbose output)\n"); + printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); + printf(" [-p] (test pop)\n"); + printf(" [-P] (test pop_all, enabled by default)\n"); + printf(" [-R] (use RCU external synchronization)\n"); + printf(" Note: default: no external synchronization used.\n"); + printf("\n"); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_enqueuer, *tid_dequeuer; + void *tret; + unsigned long long *count_enqueuer, *count_dequeuer; + unsigned long long tot_enqueues = 0, tot_dequeues = 0; + unsigned long long tot_successful_enqueues = 0, + tot_successful_dequeues = 0; + unsigned long long end_dequeues = 0; + int i, a; + unsigned int i_thr; + + if (argc < 4) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[1], "%u", &nr_dequeuers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[2], "%u", &nr_enqueuers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[3], "%lu", &duration); + if (err != 1) { + show_usage(argv); + return -1; + } + + for (i = 4; i < argc; i++) { + if (argv[i][0] != '-') + continue; + switch (argv[i][1]) { + case 'a': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + a = atoi(argv[++i]); + cpu_affinities[next_aff++] = a; + use_affinity = 1; + printf_verbose("Adding CPU %d affinity\n", a); + break; + case 'c': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + rduration = atol(argv[++i]); + break; + case 'd': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wdelay = atol(argv[++i]); + break; + case 'v': + verbose_mode = 1; + break; + case 'p': + test_pop = 1; + break; + case 'P': + test_pop_all = 1; + break; + case 'R': + test_sync = TEST_SYNC_RCU; + break; + } + } + + /* activate pop_all test by default */ + if (!test_pop && !test_pop_all) + test_pop_all = 1; + + printf_verbose("running test for %lu seconds, %u enqueuers, " + "%u dequeuers.\n", + duration, nr_enqueuers, nr_dequeuers); + if (test_pop) + printf_verbose("pop test activated.\n"); + if (test_pop_all) + printf_verbose("pop_all test activated.\n"); + if (test_sync == TEST_SYNC_RCU) + printf_verbose("External sync: RCU.\n"); + else + printf_verbose("External sync: none.\n"); + printf_verbose("Writer delay : %lu loops.\n", rduration); + printf_verbose("Reader duration : %lu loops.\n", wdelay); + printf_verbose("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + tid_enqueuer = calloc(nr_enqueuers, sizeof(*tid_enqueuer)); + tid_dequeuer = calloc(nr_dequeuers, sizeof(*tid_dequeuer)); + count_enqueuer = calloc(nr_enqueuers, 2 * sizeof(*count_enqueuer)); + count_dequeuer = calloc(nr_dequeuers, 2 * sizeof(*count_dequeuer)); + cds_lfs_init(&s); + err = create_all_cpu_call_rcu_data(0); + if (err) { + printf("Per-CPU call_rcu() worker threads unavailable. Using default global worker thread.\n"); + } + + next_aff = 0; + + for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) { + err = pthread_create(&tid_enqueuer[i_thr], NULL, thr_enqueuer, + &count_enqueuer[2 * i_thr]); + if (err != 0) + exit(1); + } + for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) { + err = pthread_create(&tid_dequeuer[i_thr], NULL, thr_dequeuer, + &count_dequeuer[2 * i_thr]); + if (err != 0) + exit(1); + } + + cmm_smp_mb(); + + begin_test(); + + for (i_thr = 0; i_thr < duration; i_thr++) { + sleep(1); + if (verbose_mode) { + fwrite(".", sizeof(char), 1, stdout); + fflush(stdout); + } + } + + end_test(); + + for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) { + err = pthread_join(tid_enqueuer[i_thr], &tret); + if (err != 0) + exit(1); + tot_enqueues += count_enqueuer[2 * i_thr]; + tot_successful_enqueues += count_enqueuer[2 * i_thr + 1]; + } + for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) { + err = pthread_join(tid_dequeuer[i_thr], &tret); + if (err != 0) + exit(1); + tot_dequeues += count_dequeuer[2 * i_thr]; + tot_successful_dequeues += count_dequeuer[2 * i_thr + 1]; + } + + test_end(&end_dequeues); + + printf_verbose("total number of enqueues : %llu, dequeues %llu\n", + tot_enqueues, tot_dequeues); + printf_verbose("total number of successful enqueues : %llu, " + "successful dequeues %llu\n", + tot_successful_enqueues, tot_successful_dequeues); + printf("SUMMARY %-25s testdur %4lu nr_enqueuers %3u wdelay %6lu " + "nr_dequeuers %3u " + "rdur %6lu nr_enqueues %12llu nr_dequeues %12llu " + "successful enqueues %12llu successful dequeues %12llu " + "end_dequeues %llu nr_ops %12llu\n", + argv[0], duration, nr_enqueuers, wdelay, + nr_dequeuers, rduration, tot_enqueues, tot_dequeues, + tot_successful_enqueues, + tot_successful_dequeues, end_dequeues, + tot_enqueues + tot_dequeues); + if (tot_successful_enqueues != tot_successful_dequeues + end_dequeues) + printf("WARNING! Discrepancy between nr succ. enqueues %llu vs " + "succ. dequeues + end dequeues %llu.\n", + tot_successful_enqueues, + tot_successful_dequeues + end_dequeues); + + free_all_cpu_call_rcu_data(); + cds_lfs_destroy(&s); + free(count_enqueuer); + free(count_dequeuer); + free(tid_enqueuer); + free(tid_dequeuer); + + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_lfs_rcu.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_lfs_rcu.c new file mode 100644 index 0000000000000..cb9236d87d05a --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_lfs_rcu.c @@ -0,0 +1,414 @@ +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2010 Paolo Bonzini +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - example RCU-based lock-free stack + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "thread-id.h" + +/* hardcoded number of CPUs */ +#define NR_CPUS 16384 + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif +#include + +/* Remove deprecation warnings from test build. */ +#define CDS_LFS_RCU_DEPRECATED + +#include + +static unsigned long rduration; + +static unsigned long duration; + +/* read-side C.S. duration, in loops */ +static unsigned long wdelay; + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +static int verbose_mode; + +#define printf_verbose(fmt, args...) \ + do { \ + if (verbose_mode) \ + printf(fmt, args); \ + } while (0) + +static unsigned int cpu_affinities[NR_CPUS]; +static unsigned int next_aff = 0; +static int use_affinity = 0; + +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void set_affinity(void) +{ +#ifdef HAVE_SCHED_SETAFFINITY + cpu_set_t mask; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ + + if (!use_affinity) + return; + +#ifdef HAVE_SCHED_SETAFFINITY + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +#endif /* HAVE_SCHED_SETAFFINITY */ +} + +/* + * returns 0 if test should end. + */ +static int test_duration_dequeue(void) +{ + return test_duration_read(); +} + +static int test_duration_enqueue(void) +{ + return test_duration_write(); +} + +static DEFINE_URCU_TLS(unsigned long long, nr_dequeues); +static DEFINE_URCU_TLS(unsigned long long, nr_enqueues); + +static DEFINE_URCU_TLS(unsigned long long, nr_successful_dequeues); +static DEFINE_URCU_TLS(unsigned long long, nr_successful_enqueues); + +static unsigned int nr_enqueuers; +static unsigned int nr_dequeuers; + +struct test { + struct cds_lfs_node_rcu list; + struct rcu_head rcu; +}; + +static struct cds_lfs_stack_rcu s; + +static +void *thr_enqueuer(void *_count) +{ + unsigned long long *count = _count; + + printf_verbose("thread_begin %s, tid %lu\n", + "enqueuer", urcu_get_thread_id()); + + set_affinity(); + + rcu_register_thread(); + + wait_until_go(); + + for (;;) { + struct test *node = malloc(sizeof(*node)); + if (!node) + goto fail; + cds_lfs_node_init_rcu(&node->list); + /* No rcu read-side is needed for push */ + cds_lfs_push_rcu(&s, &node->list); + URCU_TLS(nr_successful_enqueues)++; + + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); +fail: + URCU_TLS(nr_enqueues)++; + if (caa_unlikely(!test_duration_enqueue())) + break; + } + + rcu_unregister_thread(); + + count[0] = URCU_TLS(nr_enqueues); + count[1] = URCU_TLS(nr_successful_enqueues); + printf_verbose("enqueuer thread_end, tid %lu, " + "enqueues %llu successful_enqueues %llu\n", + urcu_get_thread_id(), + URCU_TLS(nr_enqueues), + URCU_TLS(nr_successful_enqueues)); + return ((void*)1); + +} + +static +void free_node_cb(struct rcu_head *head) +{ + struct test *node = + caa_container_of(head, struct test, rcu); + free(node); +} + +static +void *thr_dequeuer(void *_count) +{ + unsigned long long *count = _count; + + printf_verbose("thread_begin %s, tid %lu\n", + "dequeuer", urcu_get_thread_id()); + + set_affinity(); + + rcu_register_thread(); + + wait_until_go(); + + for (;;) { + struct cds_lfs_node_rcu *snode; + + rcu_read_lock(); + snode = cds_lfs_pop_rcu(&s); + rcu_read_unlock(); + if (snode) { + struct test *node; + + node = caa_container_of(snode, struct test, list); + call_rcu(&node->rcu, free_node_cb); + URCU_TLS(nr_successful_dequeues)++; + } + URCU_TLS(nr_dequeues)++; + if (caa_unlikely(!test_duration_dequeue())) + break; + if (caa_unlikely(rduration)) + loop_sleep(rduration); + } + + rcu_unregister_thread(); + + printf_verbose("dequeuer thread_end, tid %lu, " + "dequeues %llu, successful_dequeues %llu\n", + urcu_get_thread_id(), + URCU_TLS(nr_dequeues), + URCU_TLS(nr_successful_dequeues)); + count[0] = URCU_TLS(nr_dequeues); + count[1] = URCU_TLS(nr_successful_dequeues); + return ((void*)2); +} + +static +void test_end(unsigned long long *nr_dequeues_l) +{ + struct cds_lfs_node_rcu *snode; + + do { + snode = cds_lfs_pop_rcu(&s); + if (snode) { + struct test *node; + + node = caa_container_of(snode, struct test, list); + free(node); + (*nr_dequeues_l)++; + } + } while (snode); +} + +static +void show_usage(char **argv) +{ + printf("Usage : %s nr_dequeuers nr_enqueuers duration (s) \n", + argv[0]); + printf("OPTIONS:\n"); + printf(" [-d delay] (enqueuer period (in loops))\n"); + printf(" [-c duration] (dequeuer period (in loops))\n"); + printf(" [-v] (verbose output)\n"); + printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); + printf("\n"); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_enqueuer, *tid_dequeuer; + void *tret; + unsigned long long *count_enqueuer, *count_dequeuer; + unsigned long long tot_enqueues = 0, tot_dequeues = 0; + unsigned long long tot_successful_enqueues = 0, + tot_successful_dequeues = 0; + unsigned long long end_dequeues = 0; + int i, a; + unsigned int i_thr; + + if (argc < 4) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[1], "%u", &nr_dequeuers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[2], "%u", &nr_enqueuers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[3], "%lu", &duration); + if (err != 1) { + show_usage(argv); + return -1; + } + + for (i = 4; i < argc; i++) { + if (argv[i][0] != '-') + continue; + switch (argv[i][1]) { + case 'a': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + a = atoi(argv[++i]); + cpu_affinities[next_aff++] = a; + use_affinity = 1; + printf_verbose("Adding CPU %d affinity\n", a); + break; + case 'c': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + rduration = atol(argv[++i]); + break; + case 'd': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wdelay = atol(argv[++i]); + break; + case 'v': + verbose_mode = 1; + break; + } + } + + printf_verbose("running test for %lu seconds, %u enqueuers, " + "%u dequeuers.\n", + duration, nr_enqueuers, nr_dequeuers); + printf_verbose("Writer delay : %lu loops.\n", rduration); + printf_verbose("Reader duration : %lu loops.\n", wdelay); + printf_verbose("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + tid_enqueuer = calloc(nr_enqueuers, sizeof(*tid_enqueuer)); + tid_dequeuer = calloc(nr_dequeuers, sizeof(*tid_dequeuer)); + count_enqueuer = calloc(nr_enqueuers, 2 * sizeof(*count_enqueuer)); + count_dequeuer = calloc(nr_dequeuers, 2 * sizeof(*count_dequeuer)); + cds_lfs_init_rcu(&s); + err = create_all_cpu_call_rcu_data(0); + if (err) { + printf("Per-CPU call_rcu() worker threads unavailable. Using default global worker thread.\n"); + } + + next_aff = 0; + + for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) { + err = pthread_create(&tid_enqueuer[i_thr], NULL, thr_enqueuer, + &count_enqueuer[2 * i_thr]); + if (err != 0) + exit(1); + } + for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) { + err = pthread_create(&tid_dequeuer[i_thr], NULL, thr_dequeuer, + &count_dequeuer[2 * i_thr]); + if (err != 0) + exit(1); + } + + cmm_smp_mb(); + + begin_test(); + + for (i_thr = 0; i_thr < duration; i_thr++) { + sleep(1); + if (verbose_mode) { + fwrite(".", sizeof(char), 1, stdout); + fflush(stdout); + } + } + + end_test(); + + for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) { + err = pthread_join(tid_enqueuer[i_thr], &tret); + if (err != 0) + exit(1); + tot_enqueues += count_enqueuer[2 * i_thr]; + tot_successful_enqueues += count_enqueuer[2 * i_thr + 1]; + } + for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) { + err = pthread_join(tid_dequeuer[i_thr], &tret); + if (err != 0) + exit(1); + tot_dequeues += count_dequeuer[2 * i_thr]; + tot_successful_dequeues += count_dequeuer[2 * i_thr + 1]; + } + + test_end(&end_dequeues); + + printf_verbose("total number of enqueues : %llu, dequeues %llu\n", + tot_enqueues, tot_dequeues); + printf_verbose("total number of successful enqueues : %llu, " + "successful dequeues %llu\n", + tot_successful_enqueues, tot_successful_dequeues); + printf("SUMMARY %-25s testdur %4lu nr_enqueuers %3u wdelay %6lu " + "nr_dequeuers %3u " + "rdur %6lu nr_enqueues %12llu nr_dequeues %12llu " + "successful enqueues %12llu successful dequeues %12llu " + "end_dequeues %llu nr_ops %12llu\n", + argv[0], duration, nr_enqueuers, wdelay, + nr_dequeuers, rduration, tot_enqueues, tot_dequeues, + tot_successful_enqueues, + tot_successful_dequeues, end_dequeues, + tot_enqueues + tot_dequeues); + if (tot_successful_enqueues != tot_successful_dequeues + end_dequeues) + printf("WARNING! Discrepancy between nr succ. enqueues %llu vs " + "succ. dequeues + end dequeues %llu.\n", + tot_successful_enqueues, + tot_successful_dequeues + end_dequeues); + + free_all_cpu_call_rcu_data(); + free(count_enqueuer); + free(count_dequeuer); + free(tid_enqueuer); + free(tid_dequeuer); + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_qsbr.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_qsbr.c new file mode 100644 index 0000000000000..a33dbd342df73 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_qsbr.c @@ -0,0 +1,340 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test program + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "thread-id.h" +#include "../common/debug-yield.h" + +/* hardcoded number of CPUs */ +#define NR_CPUS 16384 + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif +#include "urcu-qsbr.h" + +static unsigned long wdelay; + +static int *test_rcu_pointer; + +static unsigned long duration; + +/* read-side C.S. duration, in loops */ +static unsigned long rduration; + +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +static int verbose_mode; + +#define printf_verbose(fmt, args...) \ + do { \ + if (verbose_mode) \ + printf(fmt, args); \ + } while (0) + +static unsigned int cpu_affinities[NR_CPUS]; +static unsigned int next_aff = 0; +static int use_affinity = 0; + +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void set_affinity(void) +{ +#ifdef HAVE_SCHED_SETAFFINITY + cpu_set_t mask; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ + + if (!use_affinity) + return; + +#ifdef HAVE_SCHED_SETAFFINITY + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +#endif /* HAVE_SCHED_SETAFFINITY */ +} + +static DEFINE_URCU_TLS(unsigned long long, nr_writes); +static DEFINE_URCU_TLS(unsigned long long, nr_reads); + +static unsigned int nr_readers; +static unsigned int nr_writers; + +pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER; + +static +void *thr_reader(void *_count) +{ + unsigned long long *count = _count; + int *local_ptr; + + printf_verbose("thread_begin %s, tid %lu\n", + "reader", urcu_get_thread_id()); + + set_affinity(); + + rcu_register_thread(); + + urcu_posix_assert(rcu_read_ongoing()); + rcu_thread_offline(); + urcu_posix_assert(!rcu_read_ongoing()); + rcu_thread_online(); + + wait_until_go(); + + for (;;) { + rcu_read_lock(); + urcu_posix_assert(rcu_read_ongoing()); + local_ptr = rcu_dereference(test_rcu_pointer); + rcu_debug_yield_read(); + if (local_ptr) + urcu_posix_assert(*local_ptr == 8); + if (caa_unlikely(rduration)) + loop_sleep(rduration); + rcu_read_unlock(); + URCU_TLS(nr_reads)++; + /* QS each 1024 reads */ + if (caa_unlikely((URCU_TLS(nr_reads) & ((1 << 10) - 1)) == 0)) + rcu_quiescent_state(); + if (caa_unlikely(!test_duration_read())) + break; + } + + rcu_unregister_thread(); + + /* test extra thread registration */ + rcu_register_thread(); + rcu_unregister_thread(); + + *count = URCU_TLS(nr_reads); + printf_verbose("thread_end %s, tid %lu\n", + "reader", urcu_get_thread_id()); + return ((void*)1); + +} + +static +void *thr_writer(void *_count) +{ + unsigned long long *count = _count; + int *new, *old; + + printf_verbose("thread_begin %s, tid %lu\n", + "writer", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + for (;;) { + new = malloc(sizeof(int)); + urcu_posix_assert(new); + *new = 8; + old = rcu_xchg_pointer(&test_rcu_pointer, new); + if (caa_unlikely(wduration)) + loop_sleep(wduration); + synchronize_rcu(); + if (old) + *old = 0; + free(old); + URCU_TLS(nr_writes)++; + if (caa_unlikely(!test_duration_write())) + break; + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); + } + + printf_verbose("thread_end %s, tid %lu\n", + "writer", urcu_get_thread_id()); + *count = URCU_TLS(nr_writes); + return ((void*)2); +} + +static +void show_usage(char **argv) +{ + printf("Usage : %s nr_readers nr_writers duration (s) \n", + argv[0]); + printf("OPTIONS:\n"); + printf(" [-r] [-w] (yield reader and/or writer)\n"); + printf(" [-d delay] (writer period (us))\n"); + printf(" [-c duration] (reader C.S. duration (in loops))\n"); + printf(" [-e duration] (writer C.S. duration (in loops))\n"); + printf(" [-v] (verbose output)\n"); + printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); + printf("\n"); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_reader, *tid_writer; + void *tret; + unsigned long long *count_reader, *count_writer; + unsigned long long tot_reads = 0, tot_writes = 0; + int i, a; + unsigned int i_thr; + + if (argc < 4) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[1], "%u", &nr_readers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[2], "%u", &nr_writers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[3], "%lu", &duration); + if (err != 1) { + show_usage(argv); + return -1; + } + + for (i = 4; i < argc; i++) { + if (argv[i][0] != '-') + continue; + switch (argv[i][1]) { + case 'r': + rcu_debug_yield_enable(RCU_YIELD_READ); + break; + case 'w': + rcu_debug_yield_enable(RCU_YIELD_WRITE); + break; + case 'a': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + a = atoi(argv[++i]); + cpu_affinities[next_aff++] = a; + use_affinity = 1; + printf_verbose("Adding CPU %d affinity\n", a); + break; + case 'c': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + rduration = atol(argv[++i]); + break; + case 'd': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wdelay = atol(argv[++i]); + break; + case 'e': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wduration = atol(argv[++i]); + break; + case 'v': + verbose_mode = 1; + break; + } + } + + printf_verbose("running test for %lu seconds, %u readers, %u writers.\n", + duration, nr_readers, nr_writers); + printf_verbose("Writer delay : %lu loops.\n", wdelay); + printf_verbose("Reader duration : %lu loops.\n", rduration); + printf_verbose("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + tid_reader = calloc(nr_readers, sizeof(*tid_reader)); + tid_writer = calloc(nr_writers, sizeof(*tid_writer)); + count_reader = calloc(nr_readers, sizeof(*count_reader)); + count_writer = calloc(nr_writers, sizeof(*count_writer)); + + next_aff = 0; + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_create(&tid_reader[i_thr], NULL, thr_reader, + &count_reader[i_thr]); + if (err != 0) + exit(1); + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_create(&tid_writer[i_thr], NULL, thr_writer, + &count_writer[i_thr]); + if (err != 0) + exit(1); + } + + test_for(duration); + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_join(tid_reader[i_thr], &tret); + if (err != 0) + exit(1); + tot_reads += count_reader[i_thr]; + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_join(tid_writer[i_thr], &tret); + if (err != 0) + exit(1); + tot_writes += count_writer[i_thr]; + } + + printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads, + tot_writes); + printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu " + "nr_writers %3u " + "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", + argv[0], duration, nr_readers, rduration, wduration, + nr_writers, wdelay, tot_reads, tot_writes, + tot_reads + tot_writes); + free(test_rcu_pointer); + free(tid_reader); + free(tid_writer); + free(count_reader); + free(count_writer); + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_qsbr_gc.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_qsbr_gc.c new file mode 100644 index 0000000000000..00f6757c9d294 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_qsbr_gc.c @@ -0,0 +1,404 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test program (with baatch reclamation) + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include "thread-id.h" +#include "../common/debug-yield.h" + +/* hardcoded number of CPUs */ +#define NR_CPUS 16384 + +#define _LGPL_SOURCE +#include + +struct test_array { + int a; +}; + +static unsigned long wdelay; + +static struct test_array *test_rcu_pointer; + +static unsigned long duration; + +/* read-side C.S. duration, in loops */ +static unsigned long rduration; +static long reclaim_batch = 1; + +struct reclaim_queue { + void **queue; /* Beginning of queue */ + void **head; /* Insert position */ +}; + +static struct reclaim_queue *pending_reclaims; + + +/* write-side C.S. duration, in loops */ +static unsigned long wduration; + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +static int verbose_mode; + +#define printf_verbose(fmt, args...) \ + do { \ + if (verbose_mode) \ + printf(fmt, args); \ + } while (0) + +static unsigned int cpu_affinities[NR_CPUS]; +static unsigned int next_aff = 0; +static int use_affinity = 0; + +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void set_affinity(void) +{ +#ifdef HAVE_SCHED_SETAFFINITY + cpu_set_t mask; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ + + if (!use_affinity) + return; + +#ifdef HAVE_SCHED_SETAFFINITY + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +#endif /* HAVE_SCHED_SETAFFINITY */ +} + +static DEFINE_URCU_TLS(unsigned long long, nr_writes); +static DEFINE_URCU_TLS(unsigned long long, nr_reads); + +static unsigned int nr_readers; +static unsigned int nr_writers; + +pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER; +static +unsigned long long __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *tot_nr_writes; + +static +void *thr_reader(void *_count) +{ + unsigned long long *count = _count; + struct test_array *local_ptr; + + printf_verbose("thread_begin %s, tid %lu\n", + "reader", urcu_get_thread_id()); + + set_affinity(); + + rcu_register_thread(); + + wait_until_go(); + + for (;;) { + _rcu_read_lock(); + local_ptr = _rcu_dereference(test_rcu_pointer); + rcu_debug_yield_read(); + if (local_ptr) + urcu_posix_assert(local_ptr->a == 8); + if (caa_unlikely(rduration)) + loop_sleep(rduration); + _rcu_read_unlock(); + URCU_TLS(nr_reads)++; + /* QS each 1024 reads */ + if (caa_unlikely((URCU_TLS(nr_reads) & ((1 << 10) - 1)) == 0)) + _rcu_quiescent_state(); + if (caa_unlikely(!test_duration_read())) + break; + } + + rcu_unregister_thread(); + + *count = URCU_TLS(nr_reads); + printf_verbose("thread_end %s, tid %lu\n", + "reader", urcu_get_thread_id()); + return ((void*)1); + +} + +static void rcu_gc_clear_queue(unsigned long wtidx) +{ + void **p; + + /* Wait for Q.S and empty queue */ + synchronize_rcu(); + + for (p = pending_reclaims[wtidx].queue; + p < pending_reclaims[wtidx].head; p++) { + /* poison */ + if (*p) + ((struct test_array *)*p)->a = 0; + free(*p); + } + pending_reclaims[wtidx].head = pending_reclaims[wtidx].queue; +} + +/* Using per-thread queue */ +static void rcu_gc_reclaim(unsigned long wtidx, void *old) +{ + /* Queue pointer */ + *pending_reclaims[wtidx].head = old; + pending_reclaims[wtidx].head++; + + if (caa_likely(pending_reclaims[wtidx].head - pending_reclaims[wtidx].queue + < reclaim_batch)) + return; + + rcu_gc_clear_queue(wtidx); +} + +static +void *thr_writer(void *data) +{ + unsigned long wtidx = (unsigned long)data; +#ifdef TEST_LOCAL_GC + struct test_array *old = NULL; +#else + struct test_array *new, *old; +#endif + + printf_verbose("thread_begin %s, tid %lu\n", + "writer", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + for (;;) { +#ifndef TEST_LOCAL_GC + new = malloc(sizeof(*new)); + new->a = 8; + old = _rcu_xchg_pointer(&test_rcu_pointer, new); +#endif + if (caa_unlikely(wduration)) + loop_sleep(wduration); + rcu_gc_reclaim(wtidx, old); + URCU_TLS(nr_writes)++; + if (caa_unlikely(!test_duration_write())) + break; + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); + } + + printf_verbose("thread_end %s, tid %lu\n", + "writer", urcu_get_thread_id()); + tot_nr_writes[wtidx] = URCU_TLS(nr_writes); + return ((void*)2); +} + +static +void show_usage(char **argv) +{ + printf("Usage : %s nr_readers nr_writers duration (s) \n", + argv[0]); + printf("OPTIONS:\n"); + printf(" [-r] [-w] (yield reader and/or writer)\n"); + printf(" [-b batch] (batch reclaim)\n"); + printf(" [-d delay] (writer period (us))\n"); + printf(" [-c duration] (reader C.S. duration (in loops))\n"); + printf(" [-e duration] (writer C.S. duration (in loops))\n"); + printf(" [-v] (verbose output)\n"); + printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); + printf("\n"); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_reader, *tid_writer; + void *tret; + unsigned long long *count_reader; + unsigned long long tot_reads = 0, tot_writes = 0; + int i, a; + unsigned int i_thr; + + if (argc < 4) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[1], "%u", &nr_readers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[2], "%u", &nr_writers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[3], "%lu", &duration); + if (err != 1) { + show_usage(argv); + return -1; + } + + for (i = 4; i < argc; i++) { + if (argv[i][0] != '-') + continue; + switch (argv[i][1]) { + case 'r': + rcu_debug_yield_enable(RCU_YIELD_READ); + break; + case 'w': + rcu_debug_yield_enable(RCU_YIELD_WRITE); + break; + case 'a': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + a = atoi(argv[++i]); + cpu_affinities[next_aff++] = a; + use_affinity = 1; + printf_verbose("Adding CPU %d affinity\n", a); + break; + case 'b': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + reclaim_batch = atol(argv[++i]); + break; + case 'c': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + rduration = atol(argv[++i]); + break; + case 'd': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wdelay = atol(argv[++i]); + break; + case 'e': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wduration = atol(argv[++i]); + break; + case 'v': + verbose_mode = 1; + break; + } + } + + printf_verbose("running test for %lu seconds, %u readers, %u writers.\n", + duration, nr_readers, nr_writers); + printf_verbose("Writer delay : %lu loops.\n", wdelay); + printf_verbose("Reader duration : %lu loops.\n", rduration); + printf_verbose("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + tid_reader = calloc(nr_readers, sizeof(*tid_reader)); + tid_writer = calloc(nr_writers, sizeof(*tid_writer)); + count_reader = calloc(nr_readers, sizeof(*count_reader)); + tot_nr_writes = calloc(nr_writers, sizeof(*tot_nr_writes)); + pending_reclaims = calloc(nr_writers, sizeof(*pending_reclaims)); + if (reclaim_batch * sizeof(*pending_reclaims[0].queue) + < CAA_CACHE_LINE_SIZE) + for (i_thr = 0; i_thr < nr_writers; i_thr++) + pending_reclaims[i_thr].queue = calloc(1, CAA_CACHE_LINE_SIZE); + else + for (i_thr = 0; i_thr < nr_writers; i_thr++) + pending_reclaims[i_thr].queue = calloc(reclaim_batch, + sizeof(*pending_reclaims[i_thr].queue)); + for (i_thr = 0; i_thr < nr_writers; i_thr++) + pending_reclaims[i_thr].head = pending_reclaims[i_thr].queue; + + next_aff = 0; + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_create(&tid_reader[i_thr], NULL, thr_reader, + &count_reader[i_thr]); + if (err != 0) + exit(1); + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_create(&tid_writer[i_thr], NULL, thr_writer, + (void *)(long)i_thr); + if (err != 0) + exit(1); + } + + test_for(duration); + + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_join(tid_reader[i_thr], &tret); + if (err != 0) + exit(1); + tot_reads += count_reader[i_thr]; + } + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_join(tid_writer[i_thr], &tret); + if (err != 0) + exit(1); + tot_writes += tot_nr_writes[i_thr]; + rcu_gc_clear_queue(i_thr); + } + + printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads, + tot_writes); + printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu " + "nr_writers %3u " + "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu " + "batch %ld\n", + argv[0], duration, nr_readers, rduration, wduration, + nr_writers, wdelay, tot_reads, tot_writes, + tot_reads + tot_writes, reclaim_batch); + + free(tid_reader); + free(tid_writer); + free(count_reader); + free(tot_nr_writes); + + for (i_thr = 0; i_thr < nr_writers; i_thr++) + free(pending_reclaims[i_thr].queue); + free(pending_reclaims); + + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_qsbr_timing.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_qsbr_timing.c new file mode 100644 index 0000000000000..00de939ffa101 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_qsbr_timing.c @@ -0,0 +1,215 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace QSBR - test program + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "thread-id.h" + +#define _LGPL_SOURCE +#include + +pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER; + +static +void rcu_copy_mutex_lock(void) +{ + int ret; + ret = pthread_mutex_lock(&rcu_copy_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } +} + +static +void rcu_copy_mutex_unlock(void) +{ + int ret; + + ret = pthread_mutex_unlock(&rcu_copy_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } +} + +struct test_array { + int a; +}; + +static struct test_array *test_rcu_pointer; + +#define OUTER_READ_LOOP 2000U +#define INNER_READ_LOOP 100000U +#define READ_LOOP ((unsigned long long)OUTER_READ_LOOP * INNER_READ_LOOP) + +#define OUTER_WRITE_LOOP 10U +#define INNER_WRITE_LOOP 200U +#define WRITE_LOOP ((unsigned long long)OUTER_WRITE_LOOP * INNER_WRITE_LOOP) + +static int num_read; +static int num_write; + +#define NR_READ num_read +#define NR_WRITE num_write + +static caa_cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *reader_time; +static caa_cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *writer_time; + +static +void *thr_reader(void *arg) +{ + unsigned int i, j; + struct test_array *local_ptr; + caa_cycles_t time1, time2; + + printf("thread_begin %s, tid %lu\n", + "reader", urcu_get_thread_id()); + sleep(2); + + rcu_register_thread(); + + time1 = caa_get_cycles(); + for (i = 0; i < OUTER_READ_LOOP; i++) { + for (j = 0; j < INNER_READ_LOOP; j++) { + _rcu_read_lock(); + local_ptr = _rcu_dereference(test_rcu_pointer); + if (local_ptr) { + urcu_posix_assert(local_ptr->a == 8); + } + _rcu_read_unlock(); + } + _rcu_quiescent_state(); + } + time2 = caa_get_cycles(); + + rcu_unregister_thread(); + + reader_time[(unsigned long)arg] = time2 - time1; + + sleep(2); + printf("thread_end %s, tid %lu\n", + "reader", urcu_get_thread_id()); + return ((void*)1); + +} + +static +void *thr_writer(void *arg) +{ + unsigned int i, j; + struct test_array *new, *old; + caa_cycles_t time1, time2; + + printf("thread_begin %s, tid %lu\n", + "writer", urcu_get_thread_id()); + sleep(2); + + for (i = 0; i < OUTER_WRITE_LOOP; i++) { + for (j = 0; j < INNER_WRITE_LOOP; j++) { + time1 = caa_get_cycles(); + new = malloc(sizeof(struct test_array)); + rcu_copy_mutex_lock(); + old = test_rcu_pointer; + if (old) { + urcu_posix_assert(old->a == 8); + } + new->a = 8; + old = rcu_xchg_pointer(&test_rcu_pointer, new); + rcu_copy_mutex_unlock(); + synchronize_rcu(); + /* can be done after unlock */ + if (old) { + old->a = 0; + } + free(old); + time2 = caa_get_cycles(); + writer_time[(unsigned long)arg] += time2 - time1; + usleep(1); + } + } + + printf("thread_end %s, tid %lu\n", + "writer", urcu_get_thread_id()); + return ((void*)2); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_reader, *tid_writer; + void *tret; + int i; + caa_cycles_t tot_rtime = 0; + caa_cycles_t tot_wtime = 0; + + if (argc < 2) { + printf("Usage : %s nr_readers nr_writers\n", argv[0]); + exit(-1); + } + num_read = atoi(argv[1]); + num_write = atoi(argv[2]); + + reader_time = calloc(num_read, sizeof(*reader_time)); + writer_time = calloc(num_write, sizeof(*writer_time)); + tid_reader = calloc(num_read, sizeof(*tid_reader)); + tid_writer = calloc(num_write, sizeof(*tid_writer)); + + printf("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + for (i = 0; i < NR_READ; i++) { + err = pthread_create(&tid_reader[i], NULL, thr_reader, + (void *)(long)i); + if (err != 0) + exit(1); + } + for (i = 0; i < NR_WRITE; i++) { + err = pthread_create(&tid_writer[i], NULL, thr_writer, + (void *)(long)i); + if (err != 0) + exit(1); + } + + sleep(10); + + for (i = 0; i < NR_READ; i++) { + err = pthread_join(tid_reader[i], &tret); + if (err != 0) + exit(1); + tot_rtime += reader_time[i]; + } + for (i = 0; i < NR_WRITE; i++) { + err = pthread_join(tid_writer[i], &tret); + if (err != 0) + exit(1); + tot_wtime += writer_time[i]; + } + free(test_rcu_pointer); + printf("Time per read : %g cycles\n", + (double)tot_rtime / ((double)NR_READ * (double)READ_LOOP)); + printf("Time per write : %g cycles\n", + (double)tot_wtime / ((double)NR_WRITE * (double)WRITE_LOOP)); + + free(reader_time); + free(writer_time); + free(tid_reader); + free(tid_writer); + + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_timing.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_timing.c new file mode 100644 index 0000000000000..6ab390d4c5b85 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_timing.c @@ -0,0 +1,215 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test program + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "thread-id.h" + +#define _LGPL_SOURCE +#include + +pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER; + +static +void rcu_copy_mutex_lock(void) +{ + int ret; + ret = pthread_mutex_lock(&rcu_copy_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } +} + +static +void rcu_copy_mutex_unlock(void) +{ + int ret; + + ret = pthread_mutex_unlock(&rcu_copy_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } +} + +struct test_array { + int a; +}; + +static struct test_array *test_rcu_pointer; + +#define OUTER_READ_LOOP 2000U +#define INNER_READ_LOOP 100000U +#define READ_LOOP ((unsigned long long)OUTER_READ_LOOP * INNER_READ_LOOP) + +#define OUTER_WRITE_LOOP 10U +#define INNER_WRITE_LOOP 200U +#define WRITE_LOOP ((unsigned long long)OUTER_WRITE_LOOP * INNER_WRITE_LOOP) + +static int num_read; +static int num_write; + +#define NR_READ num_read +#define NR_WRITE num_write + +static caa_cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *reader_time; +static caa_cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *writer_time; + +static +void *thr_reader(void *arg) +{ + unsigned int i, j; + struct test_array *local_ptr; + caa_cycles_t time1, time2; + + printf("thread_begin %s, tid %lu\n", + "reader", urcu_get_thread_id()); + sleep(2); + + rcu_register_thread(); + + time1 = caa_get_cycles(); + for (i = 0; i < OUTER_READ_LOOP; i++) { + for (j = 0; j < INNER_READ_LOOP; j++) { + rcu_read_lock(); + local_ptr = rcu_dereference(test_rcu_pointer); + if (local_ptr) { + urcu_posix_assert(local_ptr->a == 8); + } + rcu_read_unlock(); + } + } + time2 = caa_get_cycles(); + + rcu_unregister_thread(); + + reader_time[(unsigned long)arg] = time2 - time1; + + sleep(2); + printf("thread_end %s, tid %lu\n", + "reader", urcu_get_thread_id()); + return ((void*)1); + +} + +static +void *thr_writer(void *arg) +{ + unsigned int i, j; + struct test_array *new, *old; + caa_cycles_t time1, time2; + + printf("thread_begin %s, tid %lu\n", + "writer", urcu_get_thread_id()); + sleep(2); + + for (i = 0; i < OUTER_WRITE_LOOP; i++) { + for (j = 0; j < INNER_WRITE_LOOP; j++) { + time1 = caa_get_cycles(); + new = malloc(sizeof(struct test_array)); + rcu_copy_mutex_lock(); + old = test_rcu_pointer; + if (old) { + urcu_posix_assert(old->a == 8); + } + new->a = 8; + old = rcu_xchg_pointer(&test_rcu_pointer, new); + rcu_copy_mutex_unlock(); + synchronize_rcu(); + /* can be done after unlock */ + if (old) { + old->a = 0; + } + free(old); + time2 = caa_get_cycles(); + writer_time[(unsigned long)arg] += time2 - time1; + usleep(1); + } + } + + printf("thread_end %s, tid %lu\n", + "writer", urcu_get_thread_id()); + return ((void*)2); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_reader, *tid_writer; + void *tret; + int i; + caa_cycles_t tot_rtime = 0; + caa_cycles_t tot_wtime = 0; + + if (argc < 2) { + printf("Usage : %s nr_readers nr_writers\n", argv[0]); + exit(-1); + } + num_read = atoi(argv[1]); + num_write = atoi(argv[2]); + + reader_time = calloc(num_read, sizeof(*reader_time)); + writer_time = calloc(num_write, sizeof(*writer_time)); + tid_reader = calloc(num_read, sizeof(*tid_reader)); + tid_writer = calloc(num_write, sizeof(*tid_writer)); + + printf("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + for (i = 0; i < NR_READ; i++) { + err = pthread_create(&tid_reader[i], NULL, thr_reader, + (void *)(long)i); + if (err != 0) + exit(1); + } + for (i = 0; i < NR_WRITE; i++) { + err = pthread_create(&tid_writer[i], NULL, thr_writer, + (void *)(long)i); + if (err != 0) + exit(1); + } + + sleep(10); + + for (i = 0; i < NR_READ; i++) { + err = pthread_join(tid_reader[i], &tret); + if (err != 0) + exit(1); + tot_rtime += reader_time[i]; + } + for (i = 0; i < NR_WRITE; i++) { + err = pthread_join(tid_writer[i], &tret); + if (err != 0) + exit(1); + tot_wtime += writer_time[i]; + } + free(test_rcu_pointer); + printf("Time per read : %g cycles\n", + (double)tot_rtime / ((double)NR_READ * (double)READ_LOOP)); + printf("Time per write : %g cycles\n", + (double)tot_wtime / ((double)NR_WRITE * (double)WRITE_LOOP)); + + free(reader_time); + free(writer_time); + free(tid_reader); + free(tid_writer); + + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_wfcq.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_wfcq.c new file mode 100644 index 0000000000000..71bca100cd456 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_wfcq.c @@ -0,0 +1,560 @@ +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2010 Paolo Bonzini +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - example RCU-based lock-free concurrent queue + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include "thread-id.h" + +/* hardcoded number of CPUs */ +#define NR_CPUS 16384 + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif +#include + +enum test_sync { + TEST_SYNC_NONE = 0, + TEST_SYNC_MUTEX, +}; + +static enum test_sync test_sync; + +static int test_force_sync; + +static volatile int test_stop_enqueue, test_stop_dequeue; + +static unsigned long rduration; + +static unsigned long duration; + +/* read-side C.S. duration, in loops */ +static unsigned long wdelay; + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +static int verbose_mode; + +static int test_dequeue, test_splice, test_wait_empty; +static unsigned int test_enqueue_stopped; + +#define printf_verbose(fmt, args...) \ + do { \ + if (verbose_mode) \ + printf(fmt, ## args); \ + } while (0) + +static unsigned int cpu_affinities[NR_CPUS]; +static unsigned int next_aff = 0; +static int use_affinity = 0; + +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void set_affinity(void) +{ +#ifdef HAVE_SCHED_SETAFFINITY + cpu_set_t mask; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ + + if (!use_affinity) + return; + +#ifdef HAVE_SCHED_SETAFFINITY + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +#endif /* HAVE_SCHED_SETAFFINITY */ +} + +/* + * returns 0 if test should end. + */ +static int test_duration_dequeue(void) +{ + return !uatomic_load(&test_stop_dequeue, CMM_RELAXED); +} + +static int test_duration_enqueue(void) +{ + return !uatomic_load(&test_stop_enqueue, CMM_RELAXED); +} + +static DEFINE_URCU_TLS(unsigned long long, nr_dequeues); +static DEFINE_URCU_TLS(unsigned long long, nr_enqueues); + +static DEFINE_URCU_TLS(unsigned long long, nr_successful_dequeues); +static DEFINE_URCU_TLS(unsigned long long, nr_successful_enqueues); +static DEFINE_URCU_TLS(unsigned long long, nr_empty_dest_enqueues); +static DEFINE_URCU_TLS(unsigned long long, nr_splice); +static DEFINE_URCU_TLS(unsigned long long, nr_dequeue_last); + +static unsigned int nr_enqueuers; +static unsigned int nr_dequeuers; + +static struct cds_wfcq_head __attribute__((aligned(CAA_CACHE_LINE_SIZE))) head; +static struct cds_wfcq_tail __attribute__((aligned(CAA_CACHE_LINE_SIZE))) tail; + +static void *thr_enqueuer(void *_count) +{ + unsigned long long *count = _count; + bool was_nonempty; + + printf_verbose("thread_begin %s, tid %lu\n", + "enqueuer", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + for (;;) { + struct cds_wfcq_node *node = malloc(sizeof(*node)); + if (!node) + goto fail; + cds_wfcq_node_init(node); + was_nonempty = cds_wfcq_enqueue(&head, &tail, node); + URCU_TLS(nr_successful_enqueues)++; + if (!was_nonempty) + URCU_TLS(nr_empty_dest_enqueues)++; + + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); +fail: + URCU_TLS(nr_enqueues)++; + if (caa_unlikely(!test_duration_enqueue())) + break; + } + + uatomic_inc(&test_enqueue_stopped); + count[0] = URCU_TLS(nr_enqueues); + count[1] = URCU_TLS(nr_successful_enqueues); + count[2] = URCU_TLS(nr_empty_dest_enqueues); + printf_verbose("enqueuer thread_end, tid %lu, " + "enqueues %llu successful_enqueues %llu, " + "empty_dest_enqueues %llu\n", + urcu_get_thread_id(), + URCU_TLS(nr_enqueues), + URCU_TLS(nr_successful_enqueues), + URCU_TLS(nr_empty_dest_enqueues)); + return ((void*)1); + +} + +static void do_test_dequeue(enum test_sync sync) +{ + struct cds_wfcq_node *node; + int state; + + if (sync == TEST_SYNC_MUTEX) + node = cds_wfcq_dequeue_with_state_blocking(&head, &tail, + &state); + else + node = __cds_wfcq_dequeue_with_state_blocking(&head, &tail, + &state); + + if (state & CDS_WFCQ_STATE_LAST) + URCU_TLS(nr_dequeue_last)++; + + if (node) { + free(node); + URCU_TLS(nr_successful_dequeues)++; + } + URCU_TLS(nr_dequeues)++; +} + +static void do_test_splice(enum test_sync sync) +{ + struct cds_wfcq_head tmp_head; + struct cds_wfcq_tail tmp_tail; + struct cds_wfcq_node *node, *n; + enum cds_wfcq_ret ret; + + cds_wfcq_init(&tmp_head, &tmp_tail); + + if (sync == TEST_SYNC_MUTEX) + ret = cds_wfcq_splice_blocking(&tmp_head, &tmp_tail, + &head, &tail); + else + ret = __cds_wfcq_splice_blocking(&tmp_head, &tmp_tail, + &head, &tail); + + switch (ret) { + case CDS_WFCQ_RET_WOULDBLOCK: + urcu_posix_assert(0); /* blocking call */ + break; + case CDS_WFCQ_RET_DEST_EMPTY: + URCU_TLS(nr_splice)++; + URCU_TLS(nr_dequeue_last)++; + /* ok */ + break; + case CDS_WFCQ_RET_DEST_NON_EMPTY: + urcu_posix_assert(0); /* entirely unexpected */ + break; + case CDS_WFCQ_RET_SRC_EMPTY: + /* ok, we could even skip iteration on dest if we wanted */ + break; + } + + __cds_wfcq_for_each_blocking_safe(&tmp_head, &tmp_tail, node, n) { + free(node); + URCU_TLS(nr_successful_dequeues)++; + URCU_TLS(nr_dequeues)++; + } + cds_wfcq_destroy(&tmp_head, &tmp_tail); +} + +static void *thr_dequeuer(void *_count) +{ + unsigned long long *count = _count; + unsigned int counter = 0; + + printf_verbose("thread_begin %s, tid %lu\n", + "dequeuer", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + for (;;) { + if (test_dequeue && test_splice) { + if (counter & 1) + do_test_dequeue(test_sync); + else + do_test_splice(test_sync); + counter++; + } else { + if (test_dequeue) + do_test_dequeue(test_sync); + else + do_test_splice(test_sync); + } + if (caa_unlikely(!test_duration_dequeue())) + break; + if (caa_unlikely(rduration)) + loop_sleep(rduration); + } + + printf_verbose("dequeuer thread_end, tid %lu, " + "dequeues %llu, successful_dequeues %llu, " + "nr_splice %llu\n", + urcu_get_thread_id(), + URCU_TLS(nr_dequeues), URCU_TLS(nr_successful_dequeues), + URCU_TLS(nr_splice)); + count[0] = URCU_TLS(nr_dequeues); + count[1] = URCU_TLS(nr_successful_dequeues); + count[2] = URCU_TLS(nr_splice); + count[3] = URCU_TLS(nr_dequeue_last); + return ((void*)2); +} + +static void test_end(unsigned long long *nr_dequeues_l, + unsigned long long *nr_dequeue_last_l) +{ + struct cds_wfcq_node *node; + int state; + + do { + node = cds_wfcq_dequeue_with_state_blocking(&head, &tail, + &state); + if (node) { + if (state & CDS_WFCQ_STATE_LAST) + (*nr_dequeue_last_l)++; + free(node); + (*nr_dequeues_l)++; + } + } while (node); +} + +static void show_usage(char **argv) +{ + printf("Usage : %s nr_dequeuers nr_enqueuers duration (s) \n", + argv[0]); + printf("OPTIONS:\n"); + printf(" [-d delay] (enqueuer period (in loops))\n"); + printf(" [-c duration] (dequeuer period (in loops))\n"); + printf(" [-v] (verbose output)\n"); + printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); + printf(" [-q] (test dequeue)\n"); + printf(" [-s] (test splice, enabled by default)\n"); + printf(" [-M] (use mutex external synchronization)\n"); + printf(" Note: default: no external synchronization used.\n"); + printf(" [-f] (force user-provided synchronization)\n"); + printf(" [-w] Wait for dequeuer to empty queue\n"); + printf("\n"); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_enqueuer, *tid_dequeuer; + void *tret; + unsigned long long *count_enqueuer, *count_dequeuer; + unsigned long long tot_enqueues = 0, tot_dequeues = 0; + unsigned long long tot_successful_enqueues = 0, + tot_successful_dequeues = 0, + tot_empty_dest_enqueues = 0, + tot_splice = 0, tot_dequeue_last = 0; + unsigned long long end_dequeues = 0; + int i, a, retval = 0; + unsigned int i_thr; + + if (argc < 4) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[1], "%u", &nr_dequeuers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[2], "%u", &nr_enqueuers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[3], "%lu", &duration); + if (err != 1) { + show_usage(argv); + return -1; + } + + for (i = 4; i < argc; i++) { + if (argv[i][0] != '-') + continue; + switch (argv[i][1]) { + case 'a': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + a = atoi(argv[++i]); + cpu_affinities[next_aff++] = a; + use_affinity = 1; + printf_verbose("Adding CPU %d affinity\n", a); + break; + case 'c': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + rduration = atol(argv[++i]); + break; + case 'd': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wdelay = atol(argv[++i]); + break; + case 'v': + verbose_mode = 1; + break; + case 'q': + test_dequeue = 1; + break; + case 's': + test_splice = 1; + break; + case 'M': + test_sync = TEST_SYNC_MUTEX; + break; + case 'w': + test_wait_empty = 1; + break; + case 'f': + test_force_sync = 1; + break; + } + } + + /* activate splice test by default */ + if (!test_dequeue && !test_splice) + test_splice = 1; + + if (test_sync == TEST_SYNC_NONE && nr_dequeuers > 1 && test_dequeue) { + if (test_force_sync) { + fprintf(stderr, "[WARNING] Using dequeue concurrently " + "with other dequeue or splice without external " + "synchronization. Expect run-time failure.\n"); + } else { + printf("Enforcing mutex synchronization\n"); + test_sync = TEST_SYNC_MUTEX; + } + } + + printf_verbose("running test for %lu seconds, %u enqueuers, " + "%u dequeuers.\n", + duration, nr_enqueuers, nr_dequeuers); + if (test_dequeue) + printf_verbose("dequeue test activated.\n"); + else + printf_verbose("splice test activated.\n"); + if (test_sync == TEST_SYNC_MUTEX) + printf_verbose("External sync: mutex.\n"); + else + printf_verbose("External sync: none.\n"); + if (test_wait_empty) + printf_verbose("Wait for dequeuers to empty queue.\n"); + printf_verbose("Writer delay : %lu loops.\n", rduration); + printf_verbose("Reader duration : %lu loops.\n", wdelay); + printf_verbose("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + tid_enqueuer = calloc(nr_enqueuers, sizeof(*tid_enqueuer)); + tid_dequeuer = calloc(nr_dequeuers, sizeof(*tid_dequeuer)); + count_enqueuer = calloc(nr_enqueuers, 3 * sizeof(*count_enqueuer)); + count_dequeuer = calloc(nr_dequeuers, 4 * sizeof(*count_dequeuer)); + cds_wfcq_init(&head, &tail); + + next_aff = 0; + + for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) { + err = pthread_create(&tid_enqueuer[i_thr], NULL, thr_enqueuer, + &count_enqueuer[3 * i_thr]); + if (err != 0) + exit(1); + } + for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) { + err = pthread_create(&tid_dequeuer[i_thr], NULL, thr_dequeuer, + &count_dequeuer[4 * i_thr]); + if (err != 0) + exit(1); + } + + cmm_smp_mb(); + + begin_test(); + + for (i_thr = 0; i_thr < duration; i_thr++) { + sleep(1); + if (verbose_mode) { + fwrite(".", sizeof(char), 1, stdout); + fflush(stdout); + } + } + + uatomic_store(&test_stop_enqueue, 1, CMM_RELEASE); + + if (test_wait_empty) { + while (nr_enqueuers != uatomic_read(&test_enqueue_stopped)) { + sleep(1); + } + while (!cds_wfcq_empty(&head, &tail)) { + sleep(1); + } + } + + uatomic_store(&test_stop_dequeue, 1, CMM_RELAXED); + + for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) { + err = pthread_join(tid_enqueuer[i_thr], &tret); + if (err != 0) + exit(1); + tot_enqueues += count_enqueuer[3 * i_thr]; + tot_successful_enqueues += count_enqueuer[3 * i_thr + 1]; + tot_empty_dest_enqueues += count_enqueuer[3 * i_thr + 2]; + } + for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) { + err = pthread_join(tid_dequeuer[i_thr], &tret); + if (err != 0) + exit(1); + tot_dequeues += count_dequeuer[4 * i_thr]; + tot_successful_dequeues += count_dequeuer[4 * i_thr + 1]; + tot_splice += count_dequeuer[4 * i_thr + 2]; + tot_dequeue_last += count_dequeuer[4 * i_thr + 3]; + } + + test_end(&end_dequeues, &tot_dequeue_last); + + printf_verbose("total number of enqueues : %llu, dequeues %llu\n", + tot_enqueues, tot_dequeues); + printf_verbose("total number of successful enqueues : %llu, " + "enqueues to empty dest : %llu, " + "successful dequeues %llu, " + "splice : %llu, dequeue_last : %llu\n", + tot_successful_enqueues, + tot_empty_dest_enqueues, + tot_successful_dequeues, + tot_splice, tot_dequeue_last); + printf("SUMMARY %-25s testdur %4lu nr_enqueuers %3u wdelay %6lu " + "nr_dequeuers %3u " + "rdur %6lu nr_enqueues %12llu nr_dequeues %12llu " + "successful enqueues %12llu enqueues to empty dest %12llu " + "successful dequeues %12llu splice %12llu " + "dequeue_last %llu " + "end_dequeues %llu nr_ops %12llu\n", + argv[0], duration, nr_enqueuers, wdelay, + nr_dequeuers, rduration, tot_enqueues, tot_dequeues, + tot_successful_enqueues, + tot_empty_dest_enqueues, + tot_successful_dequeues, tot_splice, tot_dequeue_last, + end_dequeues, + tot_enqueues + tot_dequeues); + + if (tot_successful_enqueues != tot_successful_dequeues + end_dequeues) { + printf("WARNING! Discrepancy between nr succ. enqueues %llu vs " + "succ. dequeues + end dequeues %llu.\n", + tot_successful_enqueues, + tot_successful_dequeues + end_dequeues); + retval = 1; + } + + /* + * If only using splice to dequeue, the enqueuer should see + * exactly as many empty queues than the number of non-empty + * src splice. + */ + if (tot_empty_dest_enqueues != tot_dequeue_last) { + printf("WARNING! Discrepancy between empty enqueue (%llu) and " + "number of dequeue of last element (%llu)\n", + tot_empty_dest_enqueues, + tot_dequeue_last); + retval = 1; + } + cds_wfcq_destroy(&head, &tail); + free(count_enqueuer); + free(count_dequeuer); + free(tid_enqueuer); + free(tid_dequeuer); + + return retval; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_wfq.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_wfq.c new file mode 100644 index 0000000000000..b17df5ac37787 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_wfq.c @@ -0,0 +1,381 @@ +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2010 Paolo Bonzini +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - example RCU-based lock-free queue + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "thread-id.h" + +/* hardcoded number of CPUs */ +#define NR_CPUS 16384 + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif + +/* Remove deprecation warnings from test build. */ +#define CDS_WFQ_DEPRECATED + +#include +#include + +static unsigned long rduration; + +static unsigned long duration; + +/* read-side C.S. duration, in loops */ +static unsigned long wdelay; + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +static int verbose_mode; + +#define printf_verbose(fmt, args...) \ + do { \ + if (verbose_mode) \ + printf(fmt, args); \ + } while (0) + +static unsigned int cpu_affinities[NR_CPUS]; +static unsigned int next_aff = 0; +static int use_affinity = 0; + +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void set_affinity(void) +{ +#ifdef HAVE_SCHED_SETAFFINITY + cpu_set_t mask; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ + + if (!use_affinity) + return; + +#ifdef HAVE_SCHED_SETAFFINITY + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +#endif /* HAVE_SCHED_SETAFFINITY */ +} + +/* + * returns 0 if test should end. + */ +static int test_duration_dequeue(void) +{ + return test_duration_read(); +} + +static int test_duration_enqueue(void) +{ + return test_duration_write(); +} + +static DEFINE_URCU_TLS(unsigned long long, nr_dequeues); +static DEFINE_URCU_TLS(unsigned long long, nr_enqueues); + +static DEFINE_URCU_TLS(unsigned long long, nr_successful_dequeues); +static DEFINE_URCU_TLS(unsigned long long, nr_successful_enqueues); + +static unsigned int nr_enqueuers; +static unsigned int nr_dequeuers; + +static struct cds_wfq_queue q; + +static +void *thr_enqueuer(void *_count) +{ + unsigned long long *count = _count; + + printf_verbose("thread_begin %s, tid %lu\n", + "enqueuer", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + for (;;) { + struct cds_wfq_node *node = malloc(sizeof(*node)); + if (!node) + goto fail; + cds_wfq_node_init(node); + cds_wfq_enqueue(&q, node); + URCU_TLS(nr_successful_enqueues)++; + + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); +fail: + URCU_TLS(nr_enqueues)++; + if (caa_unlikely(!test_duration_enqueue())) + break; + } + + count[0] = URCU_TLS(nr_enqueues); + count[1] = URCU_TLS(nr_successful_enqueues); + printf_verbose("enqueuer thread_end, tid %lu, " + "enqueues %llu successful_enqueues %llu\n", + urcu_get_thread_id(), + URCU_TLS(nr_enqueues), + URCU_TLS(nr_successful_enqueues)); + return ((void*)1); + +} + +static +void *thr_dequeuer(void *_count) +{ + unsigned long long *count = _count; + + printf_verbose("thread_begin %s, tid %lu\n", + "dequeuer", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + for (;;) { + struct cds_wfq_node *node = cds_wfq_dequeue_blocking(&q); + + if (node) { + free(node); + URCU_TLS(nr_successful_dequeues)++; + } + + URCU_TLS(nr_dequeues)++; + if (caa_unlikely(!test_duration_dequeue())) + break; + if (caa_unlikely(rduration)) + loop_sleep(rduration); + } + + printf_verbose("dequeuer thread_end, tid %lu, " + "dequeues %llu, successful_dequeues %llu\n", + urcu_get_thread_id(), + URCU_TLS(nr_dequeues), + URCU_TLS(nr_successful_dequeues)); + count[0] = URCU_TLS(nr_dequeues); + count[1] = URCU_TLS(nr_successful_dequeues); + return ((void*)2); +} + +static +void test_end(unsigned long long *nr_dequeues_l) +{ + struct cds_wfq_node *node; + + do { + node = cds_wfq_dequeue_blocking(&q); + if (node) { + free(node); + (*nr_dequeues_l)++; + } + } while (node); +} + +static +void show_usage(char **argv) +{ + printf("Usage : %s nr_dequeuers nr_enqueuers duration (s) \n", + argv[0]); + printf("OPTIONS:\n"); + printf(" [-d delay] (enqueuer period (in loops))\n"); + printf(" [-c duration] (dequeuer period (in loops))\n"); + printf(" [-v] (verbose output)\n"); + printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); + printf("\n"); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_enqueuer, *tid_dequeuer; + void *tret; + unsigned long long *count_enqueuer, *count_dequeuer; + unsigned long long tot_enqueues = 0, tot_dequeues = 0; + unsigned long long tot_successful_enqueues = 0, + tot_successful_dequeues = 0; + unsigned long long end_dequeues = 0; + int i, a; + unsigned int i_thr; + + if (argc < 4) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[1], "%u", &nr_dequeuers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[2], "%u", &nr_enqueuers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[3], "%lu", &duration); + if (err != 1) { + show_usage(argv); + return -1; + } + + for (i = 4; i < argc; i++) { + if (argv[i][0] != '-') + continue; + switch (argv[i][1]) { + case 'a': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + a = atoi(argv[++i]); + cpu_affinities[next_aff++] = a; + use_affinity = 1; + printf_verbose("Adding CPU %d affinity\n", a); + break; + case 'c': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + rduration = atol(argv[++i]); + break; + case 'd': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wdelay = atol(argv[++i]); + break; + case 'v': + verbose_mode = 1; + break; + } + } + + printf_verbose("running test for %lu seconds, %u enqueuers, " + "%u dequeuers.\n", + duration, nr_enqueuers, nr_dequeuers); + printf_verbose("Writer delay : %lu loops.\n", rduration); + printf_verbose("Reader duration : %lu loops.\n", wdelay); + printf_verbose("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + tid_enqueuer = calloc(nr_enqueuers, sizeof(*tid_enqueuer)); + tid_dequeuer = calloc(nr_dequeuers, sizeof(*tid_dequeuer)); + count_enqueuer = calloc(nr_enqueuers, 2 * sizeof(*count_enqueuer)); + count_dequeuer = calloc(nr_dequeuers, 2 * sizeof(*count_dequeuer)); + cds_wfq_init(&q); + + next_aff = 0; + + for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) { + err = pthread_create(&tid_enqueuer[i_thr], NULL, thr_enqueuer, + &count_enqueuer[2 * i_thr]); + if (err != 0) + exit(1); + } + for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) { + err = pthread_create(&tid_dequeuer[i_thr], NULL, thr_dequeuer, + &count_dequeuer[2 * i_thr]); + if (err != 0) + exit(1); + } + + cmm_smp_mb(); + + begin_test(); + + for (i_thr = 0; i_thr < duration; i_thr++) { + sleep(1); + if (verbose_mode) { + fwrite(".", sizeof(char), 1, stdout); + fflush(stdout); + } + } + + end_test(); + + for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) { + err = pthread_join(tid_enqueuer[i_thr], &tret); + if (err != 0) + exit(1); + tot_enqueues += count_enqueuer[2 * i_thr]; + tot_successful_enqueues += count_enqueuer[2 * i_thr + 1]; + } + for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) { + err = pthread_join(tid_dequeuer[i_thr], &tret); + if (err != 0) + exit(1); + tot_dequeues += count_dequeuer[2 * i_thr]; + tot_successful_dequeues += count_dequeuer[2 * i_thr + 1]; + } + + test_end(&end_dequeues); + + printf_verbose("total number of enqueues : %llu, dequeues %llu\n", + tot_enqueues, tot_dequeues); + printf_verbose("total number of successful enqueues : %llu, " + "successful dequeues %llu\n", + tot_successful_enqueues, tot_successful_dequeues); + printf("SUMMARY %-25s testdur %4lu nr_enqueuers %3u wdelay %6lu " + "nr_dequeuers %3u " + "rdur %6lu nr_enqueues %12llu nr_dequeues %12llu " + "successful enqueues %12llu successful dequeues %12llu " + "end_dequeues %llu nr_ops %12llu\n", + argv[0], duration, nr_enqueuers, wdelay, + nr_dequeuers, rduration, tot_enqueues, tot_dequeues, + tot_successful_enqueues, + tot_successful_dequeues, end_dequeues, + tot_enqueues + tot_dequeues); + if (tot_successful_enqueues != tot_successful_dequeues + end_dequeues) + printf("WARNING! Discrepancy between nr succ. enqueues %llu vs " + "succ. dequeues + end dequeues %llu.\n", + tot_successful_enqueues, + tot_successful_dequeues + end_dequeues); + + cds_wfq_destroy(&q); + free(count_enqueuer); + free(count_dequeuer); + free(tid_enqueuer); + free(tid_dequeuer); + + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_wfs.c b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_wfs.c new file mode 100644 index 0000000000000..39704f4acb5cc --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/test_urcu_wfs.c @@ -0,0 +1,544 @@ +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2010 Paolo Bonzini +// +// SPDX-License-Identifier: GPL-2.0-or-later + + /* + * Userspace RCU library - example RCU-based lock-free stack + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include "thread-id.h" + +/* hardcoded number of CPUs */ +#define NR_CPUS 16384 + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif +#include + +/* + * External synchronization used. + */ +enum test_sync { + TEST_SYNC_NONE = 0, + TEST_SYNC_MUTEX, +}; + +static enum test_sync test_sync; + +static int test_force_sync; + +static volatile int test_stop_enqueue, test_stop_dequeue; + +static unsigned long rduration; + +static unsigned long duration; + +/* read-side C.S. duration, in loops */ +static unsigned long wdelay; + +static inline void loop_sleep(unsigned long loops) +{ + while (loops-- != 0) + caa_cpu_relax(); +} + +static int verbose_mode; + +static int test_pop, test_pop_all, test_wait_empty; +static unsigned int test_enqueue_stopped; + +#define printf_verbose(fmt, args...) \ + do { \ + if (verbose_mode) \ + printf(fmt, ## args); \ + } while (0) + +static unsigned int cpu_affinities[NR_CPUS]; +static unsigned int next_aff = 0; +static int use_affinity = 0; + +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void set_affinity(void) +{ +#ifdef HAVE_SCHED_SETAFFINITY + cpu_set_t mask; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ + + if (!use_affinity) + return; + +#ifdef HAVE_SCHED_SETAFFINITY + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } + cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } + + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +#endif /* HAVE_SCHED_SETAFFINITY */ +} + +/* + * returns 0 if test should end. + */ +static int test_duration_dequeue(void) +{ + return !uatomic_load(&test_stop_dequeue, CMM_RELAXED); +} + +static int test_duration_enqueue(void) +{ + return !uatomic_load(&test_stop_enqueue, CMM_RELAXED); +} + +static DEFINE_URCU_TLS(unsigned long long, nr_dequeues); +static DEFINE_URCU_TLS(unsigned long long, nr_enqueues); + +static DEFINE_URCU_TLS(unsigned long long, nr_successful_dequeues); +static DEFINE_URCU_TLS(unsigned long long, nr_successful_enqueues); +static DEFINE_URCU_TLS(unsigned long long, nr_empty_dest_enqueues); +static DEFINE_URCU_TLS(unsigned long long, nr_pop_all); +static DEFINE_URCU_TLS(unsigned long long, nr_pop_last); + +static unsigned int nr_enqueuers; +static unsigned int nr_dequeuers; + +static struct cds_wfs_stack s; + +static void *thr_enqueuer(void *_count) +{ + unsigned long long *count = _count; + bool was_nonempty; + + printf_verbose("thread_begin %s, tid %lu\n", + "enqueuer", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + for (;;) { + struct cds_wfs_node *node = malloc(sizeof(*node)); + if (!node) + goto fail; + cds_wfs_node_init(node); + was_nonempty = cds_wfs_push(&s, node); + URCU_TLS(nr_successful_enqueues)++; + if (!was_nonempty) + URCU_TLS(nr_empty_dest_enqueues)++; + + if (caa_unlikely(wdelay)) + loop_sleep(wdelay); +fail: + URCU_TLS(nr_enqueues)++; + if (caa_unlikely(!test_duration_enqueue())) + break; + } + + uatomic_inc(&test_enqueue_stopped); + count[0] = URCU_TLS(nr_enqueues); + count[1] = URCU_TLS(nr_successful_enqueues); + count[2] = URCU_TLS(nr_empty_dest_enqueues); + printf_verbose("enqueuer thread_end, tid %lu, " + "enqueues %llu successful_enqueues %llu, " + "empty_dest_enqueues %llu\n", + urcu_get_thread_id(), + URCU_TLS(nr_enqueues), + URCU_TLS(nr_successful_enqueues), + URCU_TLS(nr_empty_dest_enqueues)); + return ((void*)1); + +} + +static void do_test_pop(enum test_sync sync) +{ + struct cds_wfs_node *node; + int state; + + if (sync == TEST_SYNC_MUTEX) + cds_wfs_pop_lock(&s); + node = __cds_wfs_pop_with_state_blocking(&s, &state); + if (sync == TEST_SYNC_MUTEX) + cds_wfs_pop_unlock(&s); + + if (node) { + if (state & CDS_WFS_STATE_LAST) + URCU_TLS(nr_pop_last)++; + free(node); + URCU_TLS(nr_successful_dequeues)++; + } + URCU_TLS(nr_dequeues)++; +} + +static void do_test_pop_all(enum test_sync sync) +{ + struct cds_wfs_head *head; + struct cds_wfs_node *node, *n; + + if (sync == TEST_SYNC_MUTEX) + cds_wfs_pop_lock(&s); + head = __cds_wfs_pop_all(&s); + if (sync == TEST_SYNC_MUTEX) + cds_wfs_pop_unlock(&s); + + /* Check if empty */ + if (cds_wfs_first(head) == NULL) + return; + + URCU_TLS(nr_pop_all)++; + URCU_TLS(nr_pop_last)++; + + cds_wfs_for_each_blocking_safe(head, node, n) { + free(node); + URCU_TLS(nr_successful_dequeues)++; + URCU_TLS(nr_dequeues)++; + } +} + +static void *thr_dequeuer(void *_count) +{ + unsigned long long *count = _count; + unsigned int counter = 0; + + printf_verbose("thread_begin %s, tid %lu\n", + "dequeuer", urcu_get_thread_id()); + + set_affinity(); + + wait_until_go(); + + urcu_posix_assert(test_pop || test_pop_all); + + for (;;) { + if (test_pop && test_pop_all) { + if (counter & 1) + do_test_pop(test_sync); + else + do_test_pop_all(test_sync); + counter++; + } else { + if (test_pop) + do_test_pop(test_sync); + else + do_test_pop_all(test_sync); + } + + if (caa_unlikely(!test_duration_dequeue())) + break; + if (caa_unlikely(rduration)) + loop_sleep(rduration); + } + + printf_verbose("dequeuer thread_end, tid %lu, " + "dequeues %llu, successful_dequeues %llu " + "pop_all %llu pop_last %llu\n", + urcu_get_thread_id(), + URCU_TLS(nr_dequeues), URCU_TLS(nr_successful_dequeues), + URCU_TLS(nr_pop_all), + URCU_TLS(nr_pop_last)); + count[0] = URCU_TLS(nr_dequeues); + count[1] = URCU_TLS(nr_successful_dequeues); + count[2] = URCU_TLS(nr_pop_all); + count[3] = URCU_TLS(nr_pop_last); + return ((void*)2); +} + +static void test_end(unsigned long long *nr_dequeues_l, + unsigned long long *nr_pop_last_l) +{ + struct cds_wfs_node *node; + int state; + + do { + node = cds_wfs_pop_with_state_blocking(&s, &state); + if (node) { + if (state & CDS_WFS_STATE_LAST) + (*nr_pop_last_l)++; + free(node); + (*nr_dequeues_l)++; + } + } while (node); +} + +static void show_usage(char **argv) +{ + printf("Usage : %s nr_dequeuers nr_enqueuers duration (s) \n", + argv[0]); + printf("OPTIONS:\n"); + printf(" [-d delay] (enqueuer period (in loops))\n"); + printf(" [-c duration] (dequeuer period (in loops))\n"); + printf(" [-v] (verbose output)\n"); + printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); + printf(" [-p] (test pop)\n"); + printf(" [-P] (test pop_all, enabled by default)\n"); + printf(" [-M] (use mutex external synchronization)\n"); + printf(" Note: default: no external synchronization used.\n"); + printf(" [-f] (force user-provided synchronization)\n"); + printf(" [-w] Wait for dequeuer to empty stack\n"); + printf("\n"); +} + +int main(int argc, char **argv) +{ + int err; + pthread_t *tid_enqueuer, *tid_dequeuer; + void *tret; + unsigned long long *count_enqueuer, *count_dequeuer; + unsigned long long tot_enqueues = 0, tot_dequeues = 0; + unsigned long long tot_successful_enqueues = 0, + tot_successful_dequeues = 0, + tot_empty_dest_enqueues = 0, + tot_pop_all = 0, tot_pop_last = 0; + unsigned long long end_dequeues = 0; + int i, a, retval = 0; + unsigned int i_thr; + + if (argc < 4) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[1], "%u", &nr_dequeuers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[2], "%u", &nr_enqueuers); + if (err != 1) { + show_usage(argv); + return -1; + } + + err = sscanf(argv[3], "%lu", &duration); + if (err != 1) { + show_usage(argv); + return -1; + } + + for (i = 4; i < argc; i++) { + if (argv[i][0] != '-') + continue; + switch (argv[i][1]) { + case 'a': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + a = atoi(argv[++i]); + cpu_affinities[next_aff++] = a; + use_affinity = 1; + printf_verbose("Adding CPU %d affinity\n", a); + break; + case 'c': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + rduration = atol(argv[++i]); + break; + case 'd': + if (argc < i + 2) { + show_usage(argv); + return -1; + } + wdelay = atol(argv[++i]); + break; + case 'v': + verbose_mode = 1; + break; + case 'p': + test_pop = 1; + break; + case 'P': + test_pop_all = 1; + break; + case 'M': + test_sync = TEST_SYNC_MUTEX; + break; + case 'w': + test_wait_empty = 1; + break; + case 'f': + test_force_sync = 1; + break; + } + } + + /* activate pop_all test by default */ + if (!test_pop && !test_pop_all) + test_pop_all = 1; + + if (test_sync == TEST_SYNC_NONE && nr_dequeuers > 1 && test_pop) { + if (test_force_sync) { + fprintf(stderr, "[WARNING] Using pop concurrently " + "with other pop or pop_all without external " + "synchronization. Expect run-time failure.\n"); + } else { + printf("Enforcing mutex synchronization\n"); + test_sync = TEST_SYNC_MUTEX; + } + } + + printf_verbose("running test for %lu seconds, %u enqueuers, " + "%u dequeuers.\n", + duration, nr_enqueuers, nr_dequeuers); + if (test_pop) + printf_verbose("pop test activated.\n"); + if (test_pop_all) + printf_verbose("pop_all test activated.\n"); + if (test_sync == TEST_SYNC_MUTEX) + printf_verbose("External sync: mutex.\n"); + else + printf_verbose("External sync: none.\n"); + if (test_wait_empty) + printf_verbose("Wait for dequeuers to empty stack.\n"); + printf_verbose("Writer delay : %lu loops.\n", rduration); + printf_verbose("Reader duration : %lu loops.\n", wdelay); + printf_verbose("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); + + tid_enqueuer = calloc(nr_enqueuers, sizeof(*tid_enqueuer)); + tid_dequeuer = calloc(nr_dequeuers, sizeof(*tid_dequeuer)); + count_enqueuer = calloc(nr_enqueuers, 3 * sizeof(*count_enqueuer)); + count_dequeuer = calloc(nr_dequeuers, 4 * sizeof(*count_dequeuer)); + cds_wfs_init(&s); + + next_aff = 0; + + for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) { + err = pthread_create(&tid_enqueuer[i], NULL, thr_enqueuer, + &count_enqueuer[3 * i_thr]); + if (err != 0) + exit(1); + } + for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) { + err = pthread_create(&tid_dequeuer[i_thr], NULL, thr_dequeuer, + &count_dequeuer[4 * i_thr]); + if (err != 0) + exit(1); + } + + cmm_smp_mb(); + + begin_test(); + + for (i_thr = 0; i_thr < duration; i_thr++) { + sleep(1); + if (verbose_mode) { + fwrite(".", sizeof(char), 1, stdout); + fflush(stdout); + } + } + + uatomic_store(&test_stop_enqueue, 1, CMM_RELEASE); + + if (test_wait_empty) { + while (nr_enqueuers != uatomic_read(&test_enqueue_stopped)) { + sleep(1); + } + while (!cds_wfs_empty(&s)) { + sleep(1); + } + } + + uatomic_store(&test_stop_dequeue, 1, CMM_RELAXED); + + for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) { + err = pthread_join(tid_enqueuer[i_thr], &tret); + if (err != 0) + exit(1); + tot_enqueues += count_enqueuer[3 * i_thr]; + tot_successful_enqueues += count_enqueuer[3 * i_thr + 1]; + tot_empty_dest_enqueues += count_enqueuer[3 * i_thr + 2]; + } + for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) { + err = pthread_join(tid_dequeuer[i_thr], &tret); + if (err != 0) + exit(1); + tot_dequeues += count_dequeuer[4 * i_thr]; + tot_successful_dequeues += count_dequeuer[4 * i_thr + 1]; + tot_pop_all += count_dequeuer[4 * i_thr + 2]; + tot_pop_last += count_dequeuer[4 * i_thr + 3]; + } + + test_end(&end_dequeues, &tot_pop_last); + + printf_verbose("total number of enqueues : %llu, dequeues %llu\n", + tot_enqueues, tot_dequeues); + printf_verbose("total number of successful enqueues : %llu, " + "enqueues to empty dest : %llu, " + "successful dequeues %llu, " + "pop_all : %llu, pop_last : %llu\n", + tot_successful_enqueues, + tot_empty_dest_enqueues, + tot_successful_dequeues, + tot_pop_all, tot_pop_last); + printf("SUMMARY %-25s testdur %4lu nr_enqueuers %3u wdelay %6lu " + "nr_dequeuers %3u " + "rdur %6lu nr_enqueues %12llu nr_dequeues %12llu " + "successful enqueues %12llu enqueues to empty dest %12llu " + "successful dequeues %12llu pop_all %12llu " + "pop_last %llu end_dequeues %llu nr_ops %12llu\n", + argv[0], duration, nr_enqueuers, wdelay, + nr_dequeuers, rduration, tot_enqueues, tot_dequeues, + tot_successful_enqueues, + tot_empty_dest_enqueues, + tot_successful_dequeues, tot_pop_all, tot_pop_last, + end_dequeues, + tot_enqueues + tot_dequeues); + if (tot_successful_enqueues != tot_successful_dequeues + end_dequeues) { + printf("WARNING! Discrepancy between nr succ. enqueues %llu vs " + "succ. dequeues + end dequeues %llu.\n", + tot_successful_enqueues, + tot_successful_dequeues + end_dequeues); + retval = 1; + } + /* + * The enqueuer should see exactly as many empty queues than the + * number of non-empty stacks dequeued. + */ + if (tot_empty_dest_enqueues != tot_pop_last) { + printf("WARNING! Discrepancy between empty enqueue (%llu) and " + "number of pop last (%llu)\n", + tot_empty_dest_enqueues, + tot_pop_last); + retval = 1; + } + + cds_wfs_destroy(&s); + free(count_enqueuer); + free(count_dequeuer); + free(tid_enqueuer); + free(tid_dequeuer); + + return retval; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/urcu_1_seconds.tap b/external/lgpl2/userspace-rcu/dist/tests/benchmark/urcu_1_seconds.tap new file mode 100755 index 0000000000000..8d229bfbb3651 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/urcu_1_seconds.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"$URCU_TESTS_SRCDIR/benchmark/run-urcu-tests.sh" 1 diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/urcu_30_seconds.tap b/external/lgpl2/userspace-rcu/dist/tests/benchmark/urcu_30_seconds.tap new file mode 100755 index 0000000000000..da8aae1c5d315 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/urcu_30_seconds.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"$URCU_TESTS_SRCDIR/benchmark/run-urcu-tests.sh" 30 diff --git a/external/lgpl2/userspace-rcu/dist/tests/benchmark/urcu_3_seconds.tap b/external/lgpl2/userspace-rcu/dist/tests/benchmark/urcu_3_seconds.tap new file mode 100755 index 0000000000000..0ec6ebb508d7e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/benchmark/urcu_3_seconds.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"$URCU_TESTS_SRCDIR/benchmark/run-urcu-tests.sh" 3 diff --git a/external/lgpl2/userspace-rcu/dist/tests/common/Makefile.am b/external/lgpl2/userspace-rcu/dist/tests/common/Makefile.am new file mode 100644 index 0000000000000..af6d89f5c9c3f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/common/Makefile.am @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +AM_CPPFLAGS += -I$(top_srcdir)/src -I$(top_srcdir)/tests/common + +noinst_HEADERS = \ + api.h \ + compat-rand.h \ + thread-id.h + +noinst_LTLIBRARIES = libdebug-yield.la + +libdebug_yield_la_SOURCES = debug-yield.c debug-yield.h diff --git a/external/lgpl2/userspace-rcu/dist/tests/common/api.h b/external/lgpl2/userspace-rcu/dist/tests/common/api.h new file mode 100644 index 0000000000000..ec3ce1ef74862 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/common/api.h @@ -0,0 +1,277 @@ +// SPDX-FileCopyrightText: 2006 Paul E. McKenney, IBM. +// +// SPDX-License-Identifier: GPL-2.0-only + +#ifndef _INCLUDE_API_H +#define _INCLUDE_API_H + +/* + * common.h: Common Linux kernel-isms. + * + * Much code taken from the Linux kernel. For such code, the option + * to redistribute under later versions of GPL might not be available. + */ + +#include +#include +#include + +/* + * Machine parameters. + */ + +#define ____cacheline_internodealigned_in_smp \ + __attribute__((__aligned__(CAA_CACHE_LINE_SIZE))) + + +#include +#include +#include +#include +#include +#include +#include +/* #include "atomic.h" */ + +/* + * Exclusive locking primitives. + */ + +typedef pthread_mutex_t spinlock_t; + +#define DEFINE_SPINLOCK(lock) spinlock_t lock = PTHREAD_MUTEX_INITIALIZER; +#define __SPIN_LOCK_UNLOCKED(lockp) PTHREAD_MUTEX_INITIALIZER + +static void spin_lock_init(spinlock_t *sp) +{ + if (pthread_mutex_init(sp, NULL) != 0) { + perror("spin_lock_init:pthread_mutex_init"); + exit(-1); + } +} + +static void spin_lock(spinlock_t *sp) +{ + if (pthread_mutex_lock(sp) != 0) { + perror("spin_lock:pthread_mutex_lock"); + exit(-1); + } +} + +static void spin_unlock(spinlock_t *sp) +{ + if (pthread_mutex_unlock(sp) != 0) { + perror("spin_unlock:pthread_mutex_unlock"); + exit(-1); + } +} + +#define spin_lock_irqsave(l, f) do { f = 1; spin_lock(l); } while (0) +#define spin_unlock_irqrestore(l, f) do { f = 0; spin_unlock(l); } while (0) + +/* + * Thread creation/destruction primitives. + */ + +typedef pthread_t thread_id_t; + +#define NR_THREADS 4096 + +#define __THREAD_ID_MAP_EMPTY ((thread_id_t) 0) +#define __THREAD_ID_MAP_WAITING ((thread_id_t) 1) +thread_id_t __thread_id_map[NR_THREADS]; +spinlock_t __thread_id_map_mutex; + +#define for_each_thread(t) \ + for (t = 0; t < NR_THREADS; t++) + +#define for_each_running_thread(t) \ + for (t = 0; t < NR_THREADS; t++) \ + if ((__thread_id_map[t] != __THREAD_ID_MAP_EMPTY) && \ + (__thread_id_map[t] != __THREAD_ID_MAP_WAITING)) + +#define for_each_tid(t, tid) \ + for (t = 0; t < NR_THREADS; t++) \ + if ((((tid) = __thread_id_map[t]) != __THREAD_ID_MAP_EMPTY) && \ + ((tid) != __THREAD_ID_MAP_WAITING)) + +pthread_key_t thread_id_key; + +static int __smp_thread_id(void) +{ + int i; + thread_id_t tid = pthread_self(); + + for (i = 0; i < NR_THREADS; i++) { + if (uatomic_read(&__thread_id_map[i]) == tid) { + long v = i + 1; /* must be non-NULL. */ + + if (pthread_setspecific(thread_id_key, (void *)v) != 0) { + perror("pthread_setspecific"); + exit(-1); + } + return i; + } + } + spin_lock(&__thread_id_map_mutex); + for (i = 0; i < NR_THREADS; i++) { + if (__thread_id_map[i] == tid) { + spin_unlock(&__thread_id_map_mutex); + return i; + } + } + spin_unlock(&__thread_id_map_mutex); + fprintf(stderr, "smp_thread_id: Rogue thread, id: %lu(%#lx)\n", + (unsigned long) tid, (unsigned long) tid); + exit(-1); +} + +static int smp_thread_id(void) +{ + void *id; + + id = pthread_getspecific(thread_id_key); + if (id == NULL) + return __smp_thread_id(); + return ((long) id - 1); +} + +static thread_id_t create_thread(void *(*func)(void *), void *arg) +{ + thread_id_t tid; + int i; + + spin_lock(&__thread_id_map_mutex); + for (i = 0; i < NR_THREADS; i++) { + if (__thread_id_map[i] == __THREAD_ID_MAP_EMPTY) + break; + } + if (i >= NR_THREADS) { + spin_unlock(&__thread_id_map_mutex); + fprintf(stderr, "Thread limit of %d exceeded!\n", NR_THREADS); + exit(-1); + } + __thread_id_map[i] = __THREAD_ID_MAP_WAITING; + + if (pthread_create(&tid, NULL, func, arg) != 0) { + perror("create_thread:pthread_create"); + exit(-1); + } + uatomic_set(&__thread_id_map[i], tid); + spin_unlock(&__thread_id_map_mutex); + return tid; +} + +static void *wait_thread(thread_id_t tid) +{ + int i; + void *vp; + + for (i = 0; i < NR_THREADS; i++) { + if (uatomic_read(&__thread_id_map[i]) == tid) + break; + } + if (i >= NR_THREADS){ + fprintf(stderr, "wait_thread: bad tid = %lu(%#lx)\n", + (unsigned long)tid, (unsigned long)tid); + exit(-1); + } + if (pthread_join(tid, &vp) != 0) { + perror("wait_thread:pthread_join"); + exit(-1); + } + uatomic_set(&__thread_id_map[i], __THREAD_ID_MAP_EMPTY); + return vp; +} + +static void wait_all_threads(void) +{ + int i; + thread_id_t tid; + + for (i = 1; i < NR_THREADS; i++) { + tid = __thread_id_map[i]; + if (tid != __THREAD_ID_MAP_EMPTY && + tid != __THREAD_ID_MAP_WAITING) + (void)wait_thread(tid); + } +} + +#ifdef HAVE_SCHED_SETAFFINITY +static void run_on(int cpu) +{ + cpu_set_t mask; + + CPU_ZERO(&mask); + CPU_SET(cpu, &mask); + sched_setaffinity(0, sizeof(mask), &mask); +} +#else + +static void run_on(int cpu __attribute__((unused))) +{} +#endif /* HAVE_SCHED_SETAFFINITY */ + +/* + * timekeeping -- very crude -- should use MONOTONIC... + */ + +static inline +long long get_microseconds(void) +{ + struct timeval tv; + + if (gettimeofday(&tv, NULL) != 0) + abort(); + return ((long long)tv.tv_sec) * 1000000LL + (long long)tv.tv_usec; +} + +/* + * Per-thread variables. + */ + +#define DEFINE_PER_THREAD(type, name) \ + struct { \ + __typeof__(type) v \ + __attribute__((__aligned__(CAA_CACHE_LINE_SIZE))); \ + } __per_thread_##name[NR_THREADS] +#define DECLARE_PER_THREAD(type, name) extern DEFINE_PER_THREAD(type, name) + +#define per_thread(name, thread) __per_thread_##name[thread].v +#define __get_thread_var(name) per_thread(name, smp_thread_id()) + +#define init_per_thread(name, v) \ + do { \ + int __i_p_t_i; \ + for (__i_p_t_i = 0; __i_p_t_i < NR_THREADS; __i_p_t_i++) \ + per_thread(name, __i_p_t_i) = v; \ + } while (0) + +DEFINE_PER_THREAD(int, smp_processor_id); + +/* + * Bug checks. + */ + +#define BUG_ON(c) do { if (!(c)) abort(); } while (0) + +/* + * Initialization -- Must be called before calling any primitives. + */ + +static void smp_init(void) +{ + int i; + + spin_lock_init(&__thread_id_map_mutex); + __thread_id_map[0] = pthread_self(); + for (i = 1; i < NR_THREADS; i++) + __thread_id_map[i] = __THREAD_ID_MAP_EMPTY; + init_per_thread(smp_processor_id, 0); + if (pthread_key_create(&thread_id_key, NULL) != 0) { + perror("pthread_key_create"); + exit(-1); + } +} + +#endif diff --git a/external/lgpl2/userspace-rcu/dist/tests/common/compat-rand.h b/external/lgpl2/userspace-rcu/dist/tests/common/compat-rand.h new file mode 100644 index 0000000000000..42fbb30f994ca --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/common/compat-rand.h @@ -0,0 +1,49 @@ +// SPDX-FileCopyrightText: 1996 Ulrich Drepper +// SPDX-FileCopyrightText: 2013 Pierre-Luc St-Charles +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef _COMPAT_RAND_H +#define _COMPAT_RAND_H + +/* + * Userspace RCU library - rand/rand_r Compatibility Header + * + * Note: this file is only used to simplify the code required to + * use the 'rand_r(...)' system function across multiple platforms, + * which might not always be referenced the same way. + */ + +#ifndef HAVE_RAND_R +/* + * Reentrant random function from POSIX.1c. + * Copyright (C) 1996, 1999 Free Software Foundation, Inc. + * This file is part of the GNU C Library. + * Contributed by Ulrich Drepper >, 1996. + */ +static inline int rand_r(unsigned int *seed) +{ + unsigned int next = *seed; + int result; + + next *= 1103515245; + next += 12345; + result = (unsigned int) (next / 65536) % 2048; + + next *= 1103515245; + next += 12345; + result <<= 10; + result ^= (unsigned int) (next / 65536) % 1024; + + next *= 1103515245; + next += 12345; + result <<= 10; + result ^= (unsigned int) (next / 65536) % 1024; + + *seed = next; + + return result; +} +#endif /* HAVE_RAND_R */ + +#endif /* _COMPAT_RAND_H */ diff --git a/external/lgpl2/userspace-rcu/dist/tests/common/debug-yield.c b/external/lgpl2/userspace-rcu/dist/tests/common/debug-yield.c new file mode 100644 index 0000000000000..16205a415aa85 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/common/debug-yield.c @@ -0,0 +1,17 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * Userspace RCU library tests - Debugging code + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#include +#include "debug-yield.h" + +unsigned int rcu_yield_active; + +DEFINE_URCU_TLS(unsigned int, rcu_rand_yield); diff --git a/external/lgpl2/userspace-rcu/dist/tests/common/debug-yield.h b/external/lgpl2/userspace-rcu/dist/tests/common/debug-yield.h new file mode 100644 index 0000000000000..7d4f62ac7e604 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/common/debug-yield.h @@ -0,0 +1,83 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef URCU_TESTS_DEBUG_YIELD_H +#define URCU_TESTS_DEBUG_YIELD_H + +/* + * Userspace RCU library tests - Debugging header + * + * IBM's contributions to this file may be relicensed under LGPLv2 or later. + */ + +#include +#include +#include +#include + +#include + +#define RCU_YIELD_READ (1 << 0) +#define RCU_YIELD_WRITE (1 << 1) + +#define MAX_SLEEP 50 + +extern unsigned int rcu_yield_active; +extern DECLARE_URCU_TLS(unsigned int, rcu_rand_yield); + +#ifdef DEBUG_YIELD +static inline void rcu_debug_yield_read(void) +{ + if (rcu_yield_active & RCU_YIELD_READ) + if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1) + usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP); +} + +static inline void rcu_debug_yield_write(void) +{ + if (rcu_yield_active & RCU_YIELD_WRITE) + if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1) + usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP); +} + +static inline void rcu_debug_yield_enable(unsigned int flags) +{ + rcu_yield_active |= flags; +} + +static inline void rcu_debug_yield_disable(unsigned int flags) +{ + rcu_yield_active &= ~flags; +} + +static inline void rcu_debug_yield_init(void) +{ + URCU_TLS(rcu_rand_yield) = time(NULL) ^ (unsigned long) pthread_self(); +} +#else /* DEBUG_YIELD */ +static inline void rcu_debug_yield_read(void) +{ +} + +static inline void rcu_debug_yield_write(void) +{ +} + +static inline void rcu_debug_yield_enable( + unsigned int flags __attribute__((unused))) +{ +} + +static inline void rcu_debug_yield_disable( + unsigned int flags __attribute__((unused))) +{ +} + +static inline void rcu_debug_yield_init(void) +{ +} +#endif + +#endif /* URCU_TESTS_DEBUG_YIELD_H */ diff --git a/external/lgpl2/userspace-rcu/dist/tests/common/thread-id.h b/external/lgpl2/userspace-rcu/dist/tests/common/thread-id.h new file mode 100644 index 0000000000000..575acaf9f81c6 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/common/thread-id.h @@ -0,0 +1,79 @@ +// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers +// +// SPDX-License-Identifier: LicenseRef-Boehm-GC + +#ifndef _TEST_THREAD_ID_H +#define _TEST_THREAD_ID_H + +/* + * Userspace RCU library - thread ID + */ + +#ifdef __linux__ +# include + +# if defined(HAVE_GETTID) +/* + * Do not redefine gettid() as it is already included + * in bionic through . Some other libc + * may also already contain an implementation of gettid. + */ +# elif defined(_syscall0) +_syscall0(pid_t, gettid) +# elif defined(__NR_gettid) +static inline pid_t gettid(void) +{ + return syscall(__NR_gettid); +} +# endif + +static inline +unsigned long urcu_get_thread_id(void) +{ + return (unsigned long) gettid(); +} +#elif defined(__FreeBSD__) +# include + +static inline +unsigned long urcu_get_thread_id(void) +{ + return (unsigned long) pthread_getthreadid_np(); +} +#elif defined(__sun__) || defined(__APPLE__) +#include + +static inline +unsigned long urcu_get_thread_id(void) +{ + return (unsigned long) pthread_self(); +} +#elif defined(__CYGWIN__) +#include + +extern unsigned long pthread_getsequence_np(pthread_t *); + +static inline +unsigned long urcu_get_thread_id(void) +{ + pthread_t thr = pthread_self(); + return pthread_getsequence_np(&thr); +} +#elif defined(__OpenBSD__) +#include + +static inline +unsigned long urcu_get_thread_id(void) +{ + return (unsigned long) getthrid(); +} +#else +# warning "use pid as thread ID" +static inline +unsigned long urcu_get_thread_id(void) +{ + return (unsigned long) getpid(); +} +#endif + +#endif /* _TEST_THREAD_ID_H */ diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/Makefile.am b/external/lgpl2/userspace-rcu/dist/tests/regression/Makefile.am new file mode 100644 index 0000000000000..93c35efbeb82f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/Makefile.am @@ -0,0 +1,281 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +AM_CPPFLAGS += -I$(top_srcdir)/src -I$(top_srcdir)/tests/utils -I$(top_srcdir)/tests/common + +TEST_EXTENSIONS = .tap +TAP_LOG_DRIVER_FLAGS = --merge --comments +TAP_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' \ + URCU_TESTS_SRCDIR='$(abs_top_srcdir)/tests' \ + URCU_TESTS_BUILDDIR='$(abs_top_builddir)/tests' \ + $(SHELL) $(top_srcdir)/tests/utils/tap-driver.sh + +noinst_PROGRAMS = \ + test_urcu_fork.tap \ + test_urcu_fork_cxx.tap \ + rcutorture_urcu_membarrier \ + rcutorture_urcu_membarrier_cxx \ + rcutorture_urcu_mb \ + rcutorture_urcu_mb_cxx \ + rcutorture_urcu_bp \ + rcutorture_urcu_bp_cxx \ + rcutorture_urcu_qsbr \ + rcutorture_urcu_qsbr_cxx + +noinst_HEADERS = rcutorture.h + +URCU_COMMON_LIB=$(top_builddir)/src/liburcu-common.la +URCU_LIB=$(top_builddir)/src/liburcu.la +URCU_QSBR_LIB=$(top_builddir)/src/liburcu-qsbr.la +URCU_MB_LIB=$(top_builddir)/src/liburcu-mb.la +URCU_BP_LIB=$(top_builddir)/src/liburcu-bp.la +URCU_CDS_LIB=$(top_builddir)/src/liburcu-cds.la +TAP_LIB=$(top_builddir)/tests/utils/libtap.a + +test_urcu_fork_tap_SOURCES = test_urcu_fork.c +test_urcu_fork_tap_LDADD = $(URCU_LIB) $(TAP_LIB) + +test_urcu_fork_cxx_tap_SOURCES = test_urcu_fork_cxx.cpp +test_urcu_fork_cxx_tap_LDADD = $(URCU_LIB) $(TAP_LIB) + +rcutorture_urcu_membarrier_SOURCES = urcutorture.c +rcutorture_urcu_membarrier_CFLAGS = -DRCU_MEMBARRIER $(AM_CFLAGS) +rcutorture_urcu_membarrier_LDADD = $(URCU_LIB) $(TAP_LIB) + +rcutorture_urcu_membarrier_cxx_SOURCES = urcutorture_cxx.cpp +rcutorture_urcu_membarrier_cxx_CXXFLAGS = -DRCU_MEMBARRIER $(AM_CXXFLAGS) +rcutorture_urcu_membarrier_cxx_LDADD = $(URCU_LIB) $(TAP_LIB) + +rcutorture_urcu_mb_SOURCES = urcutorture.c +rcutorture_urcu_mb_CFLAGS = -DRCU_MB $(AM_CFLAGS) +rcutorture_urcu_mb_LDADD = $(URCU_MB_LIB) $(TAP_LIB) + +rcutorture_urcu_mb_cxx_SOURCES = urcutorture_cxx.cpp +rcutorture_urcu_mb_cxx_CXXFLAGS = -DRCU_MB $(AM_CXXFLAGS) +rcutorture_urcu_mb_cxx_LDADD = $(URCU_MB_LIB) $(TAP_LIB) + +rcutorture_urcu_qsbr_SOURCES = urcutorture.c +rcutorture_urcu_qsbr_CFLAGS = -DTORTURE_QSBR -DRCU_QSBR $(AM_CFLAGS) +rcutorture_urcu_qsbr_LDADD = $(URCU_QSBR_LIB) $(TAP_LIB) + +rcutorture_urcu_qsbr_cxx_SOURCES = urcutorture_cxx.cpp +rcutorture_urcu_qsbr_cxx_CXXFLAGS = -DTORTURE_QSBR -DRCU_QSBR $(AM_CXXFLAGS) +rcutorture_urcu_qsbr_cxx_LDADD = $(URCU_QSBR_LIB) $(TAP_LIB) + +rcutorture_urcu_bp_SOURCES = urcutorture.c +rcutorture_urcu_bp_CFLAGS = -DRCU_BP $(AM_CFLAGS) +rcutorture_urcu_bp_LDADD = $(URCU_BP_LIB) $(TAP_LIB) + +rcutorture_urcu_bp_cxx_SOURCES = urcutorture_cxx.cpp +rcutorture_urcu_bp_cxx_CXXFLAGS = -DRCU_BP $(AM_CXXFLAGS) +rcutorture_urcu_bp_cxx_LDADD = $(URCU_BP_LIB) $(TAP_LIB) + +urcutorture.c: ../common/api.h + +dist_check_SCRIPTS = \ + test_rcutorture_urcu_bp_perf_global.tap \ + test_rcutorture_urcu_bp_perf_global_cxx.tap \ + test_rcutorture_urcu_bp_perf_percpu.tap \ + test_rcutorture_urcu_bp_perf_percpu_cxx.tap \ + test_rcutorture_urcu_bp_perf_perthread.tap \ + test_rcutorture_urcu_bp_perf_perthread_cxx.tap \ + test_rcutorture_urcu_bp_rperf_global.tap \ + test_rcutorture_urcu_bp_rperf_global_cxx.tap \ + test_rcutorture_urcu_bp_rperf_percpu.tap \ + test_rcutorture_urcu_bp_rperf_percpu_cxx.tap \ + test_rcutorture_urcu_bp_rperf_perthread.tap \ + test_rcutorture_urcu_bp_rperf_perthread_cxx.tap \ + test_rcutorture_urcu_bp_stress_global.tap \ + test_rcutorture_urcu_bp_stress_global_cxx.tap \ + test_rcutorture_urcu_bp_stress_percpu.tap \ + test_rcutorture_urcu_bp_stress_percpu_cxx.tap \ + test_rcutorture_urcu_bp_stress_perthread.tap \ + test_rcutorture_urcu_bp_stress_perthread_cxx.tap \ + test_rcutorture_urcu_bp_uperf_global.tap \ + test_rcutorture_urcu_bp_uperf_global_cxx.tap \ + test_rcutorture_urcu_bp_uperf_percpu.tap \ + test_rcutorture_urcu_bp_uperf_percpu_cxx.tap \ + test_rcutorture_urcu_bp_uperf_perthread.tap \ + test_rcutorture_urcu_bp_uperf_perthread_cxx.tap \ + test_rcutorture_urcu_mb_perf_global.tap \ + test_rcutorture_urcu_mb_perf_global_cxx.tap \ + test_rcutorture_urcu_mb_perf_percpu.tap \ + test_rcutorture_urcu_mb_perf_percpu_cxx.tap \ + test_rcutorture_urcu_mb_perf_perthread.tap \ + test_rcutorture_urcu_mb_perf_perthread_cxx.tap \ + test_rcutorture_urcu_mb_rperf_global.tap \ + test_rcutorture_urcu_mb_rperf_global_cxx.tap \ + test_rcutorture_urcu_mb_rperf_percpu.tap \ + test_rcutorture_urcu_mb_rperf_percpu_cxx.tap \ + test_rcutorture_urcu_mb_rperf_perthread.tap \ + test_rcutorture_urcu_mb_rperf_perthread_cxx.tap \ + test_rcutorture_urcu_mb_stress_global.tap \ + test_rcutorture_urcu_mb_stress_global_cxx.tap \ + test_rcutorture_urcu_mb_stress_percpu.tap \ + test_rcutorture_urcu_mb_stress_percpu_cxx.tap \ + test_rcutorture_urcu_mb_stress_perthread.tap \ + test_rcutorture_urcu_mb_stress_perthread_cxx.tap \ + test_rcutorture_urcu_mb_uperf_global.tap \ + test_rcutorture_urcu_mb_uperf_global_cxx.tap \ + test_rcutorture_urcu_mb_uperf_percpu.tap \ + test_rcutorture_urcu_mb_uperf_percpu_cxx.tap \ + test_rcutorture_urcu_mb_uperf_perthread.tap \ + test_rcutorture_urcu_mb_uperf_perthread_cxx.tap \ + test_rcutorture_urcu_membarrier_perf_global.tap \ + test_rcutorture_urcu_membarrier_perf_global_cxx.tap \ + test_rcutorture_urcu_membarrier_perf_percpu.tap \ + test_rcutorture_urcu_membarrier_perf_percpu_cxx.tap \ + test_rcutorture_urcu_membarrier_perf_perthread.tap \ + test_rcutorture_urcu_membarrier_perf_perthread_cxx.tap \ + test_rcutorture_urcu_membarrier_rperf_global.tap \ + test_rcutorture_urcu_membarrier_rperf_global_cxx.tap \ + test_rcutorture_urcu_membarrier_rperf_percpu.tap \ + test_rcutorture_urcu_membarrier_rperf_percpu_cxx.tap \ + test_rcutorture_urcu_membarrier_rperf_perthread.tap \ + test_rcutorture_urcu_membarrier_rperf_perthread_cxx.tap \ + test_rcutorture_urcu_membarrier_stress_global.tap \ + test_rcutorture_urcu_membarrier_stress_global_cxx.tap \ + test_rcutorture_urcu_membarrier_stress_percpu.tap \ + test_rcutorture_urcu_membarrier_stress_percpu_cxx.tap \ + test_rcutorture_urcu_membarrier_stress_perthread.tap \ + test_rcutorture_urcu_membarrier_stress_perthread_cxx.tap \ + test_rcutorture_urcu_membarrier_uperf_global.tap \ + test_rcutorture_urcu_membarrier_uperf_global_cxx.tap \ + test_rcutorture_urcu_membarrier_uperf_percpu.tap \ + test_rcutorture_urcu_membarrier_uperf_percpu_cxx.tap \ + test_rcutorture_urcu_membarrier_uperf_perthread.tap \ + test_rcutorture_urcu_membarrier_uperf_perthread_cxx.tap \ + test_rcutorture_urcu_qsbr_perf_global.tap \ + test_rcutorture_urcu_qsbr_perf_global_cxx.tap \ + test_rcutorture_urcu_qsbr_perf_percpu.tap \ + test_rcutorture_urcu_qsbr_perf_percpu_cxx.tap \ + test_rcutorture_urcu_qsbr_perf_perthread.tap \ + test_rcutorture_urcu_qsbr_perf_perthread_cxx.tap \ + test_rcutorture_urcu_qsbr_rperf_global.tap \ + test_rcutorture_urcu_qsbr_rperf_global_cxx.tap \ + test_rcutorture_urcu_qsbr_rperf_percpu.tap \ + test_rcutorture_urcu_qsbr_rperf_percpu_cxx.tap \ + test_rcutorture_urcu_qsbr_rperf_perthread.tap \ + test_rcutorture_urcu_qsbr_rperf_perthread_cxx.tap \ + test_rcutorture_urcu_qsbr_stress_global.tap \ + test_rcutorture_urcu_qsbr_stress_global_cxx.tap \ + test_rcutorture_urcu_qsbr_stress_percpu.tap \ + test_rcutorture_urcu_qsbr_stress_percpu_cxx.tap \ + test_rcutorture_urcu_qsbr_stress_perthread.tap \ + test_rcutorture_urcu_qsbr_stress_perthread_cxx.tap \ + test_rcutorture_urcu_qsbr_uperf_global.tap \ + test_rcutorture_urcu_qsbr_uperf_global_cxx.tap \ + test_rcutorture_urcu_qsbr_uperf_percpu.tap \ + test_rcutorture_urcu_qsbr_uperf_percpu_cxx.tap \ + test_rcutorture_urcu_qsbr_uperf_perthread.tap \ + test_rcutorture_urcu_qsbr_uperf_perthread_cxx.tap + +.PHONY: regtest + +# This empty variable is required to enable the TAP test suite for custom +# targets like 'regtest' while keeping the default 'check' a noop. +TESTS = + +REGTEST_TESTS = \ + test_urcu_fork.tap \ + test_urcu_fork_cxx.tap \ + test_rcutorture_urcu_bp_perf_global.tap \ + test_rcutorture_urcu_bp_perf_global_cxx.tap \ + test_rcutorture_urcu_bp_perf_percpu.tap \ + test_rcutorture_urcu_bp_perf_percpu_cxx.tap \ + test_rcutorture_urcu_bp_perf_perthread.tap \ + test_rcutorture_urcu_bp_perf_perthread_cxx.tap \ + test_rcutorture_urcu_bp_rperf_global.tap \ + test_rcutorture_urcu_bp_rperf_global_cxx.tap \ + test_rcutorture_urcu_bp_rperf_percpu.tap \ + test_rcutorture_urcu_bp_rperf_percpu_cxx.tap \ + test_rcutorture_urcu_bp_rperf_perthread.tap \ + test_rcutorture_urcu_bp_rperf_perthread_cxx.tap \ + test_rcutorture_urcu_bp_stress_global.tap \ + test_rcutorture_urcu_bp_stress_global_cxx.tap \ + test_rcutorture_urcu_bp_stress_percpu.tap \ + test_rcutorture_urcu_bp_stress_percpu_cxx.tap \ + test_rcutorture_urcu_bp_stress_perthread.tap \ + test_rcutorture_urcu_bp_stress_perthread_cxx.tap \ + test_rcutorture_urcu_bp_uperf_global.tap \ + test_rcutorture_urcu_bp_uperf_global_cxx.tap \ + test_rcutorture_urcu_bp_uperf_percpu.tap \ + test_rcutorture_urcu_bp_uperf_percpu_cxx.tap \ + test_rcutorture_urcu_bp_uperf_perthread.tap \ + test_rcutorture_urcu_bp_uperf_perthread_cxx.tap \ + test_rcutorture_urcu_mb_perf_global.tap \ + test_rcutorture_urcu_mb_perf_global_cxx.tap \ + test_rcutorture_urcu_mb_perf_percpu.tap \ + test_rcutorture_urcu_mb_perf_percpu_cxx.tap \ + test_rcutorture_urcu_mb_perf_perthread.tap \ + test_rcutorture_urcu_mb_perf_perthread_cxx.tap \ + test_rcutorture_urcu_mb_rperf_global.tap \ + test_rcutorture_urcu_mb_rperf_global_cxx.tap \ + test_rcutorture_urcu_mb_rperf_percpu.tap \ + test_rcutorture_urcu_mb_rperf_percpu_cxx.tap \ + test_rcutorture_urcu_mb_rperf_perthread.tap \ + test_rcutorture_urcu_mb_rperf_perthread_cxx.tap \ + test_rcutorture_urcu_mb_stress_global.tap \ + test_rcutorture_urcu_mb_stress_global_cxx.tap \ + test_rcutorture_urcu_mb_stress_percpu.tap \ + test_rcutorture_urcu_mb_stress_percpu_cxx.tap \ + test_rcutorture_urcu_mb_stress_perthread.tap \ + test_rcutorture_urcu_mb_stress_perthread_cxx.tap \ + test_rcutorture_urcu_mb_uperf_global.tap \ + test_rcutorture_urcu_mb_uperf_global_cxx.tap \ + test_rcutorture_urcu_mb_uperf_percpu.tap \ + test_rcutorture_urcu_mb_uperf_percpu_cxx.tap \ + test_rcutorture_urcu_mb_uperf_perthread.tap \ + test_rcutorture_urcu_mb_uperf_perthread_cxx.tap \ + test_rcutorture_urcu_membarrier_perf_global.tap \ + test_rcutorture_urcu_membarrier_perf_global_cxx.tap \ + test_rcutorture_urcu_membarrier_perf_percpu.tap \ + test_rcutorture_urcu_membarrier_perf_percpu_cxx.tap \ + test_rcutorture_urcu_membarrier_perf_perthread.tap \ + test_rcutorture_urcu_membarrier_perf_perthread_cxx.tap \ + test_rcutorture_urcu_membarrier_rperf_global.tap \ + test_rcutorture_urcu_membarrier_rperf_global_cxx.tap \ + test_rcutorture_urcu_membarrier_rperf_percpu.tap \ + test_rcutorture_urcu_membarrier_rperf_percpu_cxx.tap \ + test_rcutorture_urcu_membarrier_rperf_perthread.tap \ + test_rcutorture_urcu_membarrier_rperf_perthread_cxx.tap \ + test_rcutorture_urcu_membarrier_stress_global.tap \ + test_rcutorture_urcu_membarrier_stress_global_cxx.tap \ + test_rcutorture_urcu_membarrier_stress_percpu.tap \ + test_rcutorture_urcu_membarrier_stress_percpu_cxx.tap \ + test_rcutorture_urcu_membarrier_stress_perthread.tap \ + test_rcutorture_urcu_membarrier_stress_perthread_cxx.tap \ + test_rcutorture_urcu_membarrier_uperf_global.tap \ + test_rcutorture_urcu_membarrier_uperf_global_cxx.tap \ + test_rcutorture_urcu_membarrier_uperf_percpu.tap \ + test_rcutorture_urcu_membarrier_uperf_percpu_cxx.tap \ + test_rcutorture_urcu_membarrier_uperf_perthread.tap \ + test_rcutorture_urcu_membarrier_uperf_perthread_cxx.tap \ + test_rcutorture_urcu_qsbr_perf_global.tap \ + test_rcutorture_urcu_qsbr_perf_global_cxx.tap \ + test_rcutorture_urcu_qsbr_perf_percpu.tap \ + test_rcutorture_urcu_qsbr_perf_percpu_cxx.tap \ + test_rcutorture_urcu_qsbr_perf_perthread.tap \ + test_rcutorture_urcu_qsbr_perf_perthread_cxx.tap \ + test_rcutorture_urcu_qsbr_rperf_global.tap \ + test_rcutorture_urcu_qsbr_rperf_global_cxx.tap \ + test_rcutorture_urcu_qsbr_rperf_percpu.tap \ + test_rcutorture_urcu_qsbr_rperf_percpu_cxx.tap \ + test_rcutorture_urcu_qsbr_rperf_perthread.tap \ + test_rcutorture_urcu_qsbr_rperf_perthread_cxx.tap \ + test_rcutorture_urcu_qsbr_stress_global.tap \ + test_rcutorture_urcu_qsbr_stress_global_cxx.tap \ + test_rcutorture_urcu_qsbr_stress_percpu.tap \ + test_rcutorture_urcu_qsbr_stress_percpu_cxx.tap \ + test_rcutorture_urcu_qsbr_stress_perthread.tap \ + test_rcutorture_urcu_qsbr_stress_perthread_cxx.tap \ + test_rcutorture_urcu_qsbr_uperf_global.tap \ + test_rcutorture_urcu_qsbr_uperf_global_cxx.tap \ + test_rcutorture_urcu_qsbr_uperf_percpu.tap \ + test_rcutorture_urcu_qsbr_uperf_percpu_cxx.tap \ + test_rcutorture_urcu_qsbr_uperf_perthread.tap \ + test_rcutorture_urcu_qsbr_uperf_perthread_cxx.tap + +regtest: + $(MAKE) $(AM_MAKEFLAGS) check TESTS="$(REGTEST_TESTS)" diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/rcutorture.h b/external/lgpl2/userspace-rcu/dist/tests/regression/rcutorture.h new file mode 100644 index 0000000000000..441ff79bf349f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/rcutorture.h @@ -0,0 +1,679 @@ +// SPDX-FileCopyrightText: 2008 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * rcutorture.h: simple user-level performance/stress test of RCU. + * + * Usage: + * ./rcu rperf [ ] + * Run a read-side performance test with the specified + * number of readers spaced by . + * Thus "./rcu 16 rperf 2" would run 16 readers on even-numbered + * CPUs from 0 to 30. + * ./rcu uperf [ ] + * Run an update-side performance test with the specified + * number of updaters and specified CPU spacing. + * ./rcu perf [ ] + * Run a combined read/update performance test with the specified + * number of readers and one updater and specified CPU spacing. + * The readers run on the low-numbered CPUs and the updater + * of the highest-numbered CPU. + * + * The above tests produce output as follows: + * + * n_reads: 46008000 n_updates: 146026 nreaders: 2 nupdaters: 1 duration: 1 + * ns/read: 43.4707 ns/update: 6848.1 + * + * The first line lists the total number of RCU reads and updates executed + * during the test, the number of reader threads, the number of updater + * threads, and the duration of the test in seconds. The second line + * lists the average duration of each type of operation in nanoseconds, + * or "nan" if the corresponding type of operation was not performed. + * + * ./rcu stress + * Run a stress test with the specified number of readers and + * one updater. None of the threads are affinitied to any + * particular CPU. + * + * This test produces output as follows: + * + * n_reads: 114633217 n_updates: 3903415 n_mberror: 0 + * rcu_stress_count: 114618391 14826 0 0 0 0 0 0 0 0 0 + * + * The first line lists the number of RCU read and update operations + * executed, followed by the number of memory-ordering violations + * (which will be zero in a correct RCU implementation). The second + * line lists the number of readers observing progressively more stale + * data. A correct RCU implementation will have all but the first two + * numbers non-zero. + * + * rcu_stress_count: Histogram of "ages" of structures seen by readers. If any + * entries past the first two are non-zero, RCU is broken. The age of a newly + * allocated structure is zero, it becomes one when removed from reader + * visibility, and is incremented once per grace period subsequently -- and is + * freed after passing through (RCU_STRESS_PIPE_LEN-2) grace periods. Since + * this tests only has one true writer (there are fake writers), only buckets at + * indexes 0 and 1 should be none-zero. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (c) 2008 Paul E. McKenney, IBM Corporation. + */ + +/* + * Test variables. + */ + +#include +#include "tap.h" + +#include + +#include "urcu-wait.h" + +#define NR_TESTS 1 + +DEFINE_PER_THREAD(long long, n_reads_pt); +DEFINE_PER_THREAD(long long, n_updates_pt); + +enum callrcu_type { + CALLRCU_GLOBAL, + CALLRCU_PERCPU, + CALLRCU_PERTHREAD, +}; + +enum writer_state { + WRITER_STATE_SYNC_RCU, + WRITER_STATE_CALL_RCU, + WRITER_STATE_POLL_RCU, +}; + +static enum callrcu_type callrcu_type = CALLRCU_GLOBAL; + +long long n_reads = 0LL; +long n_updates = 0L; +int nthreadsrunning; +char argsbuf[64]; + +#define GOFLAG_INIT 0 +#define GOFLAG_RUN 1 +#define GOFLAG_STOP 2 + +volatile int goflag __attribute__((__aligned__(CAA_CACHE_LINE_SIZE))) + = GOFLAG_INIT; + +#define RCU_READ_RUN 1000 + +//MD +#define RCU_READ_NESTABLE + +#ifdef RCU_READ_NESTABLE +#define rcu_read_lock_nest() rcu_read_lock() +#define rcu_read_unlock_nest() rcu_read_unlock() +#else /* #ifdef RCU_READ_NESTABLE */ +#define rcu_read_lock_nest() +#define rcu_read_unlock_nest() +#endif /* #else #ifdef RCU_READ_NESTABLE */ + +#ifdef TORTURE_QSBR +#define mark_rcu_quiescent_state rcu_quiescent_state +#define put_thread_offline rcu_thread_offline +#define put_thread_online rcu_thread_online +#endif + +#ifndef mark_rcu_quiescent_state +#define mark_rcu_quiescent_state() do {} while (0) +#endif /* #ifdef mark_rcu_quiescent_state */ + +#ifndef put_thread_offline +#define put_thread_offline() do {} while (0) +#define put_thread_online() do {} while (0) +#define put_thread_online_delay() do {} while (0) +#else /* #ifndef put_thread_offline */ +#define put_thread_online_delay() synchronize_rcu() +#endif /* #else #ifndef put_thread_offline */ + +/* + * Performance test. + */ + +static +void *rcu_read_perf_test(void *arg) +{ + int i; + int me = (long)arg; + long long n_reads_local = 0; + + rcu_register_thread(); + run_on(me); + uatomic_inc(&nthreadsrunning); + put_thread_offline(); + while (uatomic_read(&goflag) == GOFLAG_INIT) + (void) poll(NULL, 0, 1); + put_thread_online(); + while (uatomic_read(&goflag) == GOFLAG_RUN) { + for (i = 0; i < RCU_READ_RUN; i++) { + rcu_read_lock(); + /* rcu_read_lock_nest(); */ + /* rcu_read_unlock_nest(); */ + rcu_read_unlock(); + } + n_reads_local += RCU_READ_RUN; + mark_rcu_quiescent_state(); + } + __get_thread_var(n_reads_pt) += n_reads_local; + put_thread_offline(); + rcu_unregister_thread(); + + return (NULL); +} + +static +void *rcu_update_perf_test(void *arg __attribute__((unused))) +{ + long long n_updates_local = 0; + + if (callrcu_type == CALLRCU_PERTHREAD) { + struct call_rcu_data *crdp; + + crdp = create_call_rcu_data(0, -1); + if (crdp != NULL) { + diag("Successfully using per-thread call_rcu() worker."); + set_thread_call_rcu_data(crdp); + } + } + uatomic_inc(&nthreadsrunning); + while (uatomic_read(&goflag) == GOFLAG_INIT) + (void) poll(NULL, 0, 1); + while (uatomic_read(&goflag) == GOFLAG_RUN) { + synchronize_rcu(); + n_updates_local++; + } + __get_thread_var(n_updates_pt) += n_updates_local; + if (callrcu_type == CALLRCU_PERTHREAD) { + struct call_rcu_data *crdp; + + crdp = get_thread_call_rcu_data(); + set_thread_call_rcu_data(NULL); + call_rcu_data_free(crdp); + } + return NULL; +} + +static +void perftestinit(void) +{ + init_per_thread(n_reads_pt, 0LL); + init_per_thread(n_updates_pt, 0LL); + uatomic_set(&nthreadsrunning, 0); +} + +static +int perftestrun(int nthreads, int nreaders, int nupdaters) +{ + int t; + int duration = 1; + + while (uatomic_read(&nthreadsrunning) < nthreads) + (void) poll(NULL, 0, 1); + uatomic_set(&goflag, GOFLAG_RUN); + sleep(duration); + uatomic_set(&goflag, GOFLAG_STOP); + wait_all_threads(); + for_each_thread(t) { + n_reads += per_thread(n_reads_pt, t); + n_updates += per_thread(n_updates_pt, t); + } + diag("n_reads: %lld n_updates: %ld nreaders: %d nupdaters: %d duration: %d", + n_reads, n_updates, nreaders, nupdaters, duration); + diag("ns/read: %g ns/update: %g", + ((duration * 1000*1000*1000.*(double)nreaders) / + (double)n_reads), + ((duration * 1000*1000*1000.*(double)nupdaters) / + (double)n_updates)); + if (get_cpu_call_rcu_data(0)) { + diag("Deallocating per-CPU call_rcu threads.\n"); + free_all_cpu_call_rcu_data(); + } + return 0; +} + +static +int perftest(int nreaders, int cpustride) +{ + int i; + long arg; + + perftestinit(); + for (i = 0; i < nreaders; i++) { + arg = (long)(i * cpustride); + create_thread(rcu_read_perf_test, (void *)arg); + } + arg = (long)(i * cpustride); + create_thread(rcu_update_perf_test, (void *)arg); + return perftestrun(i + 1, nreaders, 1); +} + +static +int rperftest(int nreaders, int cpustride) +{ + int i; + long arg; + + perftestinit(); + init_per_thread(n_reads_pt, 0LL); + for (i = 0; i < nreaders; i++) { + arg = (long)(i * cpustride); + create_thread(rcu_read_perf_test, (void *)arg); + } + return perftestrun(i, nreaders, 0); +} + +static +int uperftest(int nupdaters, int cpustride) +{ + int i; + long arg; + + perftestinit(); + init_per_thread(n_reads_pt, 0LL); + for (i = 0; i < nupdaters; i++) { + arg = (long)(i * cpustride); + create_thread(rcu_update_perf_test, (void *)arg); + } + return perftestrun(i, 0, nupdaters); +} + +/* + * Stress test. + */ + +#define RCU_STRESS_PIPE_LEN 10 + +struct rcu_stress { + int pipe_count; + int mbtest; +}; + +struct rcu_stress rcu_stress_array[RCU_STRESS_PIPE_LEN] = { { 0, 0 } }; +struct rcu_stress *rcu_stress_current; +int rcu_stress_idx = 0; + +/* + * How many time a reader has seen something that should not be visible. It is + * an error if this value is different than zero at the end of the stress test. + * + * Here, the something that should not be visibile is an old pipe that has been + * freed (mbtest = 0). + */ +int n_mberror = 0; +DEFINE_PER_THREAD(long long [RCU_STRESS_PIPE_LEN + 1], rcu_stress_count); + +int garbage = 0; + +static +void *rcu_read_stress_test(void *arg __attribute__((unused))) +{ + int i; + int itercnt = 0; + struct rcu_stress *p; + int pc; + + rcu_register_thread(); + put_thread_offline(); + while (uatomic_read(&goflag) == GOFLAG_INIT) + (void) poll(NULL, 0, 1); + put_thread_online(); + while (uatomic_read(&goflag) == GOFLAG_RUN) { + rcu_read_lock(); + p = rcu_dereference(rcu_stress_current); + if (p->mbtest == 0) + uatomic_inc_mo(&n_mberror, CMM_RELAXED); + rcu_read_lock_nest(); + /* + * The value of garbage is nothing important. This is + * essentially a busy loop. The atomic operation -- while not + * important here -- helps tools such as TSAN to not flag this + * as a race condition. + */ + for (i = 0; i < 100; i++) + uatomic_inc(&garbage); + rcu_read_unlock_nest(); + pc = uatomic_read(&p->pipe_count); + rcu_read_unlock(); + if ((pc > RCU_STRESS_PIPE_LEN) || (pc < 0)) + pc = RCU_STRESS_PIPE_LEN; + __get_thread_var(rcu_stress_count)[pc]++; + __get_thread_var(n_reads_pt)++; + mark_rcu_quiescent_state(); + if ((++itercnt % 0x1000) == 0) { + put_thread_offline(); + put_thread_online_delay(); + put_thread_online(); + } + } + put_thread_offline(); + rcu_unregister_thread(); + + return (NULL); +} + +static DEFINE_URCU_WAIT_QUEUE(call_rcu_waiters); + +static +void rcu_update_stress_test_rcu(struct rcu_head *head __attribute__((unused))) +{ + struct urcu_waiters waiters; + + urcu_move_waiters(&waiters, &call_rcu_waiters); + urcu_wake_all_waiters(&waiters); +} + +static +void advance_writer_state(enum writer_state *state) +{ + switch (*state) { + case WRITER_STATE_SYNC_RCU: + *state = WRITER_STATE_CALL_RCU; + break; + case WRITER_STATE_CALL_RCU: + *state = WRITER_STATE_POLL_RCU; + break; + case WRITER_STATE_POLL_RCU: + *state = WRITER_STATE_SYNC_RCU; + break; + } +} + +static +void *rcu_update_stress_test(void *arg __attribute__((unused))) +{ + int i; + struct rcu_stress *p, *old_p; + struct rcu_head rh; + enum writer_state writer_state = WRITER_STATE_SYNC_RCU; + + rcu_register_thread(); + + /* Offline for poll. */ + put_thread_offline(); + while (uatomic_read(&goflag) == GOFLAG_INIT) + (void) poll(NULL, 0, 1); + put_thread_online(); + + old_p = NULL; + while (uatomic_read(&goflag) == GOFLAG_RUN) { + i = rcu_stress_idx + 1; + if (i >= RCU_STRESS_PIPE_LEN) + i = 0; + + rcu_read_lock(); + old_p = rcu_dereference(rcu_stress_current); + rcu_read_unlock(); + + /* + * Allocate a new pipe. + */ + p = &rcu_stress_array[i]; + p->pipe_count = 0; + p->mbtest = 1; + + rcu_assign_pointer(rcu_stress_current, p); + rcu_stress_idx = i; + + /* + * Increment every pipe except the freshly allocated one. A + * reader should only see either the old pipe or the new + * pipe. This is reflected in the rcu_stress_count histogram. + */ + for (i = 0; i < RCU_STRESS_PIPE_LEN; i++) + if (i != rcu_stress_idx) + uatomic_inc(&rcu_stress_array[i].pipe_count); + + switch (writer_state) { + case WRITER_STATE_SYNC_RCU: + synchronize_rcu(); + break; + case WRITER_STATE_CALL_RCU: + { + DEFINE_URCU_WAIT_NODE(wait, URCU_WAIT_WAITING); + + urcu_wait_add(&call_rcu_waiters, &wait); + + call_rcu(&rh, rcu_update_stress_test_rcu); + + /* Offline for busy-wait. */ + put_thread_offline(); + urcu_adaptative_busy_wait(&wait); + put_thread_online(); + break; + } + case WRITER_STATE_POLL_RCU: + { + struct urcu_gp_poll_state poll_state; + + poll_state = start_poll_synchronize_rcu(); + + /* Offline for poll. */ + put_thread_offline(); + while (!poll_state_synchronize_rcu(poll_state)) + (void) poll(NULL, 0, 1); /* Wait for 1ms */ + put_thread_online(); + break; + } + } + /* + * No readers should see that old pipe now. Setting mbtest to 0 + * to mark it as "freed". + */ + if (old_p) { + old_p->mbtest = 0; + } + old_p = p; + n_updates++; + advance_writer_state(&writer_state); + } + + rcu_unregister_thread(); + + return NULL; +} + +static +void *rcu_fake_update_stress_test(void *arg __attribute__((unused))) +{ + if (callrcu_type == CALLRCU_PERTHREAD) { + struct call_rcu_data *crdp; + + crdp = create_call_rcu_data(0, -1); + if (crdp != NULL) { + diag("Successfully using per-thread call_rcu() worker."); + set_thread_call_rcu_data(crdp); + } + } + while (uatomic_read(&goflag) == GOFLAG_INIT) + (void) poll(NULL, 0, 1); + while (uatomic_read(&goflag) == GOFLAG_RUN) { + synchronize_rcu(); + (void) poll(NULL, 0, 1); + } + if (callrcu_type == CALLRCU_PERTHREAD) { + struct call_rcu_data *crdp; + + crdp = get_thread_call_rcu_data(); + set_thread_call_rcu_data(NULL); + call_rcu_data_free(crdp); + } + return NULL; +} + +static +int stresstest(int nreaders) +{ + int i; + int t; + long long *p; + long long sum; + int ret; + + init_per_thread(n_reads_pt, 0LL); + for_each_thread(t) { + p = &per_thread(rcu_stress_count,t)[0]; + for (i = 0; i <= RCU_STRESS_PIPE_LEN; i++) + p[i] = 0LL; + } + rcu_stress_current = &rcu_stress_array[0]; + rcu_stress_current->pipe_count = 0; + rcu_stress_current->mbtest = 1; + for (i = 0; i < nreaders; i++) + create_thread(rcu_read_stress_test, NULL); + create_thread(rcu_update_stress_test, NULL); + for (i = 0; i < 5; i++) + create_thread(rcu_fake_update_stress_test, NULL); + uatomic_set(&goflag, GOFLAG_RUN); + sleep(10); + uatomic_set(&goflag, GOFLAG_STOP); + wait_all_threads(); + for_each_thread(t) + n_reads += per_thread(n_reads_pt, t); + diag("n_reads: %lld n_updates: %ld n_mberror: %d", + n_reads, n_updates, n_mberror); + rdiag_start(); + rdiag("rcu_stress_count:"); + ret = 0; + for (i = 0; i <= RCU_STRESS_PIPE_LEN; i++) { + sum = 0LL; + for_each_thread(t) { + sum += per_thread(rcu_stress_count, t)[i]; + } + /* + * If any entries past the first two are non-zero, RCU is + * broken. See details above about rcu_stress_count. + */ + if (i > 1 && sum != 0) { + ret = -1; + } + rdiag(" %lld", sum); + } + rdiag_end(); + if (get_cpu_call_rcu_data(0)) { + diag("Deallocating per-CPU call_rcu threads."); + free_all_cpu_call_rcu_data(); + } + if (n_mberror) + ret = -1; + return ret; +} + +/* + * Mainprogram. + */ + +static +void usage(char *argv[]) __attribute__((__noreturn__)); + +static +void usage(char *argv[]) +{ + diag("Usage: %s nreaders [ perf | rperf | uperf | stress ] [ stride ] [ callrcu_global | callrcu_percpu | callrcu_perthread ]\n", argv[0]); + exit(-1); +} + +int main(int argc, char *argv[]) +{ + int nreaders = 1; + int cpustride = 1; + + plan_tests(NR_TESTS); + + smp_init(); + //rcu_init(); + if (argc > 4) { + const char *callrcu_str = argv[4];; + + if (strcmp(callrcu_str, "callrcu_global") == 0) { + callrcu_type = CALLRCU_GLOBAL; + } else if (strcmp(callrcu_str, "callrcu_percpu") == 0) { + callrcu_type = CALLRCU_PERCPU; + } else if (strcmp(callrcu_str, "callrcu_perthread") == 0) { + callrcu_type = CALLRCU_PERTHREAD; + } else { + usage(argv); + goto end; + } + } + + switch (callrcu_type) { + case CALLRCU_GLOBAL: + diag("Using global per-process call_rcu thread."); + break; + case CALLRCU_PERCPU: + diag("Using per-CPU call_rcu threads."); + if (create_all_cpu_call_rcu_data(0)) + diag("create_all_cpu_call_rcu_data: %s", + strerror(errno)); + break; + case CALLRCU_PERTHREAD: + diag("Using per-thread call_rcu() worker."); + break; + default: + abort(); + } + +#ifdef DEBUG_YIELD + yield_active |= YIELD_READ; + yield_active |= YIELD_WRITE; +#endif + + if (argc > 1) { + if (strcmp(argv[1], "-h") == 0 + || strcmp(argv[1], "--help") == 0) { + usage(argv); + goto end; + } + nreaders = strtoul(argv[1], NULL, 0); + if (argc == 2) { + ok(!perftest(nreaders, cpustride), + "perftest readers: %d, stride: %d", + nreaders, cpustride); + goto end; + } + if (argc > 3) + cpustride = strtoul(argv[3], NULL, 0); + if (strcmp(argv[2], "perf") == 0) + ok(!perftest(nreaders, cpustride), + "perftest readers: %d, stride: %d", + nreaders, cpustride); + else if (strcmp(argv[2], "rperf") == 0) + ok(!rperftest(nreaders, cpustride), + "rperftest readers: %d, stride: %d", + nreaders, cpustride); + else if (strcmp(argv[2], "uperf") == 0) + ok(!uperftest(nreaders, cpustride), + "uperftest readers: %d, stride: %d", + nreaders, cpustride); + else if (strcmp(argv[2], "stress") == 0) + ok(!stresstest(nreaders), + "stresstest readers: %d, stride: %d", + nreaders, cpustride); + else + usage(argv); + } else { + usage(argv); + } +end: + return exit_status(); +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_global.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_global.tap new file mode 100755 index 0000000000000..96a640d8e7a95 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_global.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp" "$(urcu_nproc)" perf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_global_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_global_cxx.tap new file mode 100755 index 0000000000000..9c324bd71c5d3 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_global_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp_cxx" "$(urcu_nproc)" perf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_percpu.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_percpu.tap new file mode 100755 index 0000000000000..f697116305e48 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_percpu.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp" "$(urcu_nproc)" perf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_percpu_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_percpu_cxx.tap new file mode 100755 index 0000000000000..e30d6f5f2765a --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_percpu_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp_cxx" "$(urcu_nproc)" perf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_perthread.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_perthread.tap new file mode 100755 index 0000000000000..f18dc8c4fd87e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_perthread.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp" "$(urcu_nproc)" perf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_perthread_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_perthread_cxx.tap new file mode 100755 index 0000000000000..54c09ec0412cd --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_perf_perthread_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp_cxx" "$(urcu_nproc)" perf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_global.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_global.tap new file mode 100755 index 0000000000000..c003127c0d8ef --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_global.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp" "$(urcu_nproc)" rperf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_global_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_global_cxx.tap new file mode 100755 index 0000000000000..4109798aceba4 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_global_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp_cxx" "$(urcu_nproc)" rperf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_percpu.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_percpu.tap new file mode 100755 index 0000000000000..96d36745ddb45 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_percpu.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp" "$(urcu_nproc)" rperf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_percpu_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_percpu_cxx.tap new file mode 100755 index 0000000000000..9ce9e9f6ba0cc --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_percpu_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp_cxx" "$(urcu_nproc)" rperf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_perthread.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_perthread.tap new file mode 100755 index 0000000000000..9635caab22782 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_perthread.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp" "$(urcu_nproc)" rperf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_perthread_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_perthread_cxx.tap new file mode 100755 index 0000000000000..66668fe42c60e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_rperf_perthread_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp_cxx" "$(urcu_nproc)" rperf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_global.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_global.tap new file mode 100755 index 0000000000000..1fad3ac8296e0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_global.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp" "$(urcu_nproc)" stress 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_global_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_global_cxx.tap new file mode 100755 index 0000000000000..f807630d3911a --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_global_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp_cxx" "$(urcu_nproc)" stress 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_percpu.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_percpu.tap new file mode 100755 index 0000000000000..b4daa595302b3 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_percpu.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp" "$(urcu_nproc)" stress 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_percpu_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_percpu_cxx.tap new file mode 100755 index 0000000000000..84d0a4a5183ab --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_percpu_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp_cxx" "$(urcu_nproc)" stress 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_perthread.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_perthread.tap new file mode 100755 index 0000000000000..440327bd5dcef --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_perthread.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp" "$(urcu_nproc)" stress 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_perthread_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_perthread_cxx.tap new file mode 100755 index 0000000000000..05df988ed32f8 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_stress_perthread_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp_cxx" "$(urcu_nproc)" stress 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_global.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_global.tap new file mode 100755 index 0000000000000..fa908a92c4272 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_global.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp" "$(urcu_nproc)" uperf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_global_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_global_cxx.tap new file mode 100755 index 0000000000000..550049f045e67 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_global_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp_cxx" "$(urcu_nproc)" uperf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_percpu.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_percpu.tap new file mode 100755 index 0000000000000..0a84e686b51d9 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_percpu.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp" "$(urcu_nproc)" uperf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_percpu_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_percpu_cxx.tap new file mode 100755 index 0000000000000..2231c002b2bb7 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_percpu_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp_cxx" "$(urcu_nproc)" uperf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_perthread.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_perthread.tap new file mode 100755 index 0000000000000..a33820f4e8631 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_perthread.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp" "$(urcu_nproc)" uperf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_perthread_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_perthread_cxx.tap new file mode 100755 index 0000000000000..3ef20d9828c88 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_bp_uperf_perthread_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_bp_cxx" "$(urcu_nproc)" uperf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_global.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_global.tap new file mode 100755 index 0000000000000..f0f3370d2eef9 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_global.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb" "$(urcu_nproc)" perf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_global_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_global_cxx.tap new file mode 100755 index 0000000000000..416dc310234db --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_global_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb_cxx" "$(urcu_nproc)" perf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_percpu.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_percpu.tap new file mode 100755 index 0000000000000..6a6c0ee852247 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_percpu.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb" "$(urcu_nproc)" perf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_percpu_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_percpu_cxx.tap new file mode 100755 index 0000000000000..ffb2e930da4be --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_percpu_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb_cxx" "$(urcu_nproc)" perf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_perthread.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_perthread.tap new file mode 100755 index 0000000000000..898629e80b614 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_perthread.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb" "$(urcu_nproc)" perf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_perthread_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_perthread_cxx.tap new file mode 100755 index 0000000000000..718da74b1c8ae --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_perf_perthread_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb_cxx" "$(urcu_nproc)" perf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_global.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_global.tap new file mode 100755 index 0000000000000..61543ea659cc3 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_global.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb" "$(urcu_nproc)" rperf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_global_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_global_cxx.tap new file mode 100755 index 0000000000000..379ae651a0d14 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_global_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb_cxx" "$(urcu_nproc)" rperf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_percpu.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_percpu.tap new file mode 100755 index 0000000000000..5fdca8adedfe9 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_percpu.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb" "$(urcu_nproc)" rperf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_percpu_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_percpu_cxx.tap new file mode 100755 index 0000000000000..c153c78d21828 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_percpu_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb_cxx" "$(urcu_nproc)" rperf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_perthread.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_perthread.tap new file mode 100755 index 0000000000000..254d171697fc8 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_perthread.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb" "$(urcu_nproc)" rperf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_perthread_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_perthread_cxx.tap new file mode 100755 index 0000000000000..0f1cb64ddd670 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_rperf_perthread_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb_cxx" "$(urcu_nproc)" rperf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_global.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_global.tap new file mode 100755 index 0000000000000..a07fcecb16a23 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_global.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb" "$(urcu_nproc)" stress 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_global_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_global_cxx.tap new file mode 100755 index 0000000000000..a896058d2e456 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_global_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb_cxx" "$(urcu_nproc)" stress 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_percpu.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_percpu.tap new file mode 100755 index 0000000000000..bf1f9d1243469 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_percpu.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb" "$(urcu_nproc)" stress 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_percpu_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_percpu_cxx.tap new file mode 100755 index 0000000000000..67135dcbe9f4f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_percpu_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb_cxx" "$(urcu_nproc)" stress 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_perthread.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_perthread.tap new file mode 100755 index 0000000000000..73a6f04dd2646 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_perthread.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb" "$(urcu_nproc)" stress 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_perthread_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_perthread_cxx.tap new file mode 100755 index 0000000000000..520960d6b740f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_stress_perthread_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb_cxx" "$(urcu_nproc)" stress 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_global.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_global.tap new file mode 100755 index 0000000000000..2455a487fdf02 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_global.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb" "$(urcu_nproc)" uperf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_global_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_global_cxx.tap new file mode 100755 index 0000000000000..dbbca53f89aa2 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_global_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb_cxx" "$(urcu_nproc)" uperf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_percpu.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_percpu.tap new file mode 100755 index 0000000000000..36bc4b029a965 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_percpu.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb" "$(urcu_nproc)" uperf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_percpu_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_percpu_cxx.tap new file mode 100755 index 0000000000000..7115576f1ebf9 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_percpu_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb_cxx" "$(urcu_nproc)" uperf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_perthread.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_perthread.tap new file mode 100755 index 0000000000000..d6628bff4437c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_perthread.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb" "$(urcu_nproc)" uperf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_perthread_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_perthread_cxx.tap new file mode 100755 index 0000000000000..759a06892fa12 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_mb_uperf_perthread_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_mb_cxx" "$(urcu_nproc)" uperf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_global.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_global.tap new file mode 100755 index 0000000000000..05f22ac4bb189 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_global.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier" "$(urcu_nproc)" perf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_global_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_global_cxx.tap new file mode 100755 index 0000000000000..f88e08b40d5a1 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_global_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier_cxx" "$(urcu_nproc)" perf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_percpu.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_percpu.tap new file mode 100755 index 0000000000000..7c4cc531a8988 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_percpu.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier" "$(urcu_nproc)" perf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_percpu_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_percpu_cxx.tap new file mode 100755 index 0000000000000..f24a04b787698 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_percpu_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier_cxx" "$(urcu_nproc)" perf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_perthread.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_perthread.tap new file mode 100755 index 0000000000000..2b5c1b8ea466c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_perthread.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier" "$(urcu_nproc)" perf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_perthread_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_perthread_cxx.tap new file mode 100755 index 0000000000000..c40de4c859874 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_perf_perthread_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier_cxx" "$(urcu_nproc)" perf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_global.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_global.tap new file mode 100755 index 0000000000000..edea741aa3a56 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_global.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier" "$(urcu_nproc)" rperf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_global_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_global_cxx.tap new file mode 100755 index 0000000000000..5b485891ddee4 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_global_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier_cxx" "$(urcu_nproc)" rperf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_percpu.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_percpu.tap new file mode 100755 index 0000000000000..dd585cfab0ffa --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_percpu.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier" "$(urcu_nproc)" rperf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_percpu_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_percpu_cxx.tap new file mode 100755 index 0000000000000..864fa63b7bd1a --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_percpu_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier_cxx" "$(urcu_nproc)" rperf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_perthread.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_perthread.tap new file mode 100755 index 0000000000000..9875d1eb85175 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_perthread.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier" "$(urcu_nproc)" rperf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_perthread_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_perthread_cxx.tap new file mode 100755 index 0000000000000..3d60e0fc6a2f6 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_rperf_perthread_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier_cxx" "$(urcu_nproc)" rperf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_global.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_global.tap new file mode 100755 index 0000000000000..4642ce43b3e39 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_global.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier" "$(urcu_nproc)" stress 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_global_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_global_cxx.tap new file mode 100755 index 0000000000000..0cc7783ddb1c5 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_global_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier_cxx" "$(urcu_nproc)" stress 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_percpu.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_percpu.tap new file mode 100755 index 0000000000000..3f9efbf9f38d7 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_percpu.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier" "$(urcu_nproc)" stress 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_percpu_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_percpu_cxx.tap new file mode 100755 index 0000000000000..f5d1c3f2eab77 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_percpu_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier_cxx" "$(urcu_nproc)" stress 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_perthread.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_perthread.tap new file mode 100755 index 0000000000000..1b239a53b9d53 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_perthread.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier" "$(urcu_nproc)" stress 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_perthread_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_perthread_cxx.tap new file mode 100755 index 0000000000000..a7c5daac73a81 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_stress_perthread_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier_cxx" "$(urcu_nproc)" stress 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_global.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_global.tap new file mode 100755 index 0000000000000..f738f24420edf --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_global.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier" "$(urcu_nproc)" uperf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_global_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_global_cxx.tap new file mode 100755 index 0000000000000..0b183507df062 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_global_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier_cxx" "$(urcu_nproc)" uperf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_percpu.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_percpu.tap new file mode 100755 index 0000000000000..d1d24ea36706c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_percpu.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier" "$(urcu_nproc)" uperf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_percpu_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_percpu_cxx.tap new file mode 100755 index 0000000000000..a85bd48aaca2a --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_percpu_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier_cxx" "$(urcu_nproc)" uperf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_perthread.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_perthread.tap new file mode 100755 index 0000000000000..dd19f6c5396c7 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_perthread.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier" "$(urcu_nproc)" uperf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_perthread_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_perthread_cxx.tap new file mode 100755 index 0000000000000..7d79de1153dbf --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_membarrier_uperf_perthread_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_membarrier_cxx" "$(urcu_nproc)" uperf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_global.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_global.tap new file mode 100755 index 0000000000000..0b75a48655c54 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_global.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr" "$(urcu_nproc)" perf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_global_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_global_cxx.tap new file mode 100755 index 0000000000000..eba1e88a6a571 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_global_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr_cxx" "$(urcu_nproc)" perf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_percpu.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_percpu.tap new file mode 100755 index 0000000000000..8d7c80467d0be --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_percpu.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr" "$(urcu_nproc)" perf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_percpu_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_percpu_cxx.tap new file mode 100755 index 0000000000000..21e6e6380d8ab --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_percpu_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr_cxx" "$(urcu_nproc)" perf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_perthread.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_perthread.tap new file mode 100755 index 0000000000000..7058cec895dd5 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_perthread.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr" "$(urcu_nproc)" perf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_perthread_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_perthread_cxx.tap new file mode 100755 index 0000000000000..93069f69c79bc --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_perf_perthread_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr_cxx" "$(urcu_nproc)" perf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_global.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_global.tap new file mode 100755 index 0000000000000..3b0c68d345b6a --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_global.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr" "$(urcu_nproc)" rperf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_global_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_global_cxx.tap new file mode 100755 index 0000000000000..d6cf3ff4cbf6d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_global_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr_cxx" "$(urcu_nproc)" rperf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_percpu.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_percpu.tap new file mode 100755 index 0000000000000..df0bbc8ebe263 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_percpu.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr" "$(urcu_nproc)" rperf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_percpu_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_percpu_cxx.tap new file mode 100755 index 0000000000000..d7225512ed81c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_percpu_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr_cxx" "$(urcu_nproc)" rperf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_perthread.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_perthread.tap new file mode 100755 index 0000000000000..5fc6d3da5e8a2 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_perthread.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr" "$(urcu_nproc)" rperf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_perthread_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_perthread_cxx.tap new file mode 100755 index 0000000000000..35563ea2e8116 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_rperf_perthread_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr_cxx" "$(urcu_nproc)" rperf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_global.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_global.tap new file mode 100755 index 0000000000000..b7140ab6a4ce9 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_global.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr" "$(urcu_nproc)" stress 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_global_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_global_cxx.tap new file mode 100755 index 0000000000000..cd453373a74ff --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_global_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr_cxx" "$(urcu_nproc)" stress 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_percpu.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_percpu.tap new file mode 100755 index 0000000000000..38f383629c3c2 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_percpu.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr" "$(urcu_nproc)" stress 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_percpu_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_percpu_cxx.tap new file mode 100755 index 0000000000000..ee9e9444fda82 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_percpu_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr_cxx" "$(urcu_nproc)" stress 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_perthread.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_perthread.tap new file mode 100755 index 0000000000000..696192d65dfd5 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_perthread.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr" "$(urcu_nproc)" stress 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_perthread_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_perthread_cxx.tap new file mode 100755 index 0000000000000..4e79a37d261d0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_stress_perthread_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr_cxx" "$(urcu_nproc)" stress 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_global.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_global.tap new file mode 100755 index 0000000000000..ef8dce8ea84cc --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_global.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr" "$(urcu_nproc)" uperf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_global_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_global_cxx.tap new file mode 100755 index 0000000000000..678a9ff21ca38 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_global_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr_cxx" "$(urcu_nproc)" uperf 1 callrcu_global diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_percpu.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_percpu.tap new file mode 100755 index 0000000000000..c360c75ba9f44 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_percpu.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr" "$(urcu_nproc)" uperf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_percpu_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_percpu_cxx.tap new file mode 100755 index 0000000000000..24addb9ff346c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_percpu_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr_cxx" "$(urcu_nproc)" uperf 1 callrcu_percpu diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_perthread.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_perthread.tap new file mode 100755 index 0000000000000..0fd439a0a9f36 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_perthread.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr" "$(urcu_nproc)" uperf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_perthread_cxx.tap b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_perthread_cxx.tap new file mode 100755 index 0000000000000..e64df13cca0bd --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_rcutorture_urcu_qsbr_uperf_perthread_cxx.tap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + + +"${URCU_TESTS_BUILDDIR}/regression/rcutorture_urcu_qsbr_cxx" "$(urcu_nproc)" uperf 1 callrcu_perthread diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_urcu_fork.c b/external/lgpl2/userspace-rcu/dist/tests/regression/test_urcu_fork.c new file mode 100644 index 0000000000000..52ccce756b293 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_urcu_fork.c @@ -0,0 +1,200 @@ +// SPDX-FileCopyrightText: 2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test program (fork) + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#else +#define rcu_debug_yield_read() +#endif +#include + +#include "tap.h" + +/* We generate children 3 levels deep */ +#define FORK_DEPTH 3 +/* Each generation spawns 10 children */ +#define NR_FORK 10 + +#define NR_TESTS NR_FORK + +static int fork_generation; + +/* + * Only print diagnostic for top level parent process, else the console + * has trouble formatting the tap output. + */ +#define diag_gen0(...) \ + do { \ + if (!fork_generation) \ + diag(__VA_ARGS__); \ + } while (0) + +struct test_node { + int somedata; + struct rcu_head head; +}; + +static void cb(struct rcu_head *head) +{ + struct test_node *node; + + diag_gen0("rcu callback invoked in pid: %d", (int) getpid()); + node = caa_container_of(head, struct test_node, head); + free(node); +} + +static void test_rcu(void) +{ + struct test_node *node; + + rcu_register_thread(); + + synchronize_rcu(); + + rcu_read_lock(); + rcu_read_unlock(); + + node = (struct test_node *) malloc(sizeof(*node)); + urcu_posix_assert(node); + + call_rcu(&node->head, cb); + + synchronize_rcu(); + + rcu_unregister_thread(); +} + +/* + * Return 0 if child, > 0 if parent, < 0 on error. + */ +static int do_fork(const char *execname) +{ + pid_t pid; + + diag_gen0("%s parent pid: %d, before fork", + execname, (int) getpid()); + + call_rcu_before_fork(); + pid = fork(); + if (pid == 0) { + /* child */ + fork_generation++; + tap_disable(); + + call_rcu_after_fork_child(); + diag_gen0("%s child pid: %d, after fork", + execname, (int) getpid()); + test_rcu(); + diag_gen0("%s child pid: %d, after rcu test", + execname, (int) getpid()); + if (fork_generation >= FORK_DEPTH) + exit(EXIT_SUCCESS); + return 0; + } else if (pid > 0) { + int status; + + /* parent */ + call_rcu_after_fork_parent(); + diag_gen0("%s parent pid: %d, after fork", + execname, (int) getpid()); + test_rcu(); + diag_gen0("%s parent pid: %d, after rcu test", + execname, (int) getpid()); + for (;;) { + pid = wait(&status); + if (pid < 0) { + if (!fork_generation) + perror("wait"); + return -1; + } + if (WIFEXITED(status)) { + diag_gen0("child %u exited normally with status %u", + pid, WEXITSTATUS(status)); + if (WEXITSTATUS(status)) + return -1; + break; + } else if (WIFSIGNALED(status)) { + diag_gen0("child %u was terminated by signal %u", + pid, WTERMSIG(status)); + return -1; + } else { + continue; + } + } + return 1; + } else { + if (!fork_generation) + perror("fork"); + return -1; + } +} + +int main(int argc __attribute__((unused)), char **argv) +{ + unsigned int i; + + plan_tests(NR_TESTS); + +#if 0 + /* pthread_atfork does not work with malloc/free in callbacks */ + ret = pthread_atfork(call_rcu_before_fork, + call_rcu_after_fork_parent, + call_rcu_after_fork_child); + if (ret) { + errno = ret; + perror("pthread_atfork"); + exit(EXIT_FAILURE); + } +#endif + +restart: + for (i = 0; i < NR_FORK; i++) { + int ret; + + test_rcu(); + synchronize_rcu(); + ret = do_fork(argv[0]); + if (!fork_generation) { + ok(ret >= 0, "child status %d", ret); + } + if (ret == 0) { /* child */ + goto restart; + } else if (ret < 0) { + goto error; + } else { + /* else parent, continue. */ + } + } + if (!fork_generation) { + return exit_status(); + } else { + exit(EXIT_SUCCESS); + } + +error: + if (!fork_generation) { + return exit_status(); + } else { + exit(EXIT_FAILURE); + } +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/test_urcu_fork_cxx.cpp b/external/lgpl2/userspace-rcu/dist/tests/regression/test_urcu_fork_cxx.cpp new file mode 100644 index 0000000000000..2f65b4661ed08 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/test_urcu_fork_cxx.cpp @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 EfficiOS Inc. +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "test_urcu_fork.c" diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/urcutorture.c b/external/lgpl2/userspace-rcu/dist/tests/regression/urcutorture.c new file mode 100644 index 0000000000000..ed256ea0a1335 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/urcutorture.c @@ -0,0 +1,30 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include +#include +#include +#include +#include +#include "api.h" +#define _LGPL_SOURCE + +#ifdef RCU_MEMBARRIER +#include +#endif +#ifdef RCU_MB +#include +#endif +#ifdef RCU_QSBR +#include +#endif +#ifdef RCU_BP +#include +#endif + +#include +#include +#include "rcutorture.h" diff --git a/external/lgpl2/userspace-rcu/dist/tests/regression/urcutorture_cxx.cpp b/external/lgpl2/userspace-rcu/dist/tests/regression/urcutorture_cxx.cpp new file mode 100644 index 0000000000000..cacd0bf015a7f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/regression/urcutorture_cxx.cpp @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 EfficiOS Inc. +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "urcutorture.c" diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/Makefile.am b/external/lgpl2/userspace-rcu/dist/tests/unit/Makefile.am new file mode 100644 index 0000000000000..5884ccbe0dcb9 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/Makefile.am @@ -0,0 +1,178 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +AM_CPPFLAGS += -I$(top_srcdir)/src -I$(top_srcdir)/tests/utils -I$(top_srcdir)/tests/common + +LOG_DRIVER_FLAGS = --merge --comments +LOG_DRIVER = env AM_TAP_AWK='$(AWK)' \ + URCU_TESTS_SRCDIR='$(abs_top_srcdir)/tests' \ + URCU_TESTS_BUILDDIR='$(abs_top_builddir)/tests' \ + $(SHELL) $(top_srcdir)/tests/utils/tap-driver.sh + +noinst_PROGRAMS = \ + get_cpu_mask_from_sysfs \ + get_cpu_mask_from_sysfs_cxx \ + get_max_cpuid_from_sysfs \ + get_max_cpuid_from_sysfs_cxx \ + test_arch \ + test_arch_cxx \ + test_get_max_cpuid_from_mask \ + test_get_max_cpuid_from_mask_cxx \ + test_get_possible_cpus_array_len \ + test_get_possible_cpus_array_len_cxx \ + test_uatomic \ + test_uatomic_cxx \ + test_urcu_multiflavor \ + test_urcu_multiflavor_cxx \ + test_urcu_multiflavor_dynlink \ + test_urcu_multiflavor_dynlink_cxx \ + test_urcu_multiflavor_single_unit \ + test_urcu_multiflavor_single_unit_cxx \ + test_urcu_multiflavor_single_unit_dynlink \ + test_urcu_multiflavor_single_unit_dynlink_cxx \ + test_build \ + test_build_cxx \ + test_build_dynlink \ + test_build_dynlink_cxx + +dist_noinst_SCRIPTS = \ + test_get_cpu_mask_from_sysfs \ + test_get_cpu_mask_from_sysfs_cxx \ + test_get_max_cpuid_from_sysfs \ + test_get_max_cpuid_from_sysfs_cxx + +TESTS = \ + test_arch \ + test_arch_cxx \ + test_get_cpu_mask_from_sysfs \ + test_get_cpu_mask_from_sysfs_cxx \ + test_get_max_cpuid_from_mask \ + test_get_max_cpuid_from_mask_cxx \ + test_get_max_cpuid_from_sysfs \ + test_get_max_cpuid_from_sysfs_cxx \ + test_get_possible_cpus_array_len \ + test_get_possible_cpus_array_len_cxx \ + test_uatomic \ + test_uatomic_cxx \ + test_urcu_multiflavor \ + test_urcu_multiflavor_cxx \ + test_urcu_multiflavor_dynlink \ + test_urcu_multiflavor_dynlink_cxx \ + test_urcu_multiflavor_single_unit \ + test_urcu_multiflavor_single_unit_cxx \ + test_urcu_multiflavor_single_unit_dynlink \ + test_urcu_multiflavor_single_unit_dynlink_cxx \ + test_build \ + test_build_cxx \ + test_build_dynlink \ + test_build_dynlink_cxx + +noinst_HEADERS = test_urcu_multiflavor.h + +URCU_COMMON_LIB=$(top_builddir)/src/liburcu-common.la +URCU_LIB=$(top_builddir)/src/liburcu.la +URCU_QSBR_LIB=$(top_builddir)/src/liburcu-qsbr.la +URCU_MB_LIB=$(top_builddir)/src/liburcu-mb.la +URCU_BP_LIB=$(top_builddir)/src/liburcu-bp.la +URCU_CDS_LIB=$(top_builddir)/src/liburcu-cds.la +TAP_LIB=$(top_builddir)/tests/utils/libtap.a + +get_cpu_mask_from_sysfs_cxx_SOURCES = get_cpu_mask_from_sysfs_cxx.cpp +get_cpu_mask_from_sysfs_SOURCES = get_cpu_mask_from_sysfs.c +get_max_cpuid_from_sysfs_cxx_SOURCES = get_max_cpuid_from_sysfs_cxx.cpp +get_max_cpuid_from_sysfs_SOURCES = get_max_cpuid_from_sysfs.c + +test_arch_SOURCES = test_arch.c +test_arch_LDADD = $(URCU_COMMON_LIB) $(TAP_LIB) + +test_arch_cxx_SOURCES = test_arch_cxx.cpp +test_arch_cxx_LDADD = $(URCU_COMMO_LIB) $(TAP_LIB) + +test_get_max_cpuid_from_mask_SOURCES = test_get_max_cpuid_from_mask.c +test_get_max_cpuid_from_mask_LDADD = $(TAP_LIB) + +test_get_max_cpuid_from_mask_cxx_SOURCES = test_get_max_cpuid_from_mask_cxx.cpp +test_get_max_cpuid_from_mask_cxx_LDADD = $(TAP_LIB) + +test_get_possible_cpus_array_len_SOURCES = test_get_possible_cpus_array_len.c +test_get_possible_cpus_array_len_LDADD = $(TAP_LIB) + +test_get_possible_cpus_array_len_cxx_SOURCES = test_get_possible_cpus_array_len_cxx.cpp +test_get_possible_cpus_array_len_cxx_LDADD = $(TAP_LIB) + +test_uatomic_SOURCES = test_uatomic.c +test_uatomic_LDADD = $(URCU_COMMON_LIB) $(TAP_LIB) + +test_uatomic_cxx_SOURCES = test_uatomic_cxx.cpp +test_uatomic_cxx_LDADD = $(URCU_COMMON_LIB) $(TAP_LIB) + +test_urcu_multiflavor_SOURCES = test_urcu_multiflavor.c \ + test_urcu_multiflavor-memb.c \ + test_urcu_multiflavor-mb.c \ + test_urcu_multiflavor-qsbr.c \ + test_urcu_multiflavor-bp.c +test_urcu_multiflavor_LDADD = $(URCU_LIB) $(URCU_MB_LIB) \ + $(URCU_QSBR_LIB) $(URCU_BP_LIB) $(TAP_LIB) + +test_urcu_multiflavor_cxx_SOURCES = test_urcu_multiflavor_cxx.cpp \ + test_urcu_multiflavor-memb_cxx.cpp \ + test_urcu_multiflavor-mb_cxx.cpp \ + test_urcu_multiflavor-qsbr_cxx.cpp \ + test_urcu_multiflavor-bp_cxx.cpp +test_urcu_multiflavor_cxx_LDADD = $(URCU_LIB) $(URCU_MB_LIB) \ + $(URCU_QSBR_LIB) $(URCU_BP_LIB) $(TAP_LIB) + +test_urcu_multiflavor_dynlink_SOURCES = test_urcu_multiflavor.c \ + test_urcu_multiflavor-memb.c \ + test_urcu_multiflavor-mb.c \ + test_urcu_multiflavor-qsbr.c \ + test_urcu_multiflavor-bp.c +test_urcu_multiflavor_dynlink_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS) +test_urcu_multiflavor_dynlink_LDADD = $(URCU_LIB) $(URCU_MB_LIB) \ + $(URCU_QSBR_LIB) $(URCU_BP_LIB) $(TAP_LIB) + +test_urcu_multiflavor_dynlink_cxx_SOURCES = test_urcu_multiflavor_cxx.cpp \ + test_urcu_multiflavor-memb_cxx.cpp \ + test_urcu_multiflavor-mb_cxx.cpp \ + test_urcu_multiflavor-qsbr_cxx.cpp \ + test_urcu_multiflavor-bp_cxx.cpp +test_urcu_multiflavor_dynlink_cxx_CXXFLAGS = -DDYNAMIC_LINK_TEST $(AM_CXXFLAGS) +test_urcu_multiflavor_dynlink_cxx_LDADD = $(URCU_LIB) $(URCU_MB_LIB) \ + $(URCU_QSBR_LIB) $(URCU_BP_LIB) $(TAP_LIB) + +test_urcu_multiflavor_single_unit_SOURCES = test_urcu_multiflavor_single_unit.c +test_urcu_multiflavor_single_unit_LDADD = $(URCU_LIB) $(URCU_MB_LIB) \ + $(URCU_QSBR_LIB) $(URCU_BP_LIB) $(TAP_LIB) + +test_urcu_multiflavor_single_unit_cxx_SOURCES = test_urcu_multiflavor_single_unit_cxx.cpp +test_urcu_multiflavor_single_unit_cxx_LDADD = $(URCU_LIB) $(URCU_MB_LIB) \ + $(URCU_QSBR_LIB) $(URCU_BP_LIB) $(TAP_LIB) + +test_urcu_multiflavor_single_unit_dynlink_SOURCES = test_urcu_multiflavor_single_unit.c +test_urcu_multiflavor_single_unit_dynlink_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS) +test_urcu_multiflavor_single_unit_dynlink_LDADD = $(URCU_LIB) $(URCU_MB_LIB) \ + $(URCU_QSBR_LIB) $(URCU_BP_LIB) $(TAP_LIB) + +test_urcu_multiflavor_single_unit_dynlink_cxx_SOURCES = test_urcu_multiflavor_single_unit_cxx.cpp +test_urcu_multiflavor_single_unit_dynlink_cxx_CXXFLAGS = -DDYNAMIC_LINK_TEST $(AM_CXXFLAGS) +test_urcu_multiflavor_single_unit_dynlink_cxx_LDADD = $(URCU_LIB) $(URCU_MB_LIB) \ + $(URCU_QSBR_LIB) $(URCU_BP_LIB) $(TAP_LIB) + +test_build_SOURCES = \ + test_build.c +test_build_LDADD = $(URCU_COMMON_LIB) $(URCU_CDS_LIB) $(TAP_LIB) + +test_build_cxx_SOURCES = \ + test_build_cxx.cpp +test_build_cxx_LDADD = $(URCU_COMMON_LIB) $(URCU_CDS_LIB) $(TAP_LIB) + +test_build_dynlink_SOURCES = \ + test_build.c +test_build_dynlink_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS) +test_build_dynlink_LDADD = $(URCU_LIB) $(URCU_COMMON_LIB) $(URCU_CDS_LIB) $(TAP_LIB) + +test_build_dynlink_cxx_SOURCES = \ + test_build_cxx.cpp +test_build_dynlink_cxx_CXXFLAGS = -DDYNAMIC_LINK_TEST $(AM_CXXFLAGS) +test_build_dynlink_cxx_LDADD = $(URCU_LIB) $(URCU_COMMON_LIB) $(URCU_CDS_LIB) $(TAP_LIB) diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/get_cpu_mask_from_sysfs.c b/external/lgpl2/userspace-rcu/dist/tests/unit/get_cpu_mask_from_sysfs.c new file mode 100644 index 0000000000000..7938f234bc8e0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/get_cpu_mask_from_sysfs.c @@ -0,0 +1,40 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (C) 2022 Michael Jeanson + */ + +#include +#include + +#ifdef __linux__ + +#include "compat-smp.h" + +int main(int argc, char *argv[]) +{ + int ret; + char buf[URCU_CPUMASK_SIZE]; + + if( argc < 2 ) { + fprintf(stderr, "Missing argument.\n"); + return EXIT_FAILURE; + } + + ret = get_cpu_mask_from_sysfs((char *) &buf, URCU_CPUMASK_SIZE, argv[1]); + + printf("%s", buf); + + if (ret >= 0) + return EXIT_SUCCESS; + else + return EXIT_FAILURE; +} + +#else + +int main(void) +{ + return EXIT_SUCCESS; +} +#endif diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/get_cpu_mask_from_sysfs_cxx.cpp b/external/lgpl2/userspace-rcu/dist/tests/unit/get_cpu_mask_from_sysfs_cxx.cpp new file mode 100644 index 0000000000000..a413f3c88554b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/get_cpu_mask_from_sysfs_cxx.cpp @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 EfficiOS Inc. +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "get_cpu_mask_from_sysfs.c" diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/get_max_cpuid_from_sysfs.c b/external/lgpl2/userspace-rcu/dist/tests/unit/get_max_cpuid_from_sysfs.c new file mode 100644 index 0000000000000..37c4b3d4851e9 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/get_max_cpuid_from_sysfs.c @@ -0,0 +1,39 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (C) 2022 Michael Jeanson + */ + +#include +#include + +#ifdef __linux__ + +#include "compat-smp.h" + +int main(int argc, char *argv[]) +{ + int ret; + + if( argc < 2 ) { + fprintf(stderr, "Missing argument.\n"); + return EXIT_FAILURE; + } + + ret = _get_max_cpuid_from_sysfs(argv[1]); + + printf("%d\n", ret); + + if (ret >= 0) + return EXIT_SUCCESS; + else + return EXIT_FAILURE; +} + +#else + +int main(void) +{ + return EXIT_SUCCESS; +} +#endif diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/get_max_cpuid_from_sysfs_cxx.cpp b/external/lgpl2/userspace-rcu/dist/tests/unit/get_max_cpuid_from_sysfs_cxx.cpp new file mode 100644 index 0000000000000..4e46dfbd9f314 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/get_max_cpuid_from_sysfs_cxx.cpp @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 EfficiOS Inc. +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "get_max_cpuid_from_sysfs.c" diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_arch.c b/external/lgpl2/userspace-rcu/dist/tests/unit/test_arch.c new file mode 100644 index 0000000000000..141c564b3e168 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_arch.c @@ -0,0 +1,34 @@ +// SPDX-FileCopyrightText: 2021 Michael Jeanson +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include + +#include "tap.h" + +#define NR_TESTS 1 + + +/* + * This is only to make sure the static inline caa_get_cycles() in the public + * headers builds properly. + */ +static +void test_caa_get_cycles(void) { + caa_cycles_t cycles = 0; + + + cycles = caa_get_cycles(); + + ok(cycles != 0, "caa_get_cycles works"); +} + +int main(void) +{ + plan_tests(NR_TESTS); + + test_caa_get_cycles(); + + return exit_status(); +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_arch_cxx.cpp b/external/lgpl2/userspace-rcu/dist/tests/unit/test_arch_cxx.cpp new file mode 100644 index 0000000000000..6c6c97261df99 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_arch_cxx.cpp @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 EfficiOS Inc. +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "test_arch.c" diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_build.c b/external/lgpl2/userspace-rcu/dist/tests/unit/test_build.c new file mode 100644 index 0000000000000..99ddbcdd2ac4b --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_build.c @@ -0,0 +1,135 @@ +// SPDX-FileCopyrightText: 2021 Simon Marchi +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * This file is meant to verify that headers are compatible with both C and + * C++. It includes all exported headers and is compiled as C and C++ source. + */ + +#ifndef DYNAMIC_LINK_TEST +# define _LGPL_SOURCE +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tap.h" + +struct my_tls_struct { + int int1; + char char1; + void *void1; +}; + +static DEFINE_URCU_TLS(int, my_tls_int); +static DEFINE_URCU_TLS(struct my_tls_struct, my_tls_struct); + +static void test_lfstack(void) +{ + struct cds_lfs_stack s; + + cds_lfs_init(&s); + ok(cds_lfs_empty(&s), "cds_lfs_empty"); +} + +static void test_wfstack(void) +{ + struct cds_wfs_stack s; + + cds_wfs_init(&s); + ok(cds_wfs_empty(&s), "cds_lfs_empty"); +} + +static void test_wfcqueue(void) +{ + struct cds_wfcq_head head; + struct cds_wfcq_tail tail; + + cds_wfcq_init(&head, &tail); + ok(cds_wfcq_empty(&head, &tail), "cds_wfcq_empty"); +} + +static +void test_build_cds_list_head_init(void) +{ + /* Test that the CDS_LIST_HEAD_INIT macro builds correctly. */ + struct struct_with_list { + struct cds_list_head head; + }; + + struct struct_with_list list = { + .head = CDS_LIST_HEAD_INIT(list.head), + }; +} + +static +void test_urcu_tls(void) +{ + URCU_TLS(my_tls_int) = 1; + URCU_TLS(my_tls_struct).int1 = 1; + URCU_TLS(my_tls_struct).char1 = 'a'; + URCU_TLS(my_tls_struct).void1 = NULL; +} + +struct an_opaque_struct; +struct a_clear_struct +{ + int x; +}; + +static +void test_build_rcu_dereference(void) +{ + static struct an_opaque_struct *opaque = NULL; + static struct an_opaque_struct *const opaque_const = NULL; + static struct a_clear_struct *clear = NULL; + static struct a_clear_struct *const clear_const = NULL; + + (void) rcu_dereference(opaque); + (void) rcu_dereference(opaque_const); + (void) rcu_dereference(clear); + (void) rcu_dereference(clear_const); +} + +int main(void) +{ + plan_tests(3); + + test_lfstack(); + test_wfstack(); + test_wfcqueue(); + test_build_cds_list_head_init(); + test_urcu_tls(); + test_build_rcu_dereference(); + + return exit_status(); +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_build_cxx.cpp b/external/lgpl2/userspace-rcu/dist/tests/unit/test_build_cxx.cpp new file mode 100644 index 0000000000000..0d557e50ef503 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_build_cxx.cpp @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 EfficiOS Inc. +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "test_build.c" diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_cpu_mask_from_sysfs b/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_cpu_mask_from_sysfs new file mode 100755 index 0000000000000..0709892086072 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_cpu_mask_from_sysfs @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + +# shellcheck source=../../utils/tap.sh +source "$URCU_TESTS_SRCDIR/utils/tap.sh" + +CURDIR="${URCU_TESTS_BUILDDIR}/unit" + +NUM_TESTS=8 + +TESTFILE=$(mktemp) + +populate_testfile() { + local cpumask="$1" + + # shellcheck disable=SC2059 + printf "$cpumask" > "$TESTFILE" +} + +test_test_get_cpu_mask_from_sysfs() { + local cpumask="$1" + local result + + # Without '\n' + populate_testfile "$cpumask" + result=$("${CURDIR}/get_cpu_mask_from_sysfs" "$TESTFILE") + test "$cpumask" == "$result" + ok $? "test_get_cpu_mask_from_sysfs - without '\n' expected: '$cpumask', result: '$result'" + + # With '\n' + populate_testfile "$cpumask\n" + result=$("${CURDIR}/get_cpu_mask_from_sysfs" "$TESTFILE") + test "$cpumask" == "$result" + ok $? "test_get_cpu_mask_from_sysfs - with '\n' expected: '$cpumask', result: '$result'" +} + +if [ "$URCU_TESTS_OS_TYPE" == "linux" ]; then + plan_tests $NUM_TESTS + + test_test_get_cpu_mask_from_sysfs "" + test_test_get_cpu_mask_from_sysfs "0" + test_test_get_cpu_mask_from_sysfs "0-3" + test_test_get_cpu_mask_from_sysfs "0,3-7,9" +else + plan_skip_all "Linux specific tests." +fi diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_cpu_mask_from_sysfs_cxx b/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_cpu_mask_from_sysfs_cxx new file mode 100755 index 0000000000000..4ed4ebdf893b0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_cpu_mask_from_sysfs_cxx @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + +# shellcheck source=../../utils/tap.sh +source "$URCU_TESTS_SRCDIR/utils/tap.sh" + +CURDIR="${URCU_TESTS_BUILDDIR}/unit" + +NUM_TESTS=8 + +TESTFILE=$(mktemp) + +populate_testfile() { + local cpumask="$1" + + # shellcheck disable=SC2059 + printf "$cpumask" > "$TESTFILE" +} + +test_test_get_cpu_mask_from_sysfs_cxx() { + local cpumask="$1" + local result + + # Without '\n' + populate_testfile "$cpumask" + result=$("${CURDIR}/get_cpu_mask_from_sysfs_cxx" "$TESTFILE") + test "$cpumask" == "$result" + ok $? "test_get_cpu_mask_from_sysfs_cxx - without '\n' expected: '$cpumask', result: '$result'" + + # With '\n' + populate_testfile "$cpumask\n" + result=$("${CURDIR}/get_cpu_mask_from_sysfs_cxx" "$TESTFILE") + test "$cpumask" == "$result" + ok $? "test_get_cpu_mask_from_sysfs_cxx - with '\n' expected: '$cpumask', result: '$result'" +} + +if [ "$URCU_TESTS_OS_TYPE" == "linux" ]; then + plan_tests $NUM_TESTS + + test_test_get_cpu_mask_from_sysfs_cxx "" + test_test_get_cpu_mask_from_sysfs_cxx "0" + test_test_get_cpu_mask_from_sysfs_cxx "0-3" + test_test_get_cpu_mask_from_sysfs_cxx "0,3-7,9" +else + plan_skip_all "Linux specific tests." +fi diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_max_cpuid_from_mask.c b/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_max_cpuid_from_mask.c new file mode 100644 index 0000000000000..25a2417f4947c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_max_cpuid_from_mask.c @@ -0,0 +1,88 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (C) 2022 Michael Jeanson + */ + +#include + +#include "tap.h" + +#include "compat-smp.h" + +#ifdef __linux__ +struct parse_test_data { + const char *buf; + int expected; +}; + +static struct parse_test_data parse_test_data[] = { + { "", -1 }, + { "abc", -1 }, + { ",,,", -1 }, + { "--", -1 }, + { ",", -1 }, + { "-", -1 }, + { "2147483647", -1 }, + { "18446744073709551615", -1 }, + { "0-2147483647", -1 }, + { "0-18446744073709551615", -1 }, + { "0", 0 }, + { "1", 1 }, + { "0-1", 1 }, + { "1-3", 3 }, + { "0,2", 2 }, + { "1,2", 2 }, + { "0,4-6,127", 127 }, + { "0-4095", 4095 }, + + { "\n", -1 }, + { "abc\n", -1 }, + { ",,,\n", -1 }, + { "--\n", -1 }, + { ",\n", -1 }, + { "-\n", -1 }, + { "2147483647\n", -1 }, + { "18446744073709551615\n", -1 }, + { "0-2147483647\n", -1 }, + { "0-18446744073709551615\n", -1 }, + { "0\n", 0 }, + { "1\n", 1 }, + { "0-1\n", 1 }, + { "1-3\n", 3 }, + { "0,2\n", 2 }, + { "1,2\n", 2 }, + { "0,4-6,127\n", 127 }, + { "0-4095\n", 4095 }, +}; + +static int parse_test_data_len = sizeof(parse_test_data) / sizeof(parse_test_data[0]); + +int main(void) +{ + int ret, i; + + plan_tests(parse_test_data_len); + + diag("Testing smp helpers"); + + for (i = 0; i < parse_test_data_len; i++) { + ret = get_max_cpuid_from_mask(parse_test_data[i].buf, + strlen(parse_test_data[i].buf)); + ok(ret == parse_test_data[i].expected, + "get_max_cpuid_from_mask '%s', expected: '%d', result: '%d'", + parse_test_data[i].buf, parse_test_data[i].expected, ret); + } + + return exit_status(); +} + +#else + +int main(void) +{ + plan_skip_all("Linux specific tests."); + + return exit_status(); +} +#endif diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_max_cpuid_from_mask_cxx.cpp b/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_max_cpuid_from_mask_cxx.cpp new file mode 100644 index 0000000000000..bd91459ce0775 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_max_cpuid_from_mask_cxx.cpp @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 EfficiOS Inc. +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "test_get_max_cpuid_from_mask.c" diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_max_cpuid_from_sysfs b/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_max_cpuid_from_sysfs new file mode 100755 index 0000000000000..7c0abce42f1f3 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_max_cpuid_from_sysfs @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + +# shellcheck source=../../utils/tap.sh +source "$URCU_TESTS_SRCDIR/utils/tap.sh" + +CURDIR="${URCU_TESTS_BUILDDIR}/unit" + +STD_OUTPUT="/dev/null" +STD_ERROR="/dev/null" + +NUM_TESTS=13 + +TESTDIR=$(mktemp -d) + +populate_testdir() { + local cpus=("$@") + + mkdir "$TESTDIR" + + for i in "${cpus[@]}"; do + mkdir "$TESTDIR/$i" + done +} + +test_get_max_cpuid_from_sysfs() { + local num_cpus=$1 + shift + local current_cpus=("$@") + local result + + populate_testdir "${current_cpus[@]}" >"$STD_OUTPUT" 2>"$STD_ERROR" + result=$("${CURDIR}/get_max_cpuid_from_sysfs" "$TESTDIR") + is "$result" "$num_cpus" "get_max_cpuid_from_sysfs - cpu set: '${current_cpus[*]}', expected: '$num_cpus', result: '$result'" + rm -rf "$TESTDIR" +} + +if [ "$URCU_TESTS_OS_TYPE" == "linux" ]; then + plan_tests $NUM_TESTS + + diag "get_max_cpuid_from_sysfs" + + test_data=(0 "cpu0") + test_get_max_cpuid_from_sysfs "${test_data[@]}" + + test_data=(1 "cpu0" "cpu1") + test_get_max_cpuid_from_sysfs "${test_data[@]}" + + test_data=(1 "cpu1" "cpu0") + test_get_max_cpuid_from_sysfs "${test_data[@]}" + + test_data=(3 "cpu3") + test_get_max_cpuid_from_sysfs "${test_data[@]}" + + test_data=(99 "cpu99") + test_get_max_cpuid_from_sysfs "${test_data[@]}" + + test_data=(3 "cpu0" "cpu3") + test_get_max_cpuid_from_sysfs "${test_data[@]}" + + test_data=(3 "cpufreq" "cpuidle" "cpu0" "cpu1" "cpu2" "cpu3") + test_get_max_cpuid_from_sysfs "${test_data[@]}" + + test_data=(0 "cpu" "cpu0") + test_get_max_cpuid_from_sysfs "${test_data[@]}" + + test_data=(5 "cpu" "cpu5") + test_get_max_cpuid_from_sysfs "${test_data[@]}" + + + test_data=(-1 "toto") + test_get_max_cpuid_from_sysfs "${test_data[@]}" + + test_data=(-1 "cpu") + test_get_max_cpuid_from_sysfs "${test_data[@]}" + + test_data=(-1 "cpua" "cpud") + test_get_max_cpuid_from_sysfs "${test_data[@]}" + + test_data=(-1 "cpufreq" "cpuidle") + test_get_max_cpuid_from_sysfs "${test_data[@]}" +else + plan_skip_all "Linux specific tests." +fi diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_max_cpuid_from_sysfs_cxx b/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_max_cpuid_from_sysfs_cxx new file mode 100755 index 0000000000000..2283a046aa484 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_max_cpuid_from_sysfs_cxx @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi + +# shellcheck source=../utils/utils.sh +source "$UTILSSH" + +# shellcheck source=../../utils/tap.sh +source "$URCU_TESTS_SRCDIR/utils/tap.sh" + +CURDIR="${URCU_TESTS_BUILDDIR}/unit" + +STD_OUTPUT="/dev/null" +STD_ERROR="/dev/null" + +NUM_TESTS=13 + +TESTDIR=$(mktemp -d) + +populate_testdir() { + local cpus=("$@") + + mkdir "$TESTDIR" + + for i in "${cpus[@]}"; do + mkdir "$TESTDIR/$i" + done +} + +test_get_max_cpuid_from_sysfs_cxx() { + local num_cpus=$1 + shift + local current_cpus=("$@") + local result + + populate_testdir "${current_cpus[@]}" >"$STD_OUTPUT" 2>"$STD_ERROR" + result=$("${CURDIR}/get_max_cpuid_from_sysfs_cxx" "$TESTDIR") + is "$result" "$num_cpus" "get_max_cpuid_from_sysfs_cxx - cpu set: '${current_cpus[*]}', expected: '$num_cpus', result: '$result'" + rm -rf "$TESTDIR" +} + +if [ "$URCU_TESTS_OS_TYPE" == "linux" ]; then + plan_tests $NUM_TESTS + + diag "get_max_cpuid_from_sysfs_cxx" + + test_data=(0 "cpu0") + test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}" + + test_data=(1 "cpu0" "cpu1") + test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}" + + test_data=(1 "cpu1" "cpu0") + test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}" + + test_data=(3 "cpu3") + test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}" + + test_data=(99 "cpu99") + test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}" + + test_data=(3 "cpu0" "cpu3") + test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}" + + test_data=(3 "cpufreq" "cpuidle" "cpu0" "cpu1" "cpu2" "cpu3") + test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}" + + test_data=(0 "cpu" "cpu0") + test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}" + + test_data=(5 "cpu" "cpu5") + test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}" + + + test_data=(-1 "toto") + test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}" + + test_data=(-1 "cpu") + test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}" + + test_data=(-1 "cpua" "cpud") + test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}" + + test_data=(-1 "cpufreq" "cpuidle") + test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}" +else + plan_skip_all "Linux specific tests." +fi diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_possible_cpus_array_len.c b/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_possible_cpus_array_len.c new file mode 100644 index 0000000000000..c5ab2b4b68c7c --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_possible_cpus_array_len.c @@ -0,0 +1,30 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (C) 2022 Michael Jeanson + */ + +#include + +#include "tap.h" + +#include "compat-smp.h" + +int main(void) +{ + int ret; + + plan_tests(2); + + ret = get_possible_cpus_array_len(); + ok(ret > 0, "get_possible_cpus_array_len (%d > 0)", ret); + +#ifdef __linux__ + ret = get_num_possible_cpus_fallback(); + ok(ret > 0, "get_num_possible_cpus_fallback (%d > 0)", ret); +#else + skip(1, "Linux specific test."); +#endif + + return exit_status(); +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_possible_cpus_array_len_cxx.cpp b/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_possible_cpus_array_len_cxx.cpp new file mode 100644 index 0000000000000..536c509ad8c11 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_get_possible_cpus_array_len_cxx.cpp @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 EfficiOS Inc. +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "test_get_possible_cpus_array_len.c" diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_lfstack.c b/external/lgpl2/userspace-rcu/dist/tests/unit/test_lfstack.c new file mode 100644 index 0000000000000..03d16329b29fc --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_lfstack.c @@ -0,0 +1,78 @@ +// SPDX-FileCopyrightText: 2023 Olivier Dion +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * test_lfstack.c + * + * Userspace RCU library - test wftack race conditions + */ + +#define _LGPL_SOURCE + +#include + +#include + +#include + +#include "tap.h" + +#define NR_TESTS 1 +#define NR_PRODUCERS 4 +#define LOOP 100 + +static void async_run(struct cds_lfs_stack *queue) +{ + struct cds_lfs_node *node = malloc(sizeof(*node)); + + cds_lfs_node_init(node); + + cds_lfs_push(queue, node); +} + +static void *async_loop(void *queue) +{ + size_t k = 0; + + while (k < LOOP * NR_PRODUCERS) { + free(cds_lfs_pop_blocking(queue)); + ++k; + } + + return NULL; +} + +static void *spawn_jobs(void *queue) +{ + for (size_t k = 0; k < LOOP; ++k) { + async_run(queue); + } + + return 0; +} + +int main(void) +{ + pthread_t consumer; + pthread_t producers[NR_PRODUCERS]; + struct cds_lfs_stack queue; + + plan_tests(NR_TESTS); + + cds_lfs_init(&queue); + pthread_create(&consumer, NULL, async_loop, &queue); + + for (size_t k = 0; k < NR_PRODUCERS; ++k) { + pthread_create(&producers[k], NULL, spawn_jobs, &queue); + } + + pthread_join(consumer, NULL); + for (size_t k = 0; k < NR_PRODUCERS; ++k) { + pthread_join(producers[k], NULL); + } + + ok1("No race conditions"); + + return exit_status(); +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_uatomic.c b/external/lgpl2/userspace-rcu/dist/tests/unit/test_uatomic.c new file mode 100644 index 0000000000000..d9c70e0ac9127 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_uatomic.c @@ -0,0 +1,116 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include + +#include "tap.h" + +#define NR_TESTS 17 + +#define BYTE_PER_LONG (sizeof(unsigned long) / sizeof(unsigned char)) +#define SHORT_PER_LONG (sizeof(unsigned long) / sizeof(unsigned short)) +#define INT_PER_LONG (sizeof(unsigned long) / sizeof(unsigned int)) + +struct testvals { +#ifdef UATOMIC_HAS_ATOMIC_BYTE + unsigned char c[BYTE_PER_LONG]; +#endif +#ifdef UATOMIC_HAS_ATOMIC_SHORT + unsigned short s[SHORT_PER_LONG]; +#endif + unsigned int i[INT_PER_LONG]; + unsigned long l; +}; + +static struct testvals vals; + +#define do_test(ptr) \ +do { \ + __typeof__(*(ptr)) v; \ + \ + uatomic_add(ptr, 10); \ + ok1(uatomic_read(ptr) == 10); \ + \ + uatomic_add(ptr, -11UL); \ + ok1(uatomic_read(ptr) == (__typeof__(*(ptr)))-1UL); \ + \ + v = uatomic_cmpxchg(ptr, -1UL, 22); \ + ok1(uatomic_read(ptr) == 22); \ + ok1(v == (__typeof__(*(ptr)))-1UL); \ + \ + v = uatomic_cmpxchg(ptr, 33, 44); \ + ok1(uatomic_read(ptr) == 22); \ + ok1(v == 22); \ + \ + v = uatomic_xchg(ptr, 55); \ + ok1(uatomic_read(ptr) == 55); \ + ok1(v == 22); \ + \ + uatomic_set(ptr, 22); \ + uatomic_inc(ptr); \ + ok1(uatomic_read(ptr) == 23); \ + \ + uatomic_dec(ptr); \ + ok1(uatomic_read(ptr) == 22); \ + \ + v = uatomic_add_return(ptr, 74); \ + ok1(v == 96); \ + ok1(uatomic_read(ptr) == 96); \ + \ + uatomic_or(ptr, 58); \ + ok1(uatomic_read(ptr) == 122); \ + \ + v = uatomic_sub_return(ptr, 1); \ + ok1(v == 121); \ + \ + uatomic_sub(ptr, (unsigned int) 2); \ + ok1(uatomic_read(ptr) == 119); \ + \ + uatomic_inc(ptr); \ + uatomic_inc(ptr); \ + ok1(uatomic_read(ptr) == 121); \ + \ + uatomic_and(ptr, 129); \ + ok1(uatomic_read(ptr) == 1); \ + \ +} while (0) + +int main(void) +{ + int nr_run = INT_PER_LONG + 1; + unsigned long i; + +#ifdef UATOMIC_HAS_ATOMIC_BYTE + nr_run += BYTE_PER_LONG; +#endif +#ifdef UATOMIC_HAS_ATOMIC_SHORT + nr_run += SHORT_PER_LONG; +#endif + + plan_tests(nr_run * NR_TESTS); +#ifdef UATOMIC_HAS_ATOMIC_BYTE + for (i = 0; i < BYTE_PER_LONG; i++) { + diag("Test atomic ops on byte with %lu byte offset from long alignment", + i); + do_test(&vals.c[i]); + } +#endif +#ifdef UATOMIC_HAS_ATOMIC_SHORT + for (i = 0; i < SHORT_PER_LONG; i++) { + diag("Test atomic ops on short with %lu byte offset from long alignment", + i * sizeof(unsigned short)); + do_test(&vals.s[i]); + } +#endif + for (i = 0; i < INT_PER_LONG; i++) { + diag("Test atomic ops on int with %lu byte offset from long alignment", + i * sizeof(unsigned int)); + do_test(&vals.i[i]); + } + diag("Test atomic ops on long"); + do_test(&vals.l); + + return exit_status(); +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_uatomic_cxx.cpp b/external/lgpl2/userspace-rcu/dist/tests/unit/test_uatomic_cxx.cpp new file mode 100644 index 0000000000000..0f9e2753c3636 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_uatomic_cxx.cpp @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 EfficiOS Inc. +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "test_uatomic.c" diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-bp.c b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-bp.c new file mode 100644 index 0000000000000..460cfa6129afb --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-bp.c @@ -0,0 +1,24 @@ +// SPDX-FileCopyrightText: 2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test multiple RCU flavors into one program + */ + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif + +#include +#include "test_urcu_multiflavor.h" + +int test_mf_bp(void) +{ + rcu_register_thread(); + rcu_read_lock(); + rcu_read_unlock(); + synchronize_rcu(); + rcu_unregister_thread(); + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-bp_cxx.cpp b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-bp_cxx.cpp new file mode 100644 index 0000000000000..d38d159e5e3f0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-bp_cxx.cpp @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 EfficiOS Inc. +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "test_urcu_multiflavor-bp.c" diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-mb.c b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-mb.c new file mode 100644 index 0000000000000..e2d48781aecb1 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-mb.c @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test multiple RCU flavors into one program + */ + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif + +#define RCU_MB +#include +#include "test_urcu_multiflavor.h" + +int test_mf_mb(void) +{ + rcu_register_thread(); + rcu_read_lock(); + rcu_read_unlock(); + synchronize_rcu(); + rcu_unregister_thread(); + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-mb_cxx.cpp b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-mb_cxx.cpp new file mode 100644 index 0000000000000..67691deec0045 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-mb_cxx.cpp @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 EfficiOS Inc. +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "test_urcu_multiflavor-mb.c" diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-memb.c b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-memb.c new file mode 100644 index 0000000000000..43d0afa555303 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-memb.c @@ -0,0 +1,24 @@ +// SPDX-FileCopyrightText: 2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test multiple RCU flavors into one program + */ + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif + +#include +#include "test_urcu_multiflavor.h" + +int test_mf_memb(void) +{ + rcu_register_thread(); + rcu_read_lock(); + rcu_read_unlock(); + synchronize_rcu(); + rcu_unregister_thread(); + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-memb_cxx.cpp b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-memb_cxx.cpp new file mode 100644 index 0000000000000..d9fabefa30a98 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-memb_cxx.cpp @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 EfficiOS Inc. +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "test_urcu_multiflavor-memb.c" diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-qsbr.c b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-qsbr.c new file mode 100644 index 0000000000000..fa478cae67523 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-qsbr.c @@ -0,0 +1,24 @@ +// SPDX-FileCopyrightText: 2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test multiple RCU flavors into one program + */ + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif + +#include +#include "test_urcu_multiflavor.h" + +int test_mf_qsbr(void) +{ + rcu_register_thread(); + rcu_read_lock(); + rcu_read_unlock(); + synchronize_rcu(); + rcu_unregister_thread(); + return 0; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-qsbr_cxx.cpp b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-qsbr_cxx.cpp new file mode 100644 index 0000000000000..b52f783e9b0ae --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor-qsbr_cxx.cpp @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 EfficiOS Inc. +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "test_urcu_multiflavor-qsbr.c" diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor.c b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor.c new file mode 100644 index 0000000000000..ef7605a1d90c0 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor.c @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test multiple RCU flavors into one program + */ + +#include +#include "test_urcu_multiflavor.h" + +#include "tap.h" + +int main(void) +{ + plan_tests(4); + + ok1(!test_mf_memb()); + + ok1(!test_mf_mb()); + ok1(!test_mf_qsbr()); + ok1(!test_mf_bp()); + + return exit_status(); +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor.h b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor.h new file mode 100644 index 0000000000000..27e59f0de65fa --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor.h @@ -0,0 +1,14 @@ +// SPDX-FileCopyrightText: 2012 Lai Jiangshan +// SPDX-FileCopyrightText: 2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test multiple RCU flavors into one program + */ + +extern int test_mf_memb(void); +extern int test_mf_mb(void); +extern int test_mf_qsbr(void); +extern int test_mf_bp(void); + diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor_cxx.cpp b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor_cxx.cpp new file mode 100644 index 0000000000000..6794731171bca --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor_cxx.cpp @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 EfficiOS Inc. +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "test_urcu_multiflavor.c" diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor_single_unit.c b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor_single_unit.c new file mode 100644 index 0000000000000..5548744e2f6ea --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor_single_unit.c @@ -0,0 +1,71 @@ +// SPDX-FileCopyrightText: 2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Userspace RCU library - test multiple RCU flavors into one program + */ + +#ifndef DYNAMIC_LINK_TEST +#define _LGPL_SOURCE +#endif + +#include +#include +#include +#include + +#include +#include "tap.h" + +static int test_mf_mb(void) +{ + urcu_mb_register_thread(); + urcu_mb_read_lock(); + urcu_mb_read_unlock(); + urcu_mb_synchronize_rcu(); + urcu_mb_unregister_thread(); + return 0; +} + +static int test_mf_bp(void) +{ + urcu_bp_register_thread(); + urcu_bp_read_lock(); + urcu_bp_read_unlock(); + urcu_bp_synchronize_rcu(); + urcu_bp_unregister_thread(); + return 0; +} + +static int test_mf_memb(void) +{ + urcu_memb_register_thread(); + urcu_memb_read_lock(); + urcu_memb_read_unlock(); + urcu_memb_synchronize_rcu(); + urcu_memb_unregister_thread(); + return 0; +} + +static int test_mf_qsbr(void) +{ + urcu_qsbr_register_thread(); + urcu_qsbr_read_lock(); + urcu_qsbr_read_unlock(); + urcu_qsbr_synchronize_rcu(); + urcu_qsbr_unregister_thread(); + return 0; +} + +int main(void) +{ + plan_tests(4); + + ok1(!test_mf_mb()); + ok1(!test_mf_bp()); + ok1(!test_mf_memb()); + ok1(!test_mf_qsbr()); + + return exit_status(); +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor_single_unit_cxx.cpp b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor_single_unit_cxx.cpp new file mode 100644 index 0000000000000..f7cdf215ebca2 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_urcu_multiflavor_single_unit_cxx.cpp @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 EfficiOS Inc. +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "test_urcu_multiflavor_single_unit.c" diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_wfcqueue.c b/external/lgpl2/userspace-rcu/dist/tests/unit/test_wfcqueue.c new file mode 100644 index 0000000000000..45c498865f35d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_wfcqueue.c @@ -0,0 +1,107 @@ +// SPDX-FileCopyrightText: 2023 Olivier Dion +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * test_wfcqueue.c + * + * Userspace RCU library - test wfcqueue race conditions + */ + +#define _LGPL_SOURCE + +#include + +#include + +#include + +#include "tap.h" + +#define NR_TESTS 1 +#define NR_PRODUCERS 4 +#define LOOP 100 + +struct queue { + struct cds_wfcq_head head; + struct cds_wfcq_tail tail; +}; + +static void async_run(struct queue *queue) +{ + struct cds_wfcq_node *node = malloc(sizeof(*node)); + + cds_wfcq_node_init(node); + + cds_wfcq_enqueue(&queue->head, &queue->tail, node); +} +static void do_async_loop(size_t *k, struct queue *queue) +{ + struct queue my_queue; + enum cds_wfcq_ret state; + struct cds_wfcq_node *node, *next; + + cds_wfcq_init(&my_queue.head, &my_queue.tail); + + state = cds_wfcq_splice_blocking(&my_queue.head, + &my_queue.tail, + &queue->head, + &queue->tail); + + if (state == CDS_WFCQ_RET_SRC_EMPTY) { + return; + } + + __cds_wfcq_for_each_blocking_safe(&my_queue.head, + &my_queue.tail, + node, next) { + free(node); + (*k)++; + } +} + +static void *async_loop(void *queue) +{ + size_t k = 0; + + while (k < LOOP * NR_PRODUCERS) { + (void) poll(NULL, 0, 10); + do_async_loop(&k, queue); + } + + return NULL; +} + +static void *spawn_jobs(void *queue) +{ + for (size_t k = 0; k < LOOP; ++k) { + async_run(queue); + } + + return 0; +} + +int main(void) +{ + pthread_t consumer; + pthread_t producers[NR_PRODUCERS]; + struct queue queue; + + plan_tests(NR_TESTS); + + cds_wfcq_init(&queue.head, &queue.tail); + pthread_create(&consumer, NULL, async_loop, &queue); + + for (size_t k = 0; k < NR_PRODUCERS; ++k) { + pthread_create(&producers[k], NULL, spawn_jobs, &queue); + } + + pthread_join(consumer, NULL); + for (size_t k = 0; k < NR_PRODUCERS; ++k) { + pthread_join(producers[k], NULL); + } + + ok1("No race conditions"); + + return exit_status(); +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_wfqueue.c b/external/lgpl2/userspace-rcu/dist/tests/unit/test_wfqueue.c new file mode 100644 index 0000000000000..944c49a6e3f14 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_wfqueue.c @@ -0,0 +1,79 @@ +// SPDX-FileCopyrightText: 2023 Olivier Dion +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * test_wfqueue.c + * + * Userspace RCU library - test wfqueue race conditions + */ + +#define _LGPL_SOURCE + +#include + +#include + +#define CDS_WFQ_DEPRECATED +#include + +#include "tap.h" + +#define NR_TESTS 1 +#define NR_PRODUCERS 4 +#define LOOP 100 + +static void async_run(struct cds_wfq_queue *queue) +{ + struct cds_wfq_node *node = malloc(sizeof(*node)); + + cds_wfq_node_init(node); + + cds_wfq_enqueue(queue, node); +} + +static void *async_loop(void *queue) +{ + size_t k = 0; + + while (k < LOOP * NR_PRODUCERS) { + free(cds_wfq_dequeue_blocking(queue)); + ++k; + } + + return NULL; +} + +static void *spawn_jobs(void *queue) +{ + for (size_t k = 0; k < LOOP; ++k) { + async_run(queue); + } + + return 0; +} + +int main(void) +{ + pthread_t consumer; + pthread_t producers[NR_PRODUCERS]; + struct cds_wfq_queue queue; + + plan_tests(NR_TESTS); + + cds_wfq_init(&queue); + pthread_create(&consumer, NULL, async_loop, &queue); + + for (size_t k = 0; k < NR_PRODUCERS; ++k) { + pthread_create(&producers[k], NULL, spawn_jobs, &queue); + } + + pthread_join(consumer, NULL); + for (size_t k = 0; k < NR_PRODUCERS; ++k) { + pthread_join(producers[k], NULL); + } + + ok1("No race conditions"); + + return exit_status(); +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/test_wfstack.c b/external/lgpl2/userspace-rcu/dist/tests/unit/test_wfstack.c new file mode 100644 index 0000000000000..17901cec1c2bc --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/test_wfstack.c @@ -0,0 +1,78 @@ +// SPDX-FileCopyrightText: 2023 Olivier Dion +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * test_wfstack.c + * + * Userspace RCU library - test wftack race conditions + */ + +#define _LGPL_SOURCE + +#include + +#include + +#include + +#include "tap.h" + +#define NR_TESTS 1 +#define NR_PRODUCERS 4 +#define LOOP 100 + +static void async_run(struct cds_wfs_stack *queue) +{ + struct cds_wfs_node *node = malloc(sizeof(*node)); + + cds_wfs_node_init(node); + + cds_wfs_push(queue, node); +} + +static void *async_loop(void *queue) +{ + size_t k = 0; + + while (k < LOOP * NR_PRODUCERS) { + free(cds_wfs_pop_blocking(queue)); + ++k; + } + + return NULL; +} + +static void *spawn_jobs(void *queue) +{ + for (size_t k = 0; k < LOOP; ++k) { + async_run(queue); + } + + return 0; +} + +int main(void) +{ + pthread_t consumer; + pthread_t producers[NR_PRODUCERS]; + struct cds_wfs_stack queue; + + plan_tests(NR_TESTS); + + cds_wfs_init(&queue); + pthread_create(&consumer, NULL, async_loop, &queue); + + for (size_t k = 0; k < NR_PRODUCERS; ++k) { + pthread_create(&producers[k], NULL, spawn_jobs, &queue); + } + + pthread_join(consumer, NULL); + for (size_t k = 0; k < NR_PRODUCERS; ++k) { + pthread_join(producers[k], NULL); + } + + ok1("No race conditions"); + + return exit_status(); +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/urcu-asm.c b/external/lgpl2/userspace-rcu/dist/tests/unit/urcu-asm.c new file mode 100644 index 0000000000000..202854f899cfa --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/urcu-asm.c @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * urcu-asm.c + * + * Userspace RCU library - assembly dump of primitives + */ + +#include + +void show_read_lock(void) +{ + asm volatile ("/* start */"); + rcu_read_lock(); + asm volatile ("/* end */"); +} + +void show_read_unlock(void) +{ + asm volatile ("/* start */"); + rcu_read_unlock(); + asm volatile ("/* end */"); +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/unit/urcu-asm_cxx.cpp b/external/lgpl2/userspace-rcu/dist/tests/unit/urcu-asm_cxx.cpp new file mode 100644 index 0000000000000..883e7b9f93902 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/unit/urcu-asm_cxx.cpp @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 EfficiOS Inc. +// +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "urcu-asm.c" diff --git a/external/lgpl2/userspace-rcu/dist/tests/utils/Makefile.am b/external/lgpl2/userspace-rcu/dist/tests/utils/Makefile.am new file mode 100644 index 0000000000000..605d64c953deb --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/utils/Makefile.am @@ -0,0 +1,13 @@ +# SPDX-FileCopyrightText: 2023 EfficiOS Inc. +# +# SPDX-License-Identifier: MIT + +AM_CPPFLAGS += -I$(top_srcdir)/src + +noinst_LIBRARIES = libtap.a +libtap_a_SOURCES = tap.c tap.h + +dist_check_SCRIPTS = \ + tap-driver.sh \ + tap.sh \ + utils.sh diff --git a/external/lgpl2/userspace-rcu/dist/tests/utils/env.sh.in b/external/lgpl2/userspace-rcu/dist/tests/utils/env.sh.in new file mode 100644 index 0000000000000..6fa27339e55b6 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/utils/env.sh.in @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +### Base paths to test suite ### +if [ "x${URCU_TESTS_SRCDIR:-}" = "x" ]; then + URCU_TESTS_SRCDIR="@abs_top_srcdir@/tests" +fi +export URCU_TESTS_SRCDIR + +if [ "x${URCU_TESTS_BUILDDIR:-}" = "x" ]; then + URCU_TESTS_BUILDDIR="@abs_top_builddir@/tests" +fi +export URCU_TESTS_BUILDDIR + + +### External Tools ### +if [ "x${URCU_TESTS_NPROC_BIN:-}" = "x" ]; then + URCU_TESTS_NPROC_BIN="@NPROC@" +fi +export URCU_TESTS_NPROC_BIN + +if [ "x${URCU_TESTS_GETCONF_BIN:-}" = "x" ]; then + URCU_TESTS_GETCONF_BIN="@GETCONF@" +fi +export URCU_TESTS_GETCONF_BIN + +if [ "x${URCU_TESTS_TIME_BIN:-}" = "x" ]; then + URCU_TESTS_TIME_BIN="@TIME@" +fi +export URCU_TESTS_TIME_BIN + diff --git a/external/lgpl2/userspace-rcu/dist/tests/utils/tap-driver.sh b/external/lgpl2/userspace-rcu/dist/tests/utils/tap-driver.sh new file mode 100755 index 0000000000000..921e38fcc6d3f --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/utils/tap-driver.sh @@ -0,0 +1,643 @@ +#! /bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2011-2018 Free Software Foundation, Inc. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +scriptversion=2013-12-23.17; # UTC + +# Make unconditional expansion of undefined variables an error. This +# helps a lot in preventing typo-related bugs. +set -u + +me=tap-driver.sh + +fatal () +{ + echo "$me: fatal: $*" >&2 + exit 1 +} + +usage_error () +{ + echo "$me: $*" >&2 + print_usage >&2 + exit 2 +} + +print_usage () +{ + cat < + # + trap : 1 3 2 13 15 + if test $merge -gt 0; then + exec 2>&1 + else + exec 2>&3 + fi + "$@" + echo $? + ) | LC_ALL=C ${AM_TAP_AWK-awk} \ + -v me="$me" \ + -v test_script_name="$test_name" \ + -v log_file="$log_file" \ + -v trs_file="$trs_file" \ + -v expect_failure="$expect_failure" \ + -v merge="$merge" \ + -v ignore_exit="$ignore_exit" \ + -v comments="$comments" \ + -v diag_string="$diag_string" \ +' +# TODO: the usages of "cat >&3" below could be optimized when using +# GNU awk, and/on on systems that supports /dev/fd/. + +# Implementation note: in what follows, `result_obj` will be an +# associative array that (partly) simulates a TAP result object +# from the `TAP::Parser` perl module. + +## ----------- ## +## FUNCTIONS ## +## ----------- ## + +function fatal(msg) +{ + print me ": " msg | "cat >&2" + exit 1 +} + +function abort(where) +{ + fatal("internal error " where) +} + +# Convert a boolean to a "yes"/"no" string. +function yn(bool) +{ + return bool ? "yes" : "no"; +} + +function add_test_result(result) +{ + if (!test_results_index) + test_results_index = 0 + test_results_list[test_results_index] = result + test_results_index += 1 + test_results_seen[result] = 1; +} + +# Whether the test script should be re-run by "make recheck". +function must_recheck() +{ + for (k in test_results_seen) + if (k != "XFAIL" && k != "PASS" && k != "SKIP") + return 1 + return 0 +} + +# Whether the content of the log file associated to this test should +# be copied into the "global" test-suite.log. +function copy_in_global_log() +{ + for (k in test_results_seen) + if (k != "PASS") + return 1 + return 0 +} + +function get_global_test_result() +{ + if ("ERROR" in test_results_seen) + return "ERROR" + if ("FAIL" in test_results_seen || "XPASS" in test_results_seen) + return "FAIL" + all_skipped = 1 + for (k in test_results_seen) + if (k != "SKIP") + all_skipped = 0 + if (all_skipped) + return "SKIP" + return "PASS"; +} + +function stringify_result_obj(result_obj) +{ + if (result_obj["is_unplanned"] || result_obj["number"] != testno) + return "ERROR" + + if (plan_seen == LATE_PLAN) + return "ERROR" + + if (result_obj["directive"] == "TODO") + return result_obj["is_ok"] ? "XPASS" : "XFAIL" + + if (result_obj["directive"] == "SKIP") + return result_obj["is_ok"] ? "SKIP" : COOKED_FAIL; + + if (length(result_obj["directive"])) + abort("in function stringify_result_obj()") + + return result_obj["is_ok"] ? COOKED_PASS : COOKED_FAIL +} + +function decorate_result(result) +{ + color_name = color_for_result[result] + if (color_name) + return color_map[color_name] "" result "" color_map["std"] + # If we are not using colorized output, or if we do not know how + # to colorize the given result, we should return it unchanged. + return result +} + +function report(result, details) +{ + if (result ~ /^(X?(PASS|FAIL)|SKIP|ERROR)/) + { + msg = ": " test_script_name + add_test_result(result) + } + else if (result == "#") + { + msg = " " test_script_name ":" + } + else + { + abort("in function report()") + } + if (length(details)) + msg = msg " " details + # Output on console might be colorized. + print decorate_result(result) msg + # Flush stdout after each test result, this is useful when stdout + # is buffered, for example in a CI system. + fflush() + # Log the result in the log file too, to help debugging (this is + # especially true when said result is a TAP error or "Bail out!"). + print result msg | "cat >&3"; +} + +function testsuite_error(error_message) +{ + report("ERROR", "- " error_message) +} + +function handle_tap_result() +{ + details = result_obj["number"]; + if (length(result_obj["description"])) + details = details " " result_obj["description"] + + if (plan_seen == LATE_PLAN) + { + details = details " # AFTER LATE PLAN"; + } + else if (result_obj["is_unplanned"]) + { + details = details " # UNPLANNED"; + } + else if (result_obj["number"] != testno) + { + details = sprintf("%s # OUT-OF-ORDER (expecting %d)", + details, testno); + } + else if (result_obj["directive"]) + { + details = details " # " result_obj["directive"]; + if (length(result_obj["explanation"])) + details = details " " result_obj["explanation"] + } + + report(stringify_result_obj(result_obj), details) +} + +# `skip_reason` should be empty whenever planned > 0. +function handle_tap_plan(planned, skip_reason) +{ + planned += 0 # Avoid getting confused if, say, `planned` is "00" + if (length(skip_reason) && planned > 0) + abort("in function handle_tap_plan()") + if (plan_seen) + { + # Error, only one plan per stream is acceptable. + testsuite_error("multiple test plans") + return; + } + planned_tests = planned + # The TAP plan can come before or after *all* the TAP results; we speak + # respectively of an "early" or a "late" plan. If we see the plan line + # after at least one TAP result has been seen, assume we have a late + # plan; in this case, any further test result seen after the plan will + # be flagged as an error. + plan_seen = (testno >= 1 ? LATE_PLAN : EARLY_PLAN) + # If testno > 0, we have an error ("too many tests run") that will be + # automatically dealt with later, so do not worry about it here. If + # $plan_seen is true, we have an error due to a repeated plan, and that + # has already been dealt with above. Otherwise, we have a valid "plan + # with SKIP" specification, and should report it as a particular kind + # of SKIP result. + if (planned == 0 && testno == 0) + { + if (length(skip_reason)) + skip_reason = "- " skip_reason; + report("SKIP", skip_reason); + } +} + +function extract_tap_comment(line) +{ + if (index(line, diag_string) == 1) + { + # Strip leading `diag_string` from `line`. + line = substr(line, length(diag_string) + 1) + # And strip any leading and trailing whitespace left. + sub("^[ \t]*", "", line) + sub("[ \t]*$", "", line) + # Return what is left (if any). + return line; + } + return ""; +} + +# When this function is called, we know that line is a TAP result line, +# so that it matches the (perl) RE "^(not )?ok\b". +function setup_result_obj(line) +{ + # Get the result, and remove it from the line. + result_obj["is_ok"] = (substr(line, 1, 2) == "ok" ? 1 : 0) + sub("^(not )?ok[ \t]*", "", line) + + # If the result has an explicit number, get it and strip it; otherwise, + # automatically assign the next progresive number to it. + if (line ~ /^[0-9]+$/ || line ~ /^[0-9]+[^a-zA-Z0-9_]/) + { + match(line, "^[0-9]+") + # The final `+ 0` is to normalize numbers with leading zeros. + result_obj["number"] = substr(line, 1, RLENGTH) + 0 + line = substr(line, RLENGTH + 1) + } + else + { + result_obj["number"] = testno + } + + if (plan_seen == LATE_PLAN) + # No further test results are acceptable after a "late" TAP plan + # has been seen. + result_obj["is_unplanned"] = 1 + else if (plan_seen && testno > planned_tests) + result_obj["is_unplanned"] = 1 + else + result_obj["is_unplanned"] = 0 + + # Strip trailing and leading whitespace. + sub("^[ \t]*", "", line) + sub("[ \t]*$", "", line) + + # This will have to be corrected if we have a "TODO"/"SKIP" directive. + result_obj["description"] = line + result_obj["directive"] = "" + result_obj["explanation"] = "" + + if (index(line, "#") == 0) + return # No possible directive, nothing more to do. + + # Directives are case-insensitive. + rx = "[ \t]*#[ \t]*([tT][oO][dD][oO]|[sS][kK][iI][pP])[ \t]*" + + # See whether we have the directive, and if yes, where. + pos = match(line, rx "$") + if (!pos) + pos = match(line, rx "[^a-zA-Z0-9_]") + + # If there was no TAP directive, we have nothing more to do. + if (!pos) + return + + # Let`s now see if the TAP directive has been escaped. For example: + # escaped: ok \# SKIP + # not escaped: ok \\# SKIP + # escaped: ok \\\\\# SKIP + # not escaped: ok \ # SKIP + if (substr(line, pos, 1) == "#") + { + bslash_count = 0 + for (i = pos; i > 1 && substr(line, i - 1, 1) == "\\"; i--) + bslash_count += 1 + if (bslash_count % 2) + return # Directive was escaped. + } + + # Strip the directive and its explanation (if any) from the test + # description. + result_obj["description"] = substr(line, 1, pos - 1) + # Now remove the test description from the line, that has been dealt + # with already. + line = substr(line, pos) + # Strip the directive, and save its value (normalized to upper case). + sub("^[ \t]*#[ \t]*", "", line) + result_obj["directive"] = toupper(substr(line, 1, 4)) + line = substr(line, 5) + # Now get the explanation for the directive (if any), with leading + # and trailing whitespace removed. + sub("^[ \t]*", "", line) + sub("[ \t]*$", "", line) + result_obj["explanation"] = line +} + +function get_test_exit_message(status) +{ + if (status == 0) + return "" + if (status !~ /^[1-9][0-9]*$/) + abort("getting exit status") + if (status < 127) + exit_details = "" + else if (status == 127) + exit_details = " (command not found?)" + else if (status >= 128 && status <= 255) + exit_details = sprintf(" (terminated by signal %d?)", status - 128) + else if (status > 256 && status <= 384) + # We used to report an "abnormal termination" here, but some Korn + # shells, when a child process die due to signal number n, can leave + # in $? an exit status of 256+n instead of the more standard 128+n. + # Apparently, both behaviours are allowed by POSIX (2008), so be + # prepared to handle them both. See also Austing Group report ID + # 0000051 + exit_details = sprintf(" (terminated by signal %d?)", status - 256) + else + # Never seen in practice. + exit_details = " (abnormal termination)" + return sprintf("exited with status %d%s", status, exit_details) +} + +function write_test_results() +{ + print ":global-test-result: " get_global_test_result() > trs_file + print ":recheck: " yn(must_recheck()) > trs_file + print ":copy-in-global-log: " yn(copy_in_global_log()) > trs_file + for (i = 0; i < test_results_index; i += 1) + print ":test-result: " test_results_list[i] > trs_file + close(trs_file); +} + +BEGIN { + +## ------- ## +## SETUP ## +## ------- ## + +'"$init_colors"' + +# Properly initialized once the TAP plan is seen. +planned_tests = 0 + +COOKED_PASS = expect_failure ? "XPASS": "PASS"; +COOKED_FAIL = expect_failure ? "XFAIL": "FAIL"; + +# Enumeration-like constants to remember which kind of plan (if any) +# has been seen. It is important that NO_PLAN evaluates "false" as +# a boolean. +NO_PLAN = 0 +EARLY_PLAN = 1 +LATE_PLAN = 2 + +testno = 0 # Number of test results seen so far. +bailed_out = 0 # Whether a "Bail out!" directive has been seen. + +# Whether the TAP plan has been seen or not, and if yes, which kind +# it is ("early" is seen before any test result, "late" otherwise). +plan_seen = NO_PLAN + +## --------- ## +## PARSING ## +## --------- ## + +is_first_read = 1 + +while (1) + { + # Involutions required so that we are able to read the exit status + # from the last input line. + st = getline + if (st < 0) # I/O error. + fatal("I/O error while reading from input stream") + else if (st == 0) # End-of-input + { + if (is_first_read) + abort("in input loop: only one input line") + break + } + if (is_first_read) + { + is_first_read = 0 + nextline = $0 + continue + } + else + { + curline = nextline + nextline = $0 + $0 = curline + } + # Copy any input line verbatim into the log file. + print | "cat >&3" + # Parsing of TAP input should stop after a "Bail out!" directive. + if (bailed_out) + continue + + # TAP test result. + if ($0 ~ /^(not )?ok$/ || $0 ~ /^(not )?ok[^a-zA-Z0-9_]/) + { + testno += 1 + setup_result_obj($0) + handle_tap_result() + } + # TAP plan (normal or "SKIP" without explanation). + else if ($0 ~ /^1\.\.[0-9]+[ \t]*$/) + { + # The next two lines will put the number of planned tests in $0. + sub("^1\\.\\.", "") + sub("[^0-9]*$", "") + handle_tap_plan($0, "") + continue + } + # TAP "SKIP" plan, with an explanation. + else if ($0 ~ /^1\.\.0+[ \t]*#/) + { + # The next lines will put the skip explanation in $0, stripping + # any leading and trailing whitespace. This is a little more + # tricky in truth, since we want to also strip a potential leading + # "SKIP" string from the message. + sub("^[^#]*#[ \t]*(SKIP[: \t][ \t]*)?", "") + sub("[ \t]*$", ""); + handle_tap_plan(0, $0) + } + # "Bail out!" magic. + # Older versions of prove and TAP::Harness (e.g., 3.17) did not + # recognize a "Bail out!" directive when preceded by leading + # whitespace, but more modern versions (e.g., 3.23) do. So we + # emulate the latter, "more modern" behaviour. + else if ($0 ~ /^[ \t]*Bail out!/) + { + bailed_out = 1 + # Get the bailout message (if any), with leading and trailing + # whitespace stripped. The message remains stored in `$0`. + sub("^[ \t]*Bail out![ \t]*", ""); + sub("[ \t]*$", ""); + # Format the error message for the + bailout_message = "Bail out!" + if (length($0)) + bailout_message = bailout_message " " $0 + testsuite_error(bailout_message) + } + # Maybe we have too look for dianogtic comments too. + else if (comments != 0) + { + comment = extract_tap_comment($0); + if (length(comment)) + report("#", comment); + } + } + +## -------- ## +## FINISH ## +## -------- ## + +# A "Bail out!" directive should cause us to ignore any following TAP +# error, as well as a non-zero exit status from the TAP producer. +if (!bailed_out) + { + if (!plan_seen) + { + testsuite_error("missing test plan") + } + else if (planned_tests != testno) + { + bad_amount = testno > planned_tests ? "many" : "few" + testsuite_error(sprintf("too %s tests run (expected %d, got %d)", + bad_amount, planned_tests, testno)) + } + if (!ignore_exit) + { + # Fetch exit status from the last line. + exit_message = get_test_exit_message(nextline) + if (exit_message) + testsuite_error(exit_message) + } + } + +write_test_results() + +exit 0 + +} # End of "BEGIN" block. +' + +# TODO: document that we consume the file descriptor 3 :-( +} 3>"$log_file" + +test $? -eq 0 || fatal "I/O or internal error" + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/external/lgpl2/userspace-rcu/dist/tests/utils/tap.c b/external/lgpl2/userspace-rcu/dist/tests/utils/tap.c new file mode 100644 index 0000000000000..97a1c60d73b77 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/utils/tap.c @@ -0,0 +1,491 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (C) 2004 Nik Clayton + * Copyright (C) 2017 Jérémie Galarneau + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "tap.h" + +static int no_plan = 0; +static int skip_all = 0; +static int have_plan = 0; +static unsigned int test_count = 0; /* Number of tests that have been run */ +static unsigned int e_tests = 0; /* Expected number of tests to run */ +static unsigned int failures = 0; /* Number of tests that failed */ +static char *todo_msg = NULL; +static const char *todo_msg_fixed = "libtap malloc issue"; +static int todo = 0; +static int test_died = 0; +static int tap_is_disabled = 0; + +/* Encapsulate the pthread code in a conditional. In the absence of + libpthread the code does nothing */ +#ifdef HAVE_LIBPTHREAD +#include +static pthread_mutex_t M = PTHREAD_MUTEX_INITIALIZER; +# define LOCK pthread_mutex_lock(&M); +# define UNLOCK pthread_mutex_unlock(&M); +#else +# define LOCK +# define UNLOCK +#endif + +static void _expected_tests(unsigned int); +static void _tap_init(void); +static void _cleanup(void); + +#ifdef __MINGW32__ +static inline +void flockfile (FILE * filehandle) { + return; +} + +static inline +void funlockfile(FILE * filehandle) { + return; +} +#endif + +/* + * Generate a test result. + * + * ok -- boolean, indicates whether or not the test passed. + * test_name -- the name of the test, may be NULL + * test_comment -- a comment to print afterwards, may be NULL + */ +unsigned int +_gen_result(int ok, const char *func, const char *file, unsigned int line, + const char *test_name, ...) +{ + va_list ap; + char *local_test_name = NULL; + char *c; + int name_is_digits; + + LOCK; + + test_count++; + + /* Start by taking the test name and performing any printf() + expansions on it */ + if(test_name != NULL) { + va_start(ap, test_name); + if (vasprintf(&local_test_name, test_name, ap) == -1) { + local_test_name = NULL; + } + va_end(ap); + + /* Make sure the test name contains more than digits + and spaces. Emit an error message and exit if it + does */ + if(local_test_name) { + name_is_digits = 1; + for(c = local_test_name; *c != '\0'; c++) { + if(!isdigit((unsigned char) *c) && !isspace((unsigned char) *c)) { + name_is_digits = 0; + break; + } + } + + if(name_is_digits) { + diag(" You named your test '%s'. You shouldn't use numbers for your test names.", local_test_name); + diag(" Very confusing."); + } + } + } + + if(!ok) { + printf("not "); + failures++; + } + + printf("ok %d", test_count); + + if(test_name != NULL) { + printf(" - "); + + /* Print the test name, escaping any '#' characters it + might contain */ + if(local_test_name != NULL) { + flockfile(stdout); + for(c = local_test_name; *c != '\0'; c++) { + if(*c == '#') + fputc('\\', stdout); + fputc((int)*c, stdout); + } + funlockfile(stdout); + } else { /* vasprintf() failed, use a fixed message */ + printf("%s", todo_msg_fixed); + } + } + + /* If we're in a todo_start() block then flag the test as being + TODO. todo_msg should contain the message to print at this + point. If it's NULL then asprintf() failed, and we should + use the fixed message. + + This is not counted as a failure, so decrement the counter if + the test failed. */ + if(todo) { + printf(" # TODO %s", todo_msg ? todo_msg : todo_msg_fixed); + if(!ok) + failures--; + } + + printf("\n"); + + if(!ok) { + if(getenv("HARNESS_ACTIVE") != NULL) + fputs("\n", stderr); + + diag(" Failed %stest (%s:%s() at line %d)", + todo ? "(TODO) " : "", file, func, line); + } + free(local_test_name); + + UNLOCK; + + /* We only care (when testing) that ok is positive, but here we + specifically only want to return 1 or 0 */ + return ok ? 1 : 0; +} + +/* + * Initialise the TAP library. Will only do so once, however many times it's + * called. + */ +void +_tap_init(void) +{ + static int run_once = 0; + + if(!run_once) { + atexit(_cleanup); + + /* stdout needs to be unbuffered so that the output appears + in the same place relative to stderr output as it does + with Test::Harness */ + setbuf(stdout, 0); + run_once = 1; + } +} + +/* + * Note that there's no plan. + */ +int +plan_no_plan(void) +{ + + LOCK; + + _tap_init(); + + if(have_plan != 0) { + fprintf(stderr, "You tried to plan twice!\n"); + test_died = 1; + UNLOCK; + exit(255); + } + + have_plan = 1; + no_plan = 1; + + UNLOCK; + + return 1; +} + +/* + * Note that the plan is to skip all tests + */ +int +plan_skip_all(const char *reason) +{ + + LOCK; + + _tap_init(); + + skip_all = 1; + + printf("1..0"); + + if(reason != NULL) + printf(" # Skip %s", reason); + + printf("\n"); + + UNLOCK; + + exit(0); +} + +/* + * Note the number of tests that will be run. + */ +int +plan_tests(unsigned int tests) +{ + + LOCK; + + _tap_init(); + + if(have_plan != 0) { + fprintf(stderr, "You tried to plan twice!\n"); + test_died = 1; + UNLOCK; + exit(255); + } + + if(tests == 0) { + fprintf(stderr, "You said to run 0 tests! You've got to run something.\n"); + test_died = 1; + UNLOCK; + exit(255); + } + + have_plan = 1; + + _expected_tests(tests); + + UNLOCK; + + return e_tests; +} + +unsigned int +diag(const char *fmt, ...) +{ + va_list ap; + + fputs("# ", stderr); + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + + fputs("\n", stderr); + + return 0; +} + +unsigned int +rdiag_start(void) +{ + fputs("# ", stderr); + return 0; +} + +unsigned int +rdiag(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + + return 0; +} + +unsigned int +rdiag_end(void) +{ + fputs("\n", stderr); + return 0; +} + +void +diag_multiline(const char *val) +{ + size_t len, i, line_start_idx = 0; + + assert(val); + len = strlen(val); + + for (i = 0; i < len; i++) { + int line_length; + + if (val[i] != '\n') { + continue; + } + + assert((i - line_start_idx + 1) <= INT_MAX); + line_length = i - line_start_idx + 1; + fprintf(stderr, "# %.*s", line_length, &val[line_start_idx]); + line_start_idx = i + 1; + } +} + +void +_expected_tests(unsigned int tests) +{ + + printf("1..%d\n", tests); + e_tests = tests; +} + +int +skip(unsigned int n, const char *fmt, ...) +{ + va_list ap; + char *skip_msg = NULL; + + LOCK; + + va_start(ap, fmt); + if (vasprintf(&skip_msg, fmt, ap) == -1) { + skip_msg = NULL; + } + va_end(ap); + + while(n-- > 0) { + test_count++; + printf("ok %d # skip %s\n", test_count, + skip_msg != NULL ? + skip_msg : "libtap():malloc() failed"); + } + + free(skip_msg); + + UNLOCK; + + return 1; +} + +void +todo_start(const char *fmt, ...) +{ + va_list ap; + + LOCK; + + va_start(ap, fmt); + if (vasprintf(&todo_msg, fmt, ap) == -1) { + todo_msg = NULL; + } + va_end(ap); + + todo = 1; + + UNLOCK; +} + +void +todo_end(void) +{ + + LOCK; + + todo = 0; + free(todo_msg); + + UNLOCK; +} + +int +exit_status(void) +{ + int r; + + LOCK; + + /* If there's no plan, just return the number of failures */ + if(no_plan || !have_plan) { + UNLOCK; + return failures; + } + + /* Ran too many tests? Return the number of tests that were run + that shouldn't have been */ + if(e_tests < test_count) { + r = test_count - e_tests; + UNLOCK; + return r; + } + + /* Return the number of tests that failed + the number of tests + that weren't run */ + r = failures + e_tests - test_count; + UNLOCK; + + return r; +} + +/* + * Cleanup at the end of the run, produce any final output that might be + * required. + */ +void +_cleanup(void) +{ + + LOCK; + + if (tap_is_disabled) { + UNLOCK; + return; + } + + /* If plan_no_plan() wasn't called, and we don't have a plan, + and we're not skipping everything, then something happened + before we could produce any output */ + if(!no_plan && !have_plan && !skip_all) { + diag("Looks like your test died before it could output anything."); + UNLOCK; + return; + } + + if(test_died) { + diag("Looks like your test died just after %d.", test_count); + UNLOCK; + return; + } + + + /* No plan provided, but now we know how many tests were run, and can + print the header at the end */ + if(!skip_all && (no_plan || !have_plan)) { + printf("1..%d\n", test_count); + } + + if((have_plan && !no_plan) && e_tests < test_count) { + diag("Looks like you planned %d %s but ran %d extra.", + e_tests, e_tests == 1 ? "test" : "tests", test_count - e_tests); + UNLOCK; + return; + } + + if((have_plan || !no_plan) && e_tests > test_count) { + diag("Looks like you planned %d %s but only ran %d.", + e_tests, e_tests == 1 ? "test" : "tests", test_count); + UNLOCK; + return; + } + + if(failures) + diag("Looks like you failed %d %s of %d.", + failures, failures == 1 ? "test" : "tests", test_count); + + UNLOCK; +} + +/* Disable tap for this process. */ +void +tap_disable(void) +{ + LOCK; + tap_is_disabled = 1; + UNLOCK; +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/utils/tap.h b/external/lgpl2/userspace-rcu/dist/tests/utils/tap.h new file mode 100644 index 0000000000000..966706fe90344 --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/utils/tap.h @@ -0,0 +1,70 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (C) 2004 Nik Clayton + * Copyright (C) 2017 Jérémie Galarneau + */ + +#ifdef __cplusplus +extern "C" { +#endif + +# define ok(e, ...) ((e) ? \ + _gen_result(1, __func__, __FILE__, __LINE__, \ + __VA_ARGS__) : \ + _gen_result(0, __func__, __FILE__, __LINE__, \ + __VA_ARGS__)) + +# define ok1(e) ((e) ? \ + _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \ + _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e)) + +# define pass(...) ok(1, __VA_ARGS__) +# define fail(...) ok(0, __VA_ARGS__) + +# define skip_start(test, n, ...) \ + do { \ + if((test)) { \ + skip(n, __VA_ARGS__); \ + continue; \ + } + +#define skip_end() } while(0); + +#ifdef __MINGW_PRINTF_FORMAT +# define TAP_PRINTF_FORMAT __MINGW_PRINTF_FORMAT +#else +# define TAP_PRINTF_FORMAT printf +#endif + +__attribute__((format(TAP_PRINTF_FORMAT, 5, 6))) +unsigned int _gen_result(int, const char *, const char *, unsigned int, const char *, ...); + +int plan_no_plan(void); +__attribute__((__noreturn__)) +int plan_skip_all(const char *); +int plan_tests(unsigned int); + +__attribute__((format(TAP_PRINTF_FORMAT, 1, 2))) +unsigned int diag(const char *, ...); +void diag_multiline(const char *); + +__attribute__((format(TAP_PRINTF_FORMAT, 2, 3))) +int skip(unsigned int, const char *, ...); + +__attribute__((format(TAP_PRINTF_FORMAT, 1, 2))) +void todo_start(const char *, ...); +void todo_end(void); + +int exit_status(void); + +void tap_disable(void); + +unsigned int rdiag_start(void); +__attribute__((format(TAP_PRINTF_FORMAT, 1, 2))) +unsigned int rdiag(const char *fmt, ...); +unsigned int rdiag_end(void); + +#ifdef __cplusplus +} +#endif diff --git a/external/lgpl2/userspace-rcu/dist/tests/utils/tap.sh b/external/lgpl2/userspace-rcu/dist/tests/utils/tap.sh new file mode 100755 index 0000000000000..47b140722a36e --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/utils/tap.sh @@ -0,0 +1,445 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# SPDX-FileCopyrightText: 2010 Patrick LeBoutillier +# + +_version='1.01' + +_plan_set=0 +_no_plan=0 +_skip_all=0 +_test_died=0 +_expected_tests=0 +_executed_tests=0 +_failed_tests=0 +TODO= + + +usage(){ + cat <<'USAGE' +tap-functions: A TAP-producing BASH library + +PLAN: + plan_no_plan + plan_skip_all [REASON] + plan_tests NB_TESTS + +TEST: + ok RESULT [NAME] + okx COMMAND + is RESULT EXPECTED [NAME] + isnt RESULT EXPECTED [NAME] + like RESULT PATTERN [NAME] + unlike RESULT PATTERN [NAME] + pass [NAME] + fail [NAME] + +SKIP: + skip [CONDITION] [REASON] [NB_TESTS=1] + + skip $feature_not_present "feature not present" 2 || { + is $a "a" + is $b "b" + } + +TODO: + Specify TODO mode by setting $TODO: + TODO="not implemented yet" + ok $result "some not implemented test" + unset TODO + +OTHER: + diag MSG + +EXAMPLE: + #!/usr/bin/env bash + + . tap-functions + + plan_tests 7 + + me=$USER + is $USER $me "I am myself" + like $HOME $me "My home is mine" + like "`id`" $me "My id matches myself" + + /bin/ls $HOME 1>&2 + ok $? "/bin/ls $HOME" + # Same thing using okx shortcut + okx /bin/ls $HOME + + [[ "`id -u`" != "0" ]] + i_am_not_root=$? + skip $i_am_not_root "Must be root" || { + okx ls /root + } + + TODO="figure out how to become root..." + okx [ "$HOME" == "/root" ] + unset TODO +USAGE + exit +} + +opt= +set_u= +while getopts ":sx" opt ; do + case $_opt in + u) set_u=1 ;; + *) usage ;; + esac +done +shift $(( OPTIND - 1 )) +# Don't allow uninitialized variables if requested +[[ -n "$set_u" ]] && set -u +unset opt set_u + +# Used to call _cleanup on shell exit +trap _exit EXIT + + +plan_no_plan(){ + (( _plan_set != 0 )) && "You tried to plan twice!" + + _plan_set=1 + _no_plan=1 + + return 0 +} + + +plan_skip_all(){ + local reason=${1:-''} + + (( _plan_set != 0 )) && _die "You tried to plan twice!" + + _print_plan 0 "Skip $reason" + + _skip_all=1 + _plan_set=1 + _exit 0 + + return 0 +} + +plan_tests(){ + local tests=${1:?} + + (( _plan_set != 0 )) && _die "You tried to plan twice!" + (( tests == 0 )) && _die "You said to run 0 tests! You've got to run something." + + _print_plan $tests + _expected_tests=$tests + _plan_set=1 + + return $tests +} + + +_print_plan(){ + local tests=${1:?} + local directive=${2:-''} + + echo -n "1..$tests" + [[ -n "$directive" ]] && echo -n " # $directive" + echo +} + + +pass(){ + local name=$1 + ok 0 "$name" +} + + +fail(){ + local name=$1 + ok 1 "$name" +} + +# This is the workhorse method that actually +# prints the tests result. +ok(){ + local result=${1:?} + local name=${2:-''} + + (( _plan_set == 0 )) && _die "You tried to run a test without a plan! Gotta have a plan." + + _executed_tests=$(( $_executed_tests + 1 )) + + if [[ -n "$name" ]] ; then + if _matches "$name" "^[0-9]+$" ; then + diag " You named your test '$name'. You shouldn't use numbers for your test names." + diag " Very confusing." + fi + fi + + if (( result != 0 )) ; then + echo -n "not " + _failed_tests=$(( _failed_tests + 1 )) + fi + echo -n "ok $_executed_tests" + + if [[ -n "$name" ]] ; then + local ename=${name//\#/\\#} + echo -n " - $ename" + fi + + if [[ -n "$TODO" ]] ; then + echo -n " # TODO $TODO" ; + if (( result != 0 )) ; then + _failed_tests=$(( _failed_tests - 1 )) + fi + fi + + echo + if (( result != 0 )) ; then + local file='tap-functions' + local func= + local line= + + local i=0 + local bt=$(caller $i) + while _matches "$bt" "tap-functions$" ; do + i=$(( $i + 1 )) + bt=$(caller $i) + done + local backtrace= + eval $(caller $i | (read line func file ; echo "backtrace=\"$file:$func() at line $line.\"")) + + local t= + [[ -n "$TODO" ]] && t="(TODO) " + + if [[ -n "$name" ]] ; then + diag " Failed ${t}test '$name'" + diag " in $backtrace" + else + diag " Failed ${t}test in $backtrace" + fi + fi + + return $result +} + + +okx(){ + local command="$@" + + local line= + diag "Output of '$command':" + "$@" | while read line ; do + diag "$line" + done + ok ${PIPESTATUS[0]} "$command" +} + + +_equals(){ + local result=${1:?} + local expected=${2:?} + + if [[ "$result" == "$expected" ]] ; then + return 0 + else + return 1 + fi +} + + +# Thanks to Aaron Kangas for the patch to allow regexp matching +# under bash < 3. + _bash_major_version=${BASH_VERSION%%.*} +_matches(){ + local result=${1:?} + local pattern=${2:?} + + if [[ -z "$result" || -z "$pattern" ]] ; then + return 1 + else + if (( _bash_major_version >= 3 )) ; then + [[ "$result" =~ "$pattern" ]] + else + echo "$result" | egrep -q "$pattern" + fi + fi +} + + +_is_diag(){ + local result=${1:?} + local expected=${2:?} + + diag " got: '$result'" + diag " expected: '$expected'" +} + + +is(){ + local result=${1:?} + local expected=${2:?} + local name=${3:-''} + + _equals "$result" "$expected" + (( $? == 0 )) + ok $? "$name" + local r=$? + (( r != 0 )) && _is_diag "$result" "$expected" + return $r +} + + +isnt(){ + local result=${1:?} + local expected=${2:?} + local name=${3:-''} + + _equals "$result" "$expected" + (( $? != 0 )) + ok $? "$name" + local r=$? + (( r != 0 )) && _is_diag "$result" "$expected" + return $r +} + + +like(){ + local result=${1:?} + local pattern=${2:?} + local name=${3:-''} + + _matches "$result" "$pattern" + (( $? == 0 )) + ok $? "$name" + local r=$? + (( r != 0 )) && diag " '$result' doesn't match '$pattern'" + return $r +} + + +unlike(){ + local result=${1:?} + local pattern=${2:?} + local name=${3:-''} + + _matches "$result" "$pattern" + (( $? != 0 )) + ok $? "$name" + local r=$? + (( r != 0 )) && diag " '$result' matches '$pattern'" + return $r +} + + +skip(){ + local condition=${1:?} + local reason=${2:-''} + local n=${3:-1} + + if (( condition == 0 )) ; then + local i= + for (( i=0 ; i<$n ; i++ )) ; do + _executed_tests=$(( _executed_tests + 1 )) + echo "ok $_executed_tests # skip: $reason" + done + return 0 + else + return + fi +} + + +diag(){ + local msg=${1:?} + + if [[ -n "$msg" ]] ; then + echo "# $msg" + fi + + return 1 +} + + +_die(){ + local reason=${1:-''} + + echo "$reason" >&2 + _test_died=1 + _exit 255 +} + + +BAIL_OUT(){ + local reason=${1:-''} + + echo "Bail out! $reason" >&2 + _exit 255 +} + + +_cleanup(){ + local rc=0 + + if (( _plan_set == 0 )) ; then + diag "Looks like your test died before it could output anything." + return $rc + fi + + if (( _test_died != 0 )) ; then + diag "Looks like your test died just after $_executed_tests." + return $rc + fi + + if (( _skip_all == 0 && _no_plan != 0 )) ; then + _print_plan $_executed_tests + fi + + local s= + if (( _no_plan == 0 && _expected_tests < _executed_tests )) ; then + s= ; (( _expected_tests > 1 )) && s=s + local extra=$(( _executed_tests - _expected_tests )) + diag "Looks like you planned $_expected_tests test$s but ran $extra extra." + rc=1 ; + fi + + if (( _no_plan == 0 && _expected_tests > _executed_tests )) ; then + s= ; (( _expected_tests > 1 )) && s=s + diag "Looks like you planned $_expected_tests test$s but only ran $_executed_tests." + fi + + if (( _failed_tests > 0 )) ; then + s= ; (( _failed_tests > 1 )) && s=s + diag "Looks like you failed $_failed_tests test$s of $_executed_tests." + fi + + return $rc +} + + +_exit_status(){ + if (( _no_plan != 0 || _plan_set == 0 )) ; then + return $_failed_tests + fi + + if (( _expected_tests < _executed_tests )) ; then + return $(( _executed_tests - _expected_tests )) + fi + + return $(( _failed_tests + ( _expected_tests - _executed_tests ))) +} + + +_exit(){ + local rc=${1:-''} + if [[ -z "$rc" ]] ; then + _exit_status + rc=$? + fi + + _cleanup + local alt_rc=$? + (( alt_rc != 0 )) && rc=$alt_rc + trap - EXIT + exit $rc +} diff --git a/external/lgpl2/userspace-rcu/dist/tests/utils/utils.sh b/external/lgpl2/userspace-rcu/dist/tests/utils/utils.sh new file mode 100755 index 0000000000000..5c96fb072256d --- /dev/null +++ b/external/lgpl2/userspace-rcu/dist/tests/utils/utils.sh @@ -0,0 +1,112 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. +# + +# This file is meant to be sourced at the start of shell script-based tests. + + +# Error out when encountering an undefined variable +set -u + +# If "readlink -f" is available, get a resolved absolute path to the +# tests source dir, otherwise make do with a relative path. +scriptdir="$(dirname "${BASH_SOURCE[0]}")" +if readlink -f "." >/dev/null 2>&1; then + testsdir=$(readlink -f "$scriptdir/..") +else + testsdir="$scriptdir/.." +fi + +# The OS on which we are running. See [1] for possible values of 'uname -s'. +# We do a bit of translation to ease our life down the road for comparison. +# Export it so that called executables can use it. +# [1] https://en.wikipedia.org/wiki/Uname#Examples +if [ "x${URCU_TESTS_OS_TYPE:-}" = "x" ]; then + URCU_TESTS_OS_TYPE="$(uname -s)" + case "$URCU_TESTS_OS_TYPE" in + MINGW*) + URCU_TESTS_OS_TYPE="mingw" + ;; + Darwin) + URCU_TESTS_OS_TYPE="darwin" + ;; + Linux) + URCU_TESTS_OS_TYPE="linux" + ;; + CYGWIN*) + URCU_TESTS_OS_TYPE="cygwin" + ;; + *) + URCU_TESTS_OS_TYPE="unsupported" + ;; + esac +fi +export URCU_TESTS_OS_TYPE + +# Allow overriding the source and build directories +if [ "x${URCU_TESTS_SRCDIR:-}" = "x" ]; then + URCU_TESTS_SRCDIR="$testsdir" +fi +export URCU_TESTS_SRCDIR + +if [ "x${URCU_TESTS_BUILDDIR:-}" = "x" ]; then + URCU_TESTS_BUILDDIR="$testsdir" +fi +export URCU_TESTS_BUILDDIR + +# Source the generated environment file if it's present. +if [ -f "${URCU_TESTS_BUILDDIR}/utils/env.sh" ]; then + # shellcheck source=./env.sh + . "${URCU_TESTS_BUILDDIR}/utils/env.sh" +fi + + +### External Tools ### + +if [ "x${URCU_TESTS_NPROC_BIN:-}" = "x" ]; then + URCU_TESTS_NPROC_BIN="nproc" +fi +export URCU_TESTS_NPROC_BIN + +if [ "x${URCU_TESTS_GETCONF_BIN:-}" = "x" ]; then + URCU_TESTS_GETCONF_BIN="getconf" +fi +export URCU_TESTS_GETCONF_BIN + + +# By default, it will not source tap.sh. If you to tap output directly from +# the test script, define the 'SH_TAP' variable to '1' before sourcing this +# script. +if [ "x${SH_TAP:-}" = x1 ]; then + # shellcheck source=./tap.sh + . "${URCU_TESTS_SRCDIR}/utils/tap.sh" +fi + + +### Functions ### + +# Print the number of online CPUs, fallback to '1' if no tools to count CPUs +# are found in the environment. +urcu_nproc() { + if command -v "${URCU_TESTS_NPROC_BIN}" >/dev/null 2>&1; then + "${URCU_TESTS_NPROC_BIN}" + elif command -v "${URCU_TESTS_GETCONF_BIN}" >/dev/null 2>&1; then + "${URCU_TESTS_GETCONF_BIN}" _NPROCESSORS_ONLN + else + # Fallback to '1' + echo 1 + fi +} + +# Shell implementation of the 'seq' command. +urcu_xseq() { + local i=$1 + + while [[ "$i" -le "$2" ]]; do + echo "$i" + i=$(( i + 1 )) + done +}