From patchwork Tue Jun 9 20:07:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187708 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp860465ilo; Tue, 9 Jun 2020 13:09:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdiTQHpuqduCrr6mtZZLfNQyGXnVI2gTrd/obvzorqDXK5hpnQC6wh9jTmjF7pMFYvQm2N X-Received: by 2002:a25:dfcc:: with SMTP id w195mr9751386ybg.372.1591733394354; Tue, 09 Jun 2020 13:09:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591733394; cv=none; d=google.com; s=arc-20160816; b=jQSuzBqM2ko94VHu3tb43VqbTtc69SgOHxmwC2ytklp7lqaCRJxQtxdMBhabL4HSWi 7gkRbr2EYSMEv6T/jzl1nyRaVNE8QPNjYVWuUWJqCdwrB3lOnSBhVJ7qRQTMCeqgSYFK R/F/SBQ6YtGfQy9/UzlRXAo77TxcirjapvYhxQDTCpestGhYosEIggorJ+K+sIW165lH /2XnELJRC4IxHqYhPFQsZQACpS6vC8UL1zwX6aFumC162snda6nbh80vTnDE2mjjNAB8 bj1bFZLBaRosFqbx+cPcP1ARx6CQo0M+GIbfWNWk1orh/P1S0Yc6gMPwzDZajASL3HeT 5ySw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=PEbujPtBaJg3B2IT0hPnYXWImSAP6JwyxZ2Cqb86MEY=; b=w39Ok6iCY2qdAICmGlmNHDWB5/4+Jwg6WAjU7u/b+Ijzy5apJa2NpEj0up2o/7CMKd w8A4vE+bYklqME41dPqfC6JtYceD7hVxyQGQeZkEZIELMuxnt/m7KjUTMUfWQ6Z9VteD 6mu5/JHWxWL3tl6cidTFnLFsDrmYAR4uDfzWQIuuxbLgTFPbXbQ4SkPVTaZie0VT7BuZ gHevu9wVw/OooLOc+gxYfzflVuYUflHEru9vi5lLYG7myQZvz7jq9FCcwxheRvd3Q7Ed KbtH0zEHZahMYntz2LNb+O/OXq5Yvy3HjKRkiValdVW+33jizq6a2e9cQvivK/TgtZz9 k9Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SvN7s+Mj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u8si2078100ybb.311.2020.06.09.13.09.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jun 2020 13:09:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SvN7s+Mj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:56598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jikZF-0007Op-NO for patch@linaro.org; Tue, 09 Jun 2020 16:09:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jikZ1-0007NR-UN for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:39 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:33148) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jikZ0-0005Yy-AX for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:39 -0400 Received: by mail-pl1-x643.google.com with SMTP id t7so25209plr.0 for ; Tue, 09 Jun 2020 13:09:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PEbujPtBaJg3B2IT0hPnYXWImSAP6JwyxZ2Cqb86MEY=; b=SvN7s+MjJJ7ADNt5weFq9NU9aiPFWeG9ft6r1PtTQHd+3Gl7ccE4YXSi6/TY6Gxcac D20wS7o7f1naPiFINjoWEKkNr4pVdtSQa0S/aYdAGEVSSl9rpTeE1WFFUnHAVq2WrZBA PFgxacabSIBZ7svHkx90sm50Kia5ly7lZiWHk5d5sXp5ZuP/0FZBdtFlGPqRXLHlwtg9 YP6STyvxaK1o2xW3JeBTkMD+genH0b9J5KssTSRw+TXuJUWuWXYeBiNVKIgUtc9GR0Nh s/0r0LlMZ8y3LVrOLt8Y/0HC7M1TT6DkYv+99MOU9xMp2+ykz47o0OKzLClwjOWwGRje ekNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PEbujPtBaJg3B2IT0hPnYXWImSAP6JwyxZ2Cqb86MEY=; b=ouAi0af6BUydq+FGArZCkyP2GK1Pv0V9Z8egfKN/jP0nl+gSHBCYHbz4c7C48KcY4D 9PbwFcAgG05trcVm9rgpX+tGffxerAtAepHS6YMFTBWOtoT3LMg/4y7+4vgjZZ7vvPfE YsWlvAJvfB4+TbdT1Sfx+lcqJChCt9CHKLLRF+npOjmc7xBQLArvYHTyK7CjcWNRQF3z Nr5j5ytqiMyCyqbEjMDM65YuhhDQamKMQEEE9vnvCZ5syzuKF0EzIEyx3rHFEfO2Xi/I L+KuQqgvxIrirp8YDzPmxYt5ppnhU4ictRtuphFo2/84e88SoJSZUy+6sJBPyzfM7D3Z pkXQ== X-Gm-Message-State: AOAM532o3oE9D+Uwqxl4ff9Ixf4ReALGfJ2uestRRlnzu2I/Abvc5g7p t++v28RsF3zafOikxRWysS+UfC1h4hv1Wg== X-Received: by 2002:a17:90a:3608:: with SMTP id s8mr6294130pjb.167.1591733376257; Tue, 09 Jun 2020 13:09:36 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:1d09:cef2:3b1f:abce]) by smtp.gmail.com with ESMTPSA id n19sm10523374pfu.194.2020.06.09.13.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 13:09:35 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v3 01/13] configure: add --enable-tsan flag + fiber annotations for coroutine-ucontext Date: Tue, 9 Jun 2020 16:07:26 -0400 Message-Id: <20200609200738.445-2-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609200738.445-1-robert.foley@linaro.org> References: <20200609200738.445-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::643; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x643.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , robert.foley@linaro.org, alex.bennee@linaro.org, cota@braap.org, Stefan Hajnoczi , Lingfeng Yang , peter.puhov@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Lingfeng Yang We tried running QEMU under tsan in 2016, but tsan's lack of support for longjmp-based fibers was a blocker: https://groups.google.com/forum/#!topic/thread-sanitizer/se0YuzfWazw Fortunately, thread sanitizer gained fiber support in early 2019: https://reviews.llvm.org/D54889 This patch brings tsan support upstream by importing the patch that annotated QEMU's coroutines as tsan fibers in Android's QEMU fork: https://android-review.googlesource.com/c/platform/external/qemu/+/844675 Tested with '--enable-tsan --cc=clang-9 --cxx=clang++-9 --disable-werror' configure flags. Signed-off-by: Lingfeng Yang Signed-off-by: Emilio G. Cota [cota: minor modifications + configure changes] Signed-off-by: Robert Foley [RF: configure changes, coroutine fix + minor modifications] Reviewed-by: Alex Bennée --- configure | 47 +++++++++++++++++++++++++++- util/coroutine-ucontext.c | 66 +++++++++++++++++++++++++++++++++------ 2 files changed, 103 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/configure b/configure index 597e909b53..da46f9556e 100755 --- a/configure +++ b/configure @@ -395,6 +395,7 @@ gprof="no" debug_tcg="no" debug="no" sanitizers="no" +tsan="no" fortify_source="" strip_opt="yes" tcg_interpreter="no" @@ -1150,6 +1151,10 @@ for opt do ;; --disable-sanitizers) sanitizers="no" ;; + --enable-tsan) tsan="yes" + ;; + --disable-tsan) tsan="no" + ;; --enable-sparse) sparse="yes" ;; --disable-sparse) sparse="no" @@ -1754,6 +1759,7 @@ Advanced options (experts only): --with-pkgversion=VERS use specified string as sub-version of the package --enable-debug enable common debug build options --enable-sanitizers enable default sanitizers + --enable-tsan enable thread sanitizer --disable-strip disable stripping binaries --disable-werror disable compilation abort on warning --disable-stack-protector disable compiler-provided stack protection @@ -6196,6 +6202,30 @@ if test "$fuzzing" = "yes" ; then fi fi +# Thread sanitizer is, for now, much noisier than the other sanitizers; +# keep it separate until that is not the case. +if test "$tsan" = "yes" && test "$sanitizers" = "yes"; then + error_exit "TSAN is not supported with other sanitiziers." +fi +have_tsan=no +have_tsan_iface_fiber=no +if test "$tsan" = "yes" ; then + write_c_skeleton + if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then + have_tsan=yes + fi + cat > $TMPC << EOF +#include +int main(void) { + __tsan_create_fiber(0); + return 0; +} +EOF + if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then + have_tsan_iface_fiber=yes + fi +fi + ########################################## # check for libpmem @@ -6297,6 +6327,16 @@ if test "$have_asan" = "yes"; then "Without code annotation, the report may be inferior." fi fi +if test "$have_tsan" = "yes" ; then + if test "$have_tsan_iface_fiber" = "yes" ; then + QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS" + QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS" + else + error_exit "Cannot enable TSAN due to missing fiber annotation interface." + fi +elif test "$tsan" = "yes" ; then + error_exit "Cannot enable TSAN due to missing sanitize thread interface." +fi if test "$have_ubsan" = "yes"; then QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS" QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS" @@ -6332,7 +6372,8 @@ if test "$werror" = "yes"; then QEMU_CFLAGS="-Werror $QEMU_CFLAGS" fi -if test "$solaris" = "no" ; then +# Exclude --warn-common with TSan to suppress warnings from the TSan libraries. +if test "$solaris" = "no" && test "$tsan" = "no"; then if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS" fi @@ -7386,6 +7427,10 @@ if test "$have_asan_iface_fiber" = "yes" ; then echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak fi +if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then + echo "CONFIG_TSAN=y" >> $config_host_mak +fi + if test "$has_environ" = "yes" ; then echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak fi diff --git a/util/coroutine-ucontext.c b/util/coroutine-ucontext.c index bd593e61bc..613f4c118e 100644 --- a/util/coroutine-ucontext.c +++ b/util/coroutine-ucontext.c @@ -37,12 +37,19 @@ #endif #endif +#ifdef CONFIG_TSAN +#include +#endif + typedef struct { Coroutine base; void *stack; size_t stack_size; sigjmp_buf env; + void *tsan_co_fiber; + void *tsan_caller_fiber; + #ifdef CONFIG_VALGRIND_H unsigned int valgrind_stack_id; #endif @@ -65,7 +72,18 @@ union cc_arg { int i[2]; }; -static void finish_switch_fiber(void *fake_stack_save) +/* QEMU_ALWAYS_INLINE only does so if __OPTIMIZE__, so we cannot use it. */ +static inline __attribute__((always_inline)) +void on_new_fiber(CoroutineUContext *co) +{ +#ifdef CONFIG_TSAN + co->tsan_co_fiber = __tsan_create_fiber(0); /* flags: sync on switch */ + co->tsan_caller_fiber = __tsan_get_current_fiber(); +#endif +} + +static inline __attribute__((always_inline)) +void finish_switch_fiber(void *fake_stack_save) { #ifdef CONFIG_ASAN const void *bottom_old; @@ -78,13 +96,30 @@ static void finish_switch_fiber(void *fake_stack_save) leader.stack_size = size_old; } #endif +#ifdef CONFIG_TSAN + if (fake_stack_save) { + __tsan_release(fake_stack_save); + __tsan_switch_to_fiber(fake_stack_save, 0); /* 0=synchronize */ + } +#endif } -static void start_switch_fiber(void **fake_stack_save, - const void *bottom, size_t size) +static inline __attribute__((always_inline)) void start_switch_fiber( + CoroutineAction action, void **fake_stack_save, + const void *bottom, size_t size, void *new_fiber) { #ifdef CONFIG_ASAN - __sanitizer_start_switch_fiber(fake_stack_save, bottom, size); + __sanitizer_start_switch_fiber( + action == COROUTINE_TERMINATE ? NULL : fake_stack_save, + bottom, size); +#endif +#ifdef CONFIG_TSAN + void *curr_fiber = + __tsan_get_current_fiber(); + __tsan_acquire(curr_fiber); + + *fake_stack_save = curr_fiber; + __tsan_switch_to_fiber(new_fiber, 0); /* 0=synchronize */ #endif } @@ -104,8 +139,12 @@ static void coroutine_trampoline(int i0, int i1) /* Initialize longjmp environment and switch back the caller */ if (!sigsetjmp(self->env, 0)) { - start_switch_fiber(&fake_stack_save, - leader.stack, leader.stack_size); + start_switch_fiber( + COROUTINE_YIELD, + &fake_stack_save, + leader.stack, + leader.stack_size, + self->tsan_caller_fiber); siglongjmp(*(sigjmp_buf *)co->entry_arg, 1); } @@ -154,12 +193,16 @@ Coroutine *qemu_coroutine_new(void) arg.p = co; + on_new_fiber(co); makecontext(&uc, (void (*)(void))coroutine_trampoline, 2, arg.i[0], arg.i[1]); /* swapcontext() in, siglongjmp() back out */ if (!sigsetjmp(old_env, 0)) { - start_switch_fiber(&fake_stack_save, co->stack, co->stack_size); + start_switch_fiber( + COROUTINE_YIELD, + &fake_stack_save, + co->stack, co->stack_size, co->tsan_co_fiber); swapcontext(&old_uc, &uc); } @@ -216,8 +259,8 @@ qemu_coroutine_switch(Coroutine *from_, Coroutine *to_, ret = sigsetjmp(from->env, 0); if (ret == 0) { - start_switch_fiber(action == COROUTINE_TERMINATE ? - NULL : &fake_stack_save, to->stack, to->stack_size); + start_switch_fiber(action, &fake_stack_save, + to->stack, to->stack_size, to->tsan_co_fiber); siglongjmp(to->env, action); } @@ -231,6 +274,11 @@ Coroutine *qemu_coroutine_self(void) if (!current) { current = &leader.base; } +#ifdef CONFIG_TSAN + if (!leader.tsan_co_fiber) { + leader.tsan_co_fiber = __tsan_get_current_fiber(); + } +#endif return current; } From patchwork Tue Jun 9 20:07:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187711 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp861892ilo; Tue, 9 Jun 2020 13:12:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDJYBEHehYfJsBvVOiDJugEfOsg//o/90URGSa1qGthq7FU4UHGL9PU3AJgOt0T2pSqyOx X-Received: by 2002:a25:6403:: with SMTP id y3mr9520738ybb.229.1591733522580; Tue, 09 Jun 2020 13:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591733522; cv=none; d=google.com; s=arc-20160816; b=tHDFudFSESw1Zt4LPCP0ujscuFbj2+bl4TSekMU2h3Yl9YUAgy4s/zfQJHwsbQzMcS mBYyAfksvppLOLV8Sg5ypl3QV8EbonZJCF1UoOuwuQ44F5yGmNnme2VXN7cfYNgB7QLr 5PEzZhfAiE3d8fsME2l7TJly3YkSvS19NTw1FnBsdYSjzAwLm6CQZyeBJux+1zAZLgSC 6iUdhIiyT1zDBr7sbPNLoMp7DPtwpe6Ca70Bm1iIboqQHQf1qpOH/omufVqJBbb/j/uQ Mkk9URucT85QA2ZosNd4YQYTRtF9lPSBWoQjPSAa6S4WBu2hNjQ+cqC7Dzm8wLJAC2RD GFdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=pD3JWxT76a4NROnBN3hpZMTAPaW7sxqBc70GvHSGYPw=; b=BzgCF+HGOdYHvCbDi9gC5bw3Rwu/0/EC8XlH1SWnjdeuK0gkaAZoVXvv8fjMieXIYk G+P5zhaGAfnkT3tnsNnnAYIvtTifDFcY77lBl1VrrkUoPQF3OMgqyAD/9+Gcp1F9qA9Y PSjtcvXhMhUUOMP0J79rLV7uVYJR9N3egNawsGZNiqwbqUyFMV08e1A2lKgV3ohOhbWH WrQtXo/wSwsJhTk1GJ7XySN5HNWqw+BOaHnvvVesWXRzR6luIUTOklqJsEKakMF86p2i I7cIy5/5tCDtTCbTdLCNW9Q3oEGyhyhhOhUzxzbfac7mXKSu/P4TVcyoDY1KMhgRMeFl +CCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wCQnDTZK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n8si3279760ybk.265.2020.06.09.13.12.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jun 2020 13:12:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wCQnDTZK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:35866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jikbJ-00027p-Vg for patch@linaro.org; Tue, 09 Jun 2020 16:12:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jikZ3-0007Os-67 for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:41 -0400 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]:36666) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jikZ2-0005ZH-7E for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:40 -0400 Received: by mail-pj1-x1043.google.com with SMTP id q24so1885049pjd.1 for ; Tue, 09 Jun 2020 13:09:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pD3JWxT76a4NROnBN3hpZMTAPaW7sxqBc70GvHSGYPw=; b=wCQnDTZKeoZgWMDzK6ZzWdAIyphAjAWuDsiT1OCXPbI2zLvafiPEIs3hsKVdrm0LQv 4c7ABOz46g0c/CtX9kuWYATO/3bTb9ToHouMW3cjNrgLYRsbubnYCDEETXG5EH6ISEtc 0dPqkXzdw8t2NhpxWntekoroRYJalibvDEKKraXQKwq1PGsY77Ky8dtZ0A5d7iuedN/Z FF2OZu/YKr8jyl6yH2n8TFMrOaRmCh/6p3464DttMRgKevX8w18Kn0HQQrIO1JVwIdrh 4gGBEz4xB5Jv0/A7CNs6NPSD3DhzLb+wLdMSQiLWAMsVlsLCGEY3DzHGDKfJQK8K5P9F mJKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pD3JWxT76a4NROnBN3hpZMTAPaW7sxqBc70GvHSGYPw=; b=qO8o+YNZqE6DA3pX2s9WB8i885AZTkmAmxuH6LRRL4PhSvPKfpa2x62QXIPBopVxOL JHEvhi5BhULb0elgZiWVq99jPHEdnAtIEEhcXGvJbXbWwvc6SvoLVM2RAOOoktZ79kiS u7LKU2x1RfAtK7hYnq5v/S/8nmUAbv/Yr0C5kULTAOnv8cwzdVA7bRDZP6DjeoiiPWFZ pRVaBm3cCoCsJLBl4gIBiwHMfUjBSlRNqdhECngK3oPpF7cyX25WgOJj4E7Xhmj0U6k+ BM+MSy53MWuYCTVyAI81zLdpbFGqcq728NaUTeIZkFjmfiDwbbdEIEf6haRwcOtCP3Eo JxiA== X-Gm-Message-State: AOAM532QSaRyNMTuara+MUnPn2yNtPq8p4UaW84QVOBEydm9WCgaaE6s MJNwIj12p9Cp4uEX/Vj9ZZKAqEFHKVrUMA== X-Received: by 2002:a17:90a:240c:: with SMTP id h12mr6670763pje.42.1591733378558; Tue, 09 Jun 2020 13:09:38 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:1d09:cef2:3b1f:abce]) by smtp.gmail.com with ESMTPSA id n19sm10523374pfu.194.2020.06.09.13.09.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 13:09:37 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v3 02/13] cpu: convert queued work to a QSIMPLEQ Date: Tue, 9 Jun 2020 16:07:27 -0400 Message-Id: <20200609200738.445-3-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609200738.445-1-robert.foley@linaro.org> References: <20200609200738.445-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1043; envelope-from=robert.foley@linaro.org; helo=mail-pj1-x1043.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@linaro.org, Eduardo Habkost , cota@braap.org, Paolo Bonzini , peter.puhov@linaro.org, alex.bennee@linaro.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" We convert queued work to a QSIMPLEQ, instead of open-coding it. While at it, make sure that all accesses to the list are performed while holding the list's lock. Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Emilio G. Cota Signed-off-by: Robert Foley --- cpus-common.c | 25 ++++++++----------------- cpus.c | 14 ++++++++++++-- hw/core/cpu.c | 1 + include/hw/core/cpu.h | 6 +++--- 4 files changed, 24 insertions(+), 22 deletions(-) -- 2.17.1 diff --git a/cpus-common.c b/cpus-common.c index 70a9d12981..8f5512b3d7 100644 --- a/cpus-common.c +++ b/cpus-common.c @@ -97,7 +97,7 @@ void cpu_list_remove(CPUState *cpu) } struct qemu_work_item { - struct qemu_work_item *next; + QSIMPLEQ_ENTRY(qemu_work_item) node; run_on_cpu_func func; run_on_cpu_data data; bool free, exclusive, done; @@ -106,13 +106,7 @@ struct qemu_work_item { static void queue_work_on_cpu(CPUState *cpu, struct qemu_work_item *wi) { qemu_mutex_lock(&cpu->work_mutex); - if (cpu->queued_work_first == NULL) { - cpu->queued_work_first = wi; - } else { - cpu->queued_work_last->next = wi; - } - cpu->queued_work_last = wi; - wi->next = NULL; + QSIMPLEQ_INSERT_TAIL(&cpu->work_list, wi, node); wi->done = false; qemu_mutex_unlock(&cpu->work_mutex); @@ -306,17 +300,14 @@ void process_queued_cpu_work(CPUState *cpu) { struct qemu_work_item *wi; - if (cpu->queued_work_first == NULL) { + qemu_mutex_lock(&cpu->work_mutex); + if (QSIMPLEQ_EMPTY(&cpu->work_list)) { + qemu_mutex_unlock(&cpu->work_mutex); return; } - - qemu_mutex_lock(&cpu->work_mutex); - while (cpu->queued_work_first != NULL) { - wi = cpu->queued_work_first; - cpu->queued_work_first = wi->next; - if (!cpu->queued_work_first) { - cpu->queued_work_last = NULL; - } + while (!QSIMPLEQ_EMPTY(&cpu->work_list)) { + wi = QSIMPLEQ_FIRST(&cpu->work_list); + QSIMPLEQ_REMOVE_HEAD(&cpu->work_list, node); qemu_mutex_unlock(&cpu->work_mutex); if (wi->exclusive) { /* Running work items outside the BQL avoids the following deadlock: diff --git a/cpus.c b/cpus.c index 5670c96bcf..af44027549 100644 --- a/cpus.c +++ b/cpus.c @@ -97,9 +97,19 @@ bool cpu_is_stopped(CPUState *cpu) return cpu->stopped || !runstate_is_running(); } +static inline bool cpu_work_list_empty(CPUState *cpu) +{ + bool ret; + + qemu_mutex_lock(&cpu->work_mutex); + ret = QSIMPLEQ_EMPTY(&cpu->work_list); + qemu_mutex_unlock(&cpu->work_mutex); + return ret; +} + static bool cpu_thread_is_idle(CPUState *cpu) { - if (cpu->stop || cpu->queued_work_first) { + if (cpu->stop || !cpu_work_list_empty(cpu)) { return false; } if (cpu_is_stopped(cpu)) { @@ -1498,7 +1508,7 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg) cpu = first_cpu; } - while (cpu && !cpu->queued_work_first && !cpu->exit_request) { + while (cpu && cpu_work_list_empty(cpu) && !cpu->exit_request) { atomic_mb_set(&tcg_current_rr_cpu, cpu); current_cpu = cpu; diff --git a/hw/core/cpu.c b/hw/core/cpu.c index f31ec48ee6..80d51c24dd 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -370,6 +370,7 @@ static void cpu_common_initfn(Object *obj) cpu->nr_threads = 1; qemu_mutex_init(&cpu->work_mutex); + QSIMPLEQ_INIT(&cpu->work_list); QTAILQ_INIT(&cpu->breakpoints); QTAILQ_INIT(&cpu->watchpoints); diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 497600c49e..b3f4b79318 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -331,8 +331,8 @@ struct qemu_work_item; * @opaque: User data. * @mem_io_pc: Host Program Counter at which the memory was accessed. * @kvm_fd: vCPU file descriptor for KVM. - * @work_mutex: Lock to prevent multiple access to queued_work_*. - * @queued_work_first: First asynchronous work pending. + * @work_mutex: Lock to prevent multiple access to @work_list. + * @work_list: List of pending asynchronous work. * @trace_dstate_delayed: Delayed changes to trace_dstate (includes all changes * to @trace_dstate). * @trace_dstate: Dynamic tracing state of events for this vCPU (bitmask). @@ -376,7 +376,7 @@ struct CPUState { sigjmp_buf jmp_env; QemuMutex work_mutex; - struct qemu_work_item *queued_work_first, *queued_work_last; + QSIMPLEQ_HEAD(, qemu_work_item) work_list; CPUAddressSpace *cpu_ases; int num_ases; From patchwork Tue Jun 9 20:07:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187709 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp860525ilo; Tue, 9 Jun 2020 13:09:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqtxXsHO89ucNy12IzdQ6k6reIk2TT0ZINIhBDcpNXRtPj7y5bQXZplH7TCmKaFweV51Hd X-Received: by 2002:a25:d088:: with SMTP id h130mr9569759ybg.451.1591733399047; Tue, 09 Jun 2020 13:09:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591733399; cv=none; d=google.com; s=arc-20160816; b=TNQrizFHVKkmm6suni4aQEehW1BQcIYXJo88amcETSzaQWeTOlDhRA9KyoBozYUnEF zfaNQdR7f2CLKJ5+wcywur4g6mLF/t8FMTim4xd6dRUXgNoWNqEsKWiHcs/5kTIQMpFg KiaVBHWzKEXlqeycw6ry92IM49H2CODc1lUyQMjKfGis12FIJfZKYPi0axkH26WbyZxZ GJj/qP8OgzHkaLTCSIX6boAjqHglmFlS/gu28aFisPlejxGtjE9te7MTkv5l4CmXRX17 IjL/QsbmsA8hnP6wi6CTN9nKzwzVZA1aiadyDnXz8Kqv3BSDnRhE9/YypfwkP1WxxA8t 0afw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=hi7LUnC/2Vxc6CG4AyW71h/9KhgELUl20yMZDhooBMo=; b=Ge9DQVjngdFKvGXJuOzBgthiY5P1FeT6b6GuJuBv1+l87bN0bENKWe7jsSKd464KV2 qDTwEein6VCj9DG/YugHsPXsKgIDWqcsBIlL17MYTsTSZ/GEEeHmLwMDE3nL34Frdkpg gRExi8sbbL+djkPettTVkO+q91UzWoOBxi6IPgu6NDT1lsI6M1hl5yC8qleBxL8CrHcv t5sux3u5yA1MTlKNzWkZpoo242Hp2iLhZdXfSs1KqDhMqTYw7END7/8bXF3Dgy+esmWX uHgdr/sPskuY9gIxcoaO41xM8yEjCbT3VVnc2u/QsbkFcjosRqZ06bPHeCMqyDeOWChQ UgfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=U03bWEWI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 189si3593234ybn.283.2020.06.09.13.09.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jun 2020 13:09:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=U03bWEWI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:56802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jikZK-0007U9-HO for patch@linaro.org; Tue, 09 Jun 2020 16:09:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jikZ4-0007RC-K7 for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:42 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:41994) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jikZ3-0005Zd-Rb for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:42 -0400 Received: by mail-pl1-x643.google.com with SMTP id x11so7667plv.9 for ; Tue, 09 Jun 2020 13:09:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hi7LUnC/2Vxc6CG4AyW71h/9KhgELUl20yMZDhooBMo=; b=U03bWEWIv5lmCxfVjI5TYxG7RiozcKxCQ+evlMNwHzvIXrXt1/I7T6fSDdvPQR7pVP hw9kBk29qkHugmcZCb2wefK1ecjO6DaQCyVwoeu/nH+237tldj2WIkjAtT6R7QVSAdzU R1bCWRRXbzX9F+7uiweQMhNFjs2dNLwzyurj5xF7FErQdZhqezs1wc+sY8mfoTFf/keG 9jCu7LrOBjx9mMkcH4P5Qh5GWfwOWzoETs6kIpqrhsk8arLLQZvQw00cPG/u20End6NM qJHridjevr2gCVkVh+5g1LOEeJorocZlLR2LdzMDsIUOSkBeY9jQ7iDifyJh6y/+ZAy8 Qojw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hi7LUnC/2Vxc6CG4AyW71h/9KhgELUl20yMZDhooBMo=; b=S2QTGC5y5YXNmKjFKj+tQHO6iyn05azFckMbvAFhkQjVmCWCmjJ25CKGXUhCUo9vlR F1h9fVPhb7AnTo3rKFlt65NKBLqgqhii4GGHTS9A8oJavQ6pCl6qANxqF8+UOFIKxN2O Jyj+m+7u797CJRVSyk0cnUpofd5rGlL/XkRIWJnCxGyHhpfBM/5EOKDgaJLgM5lqk0Zu ujDQ3yc9DfmwnzsVPxQDn0zG0zD7iNiVWxIdFkPZgn6ox0+zBuhWqeIelrS1l6HFuht0 3MT8tn9SyqLFOoxadBdVTTwHJh+3sH/Q617GA0HYKiARbRRwnvzrayCiAtsWD2/5aY6t ULwA== X-Gm-Message-State: AOAM530oq8ikNu477zwlnfBmyaqLe08eb1W0OGYyIpbo9Xfv/r/jWC2I 4bv8TaHDQZT1yT+/hqypXnXTjVkcWONxMA== X-Received: by 2002:a17:902:7247:: with SMTP id c7mr63673pll.103.1591733380337; Tue, 09 Jun 2020 13:09:40 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:1d09:cef2:3b1f:abce]) by smtp.gmail.com with ESMTPSA id n19sm10523374pfu.194.2020.06.09.13.09.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 13:09:39 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v3 03/13] thread: add qemu_spin_destroy Date: Tue, 9 Jun 2020 16:07:28 -0400 Message-Id: <20200609200738.445-4-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609200738.445-1-robert.foley@linaro.org> References: <20200609200738.445-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::643; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x643.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.puhov@linaro.org, cota@braap.org, alex.bennee@linaro.org, robert.foley@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" It will be used for TSAN annotations. Signed-off-by: Emilio G. Cota Signed-off-by: Robert Foley Reviewed-by: Alex Bennée --- include/qemu/thread.h | 3 +++ 1 file changed, 3 insertions(+) -- 2.17.1 diff --git a/include/qemu/thread.h b/include/qemu/thread.h index d22848138e..e50a073889 100644 --- a/include/qemu/thread.h +++ b/include/qemu/thread.h @@ -215,6 +215,9 @@ static inline void qemu_spin_init(QemuSpin *spin) __sync_lock_release(&spin->value); } +static inline void qemu_spin_destroy(QemuSpin *spin) +{ } + static inline void qemu_spin_lock(QemuSpin *spin) { while (unlikely(__sync_lock_test_and_set(&spin->value, true))) { From patchwork Tue Jun 9 20:07:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187714 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp863345ilo; Tue, 9 Jun 2020 13:13:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtk0bwbhvR7Et8/0vQ3MnqCRzck2p3gEWYQMGsg39FPul2o9uCaIl1rH4b5YiyNeqqNZdN X-Received: by 2002:a5b:b89:: with SMTP id l9mr9178752ybq.82.1591733639087; Tue, 09 Jun 2020 13:13:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591733639; cv=none; d=google.com; s=arc-20160816; b=xeoDFz3WNWw+QU/E6YYcbjZP5yZNWbH2tXzb11SADi3oegoQv7fSzaQunWEZxenO5Z 0GtLX1vt85lTJJ5UTGeARbl4d/QwJlIckRlYDxuBmivIKUMl97vk4wbTdRJJ73DFamdG fVk0ZrABQDpDFMGEG5vX/iilmhXk06eIsSNhyEN5AB8F4fzNQVysLGyFGmJt3FXZpEG8 jgpdNVKSTlY5BkPLcvlJn6T3Cv2r5ltXh/LKrQJwb2fD4yc1C6qsDGe7nJ7GJFQfrPfa UKc7DX39gt25zyXXcKqDiyTfaEpHvqKrhQIyTm7Sxlny3A/ogWrA4el0Yi3PR3CjygW+ 08jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=mMbQhssouUvEnYpKM8BJ1rWl4q0BOBlTa248+fa3MEA=; b=dAByyC45JwH+f65hX84V+/47ByNtU8HshJIkKzuAWKLY8dYDga8T7dCgzNyO6IgVmx /NqzlTEtPxvGirsNH7ytN83fh6rq5SzYYS3Uz+ZmY1nCRogW+40dbDK6WMpZTOtirB0H 9prZ/k7b4RfC/EiYKyHY+cNdmbErzLCtZ1gOTO4HgiXGzSA7hRboQOgtHL+CJcDnAce8 HWxGoDkyr1JW7IYK56PRK+zAD8Am/OCbNtPOO9PM9ZApRu7zcM525Q5ejjkj0UqMvoAl rMb89SVtU71W8myeOKNO0vZ85o8u7FZK9VvVQDiWm9MfM49N8pwYwykbgrwDk3Wh0eh5 lkcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FOMrvHJr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k21si3079684ybk.116.2020.06.09.13.13.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jun 2020 13:13:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FOMrvHJr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jikdC-0004v5-Il for patch@linaro.org; Tue, 09 Jun 2020 16:13:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jikZ7-0007Vb-5J for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:45 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:37886) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jikZ6-0005aI-4t for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:44 -0400 Received: by mail-pl1-x641.google.com with SMTP id y18so17417plr.4 for ; Tue, 09 Jun 2020 13:09:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mMbQhssouUvEnYpKM8BJ1rWl4q0BOBlTa248+fa3MEA=; b=FOMrvHJrOFSJ+/V6jlfepp24K34u2dT1Y3Ao4CiNA7GTTNvDUWqQ9tsJ3FG+TV5De8 Z/Xlqaa6+3XV237J5yLXl5w7NpAMBzlL5bMrvqWeHeuZoQvjDukKmFQGoUFWF6z2a/ao VHMKOhypwPlZSOJKd3oMKdMBxJApD+Jk2eZj0J+e8V22RG4zbzZSmtadWcZqAhGe/wCv M9tL1NQ810u6sH5bW0uPrAmd2tJrMdyGCFfUSAsKG9Y9hq6jUM3Aa90dvewsLNTFS5EJ tYVquQRJoxJu8cVpHV2J0oUv5/yD3yRUiMTSmtUm4UvxX9LTzsoX3wAhGSiS1tYG+d7q OhmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mMbQhssouUvEnYpKM8BJ1rWl4q0BOBlTa248+fa3MEA=; b=J1QniRRkAApzrfaxutYEw9Tjk8pViZ44J0dntoWgmgxJueM9q+qYsfjpkIhJXe3QJN J560cie5N2QAVsgSSMGno7Urm+TNalYe7sTiWkHXw9w6iKwDFFS6F5PiXwfVD77MHSaz st0HntH8htlQ/49P2du3ghWNyauv+lpfGkYprkQHhYjOGTOAnLCW2jQVTCN/VpZqfLt6 4karAjYNkO3X3c07iubhEd298JZ5sq6zF4npLReBRnZAcRtlqvr4uObk9/vL/+LqLSJq SpV8noojaIUpOZxpAUobAaOVa/WdHxDlg0u/hXhLL3HEmr5uEJE9Ca5rY63pMxiwGiMq oEAw== X-Gm-Message-State: AOAM532IPkFuoak0YW4SQaGJEH06uSIEtoSw/AXUt8mRhHoVdAEwWNMK lF0xwnWv7iDkARPSt3Nuz3N+6A41YYIWmw== X-Received: by 2002:a17:90a:df82:: with SMTP id p2mr6707823pjv.217.1591733382355; Tue, 09 Jun 2020 13:09:42 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:1d09:cef2:3b1f:abce]) by smtp.gmail.com with ESMTPSA id n19sm10523374pfu.194.2020.06.09.13.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 13:09:41 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v3 04/13] cputlb: destroy CPUTLB with tlb_destroy Date: Tue, 9 Jun 2020 16:07:29 -0400 Message-Id: <20200609200738.445-5-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609200738.445-1-robert.foley@linaro.org> References: <20200609200738.445-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::641; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x641.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@linaro.org, cota@braap.org, Paolo Bonzini , peter.puhov@linaro.org, alex.bennee@linaro.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" I was after adding qemu_spin_destroy calls, but while at it I noticed that we are leaking some memory. Signed-off-by: Emilio G. Cota Signed-off-by: Robert Foley Reviewed-by: Alex Bennée --- accel/tcg/cputlb.c | 15 +++++++++++++++ exec.c | 1 + include/exec/exec-all.h | 8 ++++++++ 3 files changed, 24 insertions(+) -- 2.17.1 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index eb2cf9de5e..1e815357c7 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -270,6 +270,21 @@ void tlb_init(CPUState *cpu) } } +void tlb_destroy(CPUState *cpu) +{ + CPUArchState *env = cpu->env_ptr; + int i; + + qemu_spin_destroy(&env_tlb(env)->c.lock); + for (i = 0; i < NB_MMU_MODES; i++) { + CPUTLBDesc *desc = &env_tlb(env)->d[i]; + CPUTLBDescFast *fast = &env_tlb(env)->f[i]; + + g_free(fast->table); + g_free(desc->iotlb); + } +} + /* flush_all_helper: run fn across all cpus * * If the wait flag is set then the src cpu's helper will be queued as diff --git a/exec.c b/exec.c index be4be2df3a..79211fb23d 100644 --- a/exec.c +++ b/exec.c @@ -892,6 +892,7 @@ void cpu_exec_unrealizefn(CPUState *cpu) { CPUClass *cc = CPU_GET_CLASS(cpu); + tlb_destroy(cpu); cpu_list_remove(cpu); if (cc->vmsd != NULL) { diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 8792bea07a..3cf88272df 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -124,6 +124,11 @@ void cpu_address_space_init(CPUState *cpu, int asidx, * @cpu: CPU whose TLB should be initialized */ void tlb_init(CPUState *cpu); +/** + * tlb_destroy - destroy a CPU's TLB + * @cpu: CPU whose TLB should be destroyed + */ +void tlb_destroy(CPUState *cpu); /** * tlb_flush_page: * @cpu: CPU whose TLB should be flushed @@ -284,6 +289,9 @@ void tlb_set_page(CPUState *cpu, target_ulong vaddr, static inline void tlb_init(CPUState *cpu) { } +static inline void tlb_destroy(CPUState *cpu) +{ +} static inline void tlb_flush_page(CPUState *cpu, target_ulong addr) { } From patchwork Tue Jun 9 20:07:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187716 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp864139ilo; Tue, 9 Jun 2020 13:15:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0EB/RjzzdV7BPRy0cjSw1EqmasjcmZqVZ2P84TcEwpJP6+I+0+eDJdh64YCbeBW9w6WkB X-Received: by 2002:a5b:808:: with SMTP id x8mr9123744ybp.134.1591733708643; Tue, 09 Jun 2020 13:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591733708; cv=none; d=google.com; s=arc-20160816; b=e6tFel8fJb2c/XFPVpoI6tbog5d3I/jOCKewm6WTYVQMKD9RBCxrERBhTAgivUeYu6 pu7PP6XihdplRV5+DdNVw2HiWygsRN/uMG/MZZFvU+7/IOEwrlHc6QsBL5PE2rc7sv+b BBv+rCk9XusQQmemsGtj2Rh283luIiCcyu/hZH71EfKnuS2DT0CDtfmNnFC6u8EmXN+Z MABfH3DZXlQJCEXuv/8895PuZxS5MVQY3foxfyZ3Gyehx/yAFALSlQ6/5o7UCqM8yVEe ugGOuELdi3vd0Btr1wt8TkKMkvDfBNa39qw1vwqNYzYjQJ0Tve307TgFxFS8u7YmLdHb 3psw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=hMythbUcqIycDnX7vBXLsyLkA4NDGTmBWD2zTKmRWuE=; b=vVk4ylNy36Tr+W9ckG5JazZhbCEBIFdusAjyzLnfj1RlzsWoqNI6+mNpPe/qXdfSIZ /XCj263TmoNgcab2Q62Hr67FcKpYuTiu3V5un+Tudf84n5orAXhwwqMAOHIMMCkFu/P8 MSJI/yRQIO2WN/AlNqFDzahveFFxMKJPeisr0VodM58CUAmwPOqgZ/xYCDWIZXIRegmz Ej2tHueCeLYljwchuNeYgzSPzoSOKamqFezyFLf+oC2oeUlMUG4rzj0Hb8EBNcoI6//b /ZZUR8FIQvVo7CLqTEZW5AkXSfa0cvPqn14wuY+dXE8sb7XOBwresiutaCY4ceWn1pw/ YvRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=taIbyG7t; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l187si3389008ybc.192.2020.06.09.13.15.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jun 2020 13:15:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=taIbyG7t; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jikeK-0006d3-17 for patch@linaro.org; Tue, 09 Jun 2020 16:15:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jikZ8-0007Yx-O7 for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:46 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:42761) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jikZ7-0005aj-Vu for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:46 -0400 Received: by mail-pf1-x441.google.com with SMTP id b5so40861pfp.9 for ; Tue, 09 Jun 2020 13:09:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hMythbUcqIycDnX7vBXLsyLkA4NDGTmBWD2zTKmRWuE=; b=taIbyG7tjBJJgV8zx4GDb38LGhzVx0dwki4yaynSdDoTWhApgA4g6cMYNXYJg1ykTe 775xIXWqipvEbxa9kEevlG8kxg2oc8h7CLIfTYjHDLiSUcQYGLRDGpnJeh4E0CxbPioI RDNk0nnPvW43ZpaG3QBv6iiwe+5xExrdaMdgtbcGlP5kCATRH5jZKAf0RbsSVipcVeN4 jVJ47wDwIKrlZyxgtbO1fVjXonv57RYro15U/XrbP0BqLyEz+wtmB6UJve2+/42Z9vxr 8AT2MtQcmAQkPdMjdZr7gWNQILjSp8R73QtlCdl5U4+44nWckcE/9Gt9DdX7Eq9s9hzR Y1SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hMythbUcqIycDnX7vBXLsyLkA4NDGTmBWD2zTKmRWuE=; b=qCtGABhCil0Bcqz4JD5YQqoKwb0Qz4WzGe9Uo87+gtlowqzhEM5yfdlsiOVdX0uFgi ooJsJl6msHUhZsoLdwPjKjkdUTSe9nVtJAR39E6v1cBVaoDQPe6wg6BxzuGlS8nC3aep 8wF5MXpdkRnDtZXNA+tsbs4GsX3Mh24nEnfy8+qdY/CyB5hhC6gmgi2+rOJlRbdSEXHE pognDWNgv7DhwDy9wtIuuxKHCmC7jADOvUH6oR/zhPKuUzAYAytOZrQHZg9RetXcbqTO j+QTAVHcMsm+m8sh4j+K9xcjj603doJvK20FBSKqIMpHdYt7vnRKc2CNeJTSQrFTRw2+ bDsQ== X-Gm-Message-State: AOAM5326Kv+DFODHnhXXza/MuwRiRZzQO+Eo8DBp2WCLErRoOn6g8MSM 3J5athmohbMe8BECJGhYRcSrbQVE1Ynq4w== X-Received: by 2002:a63:2f43:: with SMTP id v64mr25800165pgv.232.1591733384164; Tue, 09 Jun 2020 13:09:44 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:1d09:cef2:3b1f:abce]) by smtp.gmail.com with ESMTPSA id n19sm10523374pfu.194.2020.06.09.13.09.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 13:09:43 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v3 05/13] qht: call qemu_spin_destroy for head buckets Date: Tue, 9 Jun 2020 16:07:30 -0400 Message-Id: <20200609200738.445-6-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609200738.445-1-robert.foley@linaro.org> References: <20200609200738.445-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::441; envelope-from=robert.foley@linaro.org; helo=mail-pf1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.puhov@linaro.org, cota@braap.org, alex.bennee@linaro.org, robert.foley@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Robert Foley Reviewed-by: Alex Bennée --- util/qht.c | 1 + 1 file changed, 1 insertion(+) -- 2.17.1 diff --git a/util/qht.c b/util/qht.c index aa51be3c52..67e5d5b916 100644 --- a/util/qht.c +++ b/util/qht.c @@ -348,6 +348,7 @@ static inline void qht_chain_destroy(const struct qht_bucket *head) struct qht_bucket *curr = head->next; struct qht_bucket *prev; + qemu_spin_destroy(&head->lock); while (curr) { prev = curr; curr = curr->next; From patchwork Tue Jun 9 20:07:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187717 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp865390ilo; Tue, 9 Jun 2020 13:17:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYeFo2NLrr/dip5qx2fQnHEOm7wKW0jZ/H+AMrS93HQUnRb+5HfFdWLwASGGTUO2CQtzyJ X-Received: by 2002:a25:ca45:: with SMTP id a66mr9479991ybg.164.1591733821815; Tue, 09 Jun 2020 13:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591733821; cv=none; d=google.com; s=arc-20160816; b=ghOcZf26RMbgJewdTaHzkae4uTKXuuSX6uj0fWExfIAu3cAEXYvT5Yo5J9NYJzgupp LmhX5ee/q7X8DsmW4v072DIghm9LpajrBXH6wyFNX7jDDhO6cJFQTcv24cyxemOsfDlr 4gXjq3ASYTx/p5gmEe98CahGRKDBPJu2GitamyqQLHvXsT2eQEDnFVaCGs7fcBJz1g6e 1r1lAE+ESElM0k3ov0rSBcCQJvR+KvbY1hGTiK2e/4Jp+sn6mKcWbLSWgRe4zRdha15o D0QGN+YnMuFvEpFCuNG118eUTTnmSszbUzGCwuFdys+b0vjFGLaU/d8eMS93z/l42rM0 Tikw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=qwuZW03UALyLreC41dDKLL3VuvvJz8e2voNJjWwlkPc=; b=P19bP7rHMKE2Fy4iPDjQ0OwHrGlbgUM7TnQENIBUIpJmArLpUKnYgylP2NhTQyyh+w TCshoU9uRdCmVNXvmfMrAE9og8S1g0a1YVhaIUMP2xU+TJoiCcpuB2oEa2aWVD4afZub THKshEjsUsGcT+mui7bFB6R46O7efVNQAzX0y2UjTvaoGMz0maCpdIz/udY6SPoMa3tw dn7z/QNi13o1eRiOpbWPYgZjgQZLA9UwusVYlIm+wdKMwEcB12yknUFt1U5zuQTuoiNL t5AQrtQIs2nn/QsX0xu44PjWPu3WjOJrF3kbcEIts51eC182+1ZZidA15YsMwZCNi1ih 2Exg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qe6nEER4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j82si3603424ybj.1.2020.06.09.13.17.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jun 2020 13:17:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qe6nEER4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jikg9-00009L-A5 for patch@linaro.org; Tue, 09 Jun 2020 16:17:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jikZC-0007dg-5B for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:50 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:36904) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jikZB-0005at-6y for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:49 -0400 Received: by mail-pf1-x443.google.com with SMTP id j1so52125pfe.4 for ; Tue, 09 Jun 2020 13:09:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qwuZW03UALyLreC41dDKLL3VuvvJz8e2voNJjWwlkPc=; b=qe6nEER44UMHZJMd1lWxtNsxrVCLglEqB+UsmAhsfFJgiznbPIbfk6cDYk1MugwxM7 OwhZ60uoKRWB2mTzbFmNOpm0mi3PrRs0gj3B8JGmOKiU9BCs3QTXy9s9JG+AR7E5ZydF 03jsXgTAYHxE7fYLCBsJweUdFmjFOk7icdd9oEAzM3W+wqJPEkBCZyb18fgiiswJsnmJ i76oWZIdNg+IMDJJwLXEldE7+plVvwHx7PSSpkJ5U/nWtqdw1BLMCoFocYlPTTD52NA7 aYAIPpwcxUAPeEKxjYXlIyZq4Wv/BBRkuvL1dWtdDKJKsKzqtuxvzOqTDpnFOcSlGOXC QYbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qwuZW03UALyLreC41dDKLL3VuvvJz8e2voNJjWwlkPc=; b=gCVgeE5enpSy10Xn9p0CgN2PeMeMpoES/dzwSeCRnX4P8f2QFvd+A3KqLA1YaKzF6M iPMWQ/ab6kOcmMOOQMHnHt71yS5OClddK3fcvgXEY6Cl9OFV5KNLOILq2fdsXhBfT24s YTCa5tyCN9h2snh5AHwNXvqIIwIDKmNK7sAjzI2k3pJS4rsMUeDri1pKLmgwGaCzmI94 NGjEq6FyJLtmsFEIZrcxyqniL0UlF06bd5JedySrsV+yrBgs2l6DuW86wS+aOFzMSxRJ dhH5sc7yCSC2TeQisBi9YTwo246SkhhvKtprFT3BhBvIAixVkUdG6xU1kE1WWVpwnLZc bWxg== X-Gm-Message-State: AOAM5324bcr56DKqVeqD5mVtKw6i2ZGpWlLTA9g8ZrRFssXPIzy9/asi 1tQIQ8b+bx1hEghE9mmbtu4s/5RY8I6Qig== X-Received: by 2002:a63:1a11:: with SMTP id a17mr25991301pga.227.1591733386297; Tue, 09 Jun 2020 13:09:46 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:1d09:cef2:3b1f:abce]) by smtp.gmail.com with ESMTPSA id n19sm10523374pfu.194.2020.06.09.13.09.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 13:09:45 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v3 06/13] tcg: call qemu_spin_destroy for tb->jmp_lock Date: Tue, 9 Jun 2020 16:07:31 -0400 Message-Id: <20200609200738.445-7-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609200738.445-1-robert.foley@linaro.org> References: <20200609200738.445-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::443; envelope-from=robert.foley@linaro.org; helo=mail-pf1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@linaro.org, cota@braap.org, Paolo Bonzini , peter.puhov@linaro.org, alex.bennee@linaro.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Signed-off-by: Robert Foley [RF: minor changes + remove tb_destroy_func] --- accel/tcg/translate-all.c | 8 ++++++++ include/tcg/tcg.h | 1 + tcg/tcg.c | 9 +++++++++ 3 files changed, 18 insertions(+) -- 2.17.1 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 42ce1dfcff..c937210e21 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -384,6 +384,11 @@ static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, return 0; } +void tb_destroy(TranslationBlock *tb) +{ + qemu_spin_destroy(&tb->jmp_lock); +} + bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit) { TranslationBlock *tb; @@ -413,6 +418,7 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit) /* one-shot translation, invalidate it immediately */ tb_phys_invalidate(tb, -1); tcg_tb_remove(tb); + tb_destroy(tb); } r = true; } @@ -1886,6 +1892,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, orig_aligned -= ROUND_UP(sizeof(*tb), qemu_icache_linesize); atomic_set(&tcg_ctx->code_gen_ptr, (void *)orig_aligned); + tb_destroy(tb); return existing_tb; } tcg_tb_insert(tb); @@ -2235,6 +2242,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) tb_phys_invalidate(tb->orig_tb, -1); } tcg_tb_remove(tb); + tb_destroy(tb); } /* TODO: If env->pc != tb->pc (i.e. the faulting instruction was not diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 380014ed80..e63450a893 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -819,6 +819,7 @@ void tcg_pool_reset(TCGContext *s); TranslationBlock *tcg_tb_alloc(TCGContext *s); void tcg_region_init(void); +void tb_destroy(TranslationBlock *tb); void tcg_region_reset_all(void); size_t tcg_code_size(void); diff --git a/tcg/tcg.c b/tcg/tcg.c index 1aa6cb47f2..1362bc6101 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -502,6 +502,14 @@ size_t tcg_nb_tbs(void) return nb_tbs; } +static gboolean tcg_region_tree_traverse(gpointer k, gpointer v, gpointer data) +{ + TranslationBlock *tb = v; + + tb_destroy(tb); + return FALSE; +} + static void tcg_region_tree_reset_all(void) { size_t i; @@ -510,6 +518,7 @@ static void tcg_region_tree_reset_all(void) for (i = 0; i < region.n; i++) { struct tcg_region_tree *rt = region_trees + i * tree_size; + g_tree_foreach(rt->tree, tcg_region_tree_traverse, NULL); /* Increment the refcount first so that destroy acts as a reset */ g_tree_ref(rt->tree); g_tree_destroy(rt->tree); From patchwork Tue Jun 9 20:07:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187712 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp861926ilo; Tue, 9 Jun 2020 13:12:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwt/22UgtqF4GxrCjo9U7NipvtU9i6FZHJOImr603DZeUSvPn7qvGG+6v4UqjN3DTsfCJk8 X-Received: by 2002:a25:7bc1:: with SMTP id w184mr2118599ybc.240.1591733525290; Tue, 09 Jun 2020 13:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591733525; cv=none; d=google.com; s=arc-20160816; b=r/71DptEPw/PVtpWY9pHEuRvuxL6RdHr+D+V0hKK7EP1T5L7+vO19QAyMq9aQrHUM3 BO/cY3wILomAyk1a2GTxODZLhPPZHPeh6CwX0f1bRwkTz+nuk4g63pQumq3yi/NhqNtg VaZFRRiVYRwEgJNq3xwSfym6O0Ky0JxnP5Of2swUiR7mxAAHfq2/BLq2lk0wMSSI8rvi TXX5gyLOEZ/cqt0rUlgbjjvpbasjobCi+PEC74it05IiCo9hjUaBiM7tFYSGz1x0bcPR 1YLFt5qlnQMV55Vf/bhnigFzMnzMzVfBHydgJ15rgME3nAiH7ySpcb4UwnBrFsiWhhVT zWBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=1NsThI0eMK49RH+R+oR0Ud3TTjxqLqaksL0ZDGz/oqg=; b=RAOZiILkRXv9hMhpW5NB/HDpHfejpsB1NDnt8xXGST0Un7YJ4CRYM4y92wlfqvH40a w4gl85euHRxnyOxhP0Q6pWQheUjw8+yHI+o/sK96oZG6+6AokOSPiXYiDvGjmU695Ca7 K/fc2UyVsBefU20DLdjPcTnUA9e1cnrQYMvnjWK4pNF6E079xnRHAZGwzpAzGpRGAvTm jOXUBmzW6uIBGlFYiDNx81sZSk/BQDJa+dXt5LL7LPeRtYuJx8Nz4ALye+m3y2Yskh/g MYtAw2thzncUAygAYgM+ZEJfw+8W6wBjv/7rWQwdKD8dO5D7+xVPQ00hr5Tyx+SRG7oc rwEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qNr97HSB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r204si3753536ybc.324.2020.06.09.13.12.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jun 2020 13:12:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qNr97HSB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jikbM-0002EF-Mt for patch@linaro.org; Tue, 09 Jun 2020 16:12:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jikZD-0007fU-5Z for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:51 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:35061) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jikZC-0005b3-2s for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:50 -0400 Received: by mail-pf1-x443.google.com with SMTP id h185so56290pfg.2 for ; Tue, 09 Jun 2020 13:09:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1NsThI0eMK49RH+R+oR0Ud3TTjxqLqaksL0ZDGz/oqg=; b=qNr97HSBUrOLimU07hmS+GwNc/esKVcAbmxKLUEx1422R0EYpQRn2sv06RpdmFuYYT m5six1s/d8vspHwVB5DnLLNS5GQv1bSwYsazcdAivIzg2cI702ZxcjrpjbSBGfFAe+yb 3yQq62A7Bm5wEHI3oeeTjKMO1hyVjm/8bub7qon4xNBMIf2/MUhfWtlsT/6Pmfdte6/n 0ZdMEySxVb2hgOfB++yb78dY7zW36TNeaKylC9nKcplLg5D2n9ym7VBG29ttRm0P+MRA gyJ6sMVhn441+TLYzTGraOGwwKFG36Ikaf9EKGHI1DCQNVKZ0giAGKmAsPU6zFDlwYg7 QrPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1NsThI0eMK49RH+R+oR0Ud3TTjxqLqaksL0ZDGz/oqg=; b=t7byID3GFmtKfoJ1K8gHiAz+wodBrt4I33PZCAbZpLpV5lghafi9RL/wDkEllL+HdV SlVB6LTuTJVDEaDMnFcrnvF7JUKvCzwhhPi7ZblijRb7Jhs1JMxeiRFseUD870c2mbPF 1rAP2XZ3N4y5Xfk4aD7Xj73ekzjs+XOM9I1Elk57wfdcnYhG0zK+k3ssbtjx3+9J9qKt Wcubq5ME5qPiTt7ng4iTgVM28zlFyFgj1Y1KVid1QnyYcGBkn9c7JjBLfruOe4HJz58e X/lRgS/luPR/lhIGxQwyKl+8366yNlESm8vOHM1EqaaSM7zWd7WyQsZ4sizS019CWZti bcPg== X-Gm-Message-State: AOAM533RoOTwbRfa+oiZ171+NDOmw5EP7EzrJhprz8bHwCYRZTM8Ou1z 9JSYDEGlH11d6iHQNQNkWupXEgISUPwQiw== X-Received: by 2002:a65:46cc:: with SMTP id n12mr26290909pgr.80.1591733388359; Tue, 09 Jun 2020 13:09:48 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:1d09:cef2:3b1f:abce]) by smtp.gmail.com with ESMTPSA id n19sm10523374pfu.194.2020.06.09.13.09.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 13:09:47 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v3 07/13] translate-all: call qemu_spin_destroy for PageDesc Date: Tue, 9 Jun 2020 16:07:32 -0400 Message-Id: <20200609200738.445-8-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609200738.445-1-robert.foley@linaro.org> References: <20200609200738.445-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::443; envelope-from=robert.foley@linaro.org; helo=mail-pf1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@linaro.org, cota@braap.org, Paolo Bonzini , peter.puhov@linaro.org, alex.bennee@linaro.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" The radix tree is append-only, but we can fail to insert a PageDesc if the insertion races with another thread. Signed-off-by: Emilio G. Cota Signed-off-by: Robert Foley Reviewed-by: Alex Bennée --- accel/tcg/translate-all.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.17.1 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index c937210e21..c3d37058a1 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -547,6 +547,15 @@ static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc) #endif existing = atomic_cmpxchg(lp, NULL, pd); if (unlikely(existing)) { +#ifndef CONFIG_USER_ONLY + { + int i; + + for (i = 0; i < V_L2_SIZE; i++) { + qemu_spin_destroy(&pd[i].lock); + } + } +#endif g_free(pd); pd = existing; } From patchwork Tue Jun 9 20:07:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187710 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp860737ilo; Tue, 9 Jun 2020 13:10:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2VwxJh1EbdJhjLSHagqan5I6NAq/LQssB489BHhZ9fTWCGX5oC5vCaHRQmUvVHx8jED3Q X-Received: by 2002:a25:ad56:: with SMTP id l22mr9266626ybe.383.1591733414200; Tue, 09 Jun 2020 13:10:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591733414; cv=none; d=google.com; s=arc-20160816; b=DknMzHtN98VzqyIYEONV/oLCz67LIaVRx6qoguN2V2FCBU0uxAge5NRcHCwRZzGPss oUISRQgUNQ7+rJhn7A98Mg+oUFIc/pAMgaLCXmnjQpguBL3rxGyKXODgC9rtD2ez/m3E qgjOsAt+DN0Rf96/ybGjWNmmqq4As/62rRgaYIS70bYc1khWQU7b7ia7Xp392r7F89q4 OPPTSGePBXPBVXm4R/i6XMrDPIp+qtW7D8wJeshkLPviGkcDYRInVJDrACmeeOc6l3se CE12aKYhK+dR7x5+ylj7UVYOmuwThZgO4SEBLeWo8jmH2PpwRb4kidXOCWm3NFyjV4Xz 2yJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=AYdOaJYxtk+d/I+Jwq+9vEcr8Iz8aXatF1CrO9YlEDI=; b=twv3N62C1fDIPCLM96FT0tkaMBrmn3nT6joGa/3EfNL4ozAkXztvpbVQ/k9FsJrCGS /+qpGOoOS3ayq/qYNNAaZ4pK1kJxo5thmyv0m985y85KOD1XSzhBj2M/BBX/8uFIKP/A XBrHe0+ygWtIRBg/aUJDqOwMM5vfpPAypeB/LSAvaLLpQeftOpsTn6J0cf43MjVuIUfG JB7umVBhXqLIqrplCGR1Y21FLe4836SoR5VPriDiSX/F+iCpwOaSs0NNE+x7Xvgn0bM2 9NnXBnOYR5Caqc3GRmf1nVXzIfCojwvQbTDHsA8O1VeXeIJseytuBYD/u/ha198MlO8w 2q0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="DcTY0w/8"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l125si3321655ybb.344.2020.06.09.13.10.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jun 2020 13:10:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="DcTY0w/8"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jikZZ-0007jr-Ia for patch@linaro.org; Tue, 09 Jun 2020 16:10:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jikZF-0007i6-IR for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:53 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:42048) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jikZE-0005bK-0h for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:53 -0400 Received: by mail-pg1-x544.google.com with SMTP id e9so10754541pgo.9 for ; Tue, 09 Jun 2020 13:09:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AYdOaJYxtk+d/I+Jwq+9vEcr8Iz8aXatF1CrO9YlEDI=; b=DcTY0w/8OD14Sm++yyBa4igV00n4r6Ty47GW1i8jTGsc6pxoB73b5ogmJIqP62WPlX jOswX7x96FJQ3RT9v4Uotev16p7W7o7x5ChM8w3NRx6bsb/clhNq14gu6gvPfynVfrk7 c8fExNHJ7jG2UCOo1N8nnd4DdXvGUSxjd2BdJwO/bCxCtE/aLNnOvFJR+YIfSOWHNpRZ EqLfiV484sWiFhGk255xasHZfsRdnY9WLuIsDhjClZOUaTZR6OVPbHxzHYx/8LAMmm4o 9rOCnpwx0fIW7ShgaG7tJHgj5QGszvtrSHynx2w9gypcDdlrG9ogVc5YJNFVpKaGCqOV HYVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AYdOaJYxtk+d/I+Jwq+9vEcr8Iz8aXatF1CrO9YlEDI=; b=N2o4byZrb+2L7IStiUnBFNGc/Tpk13BNSrM5lpG5etdXCfgltksCvLBtn9zERm+o9I IVI9nUoIrMBzakmgGeF2amcTjNZMj/8hZeIj2lfUcdYxuR6oMNcX/HvxNHFj3IY+Gdva dhlxM6D3A/mIA9YAciljw6Dhhurl2NAEa0dYctsVpyi/AMAfic2OZgNYTQ4ZulCaqQjl h4ZbXdR9zI3ExkBcVy2UoATCzmNWgwzSkhvHL5SBSHwxqxJpcdcBAlLeHtmDYlDjhC9I GfqXdWoIJGTLruD3lAXdoII7GCFwVhH6qGY4EJVAtajCtPNbPok7e3IB3LHhr32R7W/9 pmug== X-Gm-Message-State: AOAM531Y37Nt9KGvteanA9FdPOhpsR4Bb5hj5jBpXLpajMlYjC6zTYiw aTWntLHPGRUq342c2hxkmRsfDfpFN5rZwQ== X-Received: by 2002:a63:9258:: with SMTP id s24mr25931521pgn.362.1591733390238; Tue, 09 Jun 2020 13:09:50 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:1d09:cef2:3b1f:abce]) by smtp.gmail.com with ESMTPSA id n19sm10523374pfu.194.2020.06.09.13.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 13:09:49 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v3 08/13] thread: add tsan annotations to QemuSpin Date: Tue, 9 Jun 2020 16:07:33 -0400 Message-Id: <20200609200738.445-9-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609200738.445-1-robert.foley@linaro.org> References: <20200609200738.445-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::544; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x544.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.puhov@linaro.org, cota@braap.org, alex.bennee@linaro.org, robert.foley@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Signed-off-by: Robert Foley Reviewed-by: Alex Bennée --- include/qemu/thread.h | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/include/qemu/thread.h b/include/qemu/thread.h index e50a073889..43fc094b96 100644 --- a/include/qemu/thread.h +++ b/include/qemu/thread.h @@ -206,6 +206,10 @@ void qemu_thread_atexit_add(struct Notifier *notifier); */ void qemu_thread_atexit_remove(struct Notifier *notifier); +#ifdef CONFIG_TSAN +#include +#endif + struct QemuSpin { int value; }; @@ -213,23 +217,46 @@ struct QemuSpin { static inline void qemu_spin_init(QemuSpin *spin) { __sync_lock_release(&spin->value); +#ifdef CONFIG_TSAN + __tsan_mutex_create(spin, __tsan_mutex_not_static); +#endif } -static inline void qemu_spin_destroy(QemuSpin *spin) -{ } +/* const parameter because the only purpose here is the TSAN annotation */ +static inline void qemu_spin_destroy(const QemuSpin *spin) +{ +#ifdef CONFIG_TSAN + __tsan_mutex_destroy((void *)spin, __tsan_mutex_not_static); +#endif +} static inline void qemu_spin_lock(QemuSpin *spin) { +#ifdef CONFIG_TSAN + __tsan_mutex_pre_lock(spin, 0); +#endif while (unlikely(__sync_lock_test_and_set(&spin->value, true))) { while (atomic_read(&spin->value)) { cpu_relax(); } } +#ifdef CONFIG_TSAN + __tsan_mutex_post_lock(spin, 0, 0); +#endif } static inline bool qemu_spin_trylock(QemuSpin *spin) { - return __sync_lock_test_and_set(&spin->value, true); +#ifdef CONFIG_TSAN + __tsan_mutex_pre_lock(spin, __tsan_mutex_try_lock); +#endif + bool busy = __sync_lock_test_and_set(&spin->value, true); +#ifdef CONFIG_TSAN + unsigned flags = __tsan_mutex_try_lock; + flags |= busy ? __tsan_mutex_try_lock_failed : 0; + __tsan_mutex_post_lock(spin, flags, 0); +#endif + return busy; } static inline bool qemu_spin_locked(QemuSpin *spin) @@ -239,7 +266,13 @@ static inline bool qemu_spin_locked(QemuSpin *spin) static inline void qemu_spin_unlock(QemuSpin *spin) { +#ifdef CONFIG_TSAN + __tsan_mutex_pre_unlock(spin, 0); +#endif __sync_lock_release(&spin->value); +#ifdef CONFIG_TSAN + __tsan_mutex_post_unlock(spin, 0); +#endif } struct QemuLockCnt { From patchwork Tue Jun 9 20:07:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187713 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp862064ilo; Tue, 9 Jun 2020 13:12:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtb+D5WuQO+snOGQreSFwjHrl56ahmmf/5p1M3WZeHn5nC/1tVgyoXHlxgxMl9TjSMB9J6 X-Received: by 2002:a25:b942:: with SMTP id s2mr8884985ybm.437.1591733537897; Tue, 09 Jun 2020 13:12:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591733537; cv=none; d=google.com; s=arc-20160816; b=vE2C0h4a7wcxHFtNFUkpo5/wXe2Tg3GGu7irB/iQkRmDaQAK0JF1k4kYH+9ClVa2nI 0dZ+FPNbWW+JDcI0fdmI0OjZgIMvLnIi6MlFz4s67DdCpf6zQn48vcBGi7ghbURE6oCI Yj/u6qfgKpah62bqt2MZpDx3CHuocJ05KjmPTjJDqPHIdPW+qgGziMqWdgBJe3BjO9um ptxgqXoQHSzDfhBkUb/7ZvQlqtvIkpZCSZAILxci3B+JQUrZsD4gIlkSXfzSW0TBM4Kc hWhLUZJDlT35wpnz6mHAWLaGOgLF4WpStWXCHWjY0FwYKVNXP1PB6aHvw/HJwy7U+3IH kNcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=a1IujnwDzWygiMOVADIbNYVV1mCmC+OLrxpPE5Le/ts=; b=hnCyJrmkXFNl/kYs620xIMUpj7FMWmbGJFtd+wE6vc0CiSKQp1+NbZx9gE18laUnWh +LsglvZ7jzl/4+R7smrY8s0FBMyG8mKyl0vNpP44KvLPzy/gn8bG/1UUBjfGF/l63hIe KOHG0g/JJvbdNHj+Qchtqhp6cT/LOuCKMYRoJQYfrNnPCmYgSZ4G8E6MJcf9H2Yooe5d Kbde1pNHfkXYGwat2ncDyKaYkgfT5keJGRoeCSdkzQDi5UfvAOgSb1Xi/fJeKcNdyEXQ UlF2k4xYb9i5yA3sP2mFgHYsjYrGnGlNP1qooyRre4AmZ2tGH5VRprG7HCEITESEjsUn SQrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Pnb8W6ET; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w1si3130933yba.433.2020.06.09.13.12.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jun 2020 13:12:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Pnb8W6ET; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jikbZ-0002bz-9X for patch@linaro.org; Tue, 09 Jun 2020 16:12:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jikZI-0007lW-0b for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:56 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:33917) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jikZG-0005bk-Ee for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:55 -0400 Received: by mail-pl1-x643.google.com with SMTP id n9so23553plk.1 for ; Tue, 09 Jun 2020 13:09:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a1IujnwDzWygiMOVADIbNYVV1mCmC+OLrxpPE5Le/ts=; b=Pnb8W6ET7Y3BwO5XBHAzWyRRHzYavh+NAtfMQRw64L9OaL3xjyydIsylR1UlNvsIuI g9InhaZDEXgebaH6nQD/3pDSnuBRoLnz+O9I8BlqsOuiLQVSy14Rk9fk68mEyNR9JNO/ 16t9e7RGjPb7x2RONhQ6t16ihONAqQgT3WHUw4tW0oH/t8M+s8hg7SyQcXq2CCnD9r2U 1U7JLYcVFDRls8drGFJHi55XDqINelL7djsdpkZNa+8Y+43U9L7hS+LUe2mEhpsXX9WK 5AZ2HYAxfzmRz9rI+uoVAhJSVb376AnavagnEfOuWq6pRjIHaUleO7xA8exz0ZafG/lr DsSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a1IujnwDzWygiMOVADIbNYVV1mCmC+OLrxpPE5Le/ts=; b=pqH8HGxKgTINyfCYpHLGqk1jSCB7zlW7Ay0zYlHhF/4p82cIfNCqdczg+XoC2eVmO6 4sf7wM2nCc8yqBLsHpwZcNfk2RXL59xI9y2kW1PXEHufKVMemDHkUqZn7w61tBqFIJAK mN3wvzQLGjkYYUy+1vaN97xDHSdzGk9tG2JJoH15C40/vCBNpbkteqfnDHiWBt6JjDv8 lUYkskr7w8VXllLbxGU4ceO90eXhFzuM1yx/JtZBhd5c1lubNiAFHdQFlB2+J7/Z9usA ZrmgpafQSq3oIgQHLp3mvaefrtF6SJftCpDVmXrnTViYAD+M8VMhDFl7To+6PWCO4RX/ pLAA== X-Gm-Message-State: AOAM532PE35QAmn7JQLzAjKF5qGvuDZo3QeGNd/62BjBUoibw4Z35fHr wQb+pjIHxKGttVOp/U74+55HYXGg128Cew== X-Received: by 2002:a17:902:7204:: with SMTP id ba4mr60645plb.137.1591733392290; Tue, 09 Jun 2020 13:09:52 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:1d09:cef2:3b1f:abce]) by smtp.gmail.com with ESMTPSA id n19sm10523374pfu.194.2020.06.09.13.09.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 13:09:51 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v3 09/13] tests/docker: Added docker build support for TSan. Date: Tue, 9 Jun 2020 16:07:34 -0400 Message-Id: <20200609200738.445-10-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609200738.445-1-robert.foley@linaro.org> References: <20200609200738.445-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::643; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x643.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , robert.foley@linaro.org, =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= , cota@braap.org, peter.puhov@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Added a new docker for ubuntu 20.04. This docker has support for Thread Sanitizer including one patch we need in one of the header files. https://github.com/llvm/llvm-project/commit/a72dc86cd This command will build with tsan enabled: make docker-test-tsan-ubuntu2004 V=1 Also added the TSAN suppresion file to disable certain cases of TSAN warnings. Cc: Fam Zheng Cc: Philippe Mathieu-Daudé Signed-off-by: Robert Foley Reviewed-by: Alex Bennée --- tests/docker/dockerfiles/ubuntu2004.docker | 65 ++++++++++++++++++++++ tests/docker/test-tsan | 44 +++++++++++++++ tests/tsan/blacklist.tsan | 10 ++++ tests/tsan/suppressions.tsan | 14 +++++ 4 files changed, 133 insertions(+) create mode 100644 tests/docker/dockerfiles/ubuntu2004.docker create mode 100755 tests/docker/test-tsan create mode 100644 tests/tsan/blacklist.tsan create mode 100644 tests/tsan/suppressions.tsan -- 2.17.1 diff --git a/tests/docker/dockerfiles/ubuntu2004.docker b/tests/docker/dockerfiles/ubuntu2004.docker new file mode 100644 index 0000000000..6050ce7e8a --- /dev/null +++ b/tests/docker/dockerfiles/ubuntu2004.docker @@ -0,0 +1,65 @@ +FROM ubuntu:20.04 +ENV PACKAGES flex bison \ + ccache \ + clang-10\ + gcc \ + gettext \ + git \ + glusterfs-common \ + libaio-dev \ + libattr1-dev \ + libbrlapi-dev \ + libbz2-dev \ + libcacard-dev \ + libcap-ng-dev \ + libcurl4-gnutls-dev \ + libdrm-dev \ + libepoxy-dev \ + libfdt-dev \ + libgbm-dev \ + libgtk-3-dev \ + libibverbs-dev \ + libiscsi-dev \ + libjemalloc-dev \ + libjpeg-turbo8-dev \ + liblzo2-dev \ + libncurses5-dev \ + libncursesw5-dev \ + libnfs-dev \ + libnss3-dev \ + libnuma-dev \ + libpixman-1-dev \ + librados-dev \ + librbd-dev \ + librdmacm-dev \ + libsasl2-dev \ + libsdl2-dev \ + libseccomp-dev \ + libsnappy-dev \ + libspice-protocol-dev \ + libspice-server-dev \ + libssh-dev \ + libusb-1.0-0-dev \ + libusbredirhost-dev \ + libvdeplug-dev \ + libvte-2.91-dev \ + libxen-dev \ + libzstd-dev \ + make \ + python3-yaml \ + python3-sphinx \ + sparse \ + texinfo \ + xfslibs-dev\ + vim +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get -y install $PACKAGES +RUN dpkg -l $PACKAGES | sort > /packages.txt +ENV FEATURES clang tsan pyyaml sdl2 + +# https://bugs.launchpad.net/qemu/+bug/1838763 +ENV QEMU_CONFIGURE_OPTS --disable-libssh + +# Apply patch https://reviews.llvm.org/D75820 +# This is required for TSan in clang-10 to compile with QEMU. +RUN sed -i 's/^const/static const/g' /usr/lib/llvm-10/lib/clang/10.0.0/include/sanitizer/tsan_interface.h diff --git a/tests/docker/test-tsan b/tests/docker/test-tsan new file mode 100755 index 0000000000..eb40ac45b7 --- /dev/null +++ b/tests/docker/test-tsan @@ -0,0 +1,44 @@ +#!/bin/bash -e +# +# This test will use TSan as part of a build and a make check. +# +# Copyright (c) 2020 Linaro +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Robert Foley +# Originally based on test-quick from Fam Zheng +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +. common.rc + +setup_tsan() +{ + requires clang tsan + tsan_log_dir="/tmp/qemu-test/build/tsan" + mkdir -p $tsan_log_dir > /dev/null || true + EXTRA_CONFIGURE_OPTS="${EXTRA_CONFIGURE_OPTS} --enable-tsan \ + --cc=clang-10 --cxx=clang++-10 \ + --disable-werror --extra-cflags=-O0" + # detect deadlocks is false currently simply because + # TSan crashes immediately with deadlock detector enabled. + # We have maxed out the history size to get the best chance of finding + # warnings during testing. + # Note, to get TSan to fail on warning, use exitcode=66 below. + tsan_opts="suppressions=/tmp/qemu-test/src/tests/tsan/suppressions.tsan\ + detect_deadlocks=false history_size=7\ + halt_on_error=0 exitcode=0 verbose=5\ + log_path=$tsan_log_dir/tsan_warning" + export TSAN_OPTIONS="$tsan_opts" +} + +cd "$BUILD_DIR" + +TARGET_LIST=${TARGET_LIST:-$DEF_TARGET_LIST} \ +setup_tsan +build_qemu +check_qemu +install_qemu diff --git a/tests/tsan/blacklist.tsan b/tests/tsan/blacklist.tsan new file mode 100644 index 0000000000..75e444f5dc --- /dev/null +++ b/tests/tsan/blacklist.tsan @@ -0,0 +1,10 @@ +# This is an example blacklist. +# To enable use of the blacklist add this to configure: +# "--extra-cflags=-fsanitize-blacklist=/tests/tsan/blacklist.tsan" +# The eventual goal would be to fix these warnings. + +# TSan is not happy about setting/getting of dirty bits, +# for example, cpu_physical_memory_set_dirty_range, +# and cpu_physical_memory_get_dirty. +src:bitops.c +src:bitmap.c diff --git a/tests/tsan/suppressions.tsan b/tests/tsan/suppressions.tsan new file mode 100644 index 0000000000..73414b9ebd --- /dev/null +++ b/tests/tsan/suppressions.tsan @@ -0,0 +1,14 @@ +# This is the set of runtime suppressions of TSan warnings. +# The goal would be to have here only items we do not +# plan to fix, and to explain why for each item. + +# TSan reports a double lock on RECURSIVE mutexes. +# Since the recursive lock is intentional, we choose to ignore it. +mutex:aio_context_acquire +mutex:pthread_mutex_lock + +# TSan reports a race betwen pthread_mutex_init() and +# pthread_mutex_lock(). Since this is outside of QEMU, +# we choose to ignore it. +race:pthread_mutex_init +race:pthread_mutex_lock From patchwork Tue Jun 9 20:07:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187718 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp866375ilo; Tue, 9 Jun 2020 13:18:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUeofE/Q+JzWA+d/dh3GhI1HkocoCW0KeZ3dhvM/bILEhhaXx+R7jNtw/jZOJgUkeqRzSO X-Received: by 2002:a25:3c84:: with SMTP id j126mr8506742yba.287.1591733906222; Tue, 09 Jun 2020 13:18:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591733906; cv=none; d=google.com; s=arc-20160816; b=m7PVRr84AX9Bb9031OUX6ABSlb+y1CtYpWm96l71d1W0cZp7f4iXF1c8nkJQc3EpgG qjebr0EnUcb6bagYLQ4aaZNxnO+Wp3lnYYmTwmlH3AwZA1W5Lf2IfTaYEKt8c2zAqZ0X tP2piYylbq3kSUD/5nyBozgJ/DX+4uTumfd4vdIcU5YDfkVECA1SBPMMeCqJmOBOiIaN IblljFpv58UANszl/Uij/TjsmdkCDGd5xgtWN2pcEdVTbuQod0QJNilXkb6hGX69Q9RW eNYoUBIw0XXMg3l2MXgsZ9vA9fhpCcwu2wjaPZTIyRJd0bRkT3QdO1A6S4TO6mdx9cEy QbvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Z+OFj29yCFbAWNlzpwiIPBHhzK7hPpPDuoaMSZsMcbg=; b=1LIFlfqdJ0Pdio8E+OSsQ4RTTd13u8/j43Jtixe/3Gkf6hks/s1vaKnQ7Ksekmtfpz q2O/OuzX1TPHOSer/UfIWEcloOidvjvgGALoV2YXGUNCB6//t3ltqCSuN37QPRJcSmHC 7hZyj8teU4nhng3e/dkfsopzgUMJoJMu34+nzmULgEZVeApoclZACIHh+hzZAquk0lVz Vwlbdw4hxlw6aNlih+IedEfbnViFCsHbnGJwoCU0FHX2G4nwoIhfF/tLFSEO9F1E6rJb ssmMxuJPkF/GC5hB0zg2XNLjnCuGhZfYS6bRx4x1Mk1lyu5LgWaSPyMxzohqDJcqcifp 5ycQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Lnj7Pdp+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 14si3138037ybj.54.2020.06.09.13.18.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jun 2020 13:18:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Lnj7Pdp+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jikhV-0001qN-NC for patch@linaro.org; Tue, 09 Jun 2020 16:18:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jikZI-0007nK-SJ for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:56 -0400 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:52595) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jikZH-0005by-Qu for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:56 -0400 Received: by mail-pj1-x1042.google.com with SMTP id k2so1863108pjs.2 for ; Tue, 09 Jun 2020 13:09:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z+OFj29yCFbAWNlzpwiIPBHhzK7hPpPDuoaMSZsMcbg=; b=Lnj7Pdp+K51xUfHhblxF7XbUs3dLR9opXx9M+AWdHgBl9VVh+aeAPAmBRamIwP6iyU /uqt2K1+opgxJQemvVrnMER/Hv368Znh7CSMuNMAE6S7ekPpzwpxew1+SiCf/pX/m/rg K3Qmd+PziI0Eg82RxvuAZYJM92nTH5WDm206RXdpeWHte/y4kMPpQak+scI7j1H04Fmj E017CRiRslEP6kbefibu2oSx+4tAuvqnAQYQO/YzTuP97SH6wAC7N5nI44X3J5aVrrGl I06mTsqDypbS6gIqUI+KTHRYpnbzbveET5Y84cLl1vDZ0pk+jHeo2LburtNAy2bVQW7J CCeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z+OFj29yCFbAWNlzpwiIPBHhzK7hPpPDuoaMSZsMcbg=; b=WA0I6Ci9R78GrFvTAk2p1xQvOHUtFTGZDousAxIGoe0dgqKKxnCZ6XLZRWCHs0PRJM BU6SXhaXM6BHWK4KO+j/soIBwDj2RIUHUVESvpipbn1HJhNwEKAp0zRVYW3vOrskJHEk RiCbKXc07ELRJc+FIyjxWlaAFBxgJH5BpboXXXiHBnYfrjKtuK33lBniZdanDelHAle9 IE4UATUFqz9VjlLZc9VSTxuTeGKEckfjdf0QkkPcY5tDUz90E0mV7AgOzzzs4QZGyfZL ECKQ7jxILrooZ47iJhsENoWuE/Lr+APZSm1YEObg8IxOENL7f4b6muuAK8WWNyVjJkoV 12Xw== X-Gm-Message-State: AOAM531psS6XHtPIpe8wDoa5wuQFB6pJ+dZJhpk97mstUVhjy9m9ggcX 7OyiXlhvz957AdInmgXY3EgbaFV2K+iJug== X-Received: by 2002:a17:902:bc84:: with SMTP id bb4mr71130plb.55.1591733394129; Tue, 09 Jun 2020 13:09:54 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:1d09:cef2:3b1f:abce]) by smtp.gmail.com with ESMTPSA id n19sm10523374pfu.194.2020.06.09.13.09.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 13:09:53 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v3 10/13] include/qemu: Added tsan.h for annotations. Date: Tue, 9 Jun 2020 16:07:35 -0400 Message-Id: <20200609200738.445-11-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609200738.445-1-robert.foley@linaro.org> References: <20200609200738.445-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1042; envelope-from=robert.foley@linaro.org; helo=mail-pj1-x1042.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.puhov@linaro.org, cota@braap.org, alex.bennee@linaro.org, robert.foley@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These annotations will allow us to give tsan additional hints. For example, we can inform tsan about reads/writes to ignore to silence certain classes of warnings. We can also annotate threads so that the proper thread naming shows up in tsan warning results. Signed-off-by: Robert Foley Reviewed-by: Emilio G. Cota Reviewed-by: Alex Bennée --- include/qemu/tsan.h | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 include/qemu/tsan.h -- 2.17.1 diff --git a/include/qemu/tsan.h b/include/qemu/tsan.h new file mode 100644 index 0000000000..09cc665f91 --- /dev/null +++ b/include/qemu/tsan.h @@ -0,0 +1,71 @@ +#ifndef QEMU_TSAN_H +#define QEMU_TSAN_H +/* + * tsan.h + * + * This file defines macros used to give ThreadSanitizer + * additional information to help suppress warnings. + * This is necessary since TSan does not provide a header file + * for these annotations. The standard way to include these + * is via the below macros. + * + * Annotation examples can be found here: + * https://github.com/llvm/llvm-project/tree/master/compiler-rt/test/tsan + * annotate_happens_before.cpp or ignore_race.cpp are good places to start. + * + * The full set of annotations can be found here in tsan_interface_ann.cpp. + * https://github.com/llvm/llvm-project/blob/master/compiler-rt/lib/tsan/rtl/ + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifdef CONFIG_TSAN +/* + * Informs TSan of a happens before/after relationship. + */ +#define QEMU_TSAN_ANNOTATE_HAPPENS_BEFORE(addr) \ + AnnotateHappensBefore(__FILE__, __LINE__, (void *)(addr)) +#define QEMU_TSAN_ANNOTATE_HAPPENS_AFTER(addr) \ + AnnotateHappensAfter(__FILE__, __LINE__, (void *)(addr)) +/* + * Gives TSan more information about thread names it can report the + * name of the thread in the warning report. + */ +#define QEMU_TSAN_ANNOTATE_THREAD_NAME(name) \ + AnnotateThreadName(__FILE__, __LINE__, (void *)(name)) +/* + * Allows defining a region of code on which TSan will not record memory READS. + * This has the effect of disabling race detection for this section of code. + */ +#define QEMU_TSAN_ANNOTATE_IGNORE_READS_BEGIN() \ + AnnotateIgnoreReadsBegin(__FILE__, __LINE__) +#define QEMU_TSAN_ANNOTATE_IGNORE_READS_END() \ + AnnotateIgnoreReadsEnd(__FILE__, __LINE__) +/* + * Allows defining a region of code on which TSan will not record memory + * WRITES. This has the effect of disabling race detection for this + * section of code. + */ +#define QEMU_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN() \ + AnnotateIgnoreWritesBegin(__FILE__, __LINE__) +#define QEMU_TSAN_ANNOTATE_IGNORE_WRITES_END() \ + AnnotateIgnoreWritesEnd(__FILE__, __LINE__) +#else +#define QEMU_TSAN_ANNOTATE_HAPPENS_BEFORE(addr) +#define QEMU_TSAN_ANNOTATE_HAPPENS_AFTER(addr) +#define QEMU_TSAN_ANNOTATE_THREAD_NAME(name) +#define QEMU_TSAN_ANNOTATE_IGNORE_READS_BEGIN() +#define QEMU_TSAN_ANNOTATE_IGNORE_READS_END() +#define QEMU_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN() +#define QEMU_TSAN_ANNOTATE_IGNORE_WRITES_END() +#endif + +void AnnotateHappensBefore(const char *f, int l, void *addr); +void AnnotateHappensAfter(const char *f, int l, void *addr); +void AnnotateThreadName(const char *f, int l, char *name); +void AnnotateIgnoreReadsBegin(const char *f, int l); +void AnnotateIgnoreReadsEnd(const char *f, int l); +void AnnotateIgnoreWritesBegin(const char *f, int l); +void AnnotateIgnoreWritesEnd(const char *f, int l); +#endif From patchwork Tue Jun 9 20:07:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187719 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp867123ilo; Tue, 9 Jun 2020 13:19:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcxz5vHFvGNVG0NRQMG5HYrUtnz/Gtvj2Bp0m2EK4vWFKXj8CVFY/4Vnm1brpLRnXsAaHA X-Received: by 2002:a25:ccd5:: with SMTP id l204mr8876419ybf.51.1591733990402; Tue, 09 Jun 2020 13:19:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591733990; cv=none; d=google.com; s=arc-20160816; b=vJQmOkAI/wKb6FZm4SQhkSTutPs0s4BvjmtiFafBGuHz+UYkex/G8dP6hTmDP/NMaq ypNg3KQNXNjPEcHpzBLDLrIzkFW8UG+Qf1Jn5E0Ig+AGerqskPqt93RnE5WPr/5AjfNK OXQ7jay93BBnr1vAzTN3ETNNOjB8OLLGywKPGiV13BKESunSqyjLyUjMK/fLucZ2nwQp O3z8+Nvdp7e9Xr8K0UYBkBL/aDbGPswm9RKshtEWRgyhR/+P6qmHfJ9fdYs74JiMV7FM h0oyVgUg2g554qj0JR55n5+co9Jz6X7TG7Xx+5PlVy6lPJ9O8WRCQ7TND2Veac/JrJu0 y3DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=bZmmE8g6bACENWl1LtFwmXs+x0B5ALCEi1t1qd6zEd8=; b=zoMkpZgnpuRWS7CgF39bp4k4LlGBRcpOds0/43KsMnEe2yxNPwa9IJuOE8MMDF9Dz/ XCkcnYOgn5rTkjV0EwDFhW7fvvz/njOdX+cRcw3n8dN8wN0sk05Q0VTe4vc6JKJNe/Ha IcJ8Hhd9AbbyWqeE97+ZjSjyNFj/H9GaBQx/HNJOjvWqiPjB//FavAgsrVqKl6ayY5q8 /OIIHqrrrPWcW6FAYNBDFdysOdb00dgXReeJw2E/xgMXKreUcpYZg0AZCWfwzDKork96 Rkfcsvy2twEfqqD8yTbjo89TqFZDWJ6DmHLRgVrrblHfH827lERjH8G9xilghFSKw5UT 7Tug== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Jbd4VB5t; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j7si3634171ybc.321.2020.06.09.13.19.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jun 2020 13:19:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Jbd4VB5t; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jikir-0002iz-U2 for patch@linaro.org; Tue, 09 Jun 2020 16:19:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jikZK-0007rz-OF for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:58 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:41996) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jikZJ-0005cO-TH for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:09:58 -0400 Received: by mail-pl1-x644.google.com with SMTP id x11so7922plv.9 for ; Tue, 09 Jun 2020 13:09:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bZmmE8g6bACENWl1LtFwmXs+x0B5ALCEi1t1qd6zEd8=; b=Jbd4VB5tNNHl83ZC/85lNtZEpg1zmVsflfBRMACSeRar/5YVqcwprrkY43v9BuhXT/ OAcnBHCKQ/V3oiS+8BNsYGOZVz1RSHA6YcDdlltJ7Lk0WXuTGQUslJgOsNj72l8UzFX5 J4dvMoSDFDR4q5wpvDs4MhAqJa5Nc4IONPNAm7aaWLNBvcIncCeMwfQZouAnAvZEfUto f4SSeeTOnYAWtj2OaQ7bu6XGtA1UHI5d948/WpOHLcqHRtrkYajKthNooCkgszVwIdnf F4R9E3MP3TYBpGq4h2JBwxwosGjT+3hQv10CKClLtcSXKg8bJzJXIYNEZ6meIGbEnC6w YNJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bZmmE8g6bACENWl1LtFwmXs+x0B5ALCEi1t1qd6zEd8=; b=Aey97XeAcf22dks8Eh8OFnBpKUdGVPv137ek2tijUAG09JjPcyhPvJ2h9EyxSEP7OU Z9lqChDPSIA2urm1HbC0C1N0WE+tl5c5m/31a3lR7yq6B7x3UEQTZ+x8zLjMq6+V6YU0 W+jIdN+gc61JVX51RCBslarPGs6/yjGSmhTuWy6TE5XWqCy1nnDj/vPHyDTS/WRpQ1Vk fw0EZJbU9F9Ldihx1MzlyRaTHcMW1XsWhs+9nXL4l2Ao/GJ6vB+E25zEd9tcJvkLS9lW Buh6u2ZNAJAMDV1kf1BH6eE0rIxyk8SuKX5ASxVg9OdXfX8xLW5mGLJG1BrMUUU393eH cCLw== X-Gm-Message-State: AOAM533VSuOKSQy6wtdGL+tGuQr/QJAVayaQ8FKRkMZzVGfkXVFBvxf/ QSRhUzW6q9E9R6OdeLOwzVsK06f2eE5uqA== X-Received: by 2002:a17:90a:328d:: with SMTP id l13mr6262891pjb.236.1591733396272; Tue, 09 Jun 2020 13:09:56 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:1d09:cef2:3b1f:abce]) by smtp.gmail.com with ESMTPSA id n19sm10523374pfu.194.2020.06.09.13.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 13:09:55 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v3 11/13] util: Added tsan annotate for thread name. Date: Tue, 9 Jun 2020 16:07:36 -0400 Message-Id: <20200609200738.445-12-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609200738.445-1-robert.foley@linaro.org> References: <20200609200738.445-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::644; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x644.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.puhov@linaro.org, cota@braap.org, alex.bennee@linaro.org, robert.foley@linaro.org, Paolo Bonzini Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This allows us to see the name of the thread in tsan warning reports such as this: Thread T7 'CPU 1/TCG' (tid=24317, running) created by main thread at: Signed-off-by: Robert Foley Reviewed-by: Emilio G. Cota --- util/qemu-thread-posix.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.17.1 diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c index 838980aaa5..b4c2359272 100644 --- a/util/qemu-thread-posix.c +++ b/util/qemu-thread-posix.c @@ -15,6 +15,7 @@ #include "qemu/atomic.h" #include "qemu/notify.h" #include "qemu-thread-common.h" +#include "qemu/tsan.h" static bool name_threads; @@ -513,6 +514,7 @@ static void *qemu_thread_start(void *args) # endif } #endif + QEMU_TSAN_ANNOTATE_THREAD_NAME(qemu_thread_args->name); g_free(qemu_thread_args->name); g_free(qemu_thread_args); pthread_cleanup_push(qemu_thread_atexit_notify, NULL); From patchwork Tue Jun 9 20:07:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187720 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp867864ilo; Tue, 9 Jun 2020 13:21:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxk744zuUGDJRUFdvQkr4SeS1DAnYFcv2PQSmv2Li3vkTqhgiALVe556IXAu6Btxd8G88O4 X-Received: by 2002:a25:885:: with SMTP id 127mr9694615ybi.118.1591734063131; Tue, 09 Jun 2020 13:21:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591734063; cv=none; d=google.com; s=arc-20160816; b=ju7x4BYdk6y06USxNuMRHcIAVsLIwPVQac0GtpFfzt9GGEVtQi34uqrGvO57niKt4Z hubATg9YwzhTDpahElDHohHMkXMp4NP+6mGheRn/nch91Hw/o6nf4hS0E5wpjKq3Ryb9 lp/FFZby6avHSA742nSdOf/MNT0x5Mx0eHZFq/+coYTeTWET8mNjTJCD4aUuLIPC9TLT CMhhIvW5Zbwr9r+xUksa/XVQwYw9qLJb6PMPgh+LumzYKVzeTHbPnVrKR0/VRrwvL8V3 pE8eeGUcTXn375vyh9S/a3Kyj+O9lgnZ1FG3Qe+p1hZom6N9GMzJLu1Iac6jJoeV+Ege gHPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=zkAx8xWtCWhcEMmU8jAnkCrKBrfEu7h9Ojxrn77WllE=; b=YGFnLjl858Cyebjn2SsMDCs1ZCuOJTdCQNlXONcU5cMpKLwNsFlo2+njefF92bXmYy ZMtE1qEFTPi7xGV/jtOJup1W74mMm3w+O6xJUslpalqVfELzUpHLp9UYR9nKINVNgL8M cVojp7fNkqwB9asndUJ3t51Sl8DwIIN5R8qTj26en0mH9QORyEssLJcp48wJmIq9O0oR qoT0VFdAf26utZxbiBg8HgA3IorBnwfeK+D91I/85FpyXHtojJxFwCQQ59cV87ZlpHhx JRrAwwyvd6yxCiMMGse3H0POOIFiER+1XtMb1jf+9Nw+0H4cj0JCH0JGxfSpFfuwlTtO PdeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RY9HSuxK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d15si3144860ybs.467.2020.06.09.13.21.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jun 2020 13:21:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RY9HSuxK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jikk2-0003nD-Jx for patch@linaro.org; Tue, 09 Jun 2020 16:21:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jikZM-0007wu-Tu for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:10:00 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:43454) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jikZL-0005cX-T9 for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:10:00 -0400 Received: by mail-pf1-x441.google.com with SMTP id 23so38713pfw.10 for ; Tue, 09 Jun 2020 13:09:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zkAx8xWtCWhcEMmU8jAnkCrKBrfEu7h9Ojxrn77WllE=; b=RY9HSuxKrh+3sCVZGVO29aHtQcqu05Ks7BVdJWz6BGcbmrXjcthKCUNBmjXQFQZ1rw gvUaLSY54aJA4LA+m72NIXhgBfOyN8KufeDoEdYyw88z99Ua6y3Cdrz3ipWw5h8ThVe/ tXj43gVefliTzfn95WLeogFT3JB512U8ohSHZK9UNjiyj3eH3b3jKIJnHXc4kTAeJ/SZ VUohOqcs/EA7SMw6LFgYr3tnk4TJ2rCbL8D285xMaAFpx0+bS8aEWpft9kwVc2EnYsom 2cybvXWxHFCmAq4zwZoyOGDKqirVDKeYOguiDcnh11zalctU9OGEFufq2vNwG/ms7Tv7 M6QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zkAx8xWtCWhcEMmU8jAnkCrKBrfEu7h9Ojxrn77WllE=; b=pbMZV5u4xKf/mPqrtKje2yVRFnUxfPLuxNgmGiYTTH+WRL1W9juHGMT7jo/NYbBBMI WfWN6TyfQAbdfTuscCDoK0eSuslvphYZBGzzgvbGLvzgjx2hqThszz++Y7Sb+cz1X8gO aKzIBlLqzY48GARPRdHgTM54u450DI7XLfNT7n48OT01n3Rgih37gUM5E0AMTs0JMr8l zH71HIB6A0qjEptHyXgZJw6tzZVNUcDobeDuq0XxOGcObQgUjv9YgQB4i+cZ3inM/iL0 GXKTIMLHbOvBeMevAuO3qCf820g1w4NkSRmKo9VYEpWUCL0hf4AZWXR3n20xOUocysr/ aDiQ== X-Gm-Message-State: AOAM530M13ANuNHdV5mT6SreTXazTzoUICJPMZaQoE+QJLT2FXFd7Rh2 Zzqw0PohZ8Coa4Wy5H1U7s7PEE8XzNJvog== X-Received: by 2002:a62:55c1:: with SMTP id j184mr25464470pfb.240.1591733398111; Tue, 09 Jun 2020 13:09:58 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:1d09:cef2:3b1f:abce]) by smtp.gmail.com with ESMTPSA id n19sm10523374pfu.194.2020.06.09.13.09.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 13:09:57 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v3 12/13] docs: Added details on TSan to testing.rst Date: Tue, 9 Jun 2020 16:07:37 -0400 Message-Id: <20200609200738.445-13-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609200738.445-1-robert.foley@linaro.org> References: <20200609200738.445-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::441; envelope-from=robert.foley@linaro.org; helo=mail-pf1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.puhov@linaro.org, cota@braap.org, alex.bennee@linaro.org, robert.foley@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Adds TSan details to testing.rst. This includes background and reference details on TSan, and details on how to build and test with TSan both with and without docker. Signed-off-by: Robert Foley Reviewed-by: Emilio G. Cota Reviewed-by: Alex Bennée --- docs/devel/testing.rst | 107 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) -- 2.17.1 diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst index 770a987ea4..c1ff24370b 100644 --- a/docs/devel/testing.rst +++ b/docs/devel/testing.rst @@ -397,6 +397,113 @@ list is in the ``make docker`` help text. The frequently used ones are: * ``DEBUG=1``: enables debug. See the previous "Debugging a Docker test failure" section. +Thread Sanitizer +================ + +Thread Sanitizer (TSan) is a tool which can detect data races. QEMU supports +building and testing with this tool. + +For more information on TSan: + +https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual + +Thread Sanitizer in Docker +--------------------------- +TSan is currently supported in the ubuntu2004 docker. + +The test-tsan test will build using TSan and then run make check. + +.. code:: + + make docker-test-tsan@ubuntu2004 + +TSan warnings under docker are placed in files located at build/tsan/. + +We recommend using DEBUG=1 to allow launching the test from inside the docker, +and to allow review of the warnings generated by TSan. + +Building and Testing with TSan +------------------------------ + +It is possible to build and test with TSan, with a few additional steps. +These steps are normally done automatically in the docker. + +There is a one time patch needed in clang-9 or clang-10 at this time: + +.. code:: + + sed -i 's/^const/static const/g' \ + /usr/lib/llvm-10/lib/clang/10.0.0/include/sanitizer/tsan_interface.h + +To configure the build for TSan: + +.. code:: + + ../configure --enable-tsan --cc=clang-10 --cxx=clang++-10 \ + --disable-werror --extra-cflags="-O0" + +The runtime behavior of TSAN is controlled by the TSAN_OPTIONS environment +variable. + +More information on the TSAN_OPTIONS can be found here: + +https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags + +For example: + +.. code:: + + export TSAN_OPTIONS=suppressions=/tests/tsan/suppressions.tsan \ + detect_deadlocks=false history_size=7 exitcode=0 \ + log_path=/tsan/tsan_warning + +The above exitcode=0 has TSan continue without error if any warnings are found. +This allows for running the test and then checking the warnings afterwards. +If you want TSan to stop and exit with error on warnings, use exitcode=66. + +TSan Suppressions +----------------- +Keep in mind that for any data race warning, although there might be a data race +detected by TSan, there might be no actual bug here. TSan provides several +different mechanisms for suppressing warnings. In general it is recommended +to fix the code if possible to eliminate the data race rather than suppress +the warning. + +A few important files for suppressing warnings are: + +tests/tsan/suppressions.tsan - Has TSan warnings we wish to suppress at runtime. +The comment on each supression will typically indicate why we are +suppressing it. More information on the file format can be found here: + +https://github.com/google/sanitizers/wiki/ThreadSanitizerSuppressions + +tests/tsan/blacklist.tsan - Has TSan warnings we wish to disable +at compile time for test or debug. +Add flags to configure to enable: + +"--extra-cflags=-fsanitize-blacklist=/tests/tsan/blacklist.tsan" + +More information on the file format can be found here under "Blacklist Format": + +https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags + +TSan Annotations +---------------- +include/qemu/tsan.h defines annotations. See this file for more descriptions +of the annotations themselves. Annotations can be used to suppress +TSan warnings or give TSan more information so that it can detect proper +relationships between accesses of data. + +Annotation examples can be found here: + +https://github.com/llvm/llvm-project/tree/master/compiler-rt/test/tsan/ + +Good files to start with are: annotate_happens_before.cpp and ignore_race.cpp + +The full set of annotations can be found here: + +https://github.com/llvm/llvm-project/blob/master/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp + VM testing ========== From patchwork Tue Jun 9 20:07:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187715 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp863488ilo; Tue, 9 Jun 2020 13:14:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAVkB1B0OLu63aGN9sUbdwSkF2sNF3iCIRmNZNL8eGB/joldXJS16WU5vkkoSIKoXGYWsd X-Received: by 2002:a25:41d2:: with SMTP id o201mr9430822yba.516.1591733649793; Tue, 09 Jun 2020 13:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591733649; cv=none; d=google.com; s=arc-20160816; b=nyCTI8nyH1ZcAjJdifbd/Ddyl1/+tdEoloIbA8bHLwbIYy34IJ0351v3oAlZGiKhsa ii1GpcLwCDcSE84HjpTs2Oh2lGpqzCG6/ly7ptQoVVu5TICj8KFSSiDLxyHP4FkKiAwj w+z9mzrRAnQEYtyuR2BIWy5EHWS7Uy5MWzJxfqJDo3OO7B3CHO2SC32S5CBaClVeoFus BGfnfuOmSfEVeYusCDXYJr/wDsMGjtlqEDuE8+Hz7+vcN0BZ0IcRWtjI4gRdzFiEhuaO WDwdF2+QK2gcncccDU9syGUSwvV2bHa3GyjVCGylKReirAL2IixRHYgrVnQa07aVVSrY fmWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=cHjY5HzznfKw8VbLxbBOVqurhqy9xCUukR85p1gtXTQ=; b=et/j/O+67Av8B3tqVqnYM/gZV6wu85J8MzJN22R2IQ3MeLbIZMHR1h1s92i/TDMN3H /RP5j9JOCgf3cIvf/i6tPzPw3wP0/wlyIZ9sNJmZg6uQBwPLZKSM639w92YMX0R25HGT sBwHFi5/NEf1MdLsz9hZ/H+qOf/WVP3Fm6FGGUrQb8fJThSv0VkCYEsE8LPsV0YtrvAH JkbgnTuoR5uKqbzc8fuOn43CxKckrPFKDP+CetT1cgID9pUIfWTAim4VI7AirSJVR3i+ dkcwz8ESEo3NK28dpFLtwkyQHO1akOmGaQ59Bhh4hALtN3T1raZPVW+dbK3vhB/Y8Hpj kgMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=meFFanmv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v7si3373233ybe.190.2020.06.09.13.14.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jun 2020 13:14:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=meFFanmv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jikdN-0005Dn-8m for patch@linaro.org; Tue, 09 Jun 2020 16:14:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59360) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jikZP-000815-Mz for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:10:03 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:39678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jikZO-0005cr-ED for qemu-devel@nongnu.org; Tue, 09 Jun 2020 16:10:03 -0400 Received: by mail-pg1-x52c.google.com with SMTP id w20so10766230pga.6 for ; Tue, 09 Jun 2020 13:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cHjY5HzznfKw8VbLxbBOVqurhqy9xCUukR85p1gtXTQ=; b=meFFanmvYve6P4U84sZWJmvNJtxvl5Odzkfx3EOOaEY5IqWwcu1Km1m14phH79lK+E siDDwMZyUYpSACzfFDVm51PWeqkaCCEzWEPOtCFWKm3bivPuBYP+zmprenJG6WtDXzaC eVNGbpf1vr2zkfRk8OItepu9IEUQcFqVV7O+cLN4ZeXomi5N3P8asrGpUJpZ1jGOFyQb 8GjgAlYecgyA5wyUlQ3r4OUDaaXZuxyvmPHIvHv2x/98AivNrO6aHm1h1vw36xKxJ7bT MchefeoniBvHVRetRX7wQxSKGs8BnpJ/x45nHcJdXojORQOXuN7bM4s4Gone8VxuV0LH 6Obw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cHjY5HzznfKw8VbLxbBOVqurhqy9xCUukR85p1gtXTQ=; b=Fe5aprxNo2W2erFC9UsLro6G/IGjM388VQV0pfqiLxMr0pMKI6OccXR7mPNzVJ92ft i/osxIK22ZAC5W6AbyyfBcc18ezJo+t7pdIzwxjFiijCeknCrU2im64X+lExyyQTwP8u 8g3X9WW4KG9U3VDseBBie6ceIKiTSAFas/Xs+QrInhLWipoC7Nu79f8I8uWm21UFl0Ku 5FSdMeq2yc1kEBCdK//MfEnxgaHdSfG2uRNEsW/nuZVsrbuO27ZIPtunmKlHLOAV+tSw Hav7JxRJoPvV348SjRvq2zbFG8WH1EL5sdsIz89XULgD0Vu9C8vICaVs9jQ3ORct2uXl ZCWA== X-Gm-Message-State: AOAM530xr2PqBahfSbj9xyHFacb45J9WpF0OmGYYNevp5EOyPHYlMFdN m0ofy99W46QEs1mm7fLjxaAebDA0SEhjUQ== X-Received: by 2002:aa7:8b56:: with SMTP id i22mr26717403pfd.63.1591733400654; Tue, 09 Jun 2020 13:10:00 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:1d09:cef2:3b1f:abce]) by smtp.gmail.com with ESMTPSA id n19sm10523374pfu.194.2020.06.09.13.09.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 13:09:59 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v3 13/13] tests: Disable select tests under TSan, which hit TSan issue. Date: Tue, 9 Jun 2020 16:07:38 -0400 Message-Id: <20200609200738.445-14-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609200738.445-1-robert.foley@linaro.org> References: <20200609200738.445-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x52c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , robert.foley@linaro.org, cota@braap.org, Paolo Bonzini , peter.puhov@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Disable a few tests under CONFIG_TSAN, which run into a known TSan issue that results in a hang. https://github.com/google/sanitizers/issues/1116 The disabled tests under TSan include all the qtests as well as the test-char, test-qga, and test-qdev-global-props. Signed-off-by: Robert Foley Reviewed-by: Emilio G. Cota --- tests/Makefile.include | 9 +++++++-- tests/qtest/Makefile.include | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/tests/Makefile.include b/tests/Makefile.include index c2397de8ed..8d82c24d83 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -55,7 +55,6 @@ SYSEMU_TARGET_LIST := $(subst -softmmu.mak,,$(notdir \ check-unit-y += tests/check-qdict$(EXESUF) check-unit-y += tests/check-block-qdict$(EXESUF) -check-unit-$(CONFIG_SOFTMMU) += tests/test-char$(EXESUF) check-unit-y += tests/check-qnum$(EXESUF) check-unit-y += tests/check-qstring$(EXESUF) check-unit-y += tests/check-qlist$(EXESUF) @@ -108,7 +107,6 @@ check-unit-y += tests/test-qht$(EXESUF) check-unit-y += tests/test-qht-par$(EXESUF) check-unit-y += tests/test-bitops$(EXESUF) check-unit-y += tests/test-bitcnt$(EXESUF) -check-unit-$(CONFIG_SOFTMMU) += tests/test-qdev-global-props$(EXESUF) check-unit-y += tests/check-qom-interface$(EXESUF) check-unit-y += tests/check-qom-proplist$(EXESUF) check-unit-y += tests/test-qemu-opts$(EXESUF) @@ -123,9 +121,16 @@ check-speed-$(CONFIG_BLOCK) += tests/benchmark-crypto-cipher$(EXESUF) check-unit-$(CONFIG_BLOCK) += tests/test-crypto-secret$(EXESUF) check-unit-$(call land,$(CONFIG_BLOCK),$(CONFIG_GNUTLS)) += tests/test-crypto-tlscredsx509$(EXESUF) check-unit-$(call land,$(CONFIG_BLOCK),$(CONFIG_GNUTLS)) += tests/test-crypto-tlssession$(EXESUF) +ifndef CONFIG_TSAN +# Some tests: test-char, test-qdev-global-props, and test-qga, +# are not runnable under TSan due to a known issue. +# https://github.com/google/sanitizers/issues/1116 +check-unit-$(CONFIG_SOFTMMU) += tests/test-char$(EXESUF) +check-unit-$(CONFIG_SOFTMMU) += tests/test-qdev-global-props$(EXESUF) ifneq (,$(findstring qemu-ga,$(TOOLS))) check-unit-$(call land,$(CONFIG_LINUX),$(CONFIG_VIRTIO_SERIAL)) += tests/test-qga$(EXESUF) endif +endif check-unit-$(CONFIG_SOFTMMU) += tests/test-timed-average$(EXESUF) check-unit-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_INOTIFY1)) += tests/test-util-filemonitor$(EXESUF) check-unit-$(CONFIG_SOFTMMU) += tests/test-util-sockets$(EXESUF) diff --git a/tests/qtest/Makefile.include b/tests/qtest/Makefile.include index 9e5a51d033..71fd714a2a 100644 --- a/tests/qtest/Makefile.include +++ b/tests/qtest/Makefile.include @@ -313,12 +313,15 @@ tests/qtest/tpm-tis-device-test$(EXESUF): tests/qtest/tpm-tis-device-test.o test # QTest rules TARGETS=$(patsubst %-softmmu,%, $(filter %-softmmu,$(TARGET_DIRS))) +QTEST_TARGETS = +# The qtests are not runnable (yet) under TSan due to a known issue. +# https://github.com/google/sanitizers/issues/1116 +ifndef CONFIG_TSAN ifeq ($(CONFIG_POSIX),y) QTEST_TARGETS = $(TARGETS) check-qtest-y=$(foreach TARGET,$(TARGETS), $(check-qtest-$(TARGET)-y:%=tests/qtest/%$(EXESUF))) check-qtest-y += $(check-qtest-generic-y:%=tests/qtest/%$(EXESUF)) -else -QTEST_TARGETS = +endif endif qtest-obj-y = tests/qtest/libqtest.o $(test-util-obj-y)