v2.1 RCU Implementation for QEMU
cover v2.1 RCU Implementation for QEMU
This series applies on top today's git.qemu.org/master and is online at:
https://github.com/ncultra/qemu/tree/rcu-for-1.7
Paolo Bonzini (2):
fixed tests/Makefile to correctly link rcutorture enable TLS in build and activate test-tls in make check
configure | 63 ++++++++++++++++++++++---- include/qemu/tls.h | 127 +++++++++++++++++++++++++++++++++++++++++++++-------- include/qom/cpu.h | 2 +- tests/Makefile | 14 ++++-- tests/test-tls.c | 87 ++++++++++++++++++++++++++++++++++++ 5 files changed, 261 insertions(+), 32 deletions(-) create mode 100644 tests/test-tls.c
Signature · 1 line
1.8.3.1
PATCH 1/2 fixed tests/Makefile to correctly link rcutorture
From: Paolo Bonzini <[email protected]>
Reviewed-by Mike Day <[email protected]>
--- tests/Makefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
tests/Makefile +10 -2
@@ -44,9 +44,14 @@ check-unit-y += tests/test-cutils$(EXESUF) gcov-files-test-cutils-y += util/cutils.c check-unit-y += tests/test-mul64$(EXESUF) gcov-files-test-mul64-y = util/host-utils.c +check-unit-y += tests/test-tls$(EXESUF) +# all code tested by test-tls is inside tls.h +gcov-files-test-tls-y = check-unit-y += tests/test-int128$(EXESUF) # all code tested by test-int128 is inside int128.h gcov-files-test-int128-y = +check-unit-y += tests/rcutorture$(EXESUF) +gcov-files-rcutorture-y = util/rcu.c check-unit-y += tests/test-bitops$(EXESUF) check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh
@@ -99,8 +104,8 @@ test-obj-y = tests/check-qint.o tests/check-qstring.o tests/check-qdict.o \ tests/test-string-input-visitor.o tests/test-qmp-output-visitor.o \ tests/test-qmp-input-visitor.o tests/test-qmp-input-strict.o \ tests/test-qmp-commands.o tests/test-visitor-serialization.o \ - tests/test-x86-cpuid.o tests/test-mul64.o tests/rcutortore.o \ - tests/test-int128.o + tests/test-x86-cpuid.o tests/test-mul64.o tests/test-int128.o \ + tests/test-tls.o tests/rcutorture.o test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o
@@ -123,8 +128,9 @@ tests/test-hbitmap$(EXESUF): tests/test-hbitmap.o libqemuutil.a libqemustub.a tests/test-x86-cpuid$(EXESUF): tests/test-x86-cpuid.o tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o xbzrle.o page_cache.o libqemuutil.a tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o +tests/rcutorture$(EXESUF): tests/rcutorture.o libqemuutil.a tests/test-int128$(EXESUF): tests/test-int128.o +tests/test-tls$(EXESUF): tests/test-tls.o libqemuutil.a +tests/rcutorture$(EXESUF): tests/rcutorture.o libqemuutil.a tests/test-qapi-types.c tests/test-qapi-types.h :\
$(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py
Signature · 1 line
1.8.3.1
PATCH 2/2 enable TLS in build and activate test-tls in make check
In reply to Mike DayFrom: Paolo Bonzini <[email protected]>
Reviewed-by Mike Day <[email protected]>
--- configure | 63 ++++++++++++++++++++++---- include/qemu/tls.h | 127 +++++++++++++++++++++++++++++++++++++++++++++-------- include/qom/cpu.h | 2 +- tests/Makefile | 2 +- tests/test-tls.c | 87 ++++++++++++++++++++++++++++++++++++ 5 files changed, 252 insertions(+), 29 deletions(-) create mode 100644 tests/test-tls.c
configure +55 -8
@@ -285,6 +285,7 @@ fi ar="${AR-${cross_prefix}ar}" as="${AS-${cross_prefix}as}" cpp="${CPP-$cc -E}" +nm="${NM-${cross_prefix}nm}" objcopy="${OBJCOPY-${cross_prefix}objcopy}" ld="${LD-${cross_prefix}ld}" libtool="${LIBTOOL-${cross_prefix}libtool}"
@@ -1241,6 +1242,29 @@ if compile_prog "-Werror -fno-gcse" "" ; then TRANSLATE_OPT_CFLAGS=-fno-gcse fi +########################################## +# Using __thread is either faster than pthread_get/setspecific, +# or (if using GCC's "emutls" feature) exactly the same. So +# we always use it if available. + +cat > $TMPC << EOF +__thread int x; + +int main(void) +{ + x = 42; + return x; +} +EOF +if compile_prog "-Werror" "" ; then + tls=yes +else + tls=no +fi + +########################################## +# Position Independent executables + if test "$static" = "yes" ; then if test "$pie" = "yes" ; then error_exit "static and pie are mutually incompatible"
@@ -1260,19 +1284,18 @@ if test "$pie" = ""; then fi if test "$pie" != "no" ; then + if test "$CONFIG_TLS" = yes; then + THREAD=__thread + else + THREAD= + fi cat > $TMPC << EOF - -#ifdef __linux__ -# define THREAD __thread -#else -# define THREAD -#endif - -static THREAD int tls_var; +static $THREAD int tls_var; int main(void) { return tls_var; } EOF + unset THREAD if compile_prog "-fPIE -DPIE" "-pie"; then QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS" LDFLAGS="-pie $LDFLAGS"
@@ -3184,6 +3207,22 @@ if test "$trace_backend" = "dtrace"; then fi ########################################## +# check for TLS runtime + +# Some versions of mingw include the "magic" definitions that make +# TLS work, some don't. Check for it. + +if test "$mingw32" = yes; then + cat > $TMPC << EOF +int main(void) { return 0; } +EOF + compile_prog "" "" + if $nm $TMPE | grep _tls_used > /dev/null 2>&1; then + mingw32_tls_runtime=yes + fi +fi + +########################################## # check and set a backend for coroutine # We prefer ucontext, but it's not always possible. The fallback
@@ -3677,6 +3716,9 @@ if test "$mingw32" = "yes" ; then version_micro=0 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak + if test "$mingw32_tls_runtime" = yes; then + echo "CONFIG_MINGW32_TLS_RUNTIME=y" >> $config_host_mak + fi else echo "CONFIG_POSIX=y" >> $config_host_mak fi
@@ -3979,6 +4021,10 @@ if test "$cpuid_h" = "yes" ; then echo "CONFIG_CPUID_H=y" >> $config_host_mak fi +if test "$tls" = "yes" ; then + echo "CONFIG_TLS=y" >> $config_host_mak +fi + if test "$int128" = "yes" ; then echo "CONFIG_INT128=y" >> $config_host_mak fi
@@ -4107,6 +4153,7 @@ echo "OBJCC=$objcc" >> $config_host_mak echo "AR=$ar" >> $config_host_mak echo "AS=$as" >> $config_host_mak echo "CPP=$cpp" >> $config_host_mak +echo "NM=$nm" >> $config_host_mak echo "OBJCOPY=$objcopy" >> $config_host_mak echo "LD=$ld" >> $config_host_mak echo "WINDRES=$windres" >> $config_host_mak
include/qemu/tls.h +108 -19
143 lines not on this page · raw message
include/qom/cpu.h +1 -1
@@ -203,7 +203,7 @@ struct CPUState {extern CPUState *first_cpu; DECLARE_TLS(CPUState *, current_cpu); -#define current_cpu tls_var(current_cpu) +//#define current_cpu tls_var(current_cpu) /** * cpu_paging_enabled:
tests/Makefile +1 -1
@@ -47,7 +47,7 @@ gcov-files-test-mul64-y = util/host-utils.c check-unit-y += tests/test-tls$(EXESUF) # all code tested by test-tls is inside tls.h gcov-files-test-tls-y = -check-unit-y += tests/test-int128$(EXESUF) +#check-unit-y += tests/test-int128$(EXESUF) # all code tested by test-int128 is inside int128.h gcov-files-test-int128-y = check-unit-y += tests/rcutorture$(EXESUF)
tests/test-tls.c new file +87 -0
87 lines not on this page · raw message
Signature · 1 line
1.8.3.1