Annotate a benign data race in TraceBuffer

If the producer changes data in the shared memory buffer while we are
copying it to the central trace buffer, TSAN will (rightfully) flag this
as a data race. However the alternative would be trying to validate the
data before copying, but this is much more risky since it can change at
any time. Instead, we ignore this benign race and perform validation
offline.

Disregarding malicious clients, the only case where this issue arises is
when we try to scrape chunks from a client which is still actively
writing to the SHM buffer. The data race is not an issue here either,
because the producer will first atomically increment the number of
chunks in the buffer and then write the chunk header and payload. This
means that if we observe N chunks in the buffer, we can always safely
read N-1 chunks, i.e., everything that was committed before the counter
was incremented. This is what the scraping logic already does.

Bug: 132595466
Change-Id: Ic572e5fd0a0d1923f65b221fac95760484806c08
5 files changed
tree: 39f8a7b68a33becdaa7bd7c45ef742f0f4271469
  1. build_overrides/
  2. buildtools/
  3. debian/
  4. docs/
  5. gn/
  6. include/
  7. infra/
  8. protos/
  9. src/
  10. test/
  11. tools/
  12. ui/
  13. .clang-format
  14. .gitignore
  15. .gn
  16. .travis.yml
  17. Android.bp
  18. Android.bp.extras
  19. BUILD
  20. BUILD.extras
  21. BUILD.gn
  22. codereview.settings
  23. heapprofd.rc
  24. MODULE_LICENSE_APACHE2
  25. NOTICE
  26. OWNERS
  27. perfetto.rc
  28. PRESUBMIT.py
  29. README.chromium
  30. README.md
  31. TEST_MAPPING
README.md

Perfetto - Performance instrumentation and tracing

Perfetto is an open-source project for performance instrumentation and tracing of Linux/Android/Chrome platforms and user-space apps.

See www.perfetto.dev for docs.

Bugs

  • For bugs affecting Android or the tracing internals use the internal bug tracker (go/perfetto-bugs).
  • For bugs affecting Chrome use http://crbug.com, Component:Speed>Tracing label:Perfetto.