From d2f377a50ecaab9ad60b0be0e428711abe318a02 Mon Sep 17 00:00:00 2001 From: Sung-hun Kim Date: Tue, 23 Aug 2022 20:13:57 +0900 Subject: [PATCH] resource: Add a new property "flag" to attributes To distinguish visibility of resource attributes, a new property is added to each attribute. The visibility of each attribute is pre-defined. Pass allows or rejects user's request for setting interested attributes depends on the combination of the visibility of each resource and the visibility of each attribute. We used a flag variable for representing the visibility of the resource attribute. The flag variable can extend to represent other properties of the resource attribute. Change-Id: Ie48f00f89ec6095e05e9f8fcf395e1ea0da026bb Signed-off-by: Sung-hun Kim --- include/util/resource.h | 5 +++++ src/resource/resource-battery.c | 7 +++++++ src/resource/resource-bus.c | 7 +++++++ src/resource/resource-cpu.c | 7 +++++++ src/resource/resource-disk.c | 5 +++++ src/resource/resource-display.c | 2 ++ src/resource/resource-gpu.c | 7 +++++++ src/resource/resource-memory.c | 9 +++++++++ src/resource/resource-network.c | 1 + src/resource/resource-process-group.c | 11 +++++++++++ src/resource/resource-process.c | 13 +++++++++++++ src/resource/resource-system.c | 8 ++++++++ 12 files changed, 82 insertions(+) diff --git a/include/util/resource.h b/include/util/resource.h index 19a08ab..cd2deb3 100644 --- a/include/util/resource.h +++ b/include/util/resource.h @@ -38,6 +38,10 @@ */ #define RESOURCE_FLAG_PROCESS BIT(1) +/* Flags for resource_attribute */ +#define RESOURCE_ATTR_FLAG_PRIVATE BIT(0) +#define RESOURCE_ATTR_FLAG_PUBLIC BIT(1) + struct resource; struct resource_attribute; @@ -71,6 +75,7 @@ struct resource_attribute { const char name[BUFF_MAX]; const u_int64_t id; const int type; + const u_int64_t flag; const struct resource_attribute_ops ops; }; diff --git a/src/resource/resource-battery.c b/src/resource/resource-battery.c index ed51d39..07699b1 100644 --- a/src/resource/resource-battery.c +++ b/src/resource/resource-battery.c @@ -93,6 +93,7 @@ static const struct resource_attribute battery_attrs[] = { .name = "BATTERY_ATTR_CAPACITY", .id = BATTERY_ATTR_CAPACITY, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = battery_get_info, } @@ -100,6 +101,7 @@ static const struct resource_attribute battery_attrs[] = { .name = "BATTERY_ATTR_STATUS", .id = BATTERY_ATTR_STATUS, .type = DATA_TYPE_STRING, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = battery_get_status, } @@ -107,6 +109,7 @@ static const struct resource_attribute battery_attrs[] = { .name = "BATTERY_ATTR_TEMPERATURE", .id = BATTERY_ATTR_TEMPERATURE, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = battery_get_info, } @@ -114,6 +117,7 @@ static const struct resource_attribute battery_attrs[] = { .name = "BATTERY_ATTR_VOLTAGE_NOW", .id = BATTERY_ATTR_VOLTAGE_NOW, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = battery_get_info, } @@ -121,6 +125,7 @@ static const struct resource_attribute battery_attrs[] = { .name = "BATTERY_ATTR_CURRENT_NOW", .id = BATTERY_ATTR_CURRENT_NOW, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = battery_get_info, } @@ -128,6 +133,7 @@ static const struct resource_attribute battery_attrs[] = { .name = "BATTERY_ATTR_PRESENT", .id = BATTERY_ATTR_PRESENT, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = battery_get_info, } @@ -135,6 +141,7 @@ static const struct resource_attribute battery_attrs[] = { .name = "BATTERY_ATTR_ONLINE", .id = BATTERY_ATTR_ONLINE, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = battery_get_info, } diff --git a/src/resource/resource-bus.c b/src/resource/resource-bus.c index 007d1f4..2cbba18 100644 --- a/src/resource/resource-bus.c +++ b/src/resource/resource-bus.c @@ -130,6 +130,7 @@ static const struct resource_attribute bus_attrs[] = { .name = "BUS_ATTR_CUR_FREQ", .id = BUS_ATTR_CUR_FREQ, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = bus_get_value_from_hal_power, }, @@ -137,6 +138,7 @@ static const struct resource_attribute bus_attrs[] = { .name = "BUS_ATTR_MIN_FREQ", .id = BUS_ATTR_MIN_FREQ, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = bus_get_value_from_hal_power, }, @@ -144,6 +146,7 @@ static const struct resource_attribute bus_attrs[] = { .name = "BUS_ATTR_MAX_FREQ", .id = BUS_ATTR_MAX_FREQ, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = bus_get_value_from_hal_power, } @@ -151,6 +154,7 @@ static const struct resource_attribute bus_attrs[] = { .name = "BUS_ATTR_AVAILABLE_MIN_FREQ", .id = BUS_ATTR_AVAILABLE_MIN_FREQ, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = bus_get_value_from_hal_power, } @@ -158,6 +162,7 @@ static const struct resource_attribute bus_attrs[] = { .name = "BUS_ATTR_AVAILABLE_MAX_FREQ", .id = BUS_ATTR_AVAILABLE_MAX_FREQ, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = bus_get_value_from_hal_power, } @@ -165,6 +170,7 @@ static const struct resource_attribute bus_attrs[] = { .name = "BUS_ATTR_CUR_GOVERNOR", .id = BUS_ATTR_CUR_GOVERNOR, .type = DATA_TYPE_STRING, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = bus_get_string_value, } @@ -172,6 +178,7 @@ static const struct resource_attribute bus_attrs[] = { .name = "BUS_ATTR_NAME", .id = BUS_ATTR_NAME, .type = DATA_TYPE_STRING, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = bus_get_string_value, } diff --git a/src/resource/resource-cpu.c b/src/resource/resource-cpu.c index 82ac454..2f316be 100644 --- a/src/resource/resource-cpu.c +++ b/src/resource/resource-cpu.c @@ -129,6 +129,7 @@ static const struct resource_attribute cpu_attrs[] = { .name = "CPU_ATTR_CUR_FREQ", .id = CPU_ATTR_CUR_FREQ, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = cpu_get_value_from_hal_power, }, @@ -136,6 +137,7 @@ static const struct resource_attribute cpu_attrs[] = { .name = "CPU_ATTR_MIN_FREQ", .id = CPU_ATTR_MIN_FREQ, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = cpu_get_value_from_hal_power, }, @@ -143,6 +145,7 @@ static const struct resource_attribute cpu_attrs[] = { .name = "CPU_ATTR_MAX_FREQ", .id = CPU_ATTR_MAX_FREQ, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = cpu_get_value_from_hal_power, } @@ -150,6 +153,7 @@ static const struct resource_attribute cpu_attrs[] = { .name = "CPU_ATTR_AVAILABLE_MIN_FREQ", .id = CPU_ATTR_AVAILABLE_MIN_FREQ, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = cpu_get_value_from_hal_power, } @@ -157,6 +161,7 @@ static const struct resource_attribute cpu_attrs[] = { .name = "CPU_ATTR_AVAILABLE_MAX_FREQ", .id = CPU_ATTR_AVAILABLE_MAX_FREQ, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = cpu_get_value_from_hal_power, } @@ -164,6 +169,7 @@ static const struct resource_attribute cpu_attrs[] = { .name = "CPU_ATTR_CUR_GOVERNOR", .id = CPU_ATTR_CUR_GOVERNOR, .type = DATA_TYPE_STRING, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = cpu_get_string_value, } @@ -171,6 +177,7 @@ static const struct resource_attribute cpu_attrs[] = { .name = "CPU_ATTR_NAME", .id = CPU_ATTR_NAME, .type = DATA_TYPE_STRING, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = cpu_get_string_value, } diff --git a/src/resource/resource-disk.c b/src/resource/resource-disk.c index a28f216..20fce27 100644 --- a/src/resource/resource-disk.c +++ b/src/resource/resource-disk.c @@ -121,6 +121,7 @@ static const struct resource_attribute disk_attrs[] = { .name = "DISK_ATTR_NAME", .id = DISK_ATTR_NAME, .type = DATA_TYPE_STRING, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = disk_get_value, }, @@ -128,6 +129,7 @@ static const struct resource_attribute disk_attrs[] = { .name = "DISK_ATTR_READ_PER_SEC", .id = DISK_ATTR_READ_PER_SEC, .type = DATA_TYPE_DOUBLE, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = disk_get_value, }, @@ -135,6 +137,7 @@ static const struct resource_attribute disk_attrs[] = { .name = "DISK_ATTR_WRITE_PER_SEC", .id = DISK_ATTR_WRITE_PER_SEC, .type = DATA_TYPE_DOUBLE, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = disk_get_value, }, @@ -142,6 +145,7 @@ static const struct resource_attribute disk_attrs[] = { .name = "DISK_ATTR_READ_TOTAL", .id = DISK_ATTR_READ_TOTAL, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = disk_get_value, }, @@ -149,6 +153,7 @@ static const struct resource_attribute disk_attrs[] = { .name = "DISK_ATTR_WRITE_TOTAL", .id = DISK_ATTR_WRITE_TOTAL, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = disk_get_value, }, diff --git a/src/resource/resource-display.c b/src/resource/resource-display.c index dcba28b..ed0f55e 100644 --- a/src/resource/resource-display.c +++ b/src/resource/resource-display.c @@ -184,6 +184,7 @@ static const struct resource_attribute display_attrs[] = { .name = "DISPLAY_ATTR_FPS", .id = DISPLAY_ATTR_FPS, .type = DATA_TYPE_DOUBLE, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = display_get_fps, }, @@ -191,6 +192,7 @@ static const struct resource_attribute display_attrs[] = { .name = "DISPLAY_ATTR_NAME", .id = DISPLAY_ATTR_NAME, .type = DATA_TYPE_STRING, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = display_get_name, }, diff --git a/src/resource/resource-gpu.c b/src/resource/resource-gpu.c index 5deae14..8e6ac82 100644 --- a/src/resource/resource-gpu.c +++ b/src/resource/resource-gpu.c @@ -130,6 +130,7 @@ static const struct resource_attribute gpu_attrs[] = { .name = "GPU_ATTR_CUR_FREQ", .id = GPU_ATTR_CUR_FREQ, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = gpu_get_value_from_hal_power, }, @@ -137,6 +138,7 @@ static const struct resource_attribute gpu_attrs[] = { .name = "GPU_ATTR_MIN_FREQ", .id = GPU_ATTR_MIN_FREQ, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = gpu_get_value_from_hal_power, }, @@ -144,6 +146,7 @@ static const struct resource_attribute gpu_attrs[] = { .name = "GPU_ATTR_MAX_FREQ", .id = GPU_ATTR_MAX_FREQ, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = gpu_get_value_from_hal_power, } @@ -151,6 +154,7 @@ static const struct resource_attribute gpu_attrs[] = { .name = "GPU_ATTR_AVAILABLE_MIN_FREQ", .id = GPU_ATTR_AVAILABLE_MIN_FREQ, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = gpu_get_value_from_hal_power, } @@ -158,6 +162,7 @@ static const struct resource_attribute gpu_attrs[] = { .name = "GPU_ATTR_AVAILABLE_MAX_FREQ", .id = GPU_ATTR_AVAILABLE_MAX_FREQ, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = gpu_get_value_from_hal_power, } @@ -165,6 +170,7 @@ static const struct resource_attribute gpu_attrs[] = { .name = "GPU_ATTR_CUR_GOVERNOR", .id = GPU_ATTR_CUR_GOVERNOR, .type = DATA_TYPE_STRING, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = gpu_get_string_value, } @@ -172,6 +178,7 @@ static const struct resource_attribute gpu_attrs[] = { .name = "GPU_ATTR_NAME", .id = GPU_ATTR_NAME, .type = DATA_TYPE_STRING, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = gpu_get_string_value, } diff --git a/src/resource/resource-memory.c b/src/resource/resource-memory.c index 5258cd8..1ddfa14 100644 --- a/src/resource/resource-memory.c +++ b/src/resource/resource-memory.c @@ -127,6 +127,7 @@ static const struct resource_attribute memory_attrs[] = { .name = "MEMORY_ATTR_TOTAL", .id = MEMORY_ATTR_TOTAL, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = memory_get_memory_info, }, @@ -134,6 +135,7 @@ static const struct resource_attribute memory_attrs[] = { .name = "MEMORY_ATTR_AVAILABLE", .id = MEMORY_ATTR_AVAILABLE, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = memory_get_memory_info, }, @@ -141,6 +143,7 @@ static const struct resource_attribute memory_attrs[] = { .name = "MEMORY_ATTR_FREE", .id = MEMORY_ATTR_FREE, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = memory_get_memory_info, } @@ -148,6 +151,7 @@ static const struct resource_attribute memory_attrs[] = { .name = "MEMORY_ATTR_BUFFER", .id = MEMORY_ATTR_BUFFER, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = memory_get_memory_info, } @@ -155,6 +159,7 @@ static const struct resource_attribute memory_attrs[] = { .name = "MEMORY_ATTR_CACHED", .id = MEMORY_ATTR_CACHED, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = memory_get_memory_info, } @@ -162,6 +167,7 @@ static const struct resource_attribute memory_attrs[] = { .name = "MEMORY_ATTR_CMA_TOTAL", .id = MEMORY_ATTR_CMA_TOTAL, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = memory_get_memory_info, } @@ -169,6 +175,7 @@ static const struct resource_attribute memory_attrs[] = { .name = "MEMORY_ATTR_CMA_FREE", .id = MEMORY_ATTR_CMA_FREE, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = memory_get_memory_info, } @@ -176,6 +183,7 @@ static const struct resource_attribute memory_attrs[] = { .name = "MEMORY_ATTR_SWAP_TOTAL", .id = MEMORY_ATTR_SWAP_TOTAL, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = memory_get_memory_info, } @@ -183,6 +191,7 @@ static const struct resource_attribute memory_attrs[] = { .name = "MEMORY_ATTR_SWAP_FREE", .id = MEMORY_ATTR_SWAP_FREE, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = memory_get_memory_info, } diff --git a/src/resource/resource-network.c b/src/resource/resource-network.c index b05f9ce..016820a 100644 --- a/src/resource/resource-network.c +++ b/src/resource/resource-network.c @@ -67,6 +67,7 @@ static const struct resource_attribute network_attrs[] = { .name = "NETWORK_ATTR_NAME", .id = NETWORK_ATTR_NAME, .type = DATA_TYPE_STRING, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = network_get_name, }, diff --git a/src/resource/resource-process-group.c b/src/resource/resource-process-group.c index 5bdbf52..3985ac6 100644 --- a/src/resource/resource-process-group.c +++ b/src/resource/resource-process-group.c @@ -257,6 +257,7 @@ static const struct resource_attribute process_group_attrs[] = { .name = "PROCESS_GROUP_ATTR_PID_LIST", .id = PROCESS_GROUP_ATTR_PID_LIST, .type = DATA_TYPE_ARRAY, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_group_get_pid_list, .is_supported = process_group_check_taskstat_support, @@ -265,6 +266,7 @@ static const struct resource_attribute process_group_attrs[] = { .name = "PROCESS_GROUP_ATTR_NAME_LIST", .id = PROCESS_GROUP_ATTR_NAME_LIST, .type = DATA_TYPE_ARRAY, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_group_get_name_list, .is_supported = process_group_check_taskstat_support, @@ -273,6 +275,7 @@ static const struct resource_attribute process_group_attrs[] = { .name = "PROCESS_GROUP_ATTR_CPU_UTIL", .id = PROCESS_GROUP_ATTR_CPU_UTIL, .type = DATA_TYPE_DOUBLE, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_group_get_cpu_util, .is_supported = process_group_check_taskstat_support, @@ -281,6 +284,7 @@ static const struct resource_attribute process_group_attrs[] = { .name = "PROCESS_GROUP_ATTR_DISK_READ_PER_SEC", .id = PROCESS_GROUP_ATTR_DISK_READ_PER_SEC, .type = DATA_TYPE_DOUBLE, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_group_get_disk_attrs, .is_supported = process_group_check_taskstat_support, @@ -289,6 +293,7 @@ static const struct resource_attribute process_group_attrs[] = { .name = "PROCESS_GROUP_ATTR_DISK_WRITE_PER_SEC", .id = PROCESS_GROUP_ATTR_DISK_WRITE_PER_SEC, .type = DATA_TYPE_DOUBLE, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_group_get_disk_attrs, .is_supported = process_group_check_taskstat_support, @@ -297,6 +302,7 @@ static const struct resource_attribute process_group_attrs[] = { .name = "PROCESS_GROUP_ATTR_MEM_VIRT", .id = PROCESS_GROUP_ATTR_MEM_VIRT, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_group_get_mem, .is_supported = process_group_check_taskstat_support, @@ -305,6 +311,7 @@ static const struct resource_attribute process_group_attrs[] = { .name = "PROCESS_GROUP_ATTR_MEM_RSS", .id = PROCESS_GROUP_ATTR_MEM_RSS, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_group_get_mem, .is_supported = process_group_check_taskstat_support, @@ -313,6 +320,7 @@ static const struct resource_attribute process_group_attrs[] = { .name = "PROCESS_GROUP_ATTR_MEM_PSS", .id = PROCESS_GROUP_ATTR_MEM_PSS, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_group_get_mem, .is_supported = process_group_check_taskstat_support, @@ -321,6 +329,7 @@ static const struct resource_attribute process_group_attrs[] = { .name = "PROCESS_GROUP_ATTR_MEM_SWAP", .id = PROCESS_GROUP_ATTR_MEM_SWAP, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_group_get_mem, .is_supported = process_group_check_taskstat_support, @@ -329,6 +338,7 @@ static const struct resource_attribute process_group_attrs[] = { .name = "PROCESS_GROUP_ATTR_MEM_SWAP_PSS", .id = PROCESS_GROUP_ATTR_MEM_SWAP_PSS, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_group_get_mem, .is_supported = process_group_check_taskstat_support, @@ -337,6 +347,7 @@ static const struct resource_attribute process_group_attrs[] = { .name = "PROCESS_GROUP_ATTR_MEM_GPU", .id = PROCESS_GROUP_ATTR_MEM_GPU, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_group_get_mem, .is_supported = process_group_check_gpu_support, diff --git a/src/resource/resource-process.c b/src/resource/resource-process.c index 4f68a78..f6c2a8b 100644 --- a/src/resource/resource-process.c +++ b/src/resource/resource-process.c @@ -266,6 +266,7 @@ static const struct resource_attribute process_attrs[] = { .name = "PROCESS_ATTR_CPU_UTIL", .id = PROCESS_ATTR_CPU_UTIL, .type = DATA_TYPE_DOUBLE, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_get_cpu_util, .is_supported = process_check_taskstat_support, @@ -274,6 +275,7 @@ static const struct resource_attribute process_attrs[] = { .name = "PROCESS_ATTR_MEM_VIRT", .id = PROCESS_ATTR_MEM_VIRT, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_get_mem_attrs, .is_supported = process_check_taskstat_support, @@ -282,6 +284,7 @@ static const struct resource_attribute process_attrs[] = { .name = "PROCESS_ATTR_MEM_RSS", .id = PROCESS_ATTR_MEM_RSS, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_get_mem_attrs, .is_supported = process_check_taskstat_support, @@ -290,6 +293,7 @@ static const struct resource_attribute process_attrs[] = { .name = "PROCESS_ATTR_MEM_RSS_PERCENT", .id = PROCESS_ATTR_MEM_RSS_PERCENT, .type = DATA_TYPE_DOUBLE, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_get_mem_attrs, .is_supported = process_check_taskstat_support, @@ -298,6 +302,7 @@ static const struct resource_attribute process_attrs[] = { .name = "PROCESS_ATTR_DISK_READ_PER_SEC", .id = PROCESS_ATTR_DISK_READ_PER_SEC, .type = DATA_TYPE_DOUBLE, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_get_disk_attrs, .is_supported = process_check_taskstat_support, @@ -306,6 +311,7 @@ static const struct resource_attribute process_attrs[] = { .name = "PROCESS_ATTR_DISK_WRITE_PER_SEC", .id = PROCESS_ATTR_DISK_WRITE_PER_SEC, .type = DATA_TYPE_DOUBLE, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_get_disk_attrs, .is_supported = process_check_taskstat_support, @@ -314,6 +320,7 @@ static const struct resource_attribute process_attrs[] = { .name = "PROCESS_ATTR_NAME", .id = PROCESS_ATTR_NAME, .type = DATA_TYPE_STRING, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_get_context_data, .is_supported = resource_attr_supported_always, @@ -322,6 +329,7 @@ static const struct resource_attribute process_attrs[] = { .name = "PROCESS_ATTR_PGID", .id = PROCESS_ATTR_PGID, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_get_context_data, .is_supported = resource_attr_supported_always, @@ -330,6 +338,7 @@ static const struct resource_attribute process_attrs[] = { .name = "PROCESS_ATTR_PPID", .id = PROCESS_ATTR_PPID, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_get_context_data, .is_supported = resource_attr_supported_always, @@ -338,6 +347,7 @@ static const struct resource_attribute process_attrs[] = { .name = "PROCESS_ATTR_MEM_PSS", .id = PROCESS_ATTR_MEM_PSS, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_get_mem_attrs, .is_supported = resource_attr_supported_always, @@ -346,6 +356,7 @@ static const struct resource_attribute process_attrs[] = { .name = "PROCESS_ATTR_MEM_SWAP", .id = PROCESS_ATTR_MEM_SWAP, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_get_mem_attrs, .is_supported = resource_attr_supported_always, @@ -354,6 +365,7 @@ static const struct resource_attribute process_attrs[] = { .name = "PROCESS_ATTR_MEM_SWAP_PSS", .id = PROCESS_ATTR_MEM_SWAP_PSS, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_get_mem_attrs, .is_supported = resource_attr_supported_always, @@ -362,6 +374,7 @@ static const struct resource_attribute process_attrs[] = { .name = "PROCESS_ATTR_MEM_GPU", .id = PROCESS_ATTR_MEM_GPU, .type = DATA_TYPE_UINT64, + .flag = RESOURCE_ATTR_FLAG_PRIVATE, .ops = { .get = process_get_mem_attrs, .is_supported = process_check_gpu_support, diff --git a/src/resource/resource-system.c b/src/resource/resource-system.c index 42c7d43..010c948 100644 --- a/src/resource/resource-system.c +++ b/src/resource/resource-system.c @@ -186,6 +186,7 @@ static const struct resource_attribute system_attrs[] = { .name = "SYSTEM_ATTR_CPU_UTIL", .id = SYSTEM_ATTR_CPU_UTIL, .type = DATA_TYPE_DOUBLE, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = system_get_avg_cpu_util, } @@ -193,6 +194,7 @@ static const struct resource_attribute system_attrs[] = { .name = "SYSTEM_ATTR_CPU_USER_UTIL", .id = SYSTEM_ATTR_CPU_USER_UTIL, .type = DATA_TYPE_DOUBLE, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = system_get_avg_cpu_util, } @@ -200,6 +202,7 @@ static const struct resource_attribute system_attrs[] = { .name = "SYSTEM_ATTR_CPU_SYS_UTIL", .id = SYSTEM_ATTR_CPU_SYS_UTIL, .type = DATA_TYPE_DOUBLE, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = system_get_avg_cpu_util, } @@ -207,6 +210,7 @@ static const struct resource_attribute system_attrs[] = { .name = "SYSTEM_ATTR_PER_CPU_UTIL", .id = SYSTEM_ATTR_PER_CPU_UTIL, .type = DATA_TYPE_ARRAY, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = system_get_per_cpu_util, } @@ -214,6 +218,7 @@ static const struct resource_attribute system_attrs[] = { .name = "SYSTEM_ATTR_PER_CPU_USER_UTIL", .id = SYSTEM_ATTR_PER_CPU_USER_UTIL, .type = DATA_TYPE_ARRAY, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = system_get_per_cpu_util, } @@ -221,6 +226,7 @@ static const struct resource_attribute system_attrs[] = { .name = "SYSTEM_ATTR_PER_CPU_SYS_UTIL", .id = SYSTEM_ATTR_PER_CPU_SYS_UTIL, .type = DATA_TYPE_ARRAY, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = system_get_per_cpu_util, } @@ -228,6 +234,7 @@ static const struct resource_attribute system_attrs[] = { .name = "SYSTEM_ATTR_POSSIBLE_CPU", .id = SYSTEM_ATTR_POSSIBLE_CPU, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = system_get_cpu_num, } @@ -235,6 +242,7 @@ static const struct resource_attribute system_attrs[] = { .name = "SYSTEM_ATTR_ONLINE_CPU", .id = SYSTEM_ATTR_ONLINE_CPU, .type = DATA_TYPE_INT, + .flag = RESOURCE_ATTR_FLAG_PUBLIC, .ops = { .get = system_get_cpu_num, } -- 2.7.4