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]);
}
if (rdt->proc_pids)
sfree(rdt->proc_pids);
+
+ rdt->num_ngroups = 0;
}
/*
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) {
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)