[PATCH] D60593: [GwpAsan] Introduce GWP-ASan.

Matt Morehouse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 12 13:45:26 PDT 2019


morehouse added inline comments.


================
Comment at: compiler-rt/lib/gwp_asan/guarded_pool_allocator.h:55
+    if (UNLIKELY(SampleRate == 0))
+      return false;
+
----------------
morehouse wrote:
> hctim wrote:
> > eugenis wrote:
> > > morehouse wrote:
> > > > It would be nice to avoid this check on the fast path.
> > > > 
> > > > Perhaps we can do `rand() % (SampleRate + 1)` and then check `SampleRate !=0` only just before we would return true.
> > > Or it could be another special value of NextSampleCounter, which could also serve as a way to temporarily disable sampling in a thread.
> > > 
> > Yes and no. We would have to set `SampleRate = Opts.SampleRate - 1` to get precise sampling behaviour, which would make a sample rate of always on ("1") be the same as uninitialised.
> > 
> > I've added another flag `IsInitialised` in order to counteract this.
> This doesn't seem any better.  We're still checking for initialization on the fast path.
Sorry, disregard the last comment; it's actually not on the fast path.  This looks like it will have better perf.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60593/new/

https://reviews.llvm.org/D60593





More information about the llvm-commits mailing list