From e38797be847429ef2d60ec0f060d1b4ada0e1a25 Mon Sep 17 00:00:00 2001 From: Florian Mayer Date: Tue, 11 Feb 2020 17:05:58 +0000 Subject: [PATCH] Do not disable tracing in zygote. We now use the sequence number of the atrace tag rather than a Binder transaction, so zygote can observe changes to the tags. Test: m; flash; adb shell atrace dalvik | grep hprof Bug: 137366208 Bug: 147667830 Change-Id: I50e32a19c538dd255097c035836504b4746b172b --- core/java/android/os/Trace.java | 6 +----- core/java/com/android/internal/os/Zygote.java | 10 ---------- core/java/com/android/internal/os/ZygoteInit.java | 4 ---- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/core/java/android/os/Trace.java b/core/java/android/os/Trace.java index 25584f1560844..c5c26b0d6482f 100644 --- a/core/java/android/os/Trace.java +++ b/core/java/android/os/Trace.java @@ -175,11 +175,7 @@ public final class Trace { } /** - * Set whether tracing is enabled in this process. Tracing is disabled shortly after Zygote - * initializes and re-enabled after processes fork from Zygote. This is done because Zygote - * has no way to be notified about changes to the tracing tags, and if Zygote ever reads and - * caches the tracing tags, forked processes will inherit those stale tags. - * + * Set whether tracing is enabled in this process. * @hide */ public static void setTracingEnabled(boolean enabled, int debugFlags) { diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java index e298556617df7..dfd700f511037 100644 --- a/core/java/com/android/internal/os/Zygote.java +++ b/core/java/com/android/internal/os/Zygote.java @@ -279,10 +279,8 @@ public final class Zygote { uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose, fdsToIgnore, startChildZygote, instructionSet, appDataDir, isTopApp, pkgDataInfoList); - // Enable tracing as soon as possible for the child process. if (pid == 0) { Zygote.disableExecuteOnly(targetSdkVersion); - Trace.setTracingEnabled(true, runtimeFlags); // Note that this event ends at the end of handleChildProc, Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "PostFork"); @@ -334,9 +332,6 @@ public final class Zygote { niceName, startChildZygote, instructionSet, appDataDir, isTopApp, pkgDataInfoList); - // Enable tracing as soon as possible for the child process. - Trace.setTracingEnabled(true, runtimeFlags); - // Note that this event ends at the end of handleChildProc. Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "PostFork"); @@ -393,11 +388,6 @@ public final class Zygote { uid, gid, gids, runtimeFlags, rlimits, permittedCapabilities, effectiveCapabilities); - // Enable tracing as soon as we enter the system_server. - if (pid == 0) { - Trace.setTracingEnabled(true, runtimeFlags); - } - // Set the Java Language thread priority to the default value for new apps. Thread.currentThread().setPriority(Thread.NORM_PRIORITY); diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index 7b6262b5e0d81..ae54eb210de72 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -914,10 +914,6 @@ public class ZygoteInit { bootTimingsTraceLog.traceEnd(); // PostZygoteInitGC bootTimingsTraceLog.traceEnd(); // ZygoteInit - // Disable tracing so that forked processes do not inherit stale tracing tags from - // Zygote. - Trace.setTracingEnabled(false, 0); - Zygote.initNativeState(isPrimaryZygote);