atrace: don't write the clock sync marker if --only_userspace
This CL has no other intended side effect than reducing
spam in logs.
--only_userspace is effectively used only by Perfetto.
Today the unconditional invocation of writeClockSyncMarker()
writes consistently, because perfetto invokes atrace before
writing 1 to tracing_on, and that makes the write to
trace_marker fail.
The failure has always been there and has always been fine.
This CL just silences it. I am planning to bubble up non-fatal
errors coming from atrace to the UI, this would be a confusing
false positive.
Bug: 171085599
Test: manual: perfetto -t 1s bionic am foobar -o trace;
check logcat (no clock sync errors)
Change-Id: Ic9b9cef42465bae0214e73c0dbce9ed2d288fdc6
diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp
index c2a2bc3..9bd733d 100644
--- a/cmds/atrace/atrace.cpp
+++ b/cmds/atrace/atrace.cpp
@@ -1340,10 +1340,10 @@
// contain entries from only one CPU can cause "begin" entries without a
// matching "end" entry to show up if a task gets migrated from one CPU to
// another.
- if (!onlyUserspace)
+ if (!onlyUserspace) {
ok = clearTrace();
-
- writeClockSyncMarker();
+ writeClockSyncMarker();
+ }
if (ok && !async && !traceStream) {
// Sleep to allow the trace to be captured.
struct timespec timeLeft;