diff options
author | Minyoung, Song <minyoung.song@samsung.com> | 2018-01-16 16:09:16 +0900 |
---|---|---|
committer | Sungguk Na <sungguk.na@samsung.com> | 2019-07-24 10:17:15 +0900 |
commit | 9fad3f6f0b81e38ca4657e3dfbaf6e85fdb77b9d (patch) | |
tree | 72ac8e0438c8d9128e9c994129c1df0c185d3d46 /memps.c | |
parent | 73b06d6d8ea880594b9175d2b96f95e7a4bd42a3 (diff) | |
download | memps-tizen_5.5.tar.gz memps-tizen_5.5.tar.bz2 memps-tizen_5.5.zip |
[PATCH] Support 3D memory usage value for Mali midgard GPU Drivertizen_5.5.m2_releasesubmit/tizen_5.5_wearable_hotfix/20201026.184304submit/tizen_5.5_mobile_hotfix/20201026.185104submit/tizen_5.5/20191031.000004submit/tizen/20191014.011158accepted/tizen/unified/20191014.062508accepted/tizen/5.5/unified/wearable/hotfix/20201027.112740accepted/tizen/5.5/unified/mobile/hotfix/20201027.090051accepted/tizen/5.5/unified/20191031.022202tizen_5.5_wearable_hotfixtizen_5.5_tvtizen_5.5_mobile_hotfixtizen_5.5accepted/tizen_5.5_unified_wearable_hotfixaccepted/tizen_5.5_unified_mobile_hotfixaccepted/tizen_5.5_unified
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>
Diffstat (limited to 'memps.c')
-rw-r--r-- | memps.c | 35 |
1 files changed, 33 insertions, 2 deletions
@@ -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"); |