[all-commits] [llvm/llvm-project] b62b7a: [compiler-rt][builtins] Switch libatomic locks to ...

Logikable via All-commits all-commits at lists.llvm.org
Tue Jun 4 11:19:57 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b62b7a42bbee4a3bbf9094808f460fdc9c119bd7
      https://github.com/llvm/llvm-project/commit/b62b7a42bbee4a3bbf9094808f460fdc9c119bd7
  Author: Logikable <seanluchen at google.com>
  Date:   2024-06-04 (Tue, 04 Jun 2024)

  Changed paths:
    M compiler-rt/lib/builtins/atomic.c

  Log Message:
  -----------
  [compiler-rt][builtins] Switch libatomic locks to pthread_mutex_t (#94374)

When an uninstrumented libatomic is used with a TSan instrumented
memcpy, TSan may report a data race in circumstances where writes are
arguably safe.

This occurs because __atomic_compare_exchange won't be instrumented in
an uninstrumented libatomic, so TSan doesn't know that the subsequent
memcpy is race-free.

On the other hand, pthread_mutex_(un)lock will be intercepted by TSan,
meaning an uninstrumented libatomic will not report this false-positive.

pthread_mutexes also may try a number of different strategies to acquire
the lock, which may bound the amount of time a thread has to wait for a
lock during contention.

While pthread_mutex_lock has a larger overhead (due to the function
call and some dispatching), a dispatch to libatomic already predicates
a lack of performance guarantees.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list