resource: process: Add PROCESS_ATTR_MEM_GPU attribute 96/276596/3 accepted/tizen/unified/20220701.055139 submit/tizen/20220630.063053
authorDongwoo Lee <dwoo08.lee@samsung.com>
Tue, 21 Jun 2022 12:38:24 +0000 (21:38 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Wed, 29 Jun 2022 10:29:53 +0000 (19:29 +0900)
Change-Id: Ie614d613cd242dd8dfaf4d315a0e122e88a9ae43
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
lib/resource-monitor/resource-monitor.h
src/resource/resource-process.c

index bf5d57f..d31e730 100644 (file)
@@ -126,6 +126,7 @@ extern "C" {
 #define PROCESS_ATTR_MEM_PSS                   BIT(9)  /* DATA_TYPE_UINT64 */
 #define PROCESS_ATTR_MEM_SWAP                  BIT(10) /* DATA_TYPE_UINT64 */
 #define PROCESS_ATTR_MEM_SWAP_PSS              BIT(11) /* DATA_TYPE_UINT64 */
+#define PROCESS_ATTR_MEM_GPU                   BIT(12) /* DATA_TYPE_UINT64 */
 
 #define PROCESS_CTRL_TGID                      BIT(0)
 
index 701e3a5..b59c06b 100644 (file)
@@ -118,6 +118,9 @@ static int process_get_mem_attrs(const struct resource *res,
        case PROCESS_ATTR_MEM_SWAP_PSS:
                *mem = (u_int64_t)ctx->map_info.swap_pss * 1024;
                break;
+       case PROCESS_ATTR_MEM_GPU:
+               *mem = (u_int64_t)ctx->map_info.gpu_mem * 1024;
+               break;
        default:
                return -EINVAL;
        }
@@ -303,6 +306,14 @@ static const struct resource_attribute process_attrs[] = {
                        .get = process_get_mem_attrs,
                        .is_supported = resource_attr_supported_always,
                },
+       }, {
+               .name   = "PROCESS_ATTR_MEM_GPU",
+               .id     = PROCESS_ATTR_MEM_GPU,
+               .type   = DATA_TYPE_UINT64,
+               .ops    = {
+                       .get = process_get_mem_attrs,
+                       .is_supported = resource_attr_supported_always,
+               },
        },
 };
 
@@ -333,6 +344,7 @@ static int process_setup_tgid(const struct resource *res,
        struct process_context *ctx;
        u_int64_t total_memory;
        int ret;
+       bool include_gpu_mem = is_resource_attr_interested(res, PROCESS_GROUP_ATTR_MEM_GPU);
 
        if (!res || !res->priv || !ctrl)
                return -EINVAL;
@@ -351,7 +363,7 @@ static int process_setup_tgid(const struct resource *res,
        if (ret < 0)
                return ret;
 
-       ret = kernel_get_thread_group_map_info(&ctx->map_info, ctx->tgid, false);
+       ret = kernel_get_thread_group_map_info(&ctx->map_info, ctx->tgid, include_gpu_mem);
        if (ret < 0)
                return ret;
 
@@ -378,6 +390,7 @@ static int process_prepare_update(struct resource *res)
        struct process_context *ctx = res->priv;
        u_int64_t total_time;
        int ret, online;
+       bool include_gpu_mem = is_resource_attr_interested(res, PROCESS_GROUP_ATTR_MEM_GPU);
 
        memcpy(&ctx->prev, &ctx->curr, sizeof(struct taskstats));
 
@@ -385,7 +398,7 @@ static int process_prepare_update(struct resource *res)
        if (ret < 0)
                return ret;
 
-       ret = kernel_get_thread_group_map_info(&ctx->map_info, ctx->tgid, false);
+       ret = kernel_get_thread_group_map_info(&ctx->map_info, ctx->tgid, include_gpu_mem);
        if (ret < 0)
                return ret;