Revert "Set the atrace clock to boot when possible and mono otherwise."

This change broke CTS tests.

This reverts commit 56a2ba0b0009b6a8db7c385489e5fef4c0d32d0a.

Bug: 37906221
Test: cts-tradefed run singleCommand cts-dev --module
CtsAtraceHostTestCases passes locally.
Change-Id: Ia82732eac33fbde8bddc1e8de7a68c20befe760e
diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp
index ed53af1..f8e0ad5 100644
--- a/cmds/atrace/atrace.cpp
+++ b/cmds/atrace/atrace.cpp
@@ -450,8 +450,8 @@
         return false;
     }
 
-    char buf[100];
-    ssize_t n = read(fd, buf, 99);
+    char buf[4097];
+    ssize_t n = read(fd, buf, 4096);
     close(fd);
     if (n == -1) {
         fprintf(stderr, "error reading %s: %s (%d)\n", k_traceClockPath,
@@ -475,38 +475,13 @@
     return strcmp(mode, start) == 0;
 }
 
-// Read the trace_clock sysfs file and return true if it contains the requested
-// value.  The trace_clock file format is:
-// local [global] counter uptime perf
-static bool traceClockContains(const char *mode)
-{
-    int fd = open((g_traceFolder + k_traceClockPath).c_str(), O_RDONLY);
-    if (fd == -1) {
-        fprintf(stderr, "error opening %s: %s (%d)\n", k_traceClockPath,
-            strerror(errno), errno);
-        return false;
-    }
-
-    char buf[100];
-    ssize_t n = read(fd, buf, 99);
-    close(fd);
-    if (n == -1) {
-        fprintf(stderr, "error reading %s: %s (%d)\n", k_traceClockPath,
-            strerror(errno), errno);
-        return false;
-    }
-    buf[n] = '\0';
-
-    return strstr(buf, mode) != NULL;
-}
-
-// Set the clock to the best available option while tracing. Use 'boot' if it's
-// available; otherwise, use 'mono'.
+// Enable or disable the kernel's use of the global clock.  Disabling the global
+// clock will result in the kernel using a per-CPU local clock.
 // Any write to the trace_clock sysfs file will reset the buffer, so only
 // update it if the requested value is not the current value.
-static bool setClock()
+static bool setGlobalClockEnable(bool enable)
 {
-    const char* clock = traceClockContains("boot") ? "boot" : "mono";
+    const char *clock = enable ? "global" : "local";
 
     if (isTraceClock(clock)) {
         return true;
@@ -808,7 +783,7 @@
     ok &= setCategoriesEnableFromFile(g_categoriesFile);
     ok &= setTraceOverwriteEnable(g_traceOverwrite);
     ok &= setTraceBufferSizeKB(g_traceBufferSizeKB);
-    ok &= setClock();
+    ok &= setGlobalClockEnable(true);
     ok &= setPrintTgidEnableIfPresent(true);
     ok &= setKernelTraceFuncs(g_kernelTraceFuncs);
 
@@ -884,6 +859,7 @@
     // Set the options back to their defaults.
     setTraceOverwriteEnable(true);
     setTraceBufferSizeKB(1);
+    setGlobalClockEnable(false);
     setPrintTgidEnableIfPresent(false);
     setKernelTraceFuncs(NULL);
 }