From ed9955b6e44cd1ccd01bb3f4b8277102ef069d21 Mon Sep 17 00:00:00 2001 From: Mitch Phillips Date: Wed, 20 Jan 2021 16:11:01 -0800 Subject: [MemInit] Use new MemInit API. Use the new mallopt() api for MemInit, and only call it iff MTE isn't enabled. Bug: 135772972 Test: Device boots. Change-Id: I235a8fc93af7b52aaa30f68275c650d9f231906a --- core/jni/com_android_internal_os_Zygote.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index b2e562c9650e..d7001d8d36ea 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -70,7 +70,6 @@ #include #include #include -#include #include #include #include @@ -638,13 +637,6 @@ static void PreApplicationInit() { // Set the jemalloc decay time to 1. mallopt(M_DECAY_TIME, 1); - - // Avoid potentially expensive memory mitigations, mostly meant for system - // processes, in apps. These may cause app compat problems, use more memory, - // or reduce performance. While it would be nice to have them for apps, - // we will have to wait until they are proven out, have more efficient - // hardware, and/or apply them only to new applications. - process_disable_memory_mitigations(); } static void SetUpSeccompFilter(uid_t uid, bool is_child_zygote) { @@ -1811,6 +1803,14 @@ static void SpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray gids, break; } mallopt(M_BIONIC_SET_HEAP_TAGGING_LEVEL, heap_tagging_level); + + // Avoid heap zero initialization for applications without MTE. Zero init may + // cause app compat problems, use more memory, or reduce performance. While it + // would be nice to have them for apps, we will have to wait until they are + // proven out, have more efficient hardware, and/or apply them only to new + // applications. + mallopt(M_BIONIC_ZERO_INIT, 0); + // Now that we've used the flag, clear it so that we don't pass unknown flags to the ART runtime. runtime_flags &= ~RuntimeFlags::MEMORY_TAG_LEVEL_MASK; -- cgit v1.2.3-59-g8ed1b