From patchwork Fri May 22 16:07:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187185 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2651472ilb; Fri, 22 May 2020 09:24:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcPxi3pfFtE0K66wq/bhe1ovKs2jpJ5YAHHyNYJWxy+Indgi7GCbg0rKjJv7ApQ2VW+HcU X-Received: by 2002:a37:e309:: with SMTP id y9mr6646034qki.206.1590164684527; Fri, 22 May 2020 09:24:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590164684; cv=none; d=google.com; s=arc-20160816; b=zf1l1dDZA8e1PY7H+7fVyU5UCA6lRP6AucEJl1UtxCFI+RLrjWXN9GUApQHyIN0k+Y RBvpjDNdQzftsIPr6RzkCE3I8gqV8eoQWvGR4hHe0852vDQmwjQTdGB76A5UTkVyi3Fj R9SNd1vDfyZ5DoMMg4q7HV2uvapudBW9GesN5Wn4gEny9wlQzDdwVBxlJ6lG8tszT6aT e8VrJ1U79MFbqPq1VKWPTKrORxqmfDaIzwasd74Vf67DqqemmIlDAlkgSIfSxjcn2mv9 fZ709ifEC2cbdf2djRfVsI6x8r/v8ap/7GxiytRLCrUjFsl+XVf1APtKPdfFO9F9rN+e CJfw== 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=NheIrwAPnCYgtMEumEcCojybpzE1xkpB6QxsKMCy5vo=; b=VSrIcQ1M4UYOKEJ1+nnCh/i1CC+v+EgGOHWf1ZUWbk7ZZnB7cqnKMrF6phnzGymaXs lg4z9NOEdH+hY1kYwgsQ8V5ilbamDFfDB9I1Fje7FU8YtqDRS9o5G4O+VcLDOv8fK3Wn AV6k7fR8+Kmeqt8ce6Sy6TYMkKU0D0fSw8z4B2sVpSz1+OQg3y2AyT7RAHX1xdJs+Fm5 fLXGqOY4+rydCGAu3GsM2XxUbvDllVfBHEqX6GEclTdNyneiaBSSHJiPDjG3ig5q4SXD Z/WMqNq35qx0QMNDlCS81OMf/9XGyunYrd9MnIWG5qUkFhvvKVSr1E3S6nwv9MudANN3 Bzzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GaOU4WrC; 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 d12si5328334qvv.24.2020.05.22.09.24.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 May 2020 09:24:44 -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=GaOU4WrC; 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]:57800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcATT-0004op-UF for patch@linaro.org; Fri, 22 May 2020 12:24:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcAKj-0003dT-0h for qemu-devel@nongnu.org; Fri, 22 May 2020 12:15:41 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:35635) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jcAKh-0006JT-Qp for qemu-devel@nongnu.org; Fri, 22 May 2020 12:15:40 -0400 Received: by mail-pl1-x644.google.com with SMTP id q16so4580738plr.2 for ; Fri, 22 May 2020 09:15:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NheIrwAPnCYgtMEumEcCojybpzE1xkpB6QxsKMCy5vo=; b=GaOU4WrCYODdrY8UKoFMtLv93SAadUOT5ArmGLTkLq+AHpZuoiQFKQa+IMWvS0lqss eU1I/J1b/i1fjNWgHGMWmfCs0DqwAFCfyHOLqIWAcc1nLx2rXo+mN6xj6nMon+vf0s7J luKu8y9Cnp1/85Pg2i6b5x6mGOyj9vwfRkJ32xqFkDZYjUozjAF1K+FqaghHX3Upkv3z mfCKIalBSdooEGfy2aFGy8wMxxUjW9pVG7JhdMTJCvQO+8pf6DOiCbAhTuZSRs1Et0t8 7awqt4hUHVwdahTXHmTy61xcSotRSKqnm87yraG6gd9KkearXHhKabyht+ACBtReFNuQ 2HOQ== 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=NheIrwAPnCYgtMEumEcCojybpzE1xkpB6QxsKMCy5vo=; b=jNoeHJwVq3BEI1ZHDbQm67Jt1mL5JFKQEDToNRsneunZ9a/sLecq8G8wGdnFm5shWJ 21sHBv4+9mioUjrxbfutpEi1fkEsSXbqcuPHkdn/o/EfEiwV4aQZNP8nAIyAE/RQ+zL/ 2hWuh3MfOEYbBZM/ijcd75GslD4zVYyOAXWw9DGR8LmTIAv6sG/pHq9GoCgbFtbrqAee XvETVZCBT0muB4xHHK059dj3DLRDses7Uh5gM3x3MV+MnwAQajM5Wjwpsg6KTyaj6pbx FxCMnOZWIvQsP029HUSGq2XHZ8Vf7Al/Vn1/ao9EQtDsQfTtgm5H63Y6Tavtwh/UjUVa o9Dw== X-Gm-Message-State: AOAM531+lzV2w6/x+cehvVBQ3ic5gdPfg2S4dApal6wHPjG7EXJCZr+Y nULmQ/NEShmW+8hDzgIdhmqlycj8MaSDFA== X-Received: by 2002:a17:902:44e:: with SMTP id 72mr15445673ple.301.1590164137952; Fri, 22 May 2020 09:15:37 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:f1d9:5fce:c451:d2e2]) by smtp.gmail.com with ESMTPSA id y75sm7255428pfb.212.2020.05.22.09.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 09:15:37 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH 19/19] docs: Added details on TSan to testing.rst Date: Fri, 22 May 2020 12:07:55 -0400 Message-Id: <20200522160755.886-20-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200522160755.886-1-robert.foley@linaro.org> References: <20200522160755.886-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::644; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x644.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.puhov@linaro.org, cota@braap.org, alex.bennee@linaro.org, robert.foley@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This includes details on how to build and test with TSan both inside a docker and outside. Signed-off-by: Robert Foley --- docs/devel/testing.rst | 72 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) -- 2.17.1 Reviewed-by: Emilio G. Cota diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst index 770a987ea4..5b0a828068 100644 --- a/docs/devel/testing.rst +++ b/docs/devel/testing.rst @@ -397,6 +397,78 @@ 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 +================ +TSan is currently supported in the ubuntu2004 docker. + +Just add the TSAN=1 argument to use TSan + +.. code:: + + make docker-test-build@ubuntu2004 TSAN=1 + +or + +.. code:: + + make docker-test-quick@ubuntu2004 TSAN=1 + +The runtime behavior or TSAN is controlled by the TSAN_OPTIONS environment +variable. We set this variable automatically to for example, maximize +the number of warnings TSan can find and also to specify the location of +the files with TSan warnings. + +TSan warnings 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. +A few important files to note are: + +tests/tsan/suppressions.tsan - Has TSan warnings we wish to suppress at runtime. +In some cases we choose to put suppressions here since the resolution is +slightly finer than the blacklist, since we can disable by warning type. + +tests/tsan/blacklist.tsan - Has TSan warnings we wish to disable +at compile time. + +include/qemu/tsan.h - Defines various annotations which can also be used +to give TSan more information some example uses are to allow suppressing +TSan warnings, or annotating thread names so they show up properly in +the TSan warnings. + +TSan without docker +------------------- + +It is possible to build and test with TSan outside of a docker, but with a +few additional steps required. +These steps are normally done automatically in the docker. + +First, to configure the build for TSan: + +.. code:: + + ../configure --enable-tsan --cc=clang-10 --cxx=clang++-10 \ + --disable-werror --extra-cflags="-O0" + +There is also a one time patch needed in clang-9 or clang-10: + +.. code:: + + sed -i 's/^const/static const/g' \ + /usr/lib/llvm-10/lib/clang/10.0.0/include/sanitizer/tsan_interface.h + +When running tests, the TSAN_OPTIONS environment variable needs to be set. + +.. code:: + + export TSAN_OPTIONS=suppressions=/tests/tsan/suppressions.tsan \ + detect_deadlocks=false history_size=7 exitcode=0 \ + log_path=/tsan/tsan_warnings.txt + +The above exitcode makes 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. + VM testing ==========