Merge "Introduce IonHeapSize atom"

This commit is contained in:
Rafal Slawik
2020-01-16 12:58:28 +00:00
committed by Android (Google) Code Review
2 changed files with 41 additions and 2 deletions

View File

@@ -342,7 +342,7 @@ message Atom {
}
// Pulled events will start at field 10000.
// Next: 10070
// Next: 10071
oneof pulled {
WifiBytesTransfer wifi_bytes_transfer = 10000;
WifiBytesTransferByFgBg wifi_bytes_transfer_by_fg_bg = 10001;
@@ -399,7 +399,7 @@ message Atom {
ExternalStorageInfo external_storage_info = 10053;
GpuStatsGlobalInfo gpu_stats_global_info = 10054;
GpuStatsAppInfo gpu_stats_app_info = 10055;
SystemIonHeapSize system_ion_heap_size = 10056;
SystemIonHeapSize system_ion_heap_size = 10056 [deprecated = true];
AppsOnExternalStorageInfo apps_on_external_storage_info = 10057;
FaceSettings face_settings = 10058;
CoolingDevice cooling_device = 10059;
@@ -413,6 +413,7 @@ message Atom {
DangerousPermissionStateSampled dangerous_permission_state_sampled = 10067;
GraphicsStats graphics_stats = 10068;
RuntimeAppOpsAccess runtime_app_ops_access = 10069;
IonHeapSize ion_heap_size = 10070;
}
// DO NOT USE field numbers above 100,000 in AOSP.
@@ -6946,10 +6947,26 @@ message GpuStatsAppInfo {
* Pulled from StatsCompanionService.
*/
message SystemIonHeapSize {
// Deprecated due to limited support of ion stats in debugfs.
// Use `IonHeapSize` instead.
option deprecated = true;
// Size of the system ion heap in bytes.
// Read from debugfs.
optional int64 size_in_bytes = 1;
}
/*
* Logs the total size of the ion heap.
*
* Pulled from StatsCompanionService.
*/
message IonHeapSize {
// Total size of all ion heaps in kilobytes.
// Read from: /sys/kernel/ion/total_heaps_kb.
optional int32 total_size_kb = 1;
}
/*
* Logs the per-process size of the system ion heap.
*

View File

@@ -19,6 +19,7 @@ package com.android.server.stats;
import static android.app.AppOpsManager.OP_FLAGS_ALL_TRUSTED;
import static android.content.pm.PackageInfo.REQUESTED_PERMISSION_GRANTED;
import static android.content.pm.PermissionInfo.PROTECTION_DANGEROUS;
import static android.os.Debug.getIonHeapsSizeKb;
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
import static android.os.Process.getUidForPid;
import static android.os.storage.VolumeInfo.TYPE_PRIVATE;
@@ -263,6 +264,7 @@ public class StatsPullAtomService extends SystemService {
registerProcessMemoryHighWaterMark();
registerProcessMemorySnapshot();
registerSystemIonHeapSize();
registerIonHeapSize();
registerProcessSystemIonHeapSize();
registerTemperature();
registerCoolingDevice();
@@ -954,6 +956,26 @@ public class StatsPullAtomService extends SystemService {
// No op.
}
private void registerIonHeapSize() {
int tagId = StatsLog.ION_HEAP_SIZE;
mStatsManager.registerPullAtomCallback(
tagId,
/* PullAtomMetadata */ null,
(atomTag, data) -> pullIonHeapSize(atomTag, data),
Executors.newSingleThreadExecutor()
);
}
private int pullIonHeapSize(int atomTag, List<StatsEvent> pulledData) {
int ionHeapSizeInKilobytes = (int) getIonHeapsSizeKb();
StatsEvent e = StatsEvent.newBuilder()
.setAtomId(atomTag)
.writeInt(ionHeapSizeInKilobytes)
.build();
pulledData.add(e);
return StatsManager.PULL_SUCCESS;
}
private void registerProcessSystemIonHeapSize() {
// No op.
}