summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinyoung, Song <minyoung.song@samsung.com>2018-01-16 16:09:16 +0900
committerSungguk Na <sungguk.na@samsung.com>2019-07-24 10:17:15 +0900
commit9fad3f6f0b81e38ca4657e3dfbaf6e85fdb77b9d (patch)
tree72ac8e0438c8d9128e9c994129c1df0c185d3d46
parent73b06d6d8ea880594b9175d2b96f95e7a4bd42a3 (diff)
downloadmemps-tizen_5.5_tv.tar.gz
memps-tizen_5.5_tv.tar.bz2
memps-tizen_5.5_tv.zip
The usage of 3D memory is differ from GPU series In case of Mali utgard, it comes from smaps of process In case of Mali midgard, it comes form specific debug node Change-Id: Iaef54537d107f49763ef8f8508c6787a73851a81 Signed-off-by: Minyoung, Song <minyoung.song@samsung.com>
-rw-r--r--memps.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/memps.c b/memps.c
index 8a7e9af..46b2217 100644
--- a/memps.c
+++ b/memps.c
@@ -35,6 +35,7 @@
#define STR_SGX_PATH "/dev/pvrsrvkm"
#define STR_3D_PATH1 "/dev/mali"
#define STR_3D_PATH2 "/dev/kgsl-3d0"
+#define STR_3D_UNIFIED_PATH "/usr/bin/gpu_mem_info"
#define STR_DRM_PATH1 "/drm mm object (deleted)"
#define STR_DRM_PATH2 "/dev/dri/card0"
#define MEMCG_PATH "/sys/fs/cgroup/memory"
@@ -114,6 +115,7 @@ struct geminfo {
static int sum;
static int verbos;
+static int use_gpu_mem_info = 0;
/* reads file contents into memory */
static char* cread(const char* path)
@@ -727,6 +729,28 @@ static void init_trib_mapinfo(trib_mapinfo *tmi)
tmi->gem_mmap = 0;
}
+unsigned int get_graphic_3d_meminfo(unsigned int tgid)
+{
+ char command[256], buf[256];
+ char *tmp[2];
+ unsigned int size = 0;
+ int tid, ret;
+ FILE *p_gpu;
+
+ snprintf(command, sizeof(command), "%s %d", STR_3D_UNIFIED_PATH, tgid);
+ p_gpu = popen(command, "r");
+ if (p_gpu) {
+ fgets(buf, 256, p_gpu);
+ ret = sscanf(buf, "%d %ms %d %ms", &tid, &tmp[0], &size, &tmp[1]);
+ if (ret == 4) {
+ free(tmp[0]);
+ free(tmp[1]);
+ }
+ pclose(p_gpu);
+ }
+ return size;
+}
+
static int
get_trib_mapinfo(unsigned int tgid, mapinfo *milist,
geminfo *gilist, trib_mapinfo *result)
@@ -740,10 +764,14 @@ get_trib_mapinfo(unsigned int tgid, mapinfo *milist,
return -EINVAL;
init_trib_mapinfo(result);
+
+ if (use_gpu_mem_info)
+ result->graphic_3d = get_graphic_3d_meminfo(tgid);
+
for (mi = milist; mi;) {
- if (strstr(mi->name, STR_SGX_PATH)) {
+ if (!use_gpu_mem_info && strstr(mi->name, STR_SGX_PATH)) {
result->graphic_3d += mi->pss;
- } else if (strstr(mi->name, STR_3D_PATH1) ||
+ } else if (!use_gpu_mem_info && strstr(mi->name, STR_3D_PATH1) ||
strstr(mi->name, STR_3D_PATH2)) {
result->graphic_3d += mi->size;
} else if (mi->rss != 0 && mi->pss == 0
@@ -990,6 +1018,9 @@ static int show_map_all_new(int output_type, char *output_path)
return 0;
}
+ use_gpu_mem_info = (!access(STR_3D_UNIFIED_PATH, F_OK | X_OK)) ? 1 : 0;
+ errno = 0;
+
pDir = opendir("/proc");
if (pDir == NULL) {
fprintf(stderr, "cannot read directory /proc.\n");