summaryrefslogtreecommitdiff
path: root/libmemtrack
diff options
context:
space:
mode:
Diffstat (limited to 'libmemtrack')
-rw-r--r--libmemtrack/kgsl.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/libmemtrack/kgsl.c b/libmemtrack/kgsl.c
index 11c7e8a2..9ec69f08 100644
--- a/libmemtrack/kgsl.c
+++ b/libmemtrack/kgsl.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 The Android Open Source Project
+ * Copyright (C) 2013, 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,7 +48,6 @@ int kgsl_memtrack_get_memory(pid_t pid, enum memtrack_type type,
FILE *fp;
char line[1024];
char tmp[128];
- bool is_surfaceflinger = false;
size_t accounted_size = 0;
size_t unaccounted_size = 0;
@@ -59,16 +58,6 @@ int kgsl_memtrack_get_memory(pid_t pid, enum memtrack_type type,
return 0;
}
- snprintf(tmp, sizeof(tmp), "/proc/%d/cmdline", pid);
- fp = fopen(tmp, "r");
- if (fp != NULL) {
- if (fgets(line, sizeof(line), fp)) {
- if (strcmp(line, "/system/bin/surfaceflinger") == 0)
- is_surfaceflinger = true;
- }
- fclose(fp);
- }
-
memcpy(records, record_templates,
sizeof(struct memtrack_record) * allocated_records);
@@ -87,19 +76,20 @@ int kgsl_memtrack_get_memory(pid_t pid, enum memtrack_type type,
char line_type[7];
char flags[9];
char line_usage[19];
- int ret;
+ int ret, egl_surface_count = 0, egl_image_count = 0;
if (fgets(line, sizeof(line), fp) == NULL) {
break;
}
/* Format:
- * gpuaddr useraddr size id flags type usage sglen mapsize
- * 545ba000 545ba000 4096 1 -----pY gpumem arraybuffer 1 4096
+ * gpuaddr useraddr size id flags type usage sglen mapsize eglsrf eglimg
+ * 545ba000 545ba000 4096 1 -----pY gpumem arraybuffer 1 4096 0 0
*/
- ret = sscanf(line, "%*x %*x %lu %*d %8s %6s %18s %*d %lu\n",
- &size, flags, line_type, line_usage, &mapsize);
- if (ret != 5) {
+ ret = sscanf(line, "%*x %*x %lu %*d %8s %6s %18s %*d %lu %6d %6d\n",
+ &size, flags, line_type, line_usage, &mapsize,
+ &egl_surface_count, &egl_image_count);
+ if (ret != 7) {
continue;
}
@@ -112,9 +102,10 @@ int kgsl_memtrack_get_memory(pid_t pid, enum memtrack_type type,
unaccounted_size += size;
} else if (type == MEMTRACK_TYPE_GRAPHICS && strcmp(line_type, "ion") == 0) {
- if ( !(is_surfaceflinger == false && strcmp(line_usage, "egl_surface") == 0)) {
+ if (strcmp(line_usage, "egl_surface") == 0)
unaccounted_size += size;
- }
+ else if (egl_surface_count == 0)
+ unaccounted_size += size / (egl_image_count ? egl_image_count : 1);
}
}