X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fintel_rdt.c;h=7328836694dee755dbdeaa38c51413286dfa6c52;hb=3d5b7121b097f54d50632488883cd9b943e3d1fa;hp=21f3a20635a7856ef44f38783f91fbf1d0e02efe;hpb=4a4abbb0a9412e9e43dc02da7b51a1f5f7ec69bb;p=collectd.git diff --git a/src/intel_rdt.c b/src/intel_rdt.c index 21f3a206..73288366 100644 --- a/src/intel_rdt.c +++ b/src/intel_rdt.c @@ -25,8 +25,8 @@ * Serhiy Pshyk **/ -#include "collectd.h" #include "common.h" +#include "collectd.h" #include @@ -36,6 +36,11 @@ #define RDT_MAX_SOCKET_CORES 64 #define RDT_MAX_CORES (RDT_MAX_SOCKET_CORES * RDT_MAX_SOCKETS) +typedef enum { + UNKNOWN = 0, + CONFIGURATION_ERROR, +} rdt_config_status; + struct rdt_core_group_s { char *desc; size_t num_cores; @@ -56,6 +61,8 @@ typedef struct rdt_ctx_s rdt_ctx_t; static rdt_ctx_t *g_rdt = NULL; +static rdt_config_status g_state = UNKNOWN; + static int isdup(const uint64_t *nums, size_t size, uint64_t val) { for (size_t i = 0; i < size; i++) if (nums[i] == val) @@ -523,8 +530,14 @@ static int rdt_config(oconfig_item_t *ci) { int ret = 0; ret = rdt_preinit(); - if (ret != 0) - return ret; + if (ret != 0) { + g_state = CONFIGURATION_ERROR; + /* if we return -1 at this point collectd + reports a failure in configuration and + aborts + */ + goto exit; + } for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; @@ -532,8 +545,14 @@ static int rdt_config(oconfig_item_t *ci) { if (strcasecmp("Cores", child->key) == 0) { ret = rdt_config_cgroups(child); - if (ret != 0) - return ret; + if (ret != 0) { + g_state = CONFIGURATION_ERROR; + /* if we return -1 at this point collectd + reports a failure in configuration and + aborts + */ + goto exit; + } #if COLLECT_DEBUG rdt_dump_cgroups(); @@ -544,6 +563,7 @@ static int rdt_config(oconfig_item_t *ci) { } } +exit: return (0); } @@ -626,6 +646,9 @@ static int rdt_read(__attribute__((unused)) user_data_t *ud) { static int rdt_init(void) { int ret; + if(g_state == CONFIGURATION_ERROR) + return (-1); + ret = rdt_preinit(); if (ret != 0) return ret;