scudo: Make it thread-safe to set some runtime configuration flags.
authorPeter Collingbourne <peter@pcc.me.uk>
Fri, 25 Sep 2020 00:01:24 +0000 (17:01 -0700)
committerPeter Collingbourne <peter@pcc.me.uk>
Wed, 30 Sep 2020 16:42:45 +0000 (09:42 -0700)
commit719ab7309eb7b7b5d802273b0f1871d6cdb965b1
tree599453fdad91abd2d4a6741978368e47dded2bca
parent4fcd1a8e6528ca42fe656f2745e15d2b7f5de495
scudo: Make it thread-safe to set some runtime configuration flags.

Move some of the flags previously in Options, as well as the
UseMemoryTagging flag previously in the primary allocator, into an
atomic variable so that it can be updated while other threads are
running. Relaxed accesses are used because we only have the requirement
that the other threads see the new value eventually.

The code is set up so that the variable is generally loaded once per
allocation function call with the exception of some rarely used code
such as error handlers. The flag bits can generally stay in a register
during the execution of the allocation function which means that they
can be branched on with minimal overhead (e.g. TBZ on aarch64).

Differential Revision: https://reviews.llvm.org/D88523
compiler-rt/lib/scudo/standalone/atomic_helpers.h
compiler-rt/lib/scudo/standalone/combined.h
compiler-rt/lib/scudo/standalone/options.h [new file with mode: 0644]
compiler-rt/lib/scudo/standalone/primary32.h
compiler-rt/lib/scudo/standalone/primary64.h
compiler-rt/lib/scudo/standalone/wrappers_c.inc