Loading core/java/android/os/Debug.java +8 −0 Original line number Diff line number Diff line Loading @@ -2590,4 +2590,12 @@ public final class Debug * @hide */ public static native long getIonMappedSizeKb(); /** * Return whether virtually-mapped kernel stacks are enabled (CONFIG_VMAP_STACK). * Note: caller needs config_gz read sepolicy permission * * @hide */ public static native boolean isVmapStack(); } core/java/com/android/internal/util/MemInfoReader.java +6 −3 Original line number Diff line number Diff line Loading @@ -107,9 +107,12 @@ public final class MemInfoReader { * Amount of RAM that is in use by the kernel for actual allocations. */ public long getKernelUsedSizeKb() { return mInfos[Debug.MEMINFO_SHMEM] + mInfos[Debug.MEMINFO_SLAB_UNRECLAIMABLE] + mInfos[Debug.MEMINFO_VM_ALLOC_USED] + mInfos[Debug.MEMINFO_PAGE_TABLES] + mInfos[Debug.MEMINFO_KERNEL_STACK]; long size = mInfos[Debug.MEMINFO_SHMEM] + mInfos[Debug.MEMINFO_SLAB_UNRECLAIMABLE] + mInfos[Debug.MEMINFO_VM_ALLOC_USED] + mInfos[Debug.MEMINFO_PAGE_TABLES]; if (!Debug.isVmapStack()) { size += mInfos[Debug.MEMINFO_KERNEL_STACK]; } return size; } public long getSwapTotalSizeKb() { Loading core/jni/android_os_Debug.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ #include <memunreachable/memunreachable.h> #include <android-base/strings.h> #include "android_os_Debug.h" #include <vintf/VintfObject.h> namespace android { Loading Loading @@ -835,6 +836,23 @@ static jlong android_os_Debug_getIonMappedSizeKb(JNIEnv* env, jobject clazz) { return ionPss; } static jboolean android_os_Debug_isVmapStack(JNIEnv *env, jobject clazz) { static enum { CONFIG_UNKNOWN, CONFIG_SET, CONFIG_UNSET, } cfg_state = CONFIG_UNKNOWN; if (cfg_state == CONFIG_UNKNOWN) { const std::map<std::string, std::string> configs = vintf::VintfObject::GetInstance()->getRuntimeInfo()->kernelConfigs(); std::map<std::string, std::string>::const_iterator it = configs.find("CONFIG_VMAP_STACK"); cfg_state = (it != configs.end() && it->second == "y") ? CONFIG_SET : CONFIG_UNSET; } return cfg_state == CONFIG_SET; } /* * JNI registration. */ Loading Loading @@ -884,6 +902,8 @@ static const JNINativeMethod gMethods[] = { (void*)android_os_Debug_getIonPoolsSizeKb }, { "getIonMappedSizeKb", "()J", (void*)android_os_Debug_getIonMappedSizeKb }, { "isVmapStack", "()Z", (void*)android_os_Debug_isVmapStack }, }; int register_android_os_Debug(JNIEnv *env) Loading Loading
core/java/android/os/Debug.java +8 −0 Original line number Diff line number Diff line Loading @@ -2590,4 +2590,12 @@ public final class Debug * @hide */ public static native long getIonMappedSizeKb(); /** * Return whether virtually-mapped kernel stacks are enabled (CONFIG_VMAP_STACK). * Note: caller needs config_gz read sepolicy permission * * @hide */ public static native boolean isVmapStack(); }
core/java/com/android/internal/util/MemInfoReader.java +6 −3 Original line number Diff line number Diff line Loading @@ -107,9 +107,12 @@ public final class MemInfoReader { * Amount of RAM that is in use by the kernel for actual allocations. */ public long getKernelUsedSizeKb() { return mInfos[Debug.MEMINFO_SHMEM] + mInfos[Debug.MEMINFO_SLAB_UNRECLAIMABLE] + mInfos[Debug.MEMINFO_VM_ALLOC_USED] + mInfos[Debug.MEMINFO_PAGE_TABLES] + mInfos[Debug.MEMINFO_KERNEL_STACK]; long size = mInfos[Debug.MEMINFO_SHMEM] + mInfos[Debug.MEMINFO_SLAB_UNRECLAIMABLE] + mInfos[Debug.MEMINFO_VM_ALLOC_USED] + mInfos[Debug.MEMINFO_PAGE_TABLES]; if (!Debug.isVmapStack()) { size += mInfos[Debug.MEMINFO_KERNEL_STACK]; } return size; } public long getSwapTotalSizeKb() { Loading
core/jni/android_os_Debug.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ #include <memunreachable/memunreachable.h> #include <android-base/strings.h> #include "android_os_Debug.h" #include <vintf/VintfObject.h> namespace android { Loading Loading @@ -835,6 +836,23 @@ static jlong android_os_Debug_getIonMappedSizeKb(JNIEnv* env, jobject clazz) { return ionPss; } static jboolean android_os_Debug_isVmapStack(JNIEnv *env, jobject clazz) { static enum { CONFIG_UNKNOWN, CONFIG_SET, CONFIG_UNSET, } cfg_state = CONFIG_UNKNOWN; if (cfg_state == CONFIG_UNKNOWN) { const std::map<std::string, std::string> configs = vintf::VintfObject::GetInstance()->getRuntimeInfo()->kernelConfigs(); std::map<std::string, std::string>::const_iterator it = configs.find("CONFIG_VMAP_STACK"); cfg_state = (it != configs.end() && it->second == "y") ? CONFIG_SET : CONFIG_UNSET; } return cfg_state == CONFIG_SET; } /* * JNI registration. */ Loading Loading @@ -884,6 +902,8 @@ static const JNINativeMethod gMethods[] = { (void*)android_os_Debug_getIonPoolsSizeKb }, { "getIonMappedSizeKb", "()J", (void*)android_os_Debug_getIonMappedSizeKb }, { "isVmapStack", "()Z", (void*)android_os_Debug_isVmapStack }, }; int register_android_os_Debug(JNIEnv *env) Loading