Implement ftrace flushing

This CL finally implements flushing of ftrace data and
wires it up to the Flush() API of the tracing service.
The major change introduced is in CpuReader, the multi
threaded class that reads ftrace data.
The core scheduling algorithm is left unchanged (see
//docs/ftrace.md). The old logic is still preserved:
[wait for command] -> [splice blocking] -> [splice nonblock]
However, this CL introduces a way for the FtraceController
to interrupt the splice and switch to read() mode for
flushes. read(), in fact, is the only way to read partial
pages out of the ftrace buffer.
Even when in read() mode, the scheduling algorithm is still
the same, just s/splice/read/.
There are a bunch of caveats and they are thoroughly
described in b/120188810. Essentially once we switch to
read() for the flush, we need to be careful and wait for
the ftrace read pointer to become page-aligned again before
switching back to splice().
Furthermore this CL gets rid of the internal pipe to move
data between the worker thread and the main thread and switches
to the recently introduced page pool. We still have an internal
pipe (for splice) but use it entirely in the worker therad.
Exposing the pipe to the main thread had two drawbacks:
1) Essentially limits the transfer bandwidth between the worker
   thread and the main thread, making the ftrace buffer size
   useless. Before, even if one specified a buffer size of 1GB,
   we would at most read 1 pipe buffer per read cycle.
2) That hits another kernel bug around non-blocking splice
   (b/119805587).

Test: perfetto_integrationtests --gtest_filter=PerfettoTest.VeryLargePackets
Bug: 73886018
Change-Id: I4a6e82b284971a3765b42959904f5402095e4c4e
12 files changed
tree: 1369671160511f68f27965c92b7abf92ae619e12
  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.gn
  20. codereview.settings
  21. heapprofd.rc
  22. MODULE_LICENSE_APACHE2
  23. NOTICE
  24. OWNERS
  25. perfetto.rc
  26. PRESUBMIT.py
  27. README.chromium
  28. README.md
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.