vl.values_len = 1;
sstrncpy(vl.plugin, RDT_PLUGIN, sizeof(vl.plugin));
- snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s", cgroup);
+ ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s", cgroup);
sstrncpy(vl.type, type, sizeof(vl.type));
if (type_instance)
sstrncpy(vl.type_instance, type_instance, sizeof(vl.type_instance));
vl.values_len = 1;
sstrncpy(vl.plugin, RDT_PLUGIN, sizeof(vl.plugin));
- snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s", cgroup);
+ ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s", cgroup);
sstrncpy(vl.type, type, sizeof(vl.type));
if (type_instance)
sstrncpy(vl.type_instance, type_instance, sizeof(vl.type_instance));
memset(cores, 0, sizeof(cores));
for (size_t j = 0; j < cgroup->num_cores; j++) {
- snprintf(cores + strlen(cores), sizeof(cores) - strlen(cores) - 1, " %d",
- cgroup->cores[j]);
+ ssnprintf(cores + strlen(cores), sizeof(cores) - strlen(cores) - 1, " %d",
+ cgroup->cores[j]);
}
DEBUG(RDT_PLUGIN ": group[%zu]:", i);
for (size_t i = 0; i < g_rdt->num_ngroups; i++) {
memset(names, 0, sizeof(names));
for (size_t j = 0; j < g_rdt->ngroups[i].num_names; j++)
- snprintf(names + strlen(names), sizeof(names) - strlen(names) - 1, " %s",
- g_rdt->ngroups[i].names[j]);
+ ssnprintf(names + strlen(names), sizeof(names) - strlen(names) - 1, " %s",
+ g_rdt->ngroups[i].names[j]);
DEBUG(RDT_PLUGIN ": group[%d]:", (int)i);
DEBUG(RDT_PLUGIN ": description: %s", g_rdt->ngroups[i].desc);
for (size_t i = 0; i < g_rdt->num_ngroups; ++i) {
memset(pids, 0, sizeof(pids));
for (size_t j = 0; j < g_rdt->ngroups[i].num_names; ++j) {
- pids_list_t *list = g_rdt->ngroups[i].proc_pids[j].curr;
+ pids_list_t *list = g_rdt->ngroups[i].proc_pids[j]->curr;
for (size_t k = 0; k < list->size; k++)
- snprintf(pids + strlen(pids), sizeof(pids) - strlen(pids) - 1, " %u",
- list->pids[k]);
+ ssnprintf(pids + strlen(pids), sizeof(pids) - strlen(pids) - 1, " %u",
+ list->pids[k]);
}
DEBUG(RDT_PLUGIN ": [%s] %s", g_rdt->ngroups[i].desc, pids);
}
}
if (rdt->proc_pids)
sfree(rdt->proc_pids);
+
+ rdt->num_ngroups = 0;
}
/*
}
/* update global proc_pids table */
- proc_pids_t **proc_pids = realloc(g_rdt->proc_pids,
- (g_rdt->num_proc_pids + ng->num_names) *
- sizeof(*g_rdt->proc_pids));
+ proc_pids_t **proc_pids =
+ realloc(g_rdt->proc_pids, (g_rdt->num_proc_pids + ng->num_names) *
+ sizeof(*g_rdt->proc_pids));
if (NULL == proc_pids) {
ERROR(RDT_PLUGIN ": Alloc error\n");
continue;
g_rdt->num_proc_pids += ng->num_names;
}
- int update_result =
- proc_pids_update(RDT_PROC_PATH, g_rdt->proc_pids, g_rdt->num_proc_pids);
- if (0 != update_result)
- ERROR(RDT_PLUGIN ": Initial update of proc pids failed");
+ if (g_rdt->num_ngroups > 0) {
+ int update_result =
+ proc_pids_update(RDT_PROC_PATH, g_rdt->proc_pids, g_rdt->num_proc_pids);
+ if (0 != update_result)
+ ERROR(RDT_PLUGIN ": Initial update of proc pids failed");
+ }
for (size_t group_idx = 0; group_idx < g_rdt->num_ngroups; group_idx++) {
int refresh_result = rdt_refresh_ngroup(&(g_rdt->ngroups[group_idx]),
#endif /* LIBPQOS2 */
/*
* NAME
- * rdt_free_ngroups
+ * rdt_free_cgroups
*
* DESCRIPTION
* Function to deallocate memory allocated for core groups.
for (int i = 0; i < RDT_MAX_CORES; i++) {
sfree(g_rdt->pcgroups[i]);
}
+ g_rdt->cores.num_cgroups = 0;
}
static int rdt_default_cgroups(void) {
cgroup->num_cores = 1;
cgroup->cores[0] = i;
- snprintf(desc, sizeof(desc), "%d", g_rdt->pqos_cpu->cores[i].lcore);
+ ssnprintf(desc, sizeof(desc), "%d", g_rdt->pqos_cpu->cores[i].lcore);
cgroup->desc = strdup(desc);
if (cgroup->desc == NULL) {
ERROR(RDT_PLUGIN ": Error allocating core group description");
reports a failure in configuration and
aborts
*/
- return (0);
+ return 0;
}
for (int i = 0; i < ci->children_num; i++) {
oconfig_item_t *child = ci->children + i;
if (strncasecmp("Cores", child->key, (size_t)strlen("Cores")) == 0) {
- if (rdt_config_cgroups(child) != 0) {
+ if (g_rdt->cores.num_cgroups > 0) {
+ ERROR(RDT_PLUGIN
+ ": Configuration parameter \"%s\" can be used only once.",
+ child->key);
g_state = CONFIGURATION_ERROR;
+ } else if (rdt_config_cgroups(child) != 0)
+ g_state = CONFIGURATION_ERROR;
+
+ if (g_state == CONFIGURATION_ERROR)
/* if we return -1 at this point collectd
reports a failure in configuration and
aborts
*/
- return (0);
- }
+ return 0;
#if COLLECT_DEBUG
rdt_dump_cgroups();
"Resctrl monitoring is needed for PIDs monitoring.",
child->key);
g_state = CONFIGURATION_ERROR;
- /* if we return -1 at this point collectd
- reports a failure in configuration and
- aborts
- */
- return 0;
}
- if (rdt_config_ngroups(g_rdt, child) != 0) {
+ else if (g_rdt->num_ngroups > 0) {
+ ERROR(RDT_PLUGIN
+ ": Configuration parameter \"%s\" can be used only once.",
+ child->key);
+ g_state = CONFIGURATION_ERROR;
+ }
+
+ else if (rdt_config_ngroups(g_rdt, child) != 0)
g_state = CONFIGURATION_ERROR;
+
+ if (g_state == CONFIGURATION_ERROR)
/* if we return -1 at this point collectd
reports a failure in configuration and
aborts
*/
return 0;
- }
#if COLLECT_DEBUG
rdt_dump_ngroups();
static int rdt_init(void) {
- if (g_state == CONFIGURATION_ERROR)
+ if (g_state == CONFIGURATION_ERROR) {
+ if (g_rdt != NULL) {
+ if (g_rdt->cores.num_cgroups > 0)
+ rdt_free_cgroups();
+#ifdef LIBPQOS2
+ if (g_rdt->num_ngroups > 0)
+ rdt_free_ngroups(g_rdt);
+#endif
+ }
return -1;
+ }
int rdt_preinint_result = rdt_preinit();
if (rdt_preinint_result != 0)