From: Stephen Hemminger <stephen@networkplumber.org>
To: Dengdui Huang <huangdengdui@huawei.com>
Cc: <dev@dpdk.org>, <lihuisong@huawei.com>, <fengchengwen@huawei.com>,
<haijie1@huawei.com>, <liuyonglong@huawei.com>
Subject: Re: [RFC 1/1] build: support ThreadSanitizer
Date: Tue, 31 Mar 2026 10:50:09 -0700 [thread overview]
Message-ID: <20260331105009.221272db@phoenix.local> (raw)
In-Reply-To: <20250408130556.1054041-2-huangdengdui@huawei.com>
On Tue, 8 Apr 2025 21:05:56 +0800
Dengdui Huang <huangdengdui@huawei.com> wrote:
> ThreadSanitizer is a tool that detects data races. It consists of a
> compiler instrumentation module and a run-time library.
> Typical slowdown introduced by ThreadSanitizer is about 5x-15x.
> Typical memory overhead introduced by ThreadSanitizer is about 5x-10x.
>
> UBSan is integrated with gcc and clang and can be enabled via a meson
> option: -Db_sanitize=thread.
>
> Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
> ---
This didn't look right to me, so asked AI for review.
Please address these comments.
Review: [RFC 1/1] build: support ThreadSanitizer
Patch 1/1 - build: support ThreadSanitizer
Commit message:
Warning: The commit message says "UBSan is integrated with gcc and clang
and can be enabled via a meson option: -Db_sanitize=thread." This is
confusing -- UBSan is the Undefined Behavior Sanitizer, not the Thread
Sanitizer. This sentence appears to be copy-pasted from the UBSan block
and should say "TSan is integrated with gcc and clang..."
Error: The patch uses `get_option('b_sanitize') == 'thread'` (exact
string match) but upstream ASan and UBSan blocks use `.contains()`.
The meson `b_sanitize` option accepts comma-separated values like
`'address,undefined'`. Using `== 'thread'` means the TSan block will
NOT trigger if someone passes `-Db_sanitize=thread,undefined` or any
compound value. Must use `.contains('thread')` to match the existing
pattern:
if get_option('b_sanitize').contains('thread')
Warning: The ASan and UBSan blocks for GCC both add the library to
link arguments and to `dpdk_extra_ldflags` so that downstream consumers
(pkg-config, static linking) also get the flag. The TSan block is
missing both:
add_project_link_arguments('-ltsan', language: 'c')
dpdk_extra_ldflags += '-ltsan'
Without these, the DPDK build itself may link (meson's `b_sanitize`
adds `-fsanitize=thread` to the compiler), but applications linking
against DPDK's static libraries via pkg-config will fail to resolve
TSan symbols.
Info: TSan and ASan are mutually exclusive -- they cannot be used
together. Consider adding a check at the top of the TSan block:
if get_option('b_sanitize').contains('address')
error('TSan and ASan cannot be used together')
endif
This would give a clear error message instead of cryptic linker
failures.
Info: It may be worth adding a `dpdk_conf.set10('RTE_THREAD_SANITIZER', true)`
define (analogous to `RTE_MALLOC_ASAN`) so that DPDK code can use
`#if defined(RTE_THREAD_SANITIZER)` to annotate custom synchronization
primitives with TSan annotations (`__tsan_acquire`, `__tsan_release`,
etc.). Without these annotations, TSan will produce many false positives
on DPDK's custom locking (rte_spinlock, rte_rwlock, rte_ring) since
these use inline atomics that TSan cannot automatically recognize as
synchronization. This would be the main value of build-level TSan
support beyond what the user gets from just passing `-Db_sanitize=thread`.
prev parent reply other threads:[~2026-03-31 17:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-08 13:05 [RFC 0/1] support ThreadSanitizer Dengdui Huang
2025-04-08 13:05 ` [RFC 1/1] build: " Dengdui Huang
2026-03-31 17:50 ` Stephen Hemminger [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260331105009.221272db@phoenix.local \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=haijie1@huawei.com \
--cc=huangdengdui@huawei.com \
--cc=lihuisong@huawei.com \
--cc=liuyonglong@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox