From patchwork Fri Jun 5 17:34:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187557 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp2585011ilo; Fri, 5 Jun 2020 10:38:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmDQwalFTyx9ZUQ+LnVdXJ0MY+NNE7G0Eohy4XxwrdUC2r4z0yJ7YUP2AGn/h5J3/mgq/g X-Received: by 2002:a25:8284:: with SMTP id r4mr16272637ybk.351.1591378693436; Fri, 05 Jun 2020 10:38:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591378693; cv=none; d=google.com; s=arc-20160816; b=lvXBwFWiE7jwD4E0RxweZ2e01ZQK+lERmUfJORyX0bNj/rlr61pcFGC+aJDOE52Z6r CMo97X5/S5TlnQf8lhpVx/dwNzD+zYR/kZB0SAYuGneu0rHmIs0wTLoW67wWIng1+Vf3 kwG5kzzk5+wjaZEyYWfjbgmdMks4Xh70MYkHUqD1RjqecmXJpg8RwqY9Fyaud1fi/KsM nZ18lFBht0nRLAQcLJnMQY5jGO54alhxZ+I7MJx6aezkydl5nyXrFXE25hmiUbROO1Bf unA+xYSWlj04yzIIY77YOGaiQCsfG3W51msztWFrALM58Y1lJ6JQ7ruHZdUHrBWxtCnb 5DFg== 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=PolYfWsjQxLFUFecxYjpFffyz0BlbK4AQIvIQhTtHFk=; b=Ec0BnzJvPNlvIc2Tht+ttRzScW7eleUWe7JebltFn5LsPOpboHp29ektJ5sAOswGJ0 /VsJfLYeL++XDsc01hmJPF5AuAB/r6rqxuKC03HO8qyE6Wb4qXzYoNrvPReQXKi0pdNv VnOFikeE8pDWC9kbSvJAMDibj6apChl01oc4KP6uH6M/y7YzW54IXfMt/kQUsutU9kfS PaYup/wSJqWXNqJBsbxPFEENucnRZ48EGpLoyUTFWaULQQJzyPFK6VtN95J7Qebpg/Qg HHECuN4/++NFJvOcLuHtrV6eJFUIkEQ9U7k8bK4UzrCdWP55xF7k3aOT8c+QsTM3NvUN A2MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=frrsC2El; 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 g11si7146060ybk.272.2020.06.05.10.38.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jun 2020 10:38:13 -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=frrsC2El; 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]:54466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhGIG-0003Iu-RC for patch@linaro.org; Fri, 05 Jun 2020 13:38:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhGHf-0003Gy-PE for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:35 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:33958) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhGHe-0003pr-El for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:35 -0400 Received: by mail-pf1-x444.google.com with SMTP id z64so5296232pfb.1 for ; Fri, 05 Jun 2020 10:37:34 -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=PolYfWsjQxLFUFecxYjpFffyz0BlbK4AQIvIQhTtHFk=; b=frrsC2Elmq/htA0uFNhU4ByXtqejBBJec9CpBtisYiHUYZfniReqC1lrrUGNczcoIg zFm1C9ESCWw3o9gkEkuYArO2RP4nxXWJC4VV0HI6E86YhNOg7LvdP1uIOJvgpUpNkfyL ZHOV5UjOOHnBtR0Y1PeGdBHlD+WhJN3ivXktJ3g7EGf/PXAyuI5O0pOZLWaylsMiDGLQ oxDgANy3zH09suNVRpmLFCzC0eZEEnC9grot77r35ldUs+UI9n1qrxdVKW49UWwED1yN Bv1fi0/qDP2Iold2kaIE2Kc9ZXZ+aVNE1tuW6u2MryhrWJaIt9h7o95dqnSWGmyX9oZg jipA== 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=PolYfWsjQxLFUFecxYjpFffyz0BlbK4AQIvIQhTtHFk=; b=M37pjFFZzFhWI0sH6iH5dyFSj6i5f7t+w/nDW+0JKAPDWJ2ZdZZTMLi6tTrptMlGIn RfqxUJ+RXRbkxc3ARtue0MSoo7gLqBLXmTbsEQywOAS7SuPfdjveYv0IxBs3pbbMybGc sKG3Oa2ouuXgkuMkU1FpR4Ydj/zGkx6NUl+G713hnCcrnTBegoqPWH1qlVUENDV3hRDa omP8tsmEbewiqrx4Fz8VtWl1XpnYMqvQDstZ4nzOf14hAs/XOxh/b1cXQY02roHuCWvu Q6vAgwsrdDOvMftHmPd13+Yz7gqGPSGSOT54vpXjfr6MeJZnyajDqZ3au6hSpU2ysBNj 8ahw== X-Gm-Message-State: AOAM530dP33qTP4WxbXppQNcUdlnBZzfBGbe2mmSBkvRAICMHnGzXFJh eG1o9W4oimN8p2OG47EUMU0jgVR737iROw== X-Received: by 2002:a62:2cd7:: with SMTP id s206mr3403909pfs.305.1591378652406; Fri, 05 Jun 2020 10:37:32 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net (c-73-47-162-176.hsd1.ma.comcast.net. [73.47.162.176]) by smtp.gmail.com with ESMTPSA id a19sm188307pfd.165.2020.06.05.10.37.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 10:37:31 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v2 01/13] configure: add --enable-tsan flag + fiber annotations for coroutine-ucontext Date: Fri, 5 Jun 2020 13:34:10 -0400 Message-Id: <20200605173422.1490-2-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200605173422.1490-1-robert.foley@linaro.org> References: <20200605173422.1490-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::444; envelope-from=robert.foley@linaro.org; helo=mail-pf1-x444.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 for warnings, erorr handling + minor modifications] --- configure | 47 ++++++++++++++++++- util/coroutine-ucontext.c | 97 +++++++++++++++++++++++++++++++++++---- 2 files changed, 134 insertions(+), 10 deletions(-) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/configure b/configure index f087d2bcd1..9b50820366 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" @@ -1750,6 +1755,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 @@ -6192,6 +6198,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 @@ -6293,6 +6323,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" @@ -6328,7 +6368,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 @@ -7382,6 +7423,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..a3dc78e67a 100644 --- a/util/coroutine-ucontext.c +++ b/util/coroutine-ucontext.c @@ -37,18 +37,33 @@ #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 } CoroutineUContext; +#define UC_DEBUG 0 +#if UC_DEBUG && defined(CONFIG_TSAN) +#define UC_TRACE(fmt, ...) fprintf(stderr, "%s:%d:%p " fmt "\n", \ + __func__, __LINE__, __tsan_get_current_fiber(), ##__VA_ARGS__); +#else +#define UC_TRACE(fmt, ...) +#endif + /** * Per-thread coroutine bookkeeping */ @@ -65,7 +80,20 @@ 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(); + UC_TRACE("Create new TSAN co fiber. co: %p co fiber: %p caller fiber: %p ", + co, co->tsan_co_fiber, co->tsan_caller_fiber); +#endif +} + +static inline __attribute__((always_inline)) +void finish_switch_fiber(void *fake_stack_save) { #ifdef CONFIG_ASAN const void *bottom_old; @@ -78,18 +106,40 @@ 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); + if (action == COROUTINE_TERMINATE) { + __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); + + UC_TRACE("Current fiber: %p.", curr_fiber); + *fake_stack_save = curr_fiber; + UC_TRACE("Switch to fiber %p", new_fiber); + __tsan_switch_to_fiber(new_fiber, 0); /* 0=synchronize */ #endif } static void coroutine_trampoline(int i0, int i1) { + UC_TRACE("Start trampoline"); union cc_arg arg; CoroutineUContext *self; Coroutine *co; @@ -104,21 +154,34 @@ 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); + UC_TRACE("Current fiber: %p. Set co %p to env 0x%lx", + __tsan_get_current_fiber(), self, (unsigned long)self->env); + start_switch_fiber( + COROUTINE_YIELD, + &fake_stack_save, + leader.stack, + leader.stack_size, + self->tsan_caller_fiber); + UC_TRACE("Jump to co %p caller fiber %p env 0x%lx", + co, self->tsan_caller_fiber, *(unsigned long *)co->entry_arg); siglongjmp(*(sigjmp_buf *)co->entry_arg, 1); } + UC_TRACE("After first siglongjmp"); + finish_switch_fiber(fake_stack_save); while (true) { co->entry(co->entry_arg); + UC_TRACE("switch from co %p to caller co %p fiber %p\n", + co, co->caller, self->tsan_caller_fiber); qemu_coroutine_switch(co, co->caller, COROUTINE_TERMINATE); } } Coroutine *qemu_coroutine_new(void) { + UC_TRACE("Start new coroutine"); CoroutineUContext *co; ucontext_t old_uc, uc; sigjmp_buf old_env; @@ -154,12 +217,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); } @@ -185,6 +252,7 @@ static inline void valgrind_stack_deregister(CoroutineUContext *co) void qemu_coroutine_delete(Coroutine *co_) { + UC_TRACE("Nuking co %p from orbit", co_); CoroutineUContext *co = DO_UPCAST(CoroutineUContext, base, co_); #ifdef CONFIG_VALGRIND_H @@ -209,6 +277,10 @@ qemu_coroutine_switch(Coroutine *from_, Coroutine *to_, { CoroutineUContext *from = DO_UPCAST(CoroutineUContext, base, from_); CoroutineUContext *to = DO_UPCAST(CoroutineUContext, base, to_); + UC_TRACE("from to: %p %p uc: %p %p. fibers: %p %p caller fibers: %p %p\n", + from_, to_, from, to, + from->tsan_co_fiber, to->tsan_co_fiber, + from->tsan_caller_fiber, to->tsan_caller_fiber); int ret; void *fake_stack_save = NULL; @@ -216,8 +288,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 +303,13 @@ 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(); + UC_TRACE("For co %p set leader co fiber to %p", + current, leader.tsan_co_fiber); + } +#endif return current; } From patchwork Fri Jun 5 17:34:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187558 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp2585044ilo; Fri, 5 Jun 2020 10:38:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzg3tjsJXaHBK/Vlv5viwg/RPtAZjMOzaavLz3sRtyThxQ9+UzaoCcBYgcXcVLctG/tPfRv X-Received: by 2002:a25:4f44:: with SMTP id d65mr19292944ybb.149.1591378696035; Fri, 05 Jun 2020 10:38:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591378696; cv=none; d=google.com; s=arc-20160816; b=wjN3GzY7EMLJZVSUpbngb7KrA2scKyuFo+hqZjOW+YXR5vmbkkR/5FQIzrq/ve+6QA iGsnvL1ZLvRFhdQ8wih4DC49mN8sZfMtWpTQWdIgCa7bnoutTef5sj1Ojw/gBLtS1ke1 5QpfVlWogaxHOR2ymLUelgbCzStIBkI06MGSobSjS8oOZYjLKxmrcmPMjSWXcGzGCTs9 IaVt4riG9jy81aM20gzZrmBJ0vT/xmB1a+eXiWJhLxwS6i2etIqcS7NexeBs0gBjoc+p pdsDBDe1SFKPtCFbFgsDHQBOlE4cohWz9QRALw8wHeiBlhf1fDMEtloVmkx3C+3PCeMO FWeA== 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=QonKzFLvxHetjYHv0eko5X68Tto6P2i1o+bAUOOMVq8=; b=nXx+ExjLOlB25BTScfPHk81rfPrmg6E2ZZal0RcXCydZu47rIqoznAnlA8we37wLk8 O+I6RDFmLewDACfhAp2CM6sBApWw2YjprXRnRJR9+7S/VeGGMMVCeK7N12qRqcSn1Pb6 L0fRZT9d3n/Ln3dgo15OSxWsZqJVtsCjzskMVYpLzFRVDF3IVGQMuBWGMDlJv+rYlM+N a9y2RZEsYq+aAdpXLANRj8osn2BT0nZrY8VGfkWUOCvK/pwvXDQDKFNv0Xp7S0WLmd/R O8gDVSYf47Uy4DLAAv8mlaavN8X/8GftbNrIl7GZk4Xgf86I2NffHCySR/YyGsl165Cg k1bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="IqfJ0B/6"; 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 n13si7015526ybp.102.2020.06.05.10.38.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jun 2020 10:38:16 -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="IqfJ0B/6"; 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]:54636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhGIJ-0003Og-Gy for patch@linaro.org; Fri, 05 Jun 2020 13:38:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhGHh-0003Jb-S4 for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:37 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:34899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhGHg-0003q0-Qn for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:37 -0400 Received: by mail-pf1-x443.google.com with SMTP id h185so5290034pfg.2 for ; Fri, 05 Jun 2020 10:37:36 -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=QonKzFLvxHetjYHv0eko5X68Tto6P2i1o+bAUOOMVq8=; b=IqfJ0B/6o/HB9WrnAdz0DzKWhSIhvU3L3BtJurcDXQWusz3uv1YGZvnKy6Rs3X+nWg 5XXLGHGguFT97AAbAjokOTflLlO8dBghVl/0KYD2FAsii+0MG5mJmbWUU1iqkkANWH6K b5Huid8G04XSqnLaybnwT7+/cqUnhzOJste3Ud3rYr+k1h0sL0mxN2juY8D7p9zzlniG /ebMO5NcoumH2H5cwQwHGKreFd4l9wrzaW8mEz1qQLUeZ9kgBm8dDZTV+jpJnfAxhfDw PIQEJ+8ILMnHve/9wjDAkQP8dkg2LGOmxki/mXRV3+eo6+tO1NUrXUWVu8oqOuGLanjL 4M+w== 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=QonKzFLvxHetjYHv0eko5X68Tto6P2i1o+bAUOOMVq8=; b=JAoG+8fpzJrNde8xQJNhgsrGHr9zSgIenUUp43UDT2aHr8sKmqBLKTpQ8kpxPihDXo gWI/1iMTUXM9Va6lzkK2ahDTuNzHF2M+00E/M7Ju0xjfPQ5U1ErwMioBzA1hEOTMri/T 8wDxlFqtcKlkpKwB3l+/KiNynlFyCtEhwfXIsQwlb+UZZiZ7WEpl67hFI2enUOa7Po10 z3mjIUgrqgXBtZOOaD8bj3TVZhjxv6AVDN0I/gzjFaw09o3qE2Xd6/AEyCa13Kt/or65 FYZa5ubSM5QDAIHkw8kQrzsxhRLAmNDFZJTDHOJlRQmga4spjU3NQsrkSHugM6NoMpCX E+0g== X-Gm-Message-State: AOAM533mlCb0T8+m1XBlvyA8zAeQR7PcLC5vE5Cnc6OFLLGFFGnxTOYH nrN1//d522eqvSD8jgVQZuypMXrPPF3J+Q== X-Received: by 2002:aa7:868b:: with SMTP id d11mr10304598pfo.52.1591378655149; Fri, 05 Jun 2020 10:37:35 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net (c-73-47-162-176.hsd1.ma.comcast.net. [73.47.162.176]) by smtp.gmail.com with ESMTPSA id a19sm188307pfd.165.2020.06.05.10.37.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 10:37:34 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v2 02/13] cpu: convert queued work to a QSIMPLEQ Date: Fri, 5 Jun 2020 13:34:11 -0400 Message-Id: <20200605173422.1490-3-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200605173422.1490-1-robert.foley@linaro.org> References: <20200605173422.1490-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, 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 5284d384fb..77703d62b7 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -368,6 +368,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 07f7698155..d78ff1d165 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 Fri Jun 5 17:34:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187561 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp2586120ilo; Fri, 5 Jun 2020 10:39:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfU1dRhhmexK9TDi5P6YYgBT/VLad2m7EbuZAQuhhxBDVyWYn5R81zNcHy8IpPCkn8/F63 X-Received: by 2002:a25:4f44:: with SMTP id d65mr19303025ybb.149.1591378780860; Fri, 05 Jun 2020 10:39:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591378780; cv=none; d=google.com; s=arc-20160816; b=dqNMIkHnTcRmfRA7lvzHAxONu4eDX1/8FzV/ytimw2dVG9HD/NfYOer94GPB3l6mWM AwROBl5LcB3R3X3okLR3gBDjahNNz++2l0+Y+tl0da4w628MLLQGC6sFn3m3Y+Tgmb+A NAIzRZwUGaIJmoV+31uMXcr31/nNz2gX7J+h4FuvGd92RkSGdsV3kBPT+ZqTaB/iISfR GFu0m3qq3/ukYlQBJ56OF+ZemXXXcClRDXva2cz7N71807oIOkT3Y2J85TOMXarlNICS r1gJr9llAfC+bpWGug7ljTq8AK6GXwyMPttE/LoLHWf4+Stvb6syUqHeLOdAQI+FDt6M dvGw== 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=u2QpYrRoRhLnFCVejbqDmqrcWE3F4+xWMyTJ9K74ulZM9f3gWGAlk6mWfTxqBhKbHs ZROYh75a+iHHvyLiOHsh83TQy7mmFYS9zVdMNrwPvOXRf0poPZiLGyanU7ZoypPhWmeY O0b1tbpZanev5uHs58GuwWOX6FH6lTl4QwSUAlUqR9FWF9mPcx71w3l1zt/ddwAt7WtP QiGR25lB1pQsz7FyeNnwlKKN4Xt8Wk6oFDYEcJm/bMDr7gmocwTe6PJME2S4NnT3pvIS Tf8V8V5Nc47CAWBrTzs+dEdh6pkONj+LwHwF4jtUL2DU/W4ImiBBhYmfWSdD4qwSUN+4 eQLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OVmbaf93; 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 b125si6422613ybg.145.2020.06.05.10.39.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jun 2020 10:39:40 -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=OVmbaf93; 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]:34850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhGJg-00075E-9q for patch@linaro.org; Fri, 05 Jun 2020 13:39:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhGHk-0003PX-0i for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:40 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:42956) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhGHj-0003q9-5m for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:39 -0400 Received: by mail-pg1-x541.google.com with SMTP id e9so5493054pgo.9 for ; Fri, 05 Jun 2020 10:37:38 -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=OVmbaf933xh3+YjoGnMzeKhaIMEES9/YNzfNkwU4WoU4wV4VsD72CXkV5csQ8rH96p SGNxx/1QpdRtfP/na6jfrSOPETR6s177Pkw0UB4llk/Tps/G1R/L8c/i8zvVNy8d1poT tuonWtc7WTRAqnf4JXd/6DGK989PV/wzRqN32OIJ5Sze5eE58MXE6nvxBQ00FtSC9gIv 4rMSDCIkQ3j13V7fkocxbt5BObP5bz1G44RJIerfaEjbfDD1GTSEfHAlGMlsXm12vD1o mEmx49o84FE5doG3phUctcF0FnNWq12omdU6IK4vcaS90OVik1nAzJvqhA9VHsODQJe9 771w== 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=DfZ7TeFVfNqy6bCvsILBS9RDdqU4hm5iopQr8L1SLxwIQNg6JBdMNV6YqaIiNiNYIk mUVacYHx5SMig6kD9c8WwQetlVs4x7Eo76quld0+kDg4r1ZQhovYIwGGY+n0F49OTyNA vQp56J4/0bhr1YP5AU6dIRZkerb5VevZJyp7DkSkWlw85I0vdXX5dFeqvEnEEqnDO1Gw Fl8Xmd3li5u1PngCFRC/58smGz+OIbab6lQ8Pj8wsT//nKOWsU2jffUV+8A4ynJWXxdT nF4uZsGreYeV5ay/LCaUzVFQiUw+zaocdjuDPZnTfbM5qFK/X41ECqmuS0+Bj3NAsKpZ mybQ== X-Gm-Message-State: AOAM530oO5RcoJXCeIxUyiQvVffE4slqlfG6Qwl3x+zTTku/lmiu+z6x A7iV6aB3U/N/UZqM8EkI34E286CZSh8HOw== X-Received: by 2002:a65:568d:: with SMTP id v13mr10411043pgs.436.1591378657135; Fri, 05 Jun 2020 10:37:37 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net (c-73-47-162-176.hsd1.ma.comcast.net. [73.47.162.176]) by smtp.gmail.com with ESMTPSA id a19sm188307pfd.165.2020.06.05.10.37.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 10:37:36 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v2 03/13] thread: add qemu_spin_destroy Date: Fri, 5 Jun 2020 13:34:12 -0400 Message-Id: <20200605173422.1490-4-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200605173422.1490-1-robert.foley@linaro.org> References: <20200605173422.1490-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::541; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x541.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 Fri Jun 5 17:34:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187559 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp2585440ilo; Fri, 5 Jun 2020 10:38:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQSJUtq5sZpBYsy7JSYudOhxmSdDNXChAqtBQZgxeLNrpTOqfmiXmvBl4lFAr85fZ0Bc3x X-Received: by 2002:a25:d8d5:: with SMTP id p204mr17563109ybg.28.1591378722646; Fri, 05 Jun 2020 10:38:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591378722; cv=none; d=google.com; s=arc-20160816; b=l76er/Es3wBmMAg4PzoQsG6DtNwq1Wczhfp8F6TowkrSHa6lpfMyDF+uU1npsqLuvj tXcBVOKnEUdNbjF/m6xe+UDtsap2Sr9qKsWZtO25IRTfGpb77cuUJZUR/YkttGtYbB9R IRoH+j9yvko8cfOlS8maq+AuVR+bM79NtNWRUf+MIJwCg+mNxrAoJiAbsWT9SrVqFvsC vvbjhw4Cb8zBE2GiwD+AWYIJAacyRDpko7NkL3yPuJvrm+bzYjU19y9HRz2vaFRkxYZX XSFM25CvMUY2zl+v2r6lUhC3mKujjAWb6XkSmI4Z7D5kE+zI6CKcfqVyRUy8OGavj0jg aQDg== 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=KA74qkYRKvEU3ng1kAP13z7yTrox0/WpEe+h4sJiZmM=; b=nJX+ISZkrogSpMUgsU9kCdZ3QR3rWRRsGPVwFzoQRw6iEhnZl0NeaKpZqMLqhPcVfL NZjEWBsk8kj94akit6a0ASDIcnG0ZxQ97/vDWd5xhktKgJ7QSKoSD/P3Yotq7Ox+++Ti i+zSLFRRHZGLUzVtq8V9lJersD1mSsZGudgVqiIAPP9OiWtBwUCJ4lr+TuylpnvQop1n /rw6GR7RFZGuJZHghbM8K+a+UkKDBqAMHL/j+Z00bH48TRIe9fml1cGqv7RIqcgWTuyA VZKDiny5HSr5xRaOtbmtXhsjeBTaN0hTy1Q7Jyxir9m6APM/m8BolkiyjpCwv8b3zoCR 9U1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="lw2/Uwd8"; 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 t34si1734433ybt.276.2020.06.05.10.38.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jun 2020 10:38:42 -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="lw2/Uwd8"; 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]:57596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhGIk-0004dD-4J for patch@linaro.org; Fri, 05 Jun 2020 13:38:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhGHm-0003WP-Ef for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:42 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:43332) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhGHl-0003rQ-CT for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:42 -0400 Received: by mail-pf1-x444.google.com with SMTP id 23so4392891pfw.10 for ; Fri, 05 Jun 2020 10:37:40 -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=KA74qkYRKvEU3ng1kAP13z7yTrox0/WpEe+h4sJiZmM=; b=lw2/Uwd8ZHKoaA5GuN/k3mU2SK9d8Uf+vZNl7PC/3t1lUu8jbQOB4SXaIsVyzWmdan GRPftAlfazcikKZGh4gBeGVRrXrDcw0v9el+qXwSJeajvb9FIm7dLDOJvpJ1oIcOYWgY 5cA+a1cW4kWnp70n1UW0TdbAgwiLFMdAE9yS707VIXCmt2/us8ldRUelEyEeUOaRTcEU H5IiqTnAS0kjIBxhrALY8oAq3EBgvo3zHARtPauxyCW9y+FVzqqjrefoATCSU/3qnDgH tSM/0q1X4P0qVv6Js/wuuDrZRj+OG4ruI6mndCoFbHIUhl/p20t6OWzyeze6QC5C37Tf RisQ== 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=KA74qkYRKvEU3ng1kAP13z7yTrox0/WpEe+h4sJiZmM=; b=JLzUZFNR4ODuhgfyb3CuAESpCsQRIpsJ9L30ASNF7tjrCrSjAH9vLdjfhytyL+aSDZ 43mmRlqA3QlpYdQqFL+vbxyk3Sm6mNDyg8hbp8nAwH95SxSOJmC8cDYzyy3Zaz6yNChy 9sF2eJk71/JX4aHqMtQ2/Bh9bSasd6OCW03c0sJgOwozsSAvb64Xbc1JgQ99Im87V73L NQluhtJRE/brsx25L1XBjYU8FLUSCohOjUiWyvVoiYPKO1r8esoRysUc7wr8kNdydpsu sIInAz7PiiLyl5CvbaD8Mf3FhLpSHoummpa4Cah3/3VZE7O+Drk4y7M3IUA8gtMxHeY7 SUXQ== X-Gm-Message-State: AOAM532ETORFXidpqNQa7AgcBbNp0gBQqwL5/m+rV5Uio/oFrZ5ZNii2 QSXpCjba0TJ6+NObZVpG4z1e36FFHX2JgA== X-Received: by 2002:a63:fc4a:: with SMTP id r10mr10624014pgk.417.1591378659877; Fri, 05 Jun 2020 10:37:39 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net (c-73-47-162-176.hsd1.ma.comcast.net. [73.47.162.176]) by smtp.gmail.com with ESMTPSA id a19sm188307pfd.165.2020.06.05.10.37.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 10:37:38 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v2 04/13] cputlb: destroy CPUTLB with tlb_destroy Date: Fri, 5 Jun 2020 13:34:13 -0400 Message-Id: <20200605173422.1490-5-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200605173422.1490-1-robert.foley@linaro.org> References: <20200605173422.1490-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::444; envelope-from=robert.foley@linaro.org; helo=mail-pf1-x444.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 5162f0d12f..da3d60b034 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 Fri Jun 5 17:34:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187563 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp2586478ilo; Fri, 5 Jun 2020 10:40:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxl16T3wgtgCbobhBAWjncZK0SRsza/Uoh1UUle5wyTFwy6KB/pDva25WxH7QwC/LaCgiuy X-Received: by 2002:a5b:346:: with SMTP id q6mr17569054ybp.393.1591378813689; Fri, 05 Jun 2020 10:40:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591378813; cv=none; d=google.com; s=arc-20160816; b=phInl1IbbIVVXGevotC2YYtSUjMZZFCfkr7YCF1EVfvcwMyXtwe/pMHBIMMYsso4sV p89IVh/kC0hwji5KpqbWYOFfutC1nEIAGrrPQKDEKF+Omt4maHJUy1y/br0sZG2LcGIw HLVRzcHjiK6C+5eZhYt6J7X//gZnxFgc+TdQ6AnBgVdhHWg4UteCLwsUoTXWe1FBkw63 q67WLSCOL6dV/SKnfDTyGu0v1DyrLANWHTGJFqIlUbUQXQGa6SoAHGlGefSyfR6jRTmz 8YVwWE9y3gtpvViJEnmrm9IC7VeA54ID5qxewRbMlm5bZQpBspSFCVcdFPzoVIWjfsmd N+Ig== 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=QJz1xZkws/0mkjixPKNI6oUddLiKWyV1qCj/qzmZa0xawRl08CmQRdd90auQ33E5Ad WUbux/c9f+zZLk2Jkmec7N2NKy0CEp18L3yg1zuRYnywPfV1ZDVIwsgkn76gQKW2VUd2 AAbp1r5LF7ClDfFzdq4H09EIWPDwP2mRG496vHCBoX8P10doay2LvZkmmXNsgMWD2Lu0 J/AqNkaLJCUTfmlptWghaPhzOFRcrPbeTU99QKBj/g1tQn0/4P3EkvH4fhdWuzZgjM/r MTY1jlv5oDYn7pi4k43RsVEgLlCN7EzDqE+ndnIq6I7WoDKVYzdsxzb8r+xuGYi0TBlm QtIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QF39NHud; 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 l84si7019069ybb.76.2020.06.05.10.40.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jun 2020 10:40:13 -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=QF39NHud; 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]:37794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhGKD-00007A-5T for patch@linaro.org; Fri, 05 Jun 2020 13:40:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhGHo-0003cX-IE for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:44 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:40810) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhGHn-0003rf-NX for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:44 -0400 Received: by mail-pg1-x543.google.com with SMTP id o8so5504528pgm.7 for ; Fri, 05 Jun 2020 10:37: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=hMythbUcqIycDnX7vBXLsyLkA4NDGTmBWD2zTKmRWuE=; b=QF39NHud8/ra/5ZqZBKv3m/n/nAeaD/9obblpGC2uR2ywu9ieUwSgeD0xj/Lhp0JPC I7f8pgYM/w/YGbzMvEKTLQUkKr7iDFWTkM9KNm9HAJI/MHZNZX6/ZOSGKRFzaG7YsfUt QLwZwUyV0zTMbnwQvHW79B1y0Unr/0NFSTQZN/+rLsn7mJ6cotfulusU8GlCuyoCD3xP oDvhsIjJmV0YK0vcU6xSfgoHra9GxGHFHDgtkAjO0FiBDvshRG5uxEmw7G4f+HgOKaaA n7Be7vyb+syOfzGphDOC39D4DK/Awfn0kfaoCk+vwhpJDZToyXymvJhDFkLZs+Tkv1/1 7dzQ== 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=gZXEETRiN7GsgOGgGk8bOjkjcG4/DPDqFVITtnP+QfXRVIlooEAWsT+u9OG9QOkJKY ZD9efT/ANZ0AcSj5UBL3IbL5KPGp9QBZrNmQDnseV5FmAVZOH0Yx5Yj2qSGB8i7QxQ5Y 3wXYtHzVffwr6xy/PsCJAMXSL4lqtz1JjGmy2mcrkFHMxCaSGOI32lcWHNGcUsWRO5dh mjmxef/Kjwoq/2iLIzrhPIsob5QvPUsJfXj3TFPFfOiN0P5oZPIuzh7qw6VmOEnz4SCx qJhgi+MbXaSLlkuDYHfJyQ+GZiDVwd4VB8kQBxsGrj3b+dqUl28EfWbpLEJuiLJoaVNK ZGRw== X-Gm-Message-State: AOAM530iszJv//8eubVK9FQO4P+iimEcE5Z6EFHrhrkXK2OaIexw0KX/ WZFW8EmzoeE7Q8iz9N7944gBwBn6FGDjDw== X-Received: by 2002:a63:7d58:: with SMTP id m24mr10192861pgn.81.1591378661982; Fri, 05 Jun 2020 10:37:41 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net (c-73-47-162-176.hsd1.ma.comcast.net. [73.47.162.176]) by smtp.gmail.com with ESMTPSA id a19sm188307pfd.165.2020.06.05.10.37.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 10:37:41 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v2 05/13] qht: call qemu_spin_destroy for head buckets Date: Fri, 5 Jun 2020 13:34:14 -0400 Message-Id: <20200605173422.1490-6-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200605173422.1490-1-robert.foley@linaro.org> References: <20200605173422.1490-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::543; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x543.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 Fri Jun 5 17:34:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187567 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp2588326ilo; Fri, 5 Jun 2020 10:42:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy99jQoPC3L8yFId+dtQ7oZHrmt2FpiviAHk2MgM5v2RlgnMfRCk+RCk3PvXU96iot7s3g2 X-Received: by 2002:a25:2e48:: with SMTP id b8mr16281872ybn.56.1591378973179; Fri, 05 Jun 2020 10:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591378973; cv=none; d=google.com; s=arc-20160816; b=dCwn2e4dSc6kBLXlyWxefdvADrrrsMPPplmWjD632qAWz4X/4zBz+eLkDxy6oe2lJ6 2y4jJRju+5m5zlxo/0/j0YVB3tIZCPgZzcZmbZfZDYZU1nLVDj2ellId5TTM9GPxCMF5 n29JQtTQ+K8PjohIHrgj+djsowUd8m6+kavVC1JQiDowVV+lVtK5yjFg09EcMgwntvSH iNEa1SLw+ZhizTUakKjGvzAl66xgYxBJc38xHbHnTRhYgrOku8qMSMEKNbfYL0+/eEW4 oapdyMuU0BqDBvUQY/WaPsIk9URYZSqmhpzH3IgnfYkX47EBSkcKZ9fbAzsu7Ciy4iyD a4LA== 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=6kzxdZqgA1tfO8ov7I9Hb8T4jfPMcEumhe/CTEZtvwg=; b=RacwspMU1aiCw26khXDltgXnqBmBxJ7+lFvKXbJihlsEStHex0GrlsX6iJPu7i7GYo E83HUdl6k6aIK1DUlBsMsln4qnMs7wltSMndWYUkAePHuZL1b4h7nFMQAVeyXwLGCIhJ 507so2ZdOhPDnQsKA5fzanatPhpMMDZrEC4G8SoqXqkYeTOec5bJyLXs0f2NdHvjy9SP CblIPgXSK3vKYfxzFtMVE3liseSuYBJo6ZpdAirf7zMvZyjkeI+xsebEW3Wi3Vb99GLJ 8u9NJFeDUPuwJUZLg//ORyoZ3Z9mtQJkEDI1ZOJJDEka40d1K7hR+/Wbm0LgiO8euJaz Aumg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fAjq30UD; 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 z8si7271611ybm.9.2020.06.05.10.42.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jun 2020 10:42:53 -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=fAjq30UD; 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]:46260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhGMm-0003eA-MC for patch@linaro.org; Fri, 05 Jun 2020 13:42:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhGHq-0003iZ-Vx for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:47 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:33988) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhGHq-0003rm-1Z for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:46 -0400 Received: by mail-pg1-x543.google.com with SMTP id m1so5553648pgk.1 for ; Fri, 05 Jun 2020 10:37: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; bh=6kzxdZqgA1tfO8ov7I9Hb8T4jfPMcEumhe/CTEZtvwg=; b=fAjq30UDfRMczkw9kAgAOc6e/2WHU9tQNAZohYKObI8yjhCUJDNKtU0JxMztVwR0OB /HSFNlmaBLgOvl8dy4+/Mos9gNtcdMFNkL1rAFRxP8jdxhMFYovTwmY1sIrgd1NdXPNA IijlFVKNqHfATy/OT9vnu4XWp17zi+A4Adbz2+9JragalNkcTO+qjnCY4Vh8Cl/e2IV8 p19Vr1MGmAZzfxQBVSutZYxf4JSiTAYL6AK3oRJivuHleKBFO6hFm7+OhbZn8U8v3MLq 1tgxRkRG1tqAPPbkSMbbubvNPRC5IkXt2ce+aHU3kRLUcIJHosCPnuh2Qw4lCSL/Ay8P B3BQ== 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=6kzxdZqgA1tfO8ov7I9Hb8T4jfPMcEumhe/CTEZtvwg=; b=GPZCma/BSLqO0lhLcUqyN1ZhafvN/52WzZxERXboLQYJQiE/mKPQ9tZHO2AU9XlyAE HkLyOiVXulpoqLssfZS4CK61/EoaKYNqSFYRN9d8koYXvQdrNxwh6E9t7sKzwqPOCozn xSW/HL6q0VWvsl6FE4k1D4yP1iFjnsmmnSx6daBbmQFZB/aq87bYJJ+3MElBvMUnoWXC 8SMskFOG0j8FMgRYALoWxstbhSD4ytGQ5iWYzOpJO1RjGT55+iPm/beohkI4koBtJ9dV ESoPs8SoNjIHxQuLGj8oHDXign8qlBrH7Vcw6wU5ob1LNzZFEnVZEmhpdT13ISXi1rO4 a0uQ== X-Gm-Message-State: AOAM530l/Hv/tz/auD2gm0nhEhFr7GQm883wTH9V0l0PZpA5QmicSvW5 2Dc9XKl8AdXs/ZzVwHtPjeSEBSJ7beQOBg== X-Received: by 2002:a63:f91b:: with SMTP id h27mr10442676pgi.276.1591378664440; Fri, 05 Jun 2020 10:37:44 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net (c-73-47-162-176.hsd1.ma.comcast.net. [73.47.162.176]) by smtp.gmail.com with ESMTPSA id a19sm188307pfd.165.2020.06.05.10.37.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 10:37:43 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v2 06/13] tcg: call qemu_spin_destroy for tb->jmp_lock Date: Fri, 5 Jun 2020 13:34:15 -0400 Message-Id: <20200605173422.1490-7-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200605173422.1490-1-robert.foley@linaro.org> References: <20200605173422.1490-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::543; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x543.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 to fix some checkpatch errors] --- accel/tcg/translate-all.c | 10 +++++++++- include/tcg/tcg.h | 3 ++- tcg/tcg.c | 19 ++++++++++++++++--- 3 files changed, 27 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 42ce1dfcff..3708aab36b 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; } +static 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; } @@ -1230,7 +1236,7 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) qht_reset_size(&tb_ctx.htable, CODE_GEN_HTABLE_SIZE); page_flush_tb(); - tcg_region_reset_all(); + tcg_region_reset_all(tb_destroy); /* XXX: flush processor icache at this point if cache flush is expensive */ atomic_mb_set(&tb_ctx.tb_flush_count, tb_ctx.tb_flush_count + 1); @@ -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..c8313fdcf0 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -818,8 +818,9 @@ void *tcg_malloc_internal(TCGContext *s, int size); void tcg_pool_reset(TCGContext *s); TranslationBlock *tcg_tb_alloc(TCGContext *s); +typedef void (*tb_destroy_func)(TranslationBlock *tb); void tcg_region_init(void); -void tcg_region_reset_all(void); +void tcg_region_reset_all(tb_destroy_func tb_destroy); size_t tcg_code_size(void); size_t tcg_code_capacity(void); diff --git a/tcg/tcg.c b/tcg/tcg.c index 1aa6cb47f2..7ae9dd7cf8 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -502,7 +502,16 @@ size_t tcg_nb_tbs(void) return nb_tbs; } -static void tcg_region_tree_reset_all(void) +static gboolean tcg_region_tree_traverse(gpointer k, gpointer v, gpointer data) +{ + TranslationBlock *tb = v; + tb_destroy_func tb_destroy = data; + + tb_destroy(tb); + return FALSE; +} + +static void tcg_region_tree_reset_all(tb_destroy_func tb_destroy) { size_t i; @@ -510,6 +519,10 @@ 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; + if (tb_destroy != NULL) { + g_tree_foreach(rt->tree, tcg_region_tree_traverse, tb_destroy); + } + /* Increment the refcount first so that destroy acts as a reset */ g_tree_ref(rt->tree); g_tree_destroy(rt->tree); @@ -586,7 +599,7 @@ static inline bool tcg_region_initial_alloc__locked(TCGContext *s) } /* Call from a safe-work context */ -void tcg_region_reset_all(void) +void tcg_region_reset_all(tb_destroy_func tb_destroy) { unsigned int n_ctxs = atomic_read(&n_tcg_ctxs); unsigned int i; @@ -603,7 +616,7 @@ void tcg_region_reset_all(void) } qemu_mutex_unlock(®ion.lock); - tcg_region_tree_reset_all(); + tcg_region_tree_reset_all(tb_destroy); } #ifdef CONFIG_USER_ONLY From patchwork Fri Jun 5 17:34:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187566 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp2587452ilo; Fri, 5 Jun 2020 10:41:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrxY0KU4d9vhszc/pQVPh8tbldi+e50Z5wGROhSS0qTihTBYTdqL/dDhH0qLDH5VpkvYkW X-Received: by 2002:a25:810f:: with SMTP id o15mr17156558ybk.35.1591378897359; Fri, 05 Jun 2020 10:41:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591378897; cv=none; d=google.com; s=arc-20160816; b=EWypNWDJ6+TOeb8n1bs/JgZ9YdwEpdAHavyT7qww4IF34o8pOPTYVxlXu/vLLWkAps eFrvoTYJ0pq5cJBdHmYY6MhkV3MYtV0GB7SgvStpJkyVf+u9gg9hn82pf74qYMsog10M eQ7uiJXsCARjFqOvjfr32112+VA342aty+Uhm4ZQyQiBZ0EcxLhLVtzjFPptI6i+PiG8 6zndYJ4Pg4SGWkac3DAkFlSEOYkloid3ceZeFDArAgE2E+OP/2O/aPmt5Ht3NTA9h6Df sCUOWhLcyzV2leKRYQ012NHKP7wzHP236pVk/8r+syGTJ2PxIfU/TK0ZIMrP1H6C/aoF TYDQ== 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=v6Twul2TWinr3wq/OK/PDzXQA1fcuJlgD8ranJI4BbA=; b=sMWSHD51w44jjxY2gZSd9EpcgnY2xaqhjnV+Svr35J1G/IaaWQ15FXTmQEjKvSrNwz k8jbUoqISwDiaoxbx6HI8cOUQe4/dkC3U5tqbIAsJRltrx2RIv0QWkgT6uYW17M22LOq /38ZRZh4uZtZKLeFFXI2ZXU6ySO+DzxQVA9WPyyZVDEfRgidcZ2MTWUqBjz8VQb7gXQV kPJ1YfniNbw5qaVSqGxK4neXDIsIsCn8n7UnMb07xD9i/W0VChz25TfVCHjWyIYyChRM KybzlzNyORAJy7Agry+nYsEa3B+uoNdAHdt+wavdjFCNnkcrpmaE7TTcAieq8F/dxSLM bYWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EBdON3YY; 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 h65si8084830ybi.200.2020.06.05.10.41.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jun 2020 10:41:37 -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=EBdON3YY; 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]:43444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhGLY-0002Tu-P2 for patch@linaro.org; Fri, 05 Jun 2020 13:41:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhGHt-0003np-7e for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:49 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:42921) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhGHs-0003vn-DR for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:48 -0400 Received: by mail-pl1-x643.google.com with SMTP id x11so3970325plv.9 for ; Fri, 05 Jun 2020 10:37:48 -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=v6Twul2TWinr3wq/OK/PDzXQA1fcuJlgD8ranJI4BbA=; b=EBdON3YYo2xKvrGSBkHyEwTIAXa61zRQoHX8yCulu7uFXilzRYrcVWM9Dj1XeJV2OH dZ2faymKP5rnvE1O1bvGQUH8Qq/QqL89/F/HqqqMNeQ/dO4pJAlUkUG4ovAE90P+R0TF QogqOTUVIcCacRqHeMi5U3VPZ9ym2TkIODq1pCP/CeX9OE8DMY5qc9TIlsovpH6mL4+E JjoLdTMG0ijXuMtbUPf/7ifWt47C4IA2OkPYoNgnBQHxzDLLz89qtYl40dIRxyqFz+hl 4MArs8YLqh89qlM7ouspumwDrNtiqYp6t9QWGprph2ArY/KEqGuMbqDRms579/CpnLFh gw5A== 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=v6Twul2TWinr3wq/OK/PDzXQA1fcuJlgD8ranJI4BbA=; b=fZHtlg/sZlxRe+SItfo2jV3SzOVdn3k33vIX/ShWYNc9VgZe3SdfW7KHbRlaEThBvC gpuZoEK0GGrgKcA9qlp+PZWrRph6gX+9EO0CmlzQaManr6bkHcgKf9E0MzW6WEdXVTo3 Zex1d2134nwhxQHNzuRVmfJzY/KNuttBsQ6XZ1uiYryBV90Vny9sEU1Q6qdA5/1A9LG3 CGBTQ/VJfARHvWu6sKBl1fYF2QTiL0gYnkBBshy/OScXVfrbRGqsVOVMo+BTqx9qGAjV xt/zpeIU9Tg2m6osc14LgqvySnP/10RwhCBdyH2yPdOLMKpLp6pdXL7BPklC6BQI7656 43iA== X-Gm-Message-State: AOAM5326tW9mrFXAewq2PWfMCqjKBK7Bv09PclQdfcsFdoxyTL8Wvnup SYm24c2B5SKN/29kSj8oc8RaPwDYPWbLAA== X-Received: by 2002:a17:902:c3cb:: with SMTP id j11mr2968816plj.171.1591378666868; Fri, 05 Jun 2020 10:37:46 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net (c-73-47-162-176.hsd1.ma.comcast.net. [73.47.162.176]) by smtp.gmail.com with ESMTPSA id a19sm188307pfd.165.2020.06.05.10.37.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 10:37:46 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v2 07/13] translate-all: call qemu_spin_destroy for PageDesc Date: Fri, 5 Jun 2020 13:34:16 -0400 Message-Id: <20200605173422.1490-8-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200605173422.1490-1-robert.foley@linaro.org> References: <20200605173422.1490-1-robert.foley@linaro.org> 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: 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 --- accel/tcg/translate-all.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 3708aab36b..3fb71a1503 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 Fri Jun 5 17:34:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187568 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp2588978ilo; Fri, 5 Jun 2020 10:43:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOV3DTwZqypbryyQiqim/lVjtGAlMtioC1FJL3Eat580GK9J1oJa0dgy1yQj9JSRhZj1XM X-Received: by 2002:a25:a162:: with SMTP id z89mr18915906ybh.374.1591379032101; Fri, 05 Jun 2020 10:43:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591379032; cv=none; d=google.com; s=arc-20160816; b=JOjsgCwv7eQ4y01D2MUlhrbjzVnclRldWf1t6P/jxh9rdp/RTh0Gb+DE96b3LF/BVy t8bQ0t943oxuqNhx/dQMUUDaVXagoOnR/dp4HnUvjX3yYN/jxeQjwzyHU774nbjiPJaq DRbi0fiCtVZofS4eNKzVAP80f8u0a2mR4vqvuRn2IzFR2dEWrXopIXGkDxu+I3YoRH4S inVRlLd2IXZ278AUdg3ntNDRmyhf9ti0tOQEXeT71jBvmDLZOzCcHVqudvxaSKQSs/fD oJGi4EB05xACpmjUPsnRhn5AtPbrxWKEttknQ3c/gpXLUSRsx2h4Uk36QBj7PZC7FHLh BWvQ== 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=ev5Qz+MGN1Hx8ryzM5QfZBM3YQDJGJcHXx5yDm85VCqtZ5BtARWwhSKYcWXLZb/MBe GEHKpD7U3eBlC9oxhht8TSVfg1ofrYqCC3WH8NtPVQzQ6z8MkmLOH8MCK+3dr+RjZW6w dWJLEYH+hzM2YrGxcDXKl7rYOw9+WZwQ+NMmuCAqMvD5oLPAwz8fGPfGLmG88DIdgToW jBKdwVjwCIXdxzq+DPWCP0B1m76y7xbzCZYNka/zLO0qHiS8jjt7D3opaVDGt8vUF/w1 qqPpsjHfYXQK2xSeZ55djufircHVEvGptqczVKVlD9ibXabJeHx6O4ZXrlObQOQB/wBS KWVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=p3+nbVsy; 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 c6si6811559ybs.436.2020.06.05.10.43.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jun 2020 10:43:52 -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=p3+nbVsy; 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]:51040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhGNj-0005fa-K3 for patch@linaro.org; Fri, 05 Jun 2020 13:43:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhGHw-0003vX-H0 for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:52 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:37817) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhGHv-0003zi-MO for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:52 -0400 Received: by mail-pg1-x541.google.com with SMTP id d10so5523970pgn.4 for ; Fri, 05 Jun 2020 10:37: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=p3+nbVsy4PvU9tSN8xRzYq1rT4aICEHfHySZZAcW5Vyvhf3hbtLejt4hciR33Iy5fq qQyPULZoVJl2I7Wt3oGr9IOZ0k0Zud5btJERRQHzTRTJ9AzONKSPYFnMThYLxdJfhcTh oa0pN7Da4zMTF0UBqv2+awE8VaCP4y6BgvNhlJ5OyMkYRVE/i+P8bEd3xB37BUoRC3+v QLoI8kekdxRvAJGs7bPvnBtXWfjxCsvje/39SKCxlevf95ZqqFLZuhq9SZm9XpMp+ICG hCo1Rh9scqCRP5YlKLoKkcHgy4G+ZY3JY0O+6eaiw+yWvsyzJLD6UvUl4s0aEFMyvHhz gFXA== 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=uKb3YNqfYbAITfLBdwD2qWYQE9h1+v4tE1FJYlJ/2oEOarw+yn9R7NdtiBaExjWj+M RgmLnEReOdS0pmc3EvvR5A5rK2E44ULfl67YJ+qw85X+YAV0fjxHbWAKnMtgXvE/m7d2 z5yBV5V5ceD58ish3rd0sY2r24GUQDZZmb+fb6UyGgiikOFDBBfykxwlAQkfOqPDn4zK LT000l3njlRgkWvSD9nH1menUD1rhNzf+bPOpPrEkdw008DyaZ1BoELTqK0jDpiaaqvu o0XQsWxKvBEuSX4UgohBSWgahEZl6rLtj0rOFb+C9k5v2cS8UT0VVZ/lknrRm9l51+NH 6ecQ== X-Gm-Message-State: AOAM531jrXBNpQtJUigP/GFm3GDaB/znqJNI0O3xTkvRCEmXXyT+x+Q9 xNCxJKvKAv9U932Y93pGHaU26uEFaKOIug== X-Received: by 2002:a63:e60a:: with SMTP id g10mr10856361pgh.210.1591378669027; Fri, 05 Jun 2020 10:37:49 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net (c-73-47-162-176.hsd1.ma.comcast.net. [73.47.162.176]) by smtp.gmail.com with ESMTPSA id a19sm188307pfd.165.2020.06.05.10.37.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 10:37:48 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v2 08/13] thread: add tsan annotations to QemuSpin Date: Fri, 5 Jun 2020 13:34:17 -0400 Message-Id: <20200605173422.1490-9-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200605173422.1490-1-robert.foley@linaro.org> References: <20200605173422.1490-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::541; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x541.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 Fri Jun 5 17:34:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187569 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp2589862ilo; Fri, 5 Jun 2020 10:45:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBTjbolKoLj5Rqvl/5mnPdQfvVDYJMvMrL2trJRWmymMhc8lCzf+UOojv6h5s1OyHF/E4l X-Received: by 2002:a25:9746:: with SMTP id h6mr18021197ybo.409.1591379111944; Fri, 05 Jun 2020 10:45:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591379111; cv=none; d=google.com; s=arc-20160816; b=BlKWjpna12H/5/O451Fta/pF0CjJ07bWuWrXt6/mtu8ASszOfLSkp4DMZX0A/gtUuE BCBGWXu/kO+VOiaR26aHdAYVu4m8ugbXt04S2dTOellg2l2HoqIQHAILqbu0yF7oPQYw j3kvJIWmwNqv0Fr6k2yPHN+lbTqJtJJ0W/I0lZcEiTcFRTg+3wZAbpu6npsNl1P1gGQM QHoQaxB/ZLVuai4O148a/YwJ/9U69S/yaw8zS/krGHFuSLepCpKHf01w1B1+IMYvLAyt SYYNDKTm5z9cWN/tgBsUSFQ5RQQPAirLW5idyw+1Dam5nPMZHuzdoQct+Lkc2/dZWKcl TaNQ== 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=AXPq7Uy8g5ifp8uMXZd1qJX2wag4BCDXppVYNXcf0Dw=; b=jOoRXKfP4ISRASxk+bWF6H/dH7YrgfloT5ssaDF5baLwTE8CaLimUrgktr3KWC2KAq 2XtMmoNVMzRlrBbAn9WQhtnPkQyk8zkeLsCjW92/ghJQOGJEITvhH79yjJz2Qlhcceo2 hkIEhT6YHOb4NVe1loAjjb+Ez9F1u0nMfH4Q79qD14Pspy6ZxBH1IV1Tsmk59NZGzPbK il2kpLChRZcz3RaMgwYw+nkaUpMK3nSE7vJXnGK6OjyZucdNyPA9maUDgGNJ+ghEt+3Y aRrP7jE0Qc4nsGc5pUyiprK/+kqDPSYXTNJldSeRima8YE7WNyXZIgKIFn8ZMILIvWQs xO+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="fUUR/juA"; 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 66si8376246ybv.223.2020.06.05.10.45.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jun 2020 10:45:11 -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="fUUR/juA"; 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]:57314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhGP1-0008Cc-E4 for patch@linaro.org; Fri, 05 Jun 2020 13:45:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhGHy-00040d-B0 for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:54 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:45776) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhGHx-000410-37 for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:53 -0400 Received: by mail-pg1-x541.google.com with SMTP id n23so5483253pgb.12 for ; Fri, 05 Jun 2020 10:37:52 -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=AXPq7Uy8g5ifp8uMXZd1qJX2wag4BCDXppVYNXcf0Dw=; b=fUUR/juA87kUvzkHOXidkERsoZztFGGDQkhWhPKRV96NnsT1KWLuW7SB88q4l8ESuS Wshv1Dsy3x8ozU0I3fSn927FlGcc6CdgUbhY4zZrQQiglAxtJPbg+5RiASX4w2/6gbvc d0n3ErHBBHBvQUNTjoVRRsU60K8SHrnds1WR9eVY5VNT0/Q345Ra7zTEtE9dVQRzWPHG GIfKg4eRDwE3UHyDUrbrD6yk9XyG5OdTTmZJeUceP7vkJpCwd2r1XhzE5eHqUmgnJdhn nMuFtdyJQvfB83yDSJOslDY/lSXSp5sE7ZzI8Hj/8BXghikh6eux9Y9DjyduwlSLpwP7 k5FA== 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=AXPq7Uy8g5ifp8uMXZd1qJX2wag4BCDXppVYNXcf0Dw=; b=XAAWASD84R2utapT2l/g5R3EW+FsXvAOkr94HPMLfgZeW1sQJxYIcM+DAWQvnNlpLs ZBBER60f0IHDB2wW0cCdJoXtkWJo/VvMKx7QOz7TZ2u3a4vy/3N2OouLSGAR6slmjOa5 eTiLa0NhbgmWokpBGWjmg7C4She1I1upyrIwZpQ/E9PpXJyqwX/YWbCAod7H5wH2hl7w fTCvwJGI30HJzbHx8IZ/4mbf/DGKS/n7MSFr9wfCa2jW6LJdv443BD9OxNF/Z+GpYIgF XPcvrh+ole3NMbAnIcN41pe120UShL78944shjO2G2Sv6sh3vR5FpwABq8fx/1blB+9s Lf9A== X-Gm-Message-State: AOAM5330cXVjx3rQkowyQmIlRBTI8rIaYKqxjIs6x+IBziDmikq46gyU kZHxvEOur+sfhdP+ooyjXPF3CyQlLthJUw== X-Received: by 2002:a65:568d:: with SMTP id v13mr10411924pgs.436.1591378671434; Fri, 05 Jun 2020 10:37:51 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net (c-73-47-162-176.hsd1.ma.comcast.net. [73.47.162.176]) by smtp.gmail.com with ESMTPSA id a19sm188307pfd.165.2020.06.05.10.37.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 10:37:50 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v2 09/13] tests/docker: Added docker build support for TSan. Date: Fri, 5 Jun 2020 13:34:18 -0400 Message-Id: <20200605173422.1490-10-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200605173422.1490-1-robert.foley@linaro.org> References: <20200605173422.1490-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::541; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x541.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 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 --- 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 Reviewed-by: Alex Bennée 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 Fri Jun 5 17:34:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187562 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp2586127ilo; Fri, 5 Jun 2020 10:39:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykX0wOGhYa6XzbrOB6NTMMMBPyHzvp372eGSnpWZJuYGG+llTT7e3kHYovmS/aFsqa0ttt X-Received: by 2002:a25:f206:: with SMTP id i6mr18452486ybe.415.1591378781241; Fri, 05 Jun 2020 10:39:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591378781; cv=none; d=google.com; s=arc-20160816; b=NhSLecLWxGwopsvQwYMExM9m3K+jkw8kncsqj77tVB57FGRo+lenz75Oq4Qw8q3XSU 46/QxeohiYu6pUC/TFtT5yF3nbO0r3LDN4uFrIBztC0jtAAiv3IqfNH5ZOykPzN2AZla nAKpUGOqufeOQp46E3aYXMxgGV+7GhRmhzJb0l+X6a5P76GwDr952wKIhynZhml3ROif r4enDNLtP7+kSvVd7IUJN4oHIYnybfyBRqKXZn84NX7VvkQoljUJTOI/KWfZxyiMCnPn GWyXdDmTh4yrw+J20m+6yrLu4/oROgRlLh3kUN1L2R1aPj/J9H1jE12vmsFojAMxVlVQ rdBA== 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=AOzUAJyFNQB4L+phqsSsfzj9Z8OtZxOrajLi9NoXesk=; b=AmPDhu+dxu69UFz4cSrPEKFMbTgJQUMaz8PS0nq8m9bC8toB/J/OWzyV3/6hz76miG BeUBo93nKtFm3FGi3L+EzEzOTPHU3y88ICRzS6KhTQCj/KVWqqoaFjzeFGAEiwzQiorK gjq298PwqJ3X+Hs6vSOPCCjyB6g6t7w4q5wCX3qPniylXzLg/OrliMRM1X+v03ehhWzT W+OdQy9ElGqBU+sxys/T2fKbxVi0iXU19kQCj6rCGv6PgQjORZ6ROYuO2dso2T3tQTjT vMoFoPnK6NQ1pvcQjy8a9Shke9zr/WOYO1k1ya1kMdM+1pQbiShkld89pfx1upEivnx4 uJmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FW7YwxTb; 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 u18si6991181ybu.365.2020.06.05.10.39.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jun 2020 10:39:41 -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=FW7YwxTb; 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]:34798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhGJg-00073z-OJ for patch@linaro.org; Fri, 05 Jun 2020 13:39:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhGI0-00046j-He for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:56 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:44918) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhGHz-00041E-Gn for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:56 -0400 Received: by mail-pf1-x444.google.com with SMTP id f3so5263606pfd.11 for ; Fri, 05 Jun 2020 10:37:54 -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=AOzUAJyFNQB4L+phqsSsfzj9Z8OtZxOrajLi9NoXesk=; b=FW7YwxTbepxVhFcuU9CLDUQXHRQgNNhdh8JqqkQIeqt8MwWClu34MgBwJ4+2PjfIY5 Slxua9esPHR2CdKte+EkY7Y8+JVr3WstzJ2fv+Ths7xFB+aIumtnRJjIFnP9Y4FK7o8D 4TzTOMP0C1sOWR0W39VYJ0NsJiI5vQVdRID/ZXrKlDEfBRSrosHqWzqPj7Ya8w416WFR rpp9MPXK7YRxFKLZvZeU32myI2Jnw2MYtF9MbyTjrsFkKk9FAR0tdfCx3ss10D1cvYQa IGPaG05pC9diurhxuoyamTYWF3VeSihWekNYxAdwZdhGPZJYO4MKtz7c4yMnIvV4bwRW Q6yQ== 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=AOzUAJyFNQB4L+phqsSsfzj9Z8OtZxOrajLi9NoXesk=; b=TQAxa6uESLq+LP4ktYNCInb6tN3wUcwKaLGvY7p3W0bjGQ5cLBn+Wdv8xHsHbjr8Ib 878GK53yOgjWnSBak5XXABir/ElgYNNQu9aIJbRBTwiPE3N9QYVVLKXDhRGAlQhF3vTh gagyoI/9ZXnp75bB4/zeazZSvdJXwfNvqLvnDF633rf94arocE7f42aV0J6FHfaMtVdt OfN6Kk/nkXqz1KILxEeEs5nTc8egk5GSU/LEI/QRSVLjewHatThOj0ZZdFkWBrj6VEm3 BzsDRF5XNkSnJY50DWozweBcPut5oLEZo4fX4SYaJZTt6R/AcQwMZ84vZrx2GDTGy+Pe 0KbQ== X-Gm-Message-State: AOAM531699BHk1Uysz2KIbe3CZT9EXqVpSkSYm2ylrhGAJBK3TuJr9O3 l4MKDU6T/2RYJ0YSGhwIv62SgAx+Tz72dw== X-Received: by 2002:a63:1d02:: with SMTP id d2mr10615845pgd.206.1591378673552; Fri, 05 Jun 2020 10:37:53 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net (c-73-47-162-176.hsd1.ma.comcast.net. [73.47.162.176]) by smtp.gmail.com with ESMTPSA id a19sm188307pfd.165.2020.06.05.10.37.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 10:37:52 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v2 10/13] include/qemu: Added tsan.h for annotations. Date: Fri, 5 Jun 2020 13:34:19 -0400 Message-Id: <20200605173422.1490-11-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200605173422.1490-1-robert.foley@linaro.org> References: <20200605173422.1490-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::444; envelope-from=robert.foley@linaro.org; helo=mail-pf1-x444.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 --- include/qemu/tsan.h | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 include/qemu/tsan.h -- 2.17.1 Reviewed-by: Alex Bennée 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 Fri Jun 5 17:34:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187565 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp2587438ilo; Fri, 5 Jun 2020 10:41:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwveq9eltT1o/jqQzmdxtTfzPoKy//FrheTeHX+iwLatkVsWaSLerI3Xv99uETKrzQwRixP X-Received: by 2002:a25:bb47:: with SMTP id b7mr16984789ybk.200.1591378895792; Fri, 05 Jun 2020 10:41:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591378895; cv=none; d=google.com; s=arc-20160816; b=R8rXCOPiqMF+mGY0R+EUJiGGzF25yNBWDQu0tR/XW+d3Wq0iDnCzbp7hIcKTx3iktE XVZWAp7QRZS7bp8hrHKAonfYWroPYHVSW56BH4H8iJ6wptM9tU+ZcGZdJ3z3OBMT84Zs DrDANbXzged9Icjswfcfs8F8k5vru+CoN3YC67jWTV95gF/d9Dv7lsRgZJRow9+wgIGH vNR8DdH45bHKnwxC0TSsKvSO3IOFwJkYOf2PNz/kR7G6vyVymgzieZESHrgjNZptpVEn yrXoy05Zz+T//+1CQPPgcBW+Jx1njLbUTTbi8B3fC4swzCMj1ykxHi2kSt0n+W822VwD q6tg== 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=A8n3vWLPzwieeynjxdOaVUexMITsops1GUeZsneuY9NGeRralhp1EuGUbezPJEPUFC EWU72MVzJVU0baHZ3NEtkVad1yMapMSUJNZWhI8xfEU2jePOveVUMi+R6G0/3vKOu37c Ko3/0Lu2GoHIKxI/Kcb6YoByNPOAhuUOFohaJJDbCmpDU/MjLEvIsihqrGnSKBpEw4tl JlvOIrz9If91KjzdWD6hNnKnlwfyEFkUz1tb0u0oEHr0j+TOs0VlFN7ZxlgG3PUK1Kud doK099dUInNiWVOEXggliQYTnbmAhi0UVZgvoMi5sgpaf4UMiRhIw8fihKirAG/8hfnL ImDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Pb7YG1V/"; 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 o2si7109101ybq.88.2020.06.05.10.41.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jun 2020 10:41:35 -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="Pb7YG1V/"; 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]:43344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhGLX-0002Qo-5d for patch@linaro.org; Fri, 05 Jun 2020 13:41:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhGI2-0004Bk-6h for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:58 -0400 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:54198) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhGI1-00041L-At for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:37:57 -0400 Received: by mail-pj1-x1042.google.com with SMTP id i12so2952457pju.3 for ; Fri, 05 Jun 2020 10:37:56 -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=Pb7YG1V/Bc6/e68fO44j042QeV5pS685k3SzEN9JMM8i5rIjB47b4i0OyCCLtjp+KQ 6stzaFiwg+D7f0syW+O5RT/6ph5E6kxe5oQ6YZ6B+pwjiloLjto0rPT1L/tokSUIFc0f Egy1oplXvb+OyFUm8BeXEVY6zOVyu7lisfzTbqsM62tOsfpChEKcVpWlx5s8bmEDzjIK v2KBBuiGkwKCD7iStGTynAP0gNEHKNYppjTtEwZZmXuoj8VV3VDHJmVRCjc4OHiyvF0h YStOIO2lIXx/KD+KC2xByHvbzaU/v9BAdMeiZJlONus4vXqUCMincrxX9bFd3u4cnozN qzfA== 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=M4ceFjfHudfbRR0smxknOxwgDzjbB7gb14ZX0Uiwxyn21sgDEpBRktS3ncdu58Sl8k tLSHL07WAqe0hUNPPUS4Jo6Ji0EnmUTYKBhb3FglI2k7qQiaAIeby1gFqqxxQv7aoVYZ kgk7wvWsTQT+MUqfU5D37RDvNt5TOd8LYNea7AEtMxwy3+7kU19d+lmYhZJ0OpZRpjPb ChQJN/RkGBp+Z9ve/8LkZVHTEBOQgyVxcNFwG7VCv7Wjv61w1Xb8lralncGlh5UZIM+r 7L6GYh1KzcCPtopMj8/GSHJGMhe6d08MTUltAW6QmGsSVGrSoHkMwLAJg9wRkOER3P03 ifpw== X-Gm-Message-State: AOAM5325dC5MZ7Bot228yOzjSRcIAS39twM63u6w+8updpIWst85cxzm GAMA8GZ1WcD8F6M+F6MpJ25kdqWj1vpsgQ== X-Received: by 2002:a17:90a:8594:: with SMTP id m20mr4199964pjn.38.1591378675749; Fri, 05 Jun 2020 10:37:55 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net (c-73-47-162-176.hsd1.ma.comcast.net. [73.47.162.176]) by smtp.gmail.com with ESMTPSA id a19sm188307pfd.165.2020.06.05.10.37.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 10:37:55 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v2 11/13] util: Added tsan annotate for thread name. Date: Fri, 5 Jun 2020 13:34:20 -0400 Message-Id: <20200605173422.1490-12-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200605173422.1490-1-robert.foley@linaro.org> References: <20200605173422.1490-1-robert.foley@linaro.org> 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, 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 Fri Jun 5 17:34:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187560 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp2585681ilo; Fri, 5 Jun 2020 10:38:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFLnBtydcoVIMnwga+9pMX6xn+xfxqZPERLf8eCg1hRSEqd0ODqVqVq987eL0StAr1sLY7 X-Received: by 2002:a25:d7cc:: with SMTP id o195mr18529809ybg.37.1591378739118; Fri, 05 Jun 2020 10:38:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591378739; cv=none; d=google.com; s=arc-20160816; b=YZF1z2oR30H2l+ElPlQqQpM7vsEC8N2gGQMparXFx5McucgVpx09zFz41YZhIKMn1h trzJ1XBBW9CEbaMCrg0n7fswT/IE005LaXDmpbFyI17iJuPhgL8MnkGz3CjQ6dShdgKd db8ELzpASMiQ/bu3zaetvLRgFBxDSJ2CeNVQpO0KYipGOMkzjWFT8WnQ1wy9qQIOGkJ0 bbvp53tdNdAOaKBO5y+GkC5JC02J3CMEz23hedE5HFlgXZPbx0HLhjvLPP6tf+dptuRJ sAnkLciR9x1i36/H9ieuhHMQGpmeKSfZ9biILKqUZMUVcyIVnAn3QGGtLZvLnPymfBGP y5DQ== 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=XzO4d9NfxHhnWYA5ypuQ0LUhD/s+5379iGqovYIf/8k=; b=javWY5ujxRzjwnYya2pKt3eHU8QlPgyFsWETb2FxLPNm/WhRJrAPSKsRmIvrC2yd6I DNIaqf5w8jt81OkdhmmV7RhGPI0YRCrmSGL71OL5KDVh43rWTGGq9m4V5iZEHjO7sv22 uFhXq+lveQhdv2gAFw5vB58XH7F5sb64VoLs1aD3nLWnaeapCPaBQOlJt53iHgLZqQj+ hxHLJbnKK7FLPXiEsoRXhinTaU5wCovqYpcprXuLlpI7lSj3vBsISh83A3h7xQibLjxH vVDtC4AMAG0wRFUvs+vD556zepsQWuOR4eBC7zNq8d21j4NttW29/RWcp1YF/2YTBkcV 6v6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=y52sj9Ax; 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 125si7458802ybh.403.2020.06.05.10.38.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jun 2020 10:38: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=y52sj9Ax; 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]:59488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhGJ0-0005OD-HL for patch@linaro.org; Fri, 05 Jun 2020 13:38:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhGI4-0004Im-Lw for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:38:00 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:40782) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhGI3-00041W-Hk for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:38:00 -0400 Received: by mail-pf1-x442.google.com with SMTP id s23so3961015pfh.7 for ; Fri, 05 Jun 2020 10:37: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; bh=XzO4d9NfxHhnWYA5ypuQ0LUhD/s+5379iGqovYIf/8k=; b=y52sj9Axg0xBsiHEVC44k/0Dm4IwyON9v7OpxX7YRbq8zlTRFJRXav3d11iFUrOQ38 oOBaP2GKKeHWzmUc8MtXZg+DoL5OG2sFCztWiYy/qwAl4VkgRMECZMZJjzPUjsnysh+R eWZzBcDBtWHePCEdQXowVjdKpzNJxMnO2wRSZEqsCfG4lX6SPn3HbCej/RbwJyiYCjPT n6beifZUWT5BIgt/7W0c0FjsfUiPHMYrGOZTIw58hjWgxjvT4uxGApLneL+f0O1NezGG /LV3+jeU3Sjl7UeOjqA28YslsxtA5DfvV9GOBkId5O3/V9/9/uxkMslcnsmJRE4YOAtT yjzg== 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=XzO4d9NfxHhnWYA5ypuQ0LUhD/s+5379iGqovYIf/8k=; b=MhOuAcxG0oLIHPttFrV8kX1I2yyNTDPQOD0NE4fmPOfV1185DAk5r+t8+SdFQVKeqC xByKDeSak2mLExhhcRcRno3ortlmMb28+g0yyXsiScWUJwagXf8TvZo4/dW2YKuEAbEb NpX3Vicf3T570z27FtyBq0vHJtFBrKbG+jJILuOaDkf9chViN/3yj9mlGYFQ5gBkMj29 jwoTMLWvEdQon66mkzhYU5lQsnAAyrcQog2r0D3ruWHuYlAMflAOXdeLCxEXMTQpADcC gILqOMymxR9twkePsunNUaKpdw4iAjPvR40senRG0/ZKoUwZ63IHYYw2F40WBh5fxxzs p/+A== X-Gm-Message-State: AOAM532Mn/mJQy5Ycp05T4q+6q+RXeV112K/ZkBID8RmDZQ+g2jb8Hvd M6tLLSk+q885aFFwnBcJKx+Gj99rVuGHDA== X-Received: by 2002:aa7:9a5a:: with SMTP id x26mr10972302pfj.307.1591378677823; Fri, 05 Jun 2020 10:37:57 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net (c-73-47-162-176.hsd1.ma.comcast.net. [73.47.162.176]) by smtp.gmail.com with ESMTPSA id a19sm188307pfd.165.2020.06.05.10.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 10:37:57 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v2 12/13] docs: Added details on TSan to testing.rst Date: Fri, 5 Jun 2020 13:34:21 -0400 Message-Id: <20200605173422.1490-13-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200605173422.1490-1-robert.foley@linaro.org> References: <20200605173422.1490-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::442; envelope-from=robert.foley@linaro.org; helo=mail-pf1-x442.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 --- docs/devel/testing.rst | 107 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) -- 2.17.1 Reviewed-by: Alex Bennée 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 Fri Jun 5 17:34:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187564 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp2586674ilo; Fri, 5 Jun 2020 10:40:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7mYakaX9W1wQMCI4U6JFzwfjJF7PyPduEvjsuMPcmrnfdu2sYBnxeCixP2upAbcAq2z/3 X-Received: by 2002:a25:8b04:: with SMTP id i4mr17684011ybl.399.1591378832864; Fri, 05 Jun 2020 10:40:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591378832; cv=none; d=google.com; s=arc-20160816; b=FIL5SZTJM0bF+1a4PHBD3MWljQOee7ZL6ssAImEyo8Yv2/1DOjm8lDXFgume/McC81 rQJx8DXnf7yehCyDVuDG8CbS944/w1Sjg2rZzzE8yOye+YIZKamGy8Ru8ojqBYDytbRD gJzminXiBUSBTgQyhH1Fv5d0oGrsJ1lhZQcTQCZcz6i6cMKZ1hFPwcwWzOREQfkoij2T 5kjUcFMQAOskz5E5EFweWXAJG6efWVvn+HhqAWcwxo3Qdb0RNmrdD1SOg4orjhBuda3A FP8Y7T1EOIR89iPkBG9J99gK9ZrE392GN2rY2YFK7jRs0nHeKgPyq5hD8eAuyH1DaKED 6ZtQ== 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=803eDYLxeJBOM1lm3oQCQ/DECicGijz33nVW4BPgwBQ=; b=mk4prqyE/WAKip/DRXTUyJTf+PRtCVY0t2lRdK0xnlKjhLVtobPJoHktcpKBPVScT4 MFK5n71IPfnR68rKkMzmxMY4wNP/NNh9uYJWS4ppNzuwCxHGgVv4ytkpZSH+iI/YAkym /equu1dgzJ0IHFjO8rzZM7P+83ZQ/lHx4nxSqb/RV/AntVhXsgv10T5V4EVrMEbTn20c iqgULMM9clIu4OEE/hYfsyQmT1f+An6AzKcZTUHz2oMCHl5qeFpgJmHaETKrbUXBrpGb j0BXFoQXW7aJrRIadwQD3ifiBgALT4pPwz0Mjm+82HMlZ5C3OV4WaPrqHrBdP7oE2S0D SmJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ivveq8k5; 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 a18si7048068ybs.368.2020.06.05.10.40.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jun 2020 10:40:32 -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=Ivveq8k5; 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]:39730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhGKW-0000w4-8z for patch@linaro.org; Fri, 05 Jun 2020 13:40:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhGI8-0004PG-11 for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:38:04 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:45699) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhGI6-00042q-W7 for qemu-devel@nongnu.org; Fri, 05 Jun 2020 13:38:03 -0400 Received: by mail-pg1-x535.google.com with SMTP id n23so5483546pgb.12 for ; Fri, 05 Jun 2020 10:38: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=803eDYLxeJBOM1lm3oQCQ/DECicGijz33nVW4BPgwBQ=; b=Ivveq8k5c6Bre34x7c3IBsxeBk/DMPW9wMxl+uG2Dvk0eW70QxO/XpguNZ4rrVQGnq g19ToVLqZy0pOju9y5wB6D7Po88nYsQ1oSiZfCl5Kz8IeKSI0XK5P1gU/b+NgiSIf8J/ taQ7yiqVZsCKThcJtNBBjO1Nv15TOvUEA79Aiziyd4GZHKJr5of8NrAztqTswF7/XLPz o2XE7EK2C4ktOeuLnt+zuqSIXrfxK/9ml7WgPJU6AWAQA+pYxa0jV2AxGULtcgVdf6mc 05w+CtKfIqvoopfzMqZC+k7nyVb66L/BJSUyGkXcUAHBzd3f71IFDqW7c7RWy/rigH8k YaJQ== 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=803eDYLxeJBOM1lm3oQCQ/DECicGijz33nVW4BPgwBQ=; b=g6rTyGq6TN5ASISsDpp8CLFhWu9/wm2z/0t8IpQ30N/WY6aLmLimLPuWm7skZKXMOh avbH0s7exXVD6M7pe8rGcUXfweQPbL1kjb/nmpUDFnXp6SR1zfE+yECJsRaMTKLP5ciZ eXgGsCqa+49Ko4jQZi13k6YGrWN3Ga3DCqyxaE18mluoZonOVCq1dtK5AYQhdCLHXArx GAUJwYXiddM620mHxFe7g7LAeDiQNHiFUwfcmaUEB43O0OJ1g8A/+AscqUqIRcD1W66M GuT07DpsFoTRY9E3FjObzMS75sEcOqaOKF9XQncSCClyN7zSs76DQr1o2M96wFqYQ7zG +4dA== X-Gm-Message-State: AOAM531cuwbiOtSzQFkoa+1zj8gGw9eYLXCmjQd8s1uQDYN7/HTK5sCE ViLiQxuLOQDdzPmk1+aewdkLaLZqFaoUKw== X-Received: by 2002:a62:8487:: with SMTP id k129mr10934010pfd.296.1591378680322; Fri, 05 Jun 2020 10:38:00 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net (c-73-47-162-176.hsd1.ma.comcast.net. [73.47.162.176]) by smtp.gmail.com with ESMTPSA id a19sm188307pfd.165.2020.06.05.10.37.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 10:37:59 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v2 13/13] tests: Disable select tests under TSan, which hit TSan issue. Date: Fri, 5 Jun 2020 13:34:22 -0400 Message-Id: <20200605173422.1490-14-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200605173422.1490-1-robert.foley@linaro.org> References: <20200605173422.1490-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x535.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 --- tests/Makefile.include | 9 +++++++-- tests/qtest/Makefile.include | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) -- 2.17.1 Reviewed-by: Emilio G. Cota diff --git a/tests/Makefile.include b/tests/Makefile.include index 6e3d6370df..874a2990b3 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -53,7 +53,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) @@ -106,7 +105,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-y += 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) @@ -121,9 +119,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-y += 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-y += tests/test-timed-average$(EXESUF) check-unit-$(CONFIG_INOTIFY1) += tests/test-util-filemonitor$(EXESUF) check-unit-y += 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)