From 5627db89966539f9494fa119e4c86db98ebd1690 Mon Sep 17 00:00:00 2001 From: Calin Juravle Date: Thu, 3 May 2018 19:51:18 -0700 Subject: [PATCH] Make system server profiling an explicit runtime intent Pass an explicit flag to the runtime when we need to profile the system server. This ensures that we only start the ProfileSaver and allocate the code cache when needed. Test: manual, on a device with system server profiling enabled Bug: 74081010 (cherry picked from commit 8eb891be6f53118cb4b116fe29d131de166957c1) Merged-In: I756682a9644796afb53f0c010d2bd2764ea5a828 Change-Id: I756682a9644796afb53f0c010d2bd2764ea5a828 --- core/java/com/android/internal/os/Zygote.java | 4 ++++ core/java/com/android/internal/os/ZygoteInit.java | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java index cbd3ad5980f5..4ee950aa2beb 100644 --- a/core/java/com/android/internal/os/Zygote.java +++ b/core/java/com/android/internal/os/Zygote.java @@ -68,6 +68,10 @@ public final class Zygote { */ public static final int API_ENFORCEMENT_POLICY_SHIFT = Integer.numberOfTrailingZeros(API_ENFORCEMENT_POLICY_MASK); + /** + * Enable system server ART profiling. + */ + public static final int PROFILE_SYSTEM_SERVER = 1 << 14; /** No external storage should be mounted. */ public static final int MOUNT_EXTERNAL_NONE = IVold.REMOUNT_MODE_NONE; diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index 33049be4b8ed..da195601f725 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -702,6 +702,12 @@ public class ZygoteInit { ZygoteConnection.applyDebuggerSystemProperty(parsedArgs); ZygoteConnection.applyInvokeWithSystemProperty(parsedArgs); + boolean profileSystemServer = SystemProperties.getBoolean( + "dalvik.vm.profilesystemserver", false); + if (profileSystemServer) { + parsedArgs.runtimeFlags |= Zygote.PROFILE_SYSTEM_SERVER; + } + /* Request to fork the system server process */ pid = Zygote.forkSystemServer( parsedArgs.uid, parsedArgs.gid, -- 2.11.0