Atrace: Add commandline flags to enable/disable userland tracing
Adds a commandline flag to Atrace for Perfetto: --only_userspace. When --only_userspace is passed atrace does everything atrace would normally do to set up/tear down tracing (set various system properties, poke services etc) but doesn't modify any ftrace settings, doesn't clear read or otherwise touch the ftrace buffer, and doesn't start or stop tracing. Perfetto allows recording and collection of ftrace kernel events (as systrace/atrace does for local devices). We currently integrate with atrace to collect non-kernel events using the async_start and async_stop command line arguments. These cause atrace to poke binder/hal services and apps then Perfetto scrapes the print ftrace events from the kernel ring buffer. There are two downsides: 1. Atrace attempts drain the ftrace buffer after Perfetto has already done so. 2. Any time Atrace starts/stops it modifies the global ftrace settings and clears the ring buffer. The second is especially unfortunate as otherwise Perfetto supports multiplexing multiple simultaneous traces. This flag would make it much easier to integrate atrace and Perfetto. To test: atest cts/hostsidetests/atrace external/chromium-trace/systrace.py input sched First enable ftrace: $ adb shell 'echo 2048 > /d/tracing/buffer_size_kb' $ adb shell 'echo > /d/tracing/trace' $ adb shell 'echo 1 > /d/tracing/tracing_on' Next turn on the input category. $ adb shell atrace --async_start --only_userspace input Touch the screen a bunch. $ adb shell cat /d/tracing/trace Now you should see many events. Next turn off the input category. $ adb shell atrace --async_stop --only_userspace Clear tracing. $ adb shell 'echo > /d/tracing/trace' Touch the screen a bunch. $ adb shell cat /d/tracing/trace You should see no events. Ftrace settings should not have been touched: $ adb shell cat /d/tracing/tracing_on Should be 1 still. $ adb shell cat /d/tracing/buffer_size_kb Should be 2048 still. Bug: 73625407 Test: see above. Change-Id: Ia43ab689c4f93280315eb984581187c1582c2b07 Merged-In: Ia43ab689c4f93280315eb984581187c1582c2b07
Loading
Please register or sign in to comment