[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 00/19] Add Thread Sanitizer support to QEMU
From: |
Robert Foley |
Subject: |
[PATCH 00/19] Add Thread Sanitizer support to QEMU |
Date: |
Fri, 22 May 2020 12:07:36 -0400 |
This patch series continues the work done by Emilio Cota and others to add
Thread Sanitizer (TSan) support to QEMU.
The starting point for this work was Emilio's branch here:
https://github.com/cota/qemu/commits/tsan
specifically this commit: 0be125fc0afd47218b34d2019abdd19b644f3199
The purpose of this patch is not to fix all the TSan warnings, but to enable
the TSan support so that QEMU developers can start using the tool.
We found this tool useful and even ran it on our recent changes in
the cpu-locks series.
Clearly there is work to do here to clean up all the warnings. :)
We have made a start to cleaning up these warnings by getting a VM to boot
cleanly with no TSan warnings.
We have also made an effort to introduce enough of the TSan suppression
mechanisms, so that others can continue this work.
This series adds support for:
- configure option for --enable-tsan.
- testing.rst has the full details on how to use TSan with docker
and also outside of docker.
- Docker builds with TSan.
- We added an Ubuntu 20.04 docker that supports TSan builds.
- Something like this will build TSan
make docker-test-build@ubuntu2004 DEBUG=1 TSAN=1
- Testing with TSan is also supported with docker,
although, be forwarned that test-quick currently fails.
See "Issues" section below for the current failures.
make docker-test-quick@ubuntu2004 DEBUG=1 TSAN=1
- We recommend using the DEBUG=1 option and launching the test
(like test-quick) from inside the docker so that when the test is done,
you can review the warnings from inside the docker.
- testing.rst has the full details on how to use TSan with docker.
- We added a blacklist file for files/functions
TSan should ignore at compile time.
- And added a suppression file for TSan to suppress certain warnings at
run time.
We found both of these mechanisms are needed when suppressing warnings.
- It is also worth mentioning that we were able to suppress/fix enough errors
to allow an Ubuntu 18.04 aarch64 VM to boot with zero TSan warnings.
When we started this effort, there were ~300 warnings reported by
TSan during the same VM boot !
Issues:
- When running docker-test-quick under TSan there are several tests which hang
- The unit tests which seem to hang under TSan:
test-char, test-qdev-global-props, and test-qga.
- If we comment out those tests, check-unit finishes, albeit with
a couple of warnings. :)
Emilio G. Cota (7):
cpu: convert queued work to a QSIMPLEQ
thread: add qemu_spin_destroy
cputlb: destroy CPUTLB with tlb_destroy
qht: call qemu_spin_destroy for head buckets
tcg: call qemu_spin_destroy for tb->jmp_lock
translate-all: call qemu_spin_destroy for PageDesc
thread: add tsan annotations to QemuSpin
Lingfeng Yang (1):
configure: add --enable-tsan flag + fiber annotations for
coroutine-ucontext
Robert Foley (11):
tests/docker: Added docker build support for TSan.
include/qemu: Added tsan.h for annotations.
accel/tcg: Fixed tsan warnings related to parallel_cpus
configure: added tsan support for blacklist.
accel/tcg: Fixed tsan warnings.
util/async: Fixed tsan warnings
qht: Fix tsan warnings.
util: fixed tsan warnings in thread_pool.c
util: Added tsan annotate for thread name.
target/arm: Fix tsan warning in cpu.c
docs: Added details on TSan to testing.rst
accel/tcg/cpu-exec.c | 4 +-
accel/tcg/cputlb.c | 15 ++++
accel/tcg/tcg-all.c | 4 +-
accel/tcg/tcg-runtime.c | 7 +-
accel/tcg/translate-all.c | 25 +++++-
configure | 40 +++++++++
cpus-common.c | 25 ++----
cpus.c | 16 +++-
docs/devel/testing.rst | 72 ++++++++++++++++
exec.c | 1 +
hw/core/cpu.c | 3 +-
include/exec/exec-all.h | 10 ++-
include/hw/core/cpu.h | 6 +-
include/qemu/thread.h | 38 ++++++++-
include/qemu/tsan.h | 48 +++++++++++
include/tcg/tcg.h | 3 +-
linux-user/syscall.c | 4 +-
target/arm/cpu.c | 2 +-
tcg/tcg.c | 19 ++++-
tests/docker/Makefile.include | 2 +
tests/docker/common.rc | 19 +++++
tests/docker/dockerfiles/ubuntu2004.docker | 65 +++++++++++++++
tests/tsan/blacklist.tsan | 5 ++
tests/tsan/suppressions.tsan | 14 ++++
util/async.c | 11 ++-
util/coroutine-ucontext.c | 97 ++++++++++++++++++++--
util/qemu-thread-posix.c | 2 +
util/qht.c | 4 +
util/thread-pool.c | 5 +-
29 files changed, 514 insertions(+), 52 deletions(-)
create mode 100644 include/qemu/tsan.h
create mode 100644 tests/docker/dockerfiles/ubuntu2004.docker
create mode 100644 tests/tsan/blacklist.tsan
create mode 100644 tests/tsan/suppressions.tsan
--
2.17.1
- [PATCH 00/19] Add Thread Sanitizer support to QEMU,
Robert Foley <=
- [PATCH 01/19] configure: add --enable-tsan flag + fiber annotations for coroutine-ucontext, Robert Foley, 2020/05/22
- [PATCH 02/19] cpu: convert queued work to a QSIMPLEQ, Robert Foley, 2020/05/22
- [PATCH 03/19] thread: add qemu_spin_destroy, Robert Foley, 2020/05/22
- [PATCH 04/19] cputlb: destroy CPUTLB with tlb_destroy, Robert Foley, 2020/05/22
- [PATCH 06/19] tcg: call qemu_spin_destroy for tb->jmp_lock, Robert Foley, 2020/05/22
- [PATCH 07/19] translate-all: call qemu_spin_destroy for PageDesc, Robert Foley, 2020/05/22