diff options
author | Chiawei Wang <chiaweiwang@google.com> | 2021-06-02 06:17:10 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-06-02 06:17:10 +0000 |
commit | 43e4d63427a8a574b1f40814a1a1ee10179f1e00 (patch) | |
tree | 9ac5865327e666d99a5175b437c0f1ef9d5dfd01 /pixelstats/MmMetricsReporter.cpp | |
parent | d7bc14721a123c47907fcd89122fb2ef4d01feb0 (diff) | |
parent | 31e8c27ef7478711e00020c4bb39e9f9d19ec075 (diff) |
Merge "pixelstats: collect GPU total pages from pixel specific sysfs" into sc-dev
Diffstat (limited to 'pixelstats/MmMetricsReporter.cpp')
-rw-r--r-- | pixelstats/MmMetricsReporter.cpp | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/pixelstats/MmMetricsReporter.cpp b/pixelstats/MmMetricsReporter.cpp index 4770d24..29d3dfe 100644 --- a/pixelstats/MmMetricsReporter.cpp +++ b/pixelstats/MmMetricsReporter.cpp @@ -101,7 +101,7 @@ MmMetricsReporter::MmMetricsReporter() : kVmstatPath("/proc/vmstat"), kIonTotalPoolsPath("/sys/kernel/dma_heap/total_pools_kb"), kIonTotalPoolsPathForLegacy("/sys/kernel/ion/total_pools_kb"), - kMgmDebugFs("/sys/kernel/debug/physical-memory-group-manager"), + kGpuTotalPages("/sys/kernel/pixel_stat/gpu/mem/total_page_count"), kPixelStatMm("/sys/kernel/pixel_stat/mm") {} bool MmMetricsReporter::ReadFileToUint(const char *const path, uint64_t *val) { @@ -182,36 +182,14 @@ uint64_t MmMetricsReporter::getIonTotalPools() { } /** - * Collect GPU memory from kMgmDebugFs and return the total number of 4K page. - * <kMgmDebugFs>/<group>/size is the 4KB page number - * <kMgmDebugFs>/<group>/lp_size is the 2MB page number + * Collect GPU memory from kGpuTotalPages and return the total number of 4K page. */ uint64_t MmMetricsReporter::getGpuMemory() { uint64_t gpu_size = 0; - std::unique_ptr<DIR, int (*)(DIR *)> dir(opendir(kMgmDebugFs), closedir); - if (!dir) { + if (!ReadFileToUint(kGpuTotalPages, &gpu_size)) { return 0; } - - while (struct dirent *dp = readdir(dir.get())) { - if (dp->d_type != DT_DIR) - continue; - - if (!StartsWith(dp->d_name, "group")) - continue; - - uint64_t size; - std::string path_4K = android::base::StringPrintf("%s/%s/size", kMgmDebugFs, dp->d_name); - std::string path_2M = android::base::StringPrintf("%s/%s/lp_size", kMgmDebugFs, dp->d_name); - if (ReadFileToUint(path_4K.c_str(), &size)) { - gpu_size += size; - } - - if (ReadFileToUint(path_2M.c_str(), &size)) { - gpu_size += (size * SZ_2M / SZ_4K); - } - } return gpu_size; } |