2 * collectd - src/intel_rdt.c
4 * Copyright(c) 2016-2018 Intel Corporation. All rights reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Serhiy Pshyk <serhiyx.pshyk@intel.com>
26 * Starzyk, Mateusz <mateuszx.starzyk@intel.com>
27 * Wojciech Andralojc <wojciechx.andralojc@intel.com>
31 #include "utils/common/common.h"
32 #include "utils/config_cores/config_cores.h"
35 #define RDT_PLUGIN "intel_rdt"
37 /* libpqos v2.0 or newer is required for process monitoring*/
39 #if defined(PQOS_VERSION) && PQOS_VERSION >= 20000
43 #define RDT_PLUGIN "intel_rdt"
45 #define RDT_MAX_SOCKETS 8
46 #define RDT_MAX_SOCKET_CORES 64
47 #define RDT_MAX_CORES (RDT_MAX_SOCKET_CORES * RDT_MAX_SOCKETS)
51 * Process name inside comm file is limited to 16 chars.
52 * More info here: http://man7.org/linux/man-pages/man5/proc.5.html
54 #define RDT_MAX_NAME_LEN 16
55 #define RDT_MAX_NAMES_GROUPS 64
57 #define RDT_PROC_PATH "/proc"
66 /* Helper typedef for process name array
67 * Extra 1 char is added for string null termination.
69 typedef char proc_comm_t[RDT_MAX_NAME_LEN + 1];
71 /* Linked one-way list of pids. */
72 typedef struct pids_list_s {
74 struct pids_list_s *next;
77 /* Holds process name and list of pids assigned to that name */
78 typedef struct proc_pids_s {
79 proc_comm_t proccess_name;
83 struct rdt_name_group_s {
87 proc_pids_t *proc_pids_array;
88 size_t monitored_pids_count;
89 enum pqos_mon_event events;
91 typedef struct rdt_name_group_s rdt_name_group_t;
95 core_groups_list_t cores;
96 enum pqos_mon_event events[RDT_MAX_CORES];
97 struct pqos_mon_data *pcgroups[RDT_MAX_CORES];
99 rdt_name_group_t ngroups[RDT_MAX_NAMES_GROUPS];
100 struct pqos_mon_data *pngroups[RDT_MAX_NAMES_GROUPS];
102 #endif /* LIBPQOS2 */
103 const struct pqos_cpuinfo *pqos_cpu;
104 const struct pqos_cap *pqos_cap;
105 const struct pqos_capability *cap_mon;
107 typedef struct rdt_ctx_s rdt_ctx_t;
109 static rdt_ctx_t *g_rdt;
111 static rdt_config_status g_state = UNKNOWN;
113 static int g_interface = -1;
116 static int isdupstr(const char *names[], const size_t size, const char *name) {
117 for (size_t i = 0; i < size; i++)
118 if (strncmp(names[i], name, (size_t)RDT_MAX_NAME_LEN) == 0)
129 * Converts string representing list of strings into array of strings.
131 * name,name1,name2,name3
134 * `str_list' String representing list of strings.
135 * `names' Array to put extracted strings into.
136 * `names_num' Variable to put number of extracted strings.
139 * Number of elements placed into names.
141 static int strlisttoarray(char *str_list, char ***names, size_t *names_num) {
142 char *saveptr = NULL;
144 if (str_list == NULL || names == NULL)
147 if (strstr(str_list, ",,")) {
148 /* strtok ignores empty words between separators.
149 * This condition handles that by rejecting strings
150 * with consecutive seprators */
151 ERROR(RDT_PLUGIN ": Empty process name");
156 char *token = strtok_r(str_list, ",", &saveptr);
162 while (isspace(*token))
168 if ((isdupstr((const char **)*names, *names_num, token))) {
169 ERROR(RDT_PLUGIN ": Duplicated process name \'%s\' in group \'%s\'",
173 if (0 != strarray_add(names, names_num, token)) {
174 ERROR(RDT_PLUGIN ": Error allocating process name string");
188 * Function to compare names in two name groups.
191 * `ng_a' Pointer to name group a.
192 * `ng_b' Pointer to name group b.
195 * 1 if both groups contain the same names
196 * 0 if none of their names match
197 * -1 if some but not all names match
199 static int ngroup_cmp(const rdt_name_group_t *ng_a,
200 const rdt_name_group_t *ng_b) {
203 assert(ng_a != NULL);
204 assert(ng_b != NULL);
206 const size_t sz_a = (unsigned)ng_a->num_names;
207 const size_t sz_b = (unsigned)ng_b->num_names;
208 const char **tab_a = (const char **)ng_a->names;
209 const char **tab_b = (const char **)ng_b->names;
211 for (size_t i = 0; i < sz_a; i++) {
212 for (size_t j = 0; j < sz_b; j++)
213 if (strncmp(tab_a[i], tab_b[j], (size_t)RDT_MAX_NAME_LEN) == 0)
216 /* if no names are the same */
219 /* if group contains same names */
220 if (sz_a == sz_b && sz_b == (size_t)found)
222 /* if not all names are the same */
231 * Function to set the descriptions and names for each process names group.
232 * Takes a config option containing list of strings that are used to set
233 * process group values.
236 * `item' Config option containing process names groups.
237 * `groups' Table of process name groups to set values in.
238 * `max_groups' Maximum number of process name groups allowed.
241 * On success, the number of name groups set up. On error, appropriate
242 * negative error value.
244 static int oconfig_to_ngroups(const oconfig_item_t *item,
245 rdt_name_group_t *groups,
246 const size_t max_groups) {
249 assert(groups != NULL);
250 assert(max_groups > 0);
251 assert(item != NULL);
253 for (int j = 0; j < item->values_num; j++) {
255 char value[DATA_MAX_NAME_LEN];
257 if ((item->values[j].value.string == NULL) ||
258 (strlen(item->values[j].value.string) == 0)) {
259 ERROR(RDT_PLUGIN ": Error - empty group");
263 sstrncpy(value, item->values[j].value.string, sizeof(value));
265 ret = strlisttoarray(value, &groups[index].names, &groups[index].num_names);
266 if (ret != 0 || groups[index].num_names == 0) {
267 ERROR(RDT_PLUGIN ": Error parsing process names group (%s)",
268 item->values[j].value.string);
272 /* set group description info */
273 groups[index].desc = sstrdup(item->values[j].value.string);
274 if (groups[index].desc == NULL) {
275 ERROR(RDT_PLUGIN ": Error allocating name group description");
279 groups[index].proc_pids_array = NULL;
280 groups[index].monitored_pids_count = 0;
284 if (index >= (const int)max_groups) {
285 WARNING(RDT_PLUGIN ": Too many process names groups configured");
292 #endif /* LIBPQOS2 */
295 static void rdt_dump_cgroups(void) {
296 char cores[RDT_MAX_CORES * 4];
301 DEBUG(RDT_PLUGIN ": Core Groups Dump");
302 DEBUG(RDT_PLUGIN ": groups count: %" PRIsz, g_rdt->cores.num_cgroups);
304 for (size_t i = 0; i < g_rdt->cores.num_cgroups; i++) {
305 core_group_t *cgroup = g_rdt->cores.cgroups + i;
307 memset(cores, 0, sizeof(cores));
308 for (size_t j = 0; j < cgroup->num_cores; j++) {
309 snprintf(cores + strlen(cores), sizeof(cores) - strlen(cores) - 1, " %d",
313 DEBUG(RDT_PLUGIN ": group[%zu]:", i);
314 DEBUG(RDT_PLUGIN ": description: %s", cgroup->desc);
315 DEBUG(RDT_PLUGIN ": cores: %s", cores);
316 DEBUG(RDT_PLUGIN ": events: 0x%X", g_rdt->events[i]);
323 static void rdt_dump_ngroups(void) {
325 char names[DATA_MAX_NAME_LEN];
330 DEBUG(RDT_PLUGIN ": Process Names Groups Dump");
331 DEBUG(RDT_PLUGIN ": groups count: %" PRIsz, g_rdt->num_ngroups);
333 for (size_t i = 0; i < g_rdt->num_ngroups; i++) {
334 memset(names, 0, sizeof(names));
335 for (size_t j = 0; j < g_rdt->ngroups[i].num_names; j++)
336 snprintf(names + strlen(names), sizeof(names) - strlen(names) - 1, " %s",
337 g_rdt->ngroups[i].names[j]);
339 DEBUG(RDT_PLUGIN ": group[%d]:", (int)i);
340 DEBUG(RDT_PLUGIN ": description: %s", g_rdt->ngroups[i].desc);
341 DEBUG(RDT_PLUGIN ": process names:%s", names);
342 DEBUG(RDT_PLUGIN ": events: 0x%X", g_rdt->ngroups[i].events);
347 #endif /* LIBPQOS2 */
349 static inline double bytes_to_kb(const double bytes) { return bytes / 1024.0; }
351 static inline double bytes_to_mb(const double bytes) {
352 return bytes / (1024.0 * 1024.0);
355 static void rdt_dump_cores_data(void) {
357 * CORE - monitored group of cores
358 * RMID - Resource Monitoring ID associated with the monitored group
359 * This is not available for monitoring with resource control
360 * LLC - last level cache occupancy
361 * MBL - local memory bandwidth
362 * MBR - remote memory bandwidth
365 if (g_interface == PQOS_INTER_OS_RESCTRL_MON) {
366 DEBUG(RDT_PLUGIN ": CORE LLC[KB] MBL[MB] MBR[MB]");
368 DEBUG(RDT_PLUGIN ": CORE RMID LLC[KB] MBL[MB] MBR[MB]");
371 DEBUG(RDT_PLUGIN ": CORE RMID LLC[KB] MBL[MB] MBR[MB]");
372 #endif /* LIBPQOS2 */
374 for (size_t i = 0; i < g_rdt->cores.num_cgroups; i++) {
375 const struct pqos_event_values *pv = &g_rdt->pcgroups[i]->values;
377 double llc = bytes_to_kb(pv->llc);
378 double mbr = bytes_to_mb(pv->mbm_remote_delta);
379 double mbl = bytes_to_mb(pv->mbm_local_delta);
381 if (g_interface == PQOS_INTER_OS_RESCTRL_MON) {
382 DEBUG(RDT_PLUGIN ": [%s] %10.1f %10.1f %10.1f",
383 g_rdt->cores.cgroups[i].desc, llc, mbl, mbr);
385 DEBUG(RDT_PLUGIN ": [%s] %8u %10.1f %10.1f %10.1f",
386 g_rdt->cores.cgroups[i].desc, g_rdt->pcgroups[i]->poll_ctx[0].rmid,
390 DEBUG(RDT_PLUGIN ": [%s] %8u %10.1f %10.1f %10.1f",
391 g_rdt->cores.cgroups[i].desc, g_rdt->pcgroups[i]->poll_ctx[0].rmid,
393 #endif /* LIBPQOS2 */
398 static void rdt_dump_pids_data(void) {
400 * NAME - monitored group of processes
401 * PIDs - list of PID numbers in the NAME group
402 * LLC - last level cache occupancy
403 * MBL - local memory bandwidth
404 * MBR - remote memory bandwidth
407 DEBUG(RDT_PLUGIN ": NAME PIDs");
408 char pids[DATA_MAX_NAME_LEN];
409 for (size_t i = 0; i < g_rdt->num_ngroups; ++i) {
410 memset(pids, 0, sizeof(pids));
411 for (size_t j = 0; j < g_rdt->ngroups[i].num_names; ++j) {
412 pids_list_t *list = g_rdt->ngroups[i].proc_pids_array[j].pids;
413 while (list != NULL) {
414 snprintf(pids + strlen(pids), sizeof(pids) - strlen(pids) - 1, " %u",
419 DEBUG(RDT_PLUGIN ": [%s] %s", g_rdt->ngroups[i].desc, pids);
422 DEBUG(RDT_PLUGIN ": NAME LLC[KB] MBL[MB] MBR[MB]");
423 for (size_t i = 0; i < g_rdt->num_ngroups; i++) {
425 const struct pqos_event_values *pv = &g_rdt->pngroups[i]->values;
427 double llc = bytes_to_kb(pv->llc);
428 double mbr = bytes_to_mb(pv->mbm_remote_delta);
429 double mbl = bytes_to_mb(pv->mbm_local_delta);
431 DEBUG(RDT_PLUGIN ": [%s] %10.1f %10.1f %10.1f", g_rdt->ngroups[i].desc,
435 #endif /* LIBPQOS2 */
436 #endif /* COLLECT_DEBUG */
438 static void rdt_free_cgroups(void) {
439 config_cores_cleanup(&g_rdt->cores);
440 for (int i = 0; i < RDT_MAX_CORES; i++) {
441 sfree(g_rdt->pcgroups[i]);
446 static int pids_list_free(pids_list_t *list) {
449 pids_list_t *current = list;
450 while (current != NULL) {
451 pids_list_t *previous = current;
452 current = current->next;
458 static void rdt_free_ngroups(rdt_ctx_t *rdt) {
459 for (int i = 0; i < RDT_MAX_NAMES_GROUPS; i++) {
460 if (rdt->ngroups[i].desc)
461 DEBUG(RDT_PLUGIN ": Freeing pids \'%s\' group\'s data...",
462 rdt->ngroups[i].desc);
463 sfree(rdt->ngroups[i].desc);
465 strarray_free(rdt->ngroups[i].names, rdt->ngroups[i].num_names);
467 if (rdt->ngroups[i].proc_pids_array) {
468 for (size_t j = 0; j < rdt->ngroups[i].num_names; ++j) {
469 if (NULL == rdt->ngroups[i].proc_pids_array[j].pids)
471 pids_list_free(rdt->ngroups[i].proc_pids_array[j].pids);
474 sfree(rdt->ngroups[i].proc_pids_array);
477 rdt->ngroups[i].num_names = 0;
478 sfree(rdt->pngroups[i]);
481 #endif /* LIBPQOS2 */
483 static int rdt_default_cgroups(void) {
484 unsigned num_cores = g_rdt->pqos_cpu->num_cores;
486 g_rdt->cores.cgroups = calloc(num_cores, sizeof(*g_rdt->cores.cgroups));
487 if (g_rdt->cores.cgroups == NULL) {
488 ERROR(RDT_PLUGIN ": Error allocating core groups array");
491 g_rdt->cores.num_cgroups = num_cores;
493 /* configure each core in separate group */
494 for (unsigned i = 0; i < num_cores; i++) {
495 core_group_t *cgroup = g_rdt->cores.cgroups + i;
496 char desc[DATA_MAX_NAME_LEN];
498 /* set core group info */
499 cgroup->cores = calloc(1, sizeof(*cgroup->cores));
500 if (cgroup->cores == NULL) {
501 ERROR(RDT_PLUGIN ": Error allocating cores array");
505 cgroup->num_cores = 1;
506 cgroup->cores[0] = i;
508 snprintf(desc, sizeof(desc), "%d", g_rdt->pqos_cpu->cores[i].lcore);
509 cgroup->desc = strdup(desc);
510 if (cgroup->desc == NULL) {
511 ERROR(RDT_PLUGIN ": Error allocating core group description");
520 static int rdt_is_core_id_valid(unsigned int core_id) {
522 for (unsigned int i = 0; i < g_rdt->pqos_cpu->num_cores; i++)
523 if (core_id == g_rdt->pqos_cpu->cores[i].lcore)
530 static int rdt_is_proc_name_valid(const char *name) {
533 unsigned len = strlen(name);
534 if (len > 0 && len <= RDT_MAX_NAME_LEN)
538 ": Process name \'%s\' is too long. Max supported len is %d chars.",
539 name, RDT_MAX_NAME_LEN);
545 #endif /* LIBPQOS2 */
547 static int rdt_config_cgroups(oconfig_item_t *item) {
549 enum pqos_mon_event events = 0;
551 if (config_cores_parse(item, &g_rdt->cores) < 0) {
553 ERROR(RDT_PLUGIN ": Error parsing core groups configuration.");
556 n = g_rdt->cores.num_cgroups;
558 /* validate configured core id values */
559 for (size_t group_idx = 0; group_idx < n; group_idx++) {
560 core_group_t *cgroup = g_rdt->cores.cgroups + group_idx;
561 for (size_t core_idx = 0; core_idx < cgroup->num_cores; core_idx++) {
562 if (!rdt_is_core_id_valid(cgroup->cores[core_idx])) {
563 ERROR(RDT_PLUGIN ": Core group '%s' contains invalid core id '%u'",
564 cgroup->desc, cgroup->cores[core_idx]);
572 /* create default core groups if "Cores" config option is empty */
573 int ret = rdt_default_cgroups();
576 ERROR(RDT_PLUGIN ": Error creating default core groups configuration.");
581 ": No core groups configured. Default core groups created.");
584 /* Get all available events on this platform */
585 for (unsigned int i = 0; i < g_rdt->cap_mon->u.mon->num_events; i++)
586 events |= g_rdt->cap_mon->u.mon->events[i].type;
588 events &= ~(PQOS_PERF_EVENT_LLC_MISS);
590 DEBUG(RDT_PLUGIN ": Number of cores in the system: %u",
591 g_rdt->pqos_cpu->num_cores);
592 DEBUG(RDT_PLUGIN ": Available events to monitor: %#x", events);
594 g_rdt->cores.num_cgroups = n;
595 for (int i = 0; i < n; i++) {
596 for (int j = 0; j < i; j++) {
598 found = config_cores_cmp_cgroups(&g_rdt->cores.cgroups[j],
599 &g_rdt->cores.cgroups[i]);
602 ERROR(RDT_PLUGIN ": Cannot monitor same cores in different groups.");
607 g_rdt->events[i] = events;
608 g_rdt->pcgroups[i] = calloc(1, sizeof(*g_rdt->pcgroups[i]));
609 if (g_rdt->pcgroups[i] == NULL) {
611 ERROR(RDT_PLUGIN ": Failed to allocate memory for monitoring data.");
620 static int rdt_config_ngroups(rdt_ctx_t *rdt, const oconfig_item_t *item) {
622 enum pqos_mon_event events = 0;
625 DEBUG(RDT_PLUGIN ": ngroups_config: Invalid argument.");
629 DEBUG(RDT_PLUGIN ": Process names groups [%d]:", item->values_num);
630 for (int j = 0; j < item->values_num; j++) {
631 if (item->values[j].type != OCONFIG_TYPE_STRING) {
633 ": given process names group value is not a string [idx=%d]",
637 DEBUG(RDT_PLUGIN ": [%d]: %s", j, item->values[j].value.string);
640 n = oconfig_to_ngroups(item, rdt->ngroups, RDT_MAX_NAMES_GROUPS);
642 rdt_free_ngroups(rdt);
643 ERROR(RDT_PLUGIN ": Error parsing process name groups configuration.");
647 /* validate configured process name values */
648 for (int group_idx = 0; group_idx < n; group_idx++) {
649 DEBUG(RDT_PLUGIN ": checking group [%d]: %s", group_idx,
650 rdt->ngroups[group_idx].desc);
651 for (size_t name_idx = 0; name_idx < rdt->ngroups[group_idx].num_names;
653 DEBUG(RDT_PLUGIN ": checking process name [%zu]: %s", name_idx,
654 rdt->ngroups[group_idx].names[name_idx]);
655 if (!rdt_is_proc_name_valid(rdt->ngroups[group_idx].names[name_idx])) {
656 ERROR(RDT_PLUGIN ": Process name group '%s' contains invalid name '%s'",
657 rdt->ngroups[group_idx].desc,
658 rdt->ngroups[group_idx].names[name_idx]);
659 rdt_free_ngroups(rdt);
666 ERROR(RDT_PLUGIN ": Empty process name groups configured.");
670 /* Get all available events on this platform */
671 for (unsigned i = 0; i < rdt->cap_mon->u.mon->num_events; i++)
672 events |= rdt->cap_mon->u.mon->events[i].type;
674 events &= ~(PQOS_PERF_EVENT_LLC_MISS);
676 DEBUG(RDT_PLUGIN ": Available events to monitor: %#x", events);
678 rdt->num_ngroups = n;
679 for (int i = 0; i < n; i++) {
680 for (int j = 0; j < i; j++) {
681 int found = ngroup_cmp(&rdt->ngroups[j], &rdt->ngroups[i]);
683 rdt_free_ngroups(rdt);
685 ": Cannot monitor same process name in different groups.");
690 rdt->ngroups[i].events = events;
691 rdt->pngroups[i] = calloc(1, sizeof(*rdt->pngroups[i]));
692 if (rdt->pngroups[i] == NULL) {
693 rdt_free_ngroups(rdt);
695 ": Failed to allocate memory for process name monitoring data.");
708 * Adds pid at the end of the pids list.
709 * Allocates memory for new pid element, it is up to user to free it.
712 * `list' Head of target pids_list.
713 * `pid' Pid to be added.
716 * On success, returns 0.
717 * -1 on memory allocation error.
719 static int pids_list_add_pid(pids_list_t **list, const pid_t pid) {
722 pids_list_t *new_element = calloc(1, sizeof(*new_element));
724 if (new_element == NULL) {
725 ERROR(RDT_PLUGIN ": Alloc error\n");
728 new_element->pid = pid;
729 new_element->next = NULL;
731 pids_list_t **current = list;
732 while (*current != NULL) {
733 current = &((*current)->next);
735 *current = new_element;
741 * pids_list_contains_pid
744 * Tests if pids list contains specific pid.
747 * `list' Head of pids_list.
748 * `pid' Pid to be searched for.
751 * If PID found in list, returns 1,
752 * Otherwise returns 0.
754 static int pids_list_contains_pid(pids_list_t *list, const pid_t pid) {
757 pids_list_t *current = list;
758 while (current != NULL) {
759 if (current->pid == pid)
761 current = current->next;
768 * pids_list_add_pids_list
771 * Adds pids list at the end of the pids list.
772 * Allocates memory for new pid elements, it is up to user to free it.
773 * Increases dst_num by a number of added PIDs.
776 * `dst' Head of target PIDs list.
777 * `src' Head of source PIDs list.
778 * `dst_num' Variable to be increased by a number of appended PIDs.
781 * On success, returns 0.
782 * -1 on memory allocation error.
784 static int pids_list_add_pids_list(pids_list_t **dst, pids_list_t *src,
790 pids_list_t *current = src;
793 while (current != NULL) {
794 ret = pids_list_add_pid(dst, current->pid);
799 current = current->next;
810 * Reads process name from given pid directory.
811 * Strips new-line character (\n).
814 * `procfs_path` Path to systems proc directory (e.g. /proc)
815 * `pid_entry' Dirent for PID directory
816 * `name' Output buffer for process name, recommended proc_comm.
817 * `out_size' Output buffer size, recommended sizeof(proc_comm)
820 * On success, the number of read bytes (includes stripped \n).
821 * -1 on file open error
823 static int read_proc_name(const char *procfs_path,
824 const struct dirent *pid_entry, char *name,
825 const size_t out_size) {
830 memset(name, 0, out_size);
832 const char *comm_file_name = "comm";
834 char *path = ssnprintf_alloc("%s/%s/%s", procfs_path, pid_entry->d_name,
838 FILE *f = fopen(path, "r");
840 ERROR(RDT_PLUGIN ": Failed to open comm file, error: %d\n", errno);
844 size_t read_length = fread(name, sizeof(char), out_size, f);
845 name[out_size - 1] = '\0';
848 /* strip new line ending */
849 char *newline = strchr(name, '\n');
862 * Gets pid number for given /proc/pid directory entry or
863 * returns error if input directory does not hold PID information.
866 * `entry' Dirent for PID directory
867 * `pid' PID number to be filled
870 * 0 on success. -1 on error.
872 static int get_pid_number(struct dirent *entry, pid_t *pid) {
873 char *tmp_end; /* used for strtoul error check*/
875 if (pid == NULL || entry == NULL)
878 if (entry->d_type != DT_DIR)
881 /* trying to get pid number from directory name*/
882 *pid = strtoul(entry->d_name, &tmp_end, 10);
883 if (*tmp_end != '\0') {
884 return -1; /* conversion failed, not proc-pid */
886 /* all checks passed, marking as success */
895 * Copies element from list to array. Assumes the space for the array is
899 * `array' First element of target array
900 * `list' Head of the list
901 * `array_length' Length (element count) of the target array
903 static void pids_list_to_array(pid_t *array, pids_list_t *list,
904 const size_t array_length) {
908 assert(array_length > 0);
912 while (list != NULL && current < array_length) {
913 array[current] = list->pid;
921 * initialize_proc_pids
924 * Helper function to properly initialize array of proc_pids.
925 * Allocates memory for proc_pids structs.
928 * `procs_names_array' Array of null-terminated strings with
929 * process' names to be copied to new array
930 * `procs_names_array_size' procs_names_array element count
931 * `proc_pids_array' Address of pointer, under which new
932 * array of proc_pids will be allocated.
935 * 0 on success. Negative number on error:
936 * -1: allocation error
938 static int initialize_proc_pids(const char **procs_names_array,
939 const size_t procs_names_array_size,
940 proc_pids_t **proc_pids_array) {
942 assert(proc_pids_array);
943 assert(NULL == *proc_pids_array);
945 /* Copy procs names to output array. Initialize pids list with NULL value. */
946 *proc_pids_array = calloc(procs_names_array_size, sizeof(**proc_pids_array));
948 if (NULL == *proc_pids_array)
951 for (size_t i = 0; i < procs_names_array_size; ++i) {
952 sstrncpy((*proc_pids_array)[i].proccess_name, procs_names_array[i],
953 STATIC_ARRAY_SIZE((*proc_pids_array)[i].proccess_name));
954 (*proc_pids_array)[i].pids = NULL;
962 * fetch_pids_for_procs
965 * Finds PIDs matching given process's names.
966 * Searches all PID directories in /proc fs and
967 * allocates memory for proc_pids structs, it is up to user to free it.
968 * Output array will have same element count as input array.
971 * `procfs_path' Path to systems proc directory (e.g. /proc)
972 * `procs_names_array' Array of null-terminated strings with
973 * process' names to be copied to new array
974 * `procs_names_array_size' procs_names_array element count
975 * `proc_pids_array' Address of pointer, under which new
976 * array of proc_pids will be allocated.
980 * 0 on success. -1 on error.
982 static int fetch_pids_for_procs(const char *procfs_path,
983 const char **procs_names_array,
984 const size_t procs_names_array_size,
985 proc_pids_t **proc_pids_array) {
987 assert(procs_names_array);
988 assert(procs_names_array_size);
990 DIR *proc_dir = opendir(procfs_path);
991 if (proc_dir == NULL) {
992 ERROR(RDT_PLUGIN ": Could not open %s directory, error: %d", procfs_path,
997 int init_result = initialize_proc_pids(
998 procs_names_array, procs_names_array_size, proc_pids_array);
999 if (0 != init_result)
1002 /* Go through procfs and find PIDS and their comms */
1003 struct dirent *entry;
1004 while ((entry = readdir(proc_dir)) != NULL) {
1007 int pid_conversion = get_pid_number(entry, &pid);
1008 if (pid_conversion < 0)
1013 read_proc_name(procfs_path, entry, comm, sizeof(proc_comm_t));
1014 if (read_result <= 0) {
1015 ERROR(RDT_PLUGIN ": Comm file skipped. Read result: %d", read_result);
1019 /* Try to find comm in input procs array (proc_pids_array has same names) */
1020 for (size_t i = 0; i < procs_names_array_size; ++i) {
1021 if (0 == strncmp(comm, (*proc_pids_array)[i].proccess_name,
1022 STATIC_ARRAY_SIZE(comm)))
1023 pids_list_add_pid(&((*proc_pids_array)[i].pids), pid);
1027 int close_result = closedir(proc_dir);
1028 if (0 != close_result) {
1029 ERROR(RDT_PLUGIN ": failed to close %s directory, error: %d", procfs_path,
1031 sfree(*proc_pids_array);
1036 #endif /* LIBPQOS2 */
1038 static void rdt_pqos_log(void *context, const size_t size, const char *msg) {
1039 DEBUG(RDT_PLUGIN ": %s", msg);
1042 static int rdt_preinit(void) {
1045 if (g_rdt != NULL) {
1046 /* already initialized if config callback was called before init callback */
1050 g_rdt = calloc(1, sizeof(*g_rdt));
1051 if (g_rdt == NULL) {
1052 ERROR(RDT_PLUGIN ": Failed to allocate memory for rdt context.");
1056 struct pqos_config pqos = {.fd_log = -1,
1057 .callback_log = rdt_pqos_log,
1058 .context_log = NULL,
1061 .interface = PQOS_INTER_OS_RESCTRL_MON};
1062 DEBUG(RDT_PLUGIN ": Initializing PQoS with RESCTRL interface");
1064 .interface = PQOS_INTER_MSR};
1065 DEBUG(RDT_PLUGIN ": Initializing PQoS with MSR interface");
1068 ret = pqos_init(&pqos);
1069 DEBUG(RDT_PLUGIN ": PQoS initialization result: [%d]", ret);
1072 if (ret == PQOS_RETVAL_INTER) {
1073 pqos.interface = PQOS_INTER_MSR;
1074 DEBUG(RDT_PLUGIN ": Initializing PQoS with MSR interface");
1075 ret = pqos_init(&pqos);
1076 DEBUG(RDT_PLUGIN ": PQoS initialization result: [%d]", ret);
1080 if (ret != PQOS_RETVAL_OK) {
1081 ERROR(RDT_PLUGIN ": Error initializing PQoS library!");
1082 goto rdt_preinit_error1;
1085 g_interface = pqos.interface;
1087 ret = pqos_cap_get(&g_rdt->pqos_cap, &g_rdt->pqos_cpu);
1088 if (ret != PQOS_RETVAL_OK) {
1089 ERROR(RDT_PLUGIN ": Error retrieving PQoS capabilities.");
1090 goto rdt_preinit_error2;
1093 ret = pqos_cap_get_type(g_rdt->pqos_cap, PQOS_CAP_TYPE_MON, &g_rdt->cap_mon);
1094 if (ret == PQOS_RETVAL_PARAM) {
1095 ERROR(RDT_PLUGIN ": Error retrieving monitoring capabilities.");
1096 goto rdt_preinit_error2;
1099 if (g_rdt->cap_mon == NULL) {
1102 ": Monitoring capability not detected. Nothing to do for the plugin.");
1103 goto rdt_preinit_error2;
1106 /* Reset pqos monitoring groups registers */
1120 static int rdt_config(oconfig_item_t *ci) {
1121 if (rdt_preinit() != 0) {
1122 g_state = CONFIGURATION_ERROR;
1123 /* if we return -1 at this point collectd
1124 reports a failure in configuration and
1130 for (int i = 0; i < ci->children_num; i++) {
1131 oconfig_item_t *child = ci->children + i;
1133 if (strncasecmp("Cores", child->key, (size_t)strlen("Cores")) == 0) {
1134 if (rdt_config_cgroups(child) != 0) {
1135 g_state = CONFIGURATION_ERROR;
1136 /* if we return -1 at this point collectd
1137 reports a failure in configuration and
1145 #endif /* COLLECT_DEBUG */
1146 } else if (strncasecmp("Processes", child->key,
1147 (size_t)strlen("Processes")) == 0) {
1149 if (g_interface != PQOS_INTER_OS_RESCTRL_MON) {
1150 ERROR(RDT_PLUGIN ": Configuration parameter \"%s\" not supported. "
1151 "Resctrl monitoring is needed for PIDs monitoring.",
1153 g_state = CONFIGURATION_ERROR;
1154 /* if we return -1 at this point collectd
1155 reports a failure in configuration and
1161 if (rdt_config_ngroups(g_rdt, child) != 0) {
1162 g_state = CONFIGURATION_ERROR;
1163 /* if we return -1 at this point collectd
1164 reports a failure in configuration and
1172 #endif /* COLLECT_DEBUG */
1173 #else /* !LIBPQOS2 */
1174 ERROR(RDT_PLUGIN ": Configuration parameter \"%s\" not supported, please "
1175 "recompile collectd with libpqos version 2.0 or newer.",
1177 #endif /* LIBPQOS2 */
1179 ERROR(RDT_PLUGIN ": Unknown configuration parameter \"%s\".", child->key);
1186 static void rdt_submit_derive(const char *cgroup, const char *type,
1187 const char *type_instance, derive_t value) {
1188 value_list_t vl = VALUE_LIST_INIT;
1190 vl.values = &(value_t){.derive = value};
1193 sstrncpy(vl.plugin, RDT_PLUGIN, sizeof(vl.plugin));
1194 snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s", cgroup);
1195 sstrncpy(vl.type, type, sizeof(vl.type));
1197 sstrncpy(vl.type_instance, type_instance, sizeof(vl.type_instance));
1199 plugin_dispatch_values(&vl);
1202 static void rdt_submit_gauge(const char *cgroup, const char *type,
1203 const char *type_instance, gauge_t value) {
1204 value_list_t vl = VALUE_LIST_INIT;
1206 vl.values = &(value_t){.gauge = value};
1209 sstrncpy(vl.plugin, RDT_PLUGIN, sizeof(vl.plugin));
1210 snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s", cgroup);
1211 sstrncpy(vl.type, type, sizeof(vl.type));
1213 sstrncpy(vl.type_instance, type_instance, sizeof(vl.type_instance));
1215 plugin_dispatch_values(&vl);
1219 static int rdt_pid_list_diff(pids_list_t *prev, pids_list_t *curr,
1220 pids_list_t **added, size_t *added_num,
1221 pids_list_t **removed, size_t *removed_num) {
1222 assert(prev || curr);
1227 /* append all PIDs from curr to added*/
1228 return pids_list_add_pids_list(added, curr, added_num);
1229 } else if (NULL == curr) {
1230 /* append all PIDs from prev to removed*/
1231 return pids_list_add_pids_list(removed, prev, removed_num);
1234 pids_list_t *item = prev;
1235 while (item != NULL) {
1236 if (0 == pids_list_contains_pid(curr, item->pid)) {
1237 pids_list_add_pid(removed, item->pid);
1244 while (item != NULL) {
1245 if (0 == pids_list_contains_pid(prev, item->pid)) {
1246 pids_list_add_pid(added, item->pid);
1255 static int rdt_refresh_ngroup(rdt_name_group_t *ngroup,
1256 struct pqos_mon_data *group_mon_data) {
1263 if (NULL == ngroup->proc_pids_array) {
1265 ": rdt_refresh_ngroup: \'%s\' uninitialized process pids array.",
1271 DEBUG(RDT_PLUGIN ": rdt_refresh_ngroup: \'%s\' process names group.",
1274 proc_pids_t *proc_pids_array_prev = ngroup->proc_pids_array;
1275 proc_pids_t *proc_pids_array_curr = NULL;
1278 fetch_pids_for_procs(RDT_PROC_PATH, (const char **)ngroup->names,
1279 ngroup->num_names, &proc_pids_array_curr);
1281 if (0 != fetch_result) {
1282 ERROR(RDT_PLUGIN ": rdt_refresh_ngroup: \'%s\' failed to fetch PIDs.",
1284 return fetch_result;
1287 pids_list_t *new_pids = NULL;
1288 size_t new_pids_count = 0;
1290 pids_list_t *lost_pids = NULL;
1291 size_t lost_pids_count = 0;
1293 for (size_t i = 0; i < ngroup->num_names; ++i) {
1294 if (NULL == proc_pids_array_prev[i].pids &&
1295 NULL == proc_pids_array_curr[i].pids)
1297 int diff_result = rdt_pid_list_diff(
1298 proc_pids_array_prev[i].pids, proc_pids_array_curr[i].pids, &new_pids,
1299 &new_pids_count, &lost_pids, &lost_pids_count);
1300 if (0 != diff_result) {
1302 ": rdt_refresh_ngroup: \'%s\'. Error [%d] during PID diff.",
1303 ngroup->desc, diff_result);
1309 DEBUG(RDT_PLUGIN ": rdt_refresh_ngroup: \'%s\' process names group, added: "
1311 ngroup->desc, (unsigned)new_pids_count, (unsigned)lost_pids_count);
1313 if (new_pids_count > 0 || lost_pids_count > 0) {
1315 if (new_pids && new_pids_count > 0) {
1316 pid_t new_pids_array[new_pids_count];
1317 pids_list_to_array(new_pids_array, new_pids,
1318 STATIC_ARRAY_SIZE(new_pids_array));
1320 /* no pids are monitored for this group yet: start monitoring */
1321 if (0 == ngroup->monitored_pids_count) {
1324 pqos_mon_start_pids(new_pids_count, new_pids_array, ngroup->events,
1325 (void *)ngroup->desc, group_mon_data);
1326 if (PQOS_RETVAL_OK == start_result) {
1327 ngroup->monitored_pids_count = new_pids_count;
1329 ERROR(RDT_PLUGIN ": rdt_refresh_ngroup: \'%s\'. Error [%d] while "
1330 "STARTING pids monitoring",
1331 ngroup->desc, start_result);
1333 goto pqos_error_recovery;
1339 pqos_mon_add_pids(new_pids_count, new_pids_array, group_mon_data);
1340 if (PQOS_RETVAL_OK == add_result)
1341 ngroup->monitored_pids_count += new_pids_count;
1344 ": rdt_refresh_ngroup: \'%s\'. Error [%d] while ADDING pids.",
1345 ngroup->desc, add_result);
1347 goto pqos_error_recovery;
1352 if (lost_pids && lost_pids_count > 0) {
1353 pid_t lost_pids_array[lost_pids_count];
1354 pids_list_to_array(lost_pids_array, lost_pids,
1355 STATIC_ARRAY_SIZE(lost_pids_array));
1357 if (lost_pids_count == ngroup->monitored_pids_count) {
1358 /* all pids for this group are lost: stop monitoring */
1359 int stop_result = pqos_mon_stop(group_mon_data);
1360 if (PQOS_RETVAL_OK != stop_result) {
1361 ERROR(RDT_PLUGIN ": rdt_refresh_ngroup: \'%s\'. Error [%d] while "
1362 "STOPPING monitoring",
1363 ngroup->desc, stop_result);
1365 goto pqos_error_recovery;
1367 ngroup->monitored_pids_count = 0;
1369 assert(lost_pids_count < ngroup->monitored_pids_count);
1370 int remove_result = pqos_mon_remove_pids(
1371 lost_pids_count, lost_pids_array, group_mon_data);
1372 if (PQOS_RETVAL_OK == remove_result) {
1373 ngroup->monitored_pids_count -= lost_pids_count;
1376 ": rdt_refresh_ngroup: \'%s\'. Error [%d] while REMOVING pids.",
1377 ngroup->desc, remove_result);
1379 goto pqos_error_recovery;
1384 ngroup->proc_pids_array = proc_pids_array_curr;
1389 pqos_error_recovery:
1391 * Resources might be temporary unavailable.
1394 * Collectd will halt the reading thread for this
1395 * plugin if it returns an error.
1396 * Consecutive errors will be increasing the read period
1397 * up to 1 day interval.
1398 * On pqos error stop monitoring current group
1399 * and reset the proc_pids array
1400 * monitoring will be restarted on next collectd read cycle
1402 DEBUG(RDT_PLUGIN ": rdt_refresh_ngroup: \'%s\' group RESET after error.",
1404 pqos_mon_stop(group_mon_data);
1405 for (size_t i = 0; i < ngroup->num_names; ++i) {
1406 if (ngroup->proc_pids_array[i].pids)
1407 pids_list_free(ngroup->proc_pids_array[i].pids);
1409 sfree(ngroup->proc_pids_array);
1411 initialize_proc_pids((const char **)ngroup->names, ngroup->num_names,
1412 &ngroup->proc_pids_array);
1413 ngroup->monitored_pids_count = 0;
1416 if (ngroup->proc_pids_array == proc_pids_array_curr) {
1417 assert(proc_pids_array_curr);
1418 /* new list was successfully saved, free the old one */
1419 for (size_t i = 0; i < ngroup->num_names; ++i)
1420 if (proc_pids_array_prev[i].pids)
1421 pids_list_free(proc_pids_array_prev[i].pids);
1423 sfree(proc_pids_array_prev);
1426 /* new list was not saved. Free the new list, keep the old one*/
1427 for (size_t i = 0; i < ngroup->num_names; ++i)
1428 if (proc_pids_array_curr[i].pids)
1429 pids_list_free(proc_pids_array_curr[i].pids);
1431 sfree(proc_pids_array_curr);
1435 pids_list_free(new_pids);
1438 pids_list_free(lost_pids);
1443 static int read_pids_data() {
1445 if (0 == g_rdt->num_ngroups) {
1446 DEBUG(RDT_PLUGIN ": read_pids_data: not configured - PIDs read skipped");
1450 DEBUG(RDT_PLUGIN ": read_pids_data: Scanning active groups");
1451 struct pqos_mon_data *active_groups[RDT_MAX_NAMES_GROUPS] = {0};
1452 size_t active_group_idx = 0;
1453 for (size_t pngroups_idx = 0;
1454 pngroups_idx < STATIC_ARRAY_SIZE(g_rdt->pngroups); ++pngroups_idx)
1455 if (0 != g_rdt->ngroups[pngroups_idx].monitored_pids_count)
1456 active_groups[active_group_idx++] = g_rdt->pngroups[pngroups_idx];
1460 if (0 == active_group_idx) {
1461 DEBUG(RDT_PLUGIN ": read_pids_data: no active groups - PIDs read skipped");
1462 goto groups_refresh;
1465 DEBUG(RDT_PLUGIN ": read_pids_data: PIDs data polling");
1467 int poll_result = pqos_mon_poll(active_groups, active_group_idx);
1468 if (poll_result != PQOS_RETVAL_OK) {
1469 ERROR(RDT_PLUGIN ": read_pids_data: Failed to poll monitoring data for "
1470 "pids. Error [%d].",
1473 goto groups_refresh;
1476 for (size_t i = 0; i < g_rdt->num_ngroups; i++) {
1477 enum pqos_mon_event mbm_events =
1478 (PQOS_MON_EVENT_LMEM_BW | PQOS_MON_EVENT_TMEM_BW |
1479 PQOS_MON_EVENT_RMEM_BW);
1481 if (g_rdt->pngroups[i] == NULL ||
1482 g_rdt->ngroups[i].monitored_pids_count == 0)
1485 const struct pqos_event_values *pv = &g_rdt->pngroups[i]->values;
1487 /* Submit only monitored events data */
1489 if (g_rdt->ngroups[i].events & PQOS_MON_EVENT_L3_OCCUP)
1490 rdt_submit_gauge(g_rdt->ngroups[i].desc, "bytes", "llc", pv->llc);
1492 if (g_rdt->ngroups[i].events & PQOS_PERF_EVENT_IPC)
1493 rdt_submit_gauge(g_rdt->ngroups[i].desc, "ipc", NULL, pv->ipc);
1495 if (g_rdt->ngroups[i].events & mbm_events) {
1496 rdt_submit_derive(g_rdt->ngroups[i].desc, "memory_bandwidth", "local",
1497 pv->mbm_local_delta);
1498 rdt_submit_derive(g_rdt->ngroups[i].desc, "memory_bandwidth", "remote",
1499 pv->mbm_remote_delta);
1504 rdt_dump_pids_data();
1505 #endif /* COLLECT_DEBUG */
1508 for (size_t i = 0; i < g_rdt->num_ngroups; i++) {
1509 int refresh_result =
1510 rdt_refresh_ngroup(&(g_rdt->ngroups[i]), g_rdt->pngroups[i]);
1512 if (0 != refresh_result) {
1513 ERROR(RDT_PLUGIN ": read_pids_data: NGroup %zu refresh failed. Error: %d",
1516 /* refresh error will be escalated only if there were no
1519 ret = refresh_result;
1528 static void rdt_init_pids_monitoring() {
1529 for (size_t group_idx = 0; group_idx < g_rdt->num_ngroups; group_idx++) {
1531 * Each group must have not-null proc_pids array.
1532 * Initial refresh is not mandatory for proper
1533 * PIDs statistics detection.
1535 rdt_name_group_t *ng = &g_rdt->ngroups[group_idx];
1536 int init_result = initialize_proc_pids((const char **)ng->names,
1537 ng->num_names, &ng->proc_pids_array);
1538 if (0 != init_result) {
1540 ": Initialization of proc_pids for group %zu failed. Error: %d",
1541 group_idx, init_result);
1545 int refresh_result = rdt_refresh_ngroup(&(g_rdt->ngroups[group_idx]),
1546 g_rdt->pngroups[group_idx]);
1547 if (0 != refresh_result)
1548 ERROR(RDT_PLUGIN ": Initial refresh of group %zu failed. Error: %d",
1549 group_idx, refresh_result);
1552 #endif /* LIBPQOS2 */
1554 static int read_cores_data() {
1556 if (0 == g_rdt->cores.num_cgroups) {
1557 DEBUG(RDT_PLUGIN ": read_cores_data: not configured - Cores read skipped");
1560 DEBUG(RDT_PLUGIN ": read_cores_data: Cores data poll");
1563 pqos_mon_poll(&g_rdt->pcgroups[0], (unsigned)g_rdt->cores.num_cgroups);
1564 if (ret != PQOS_RETVAL_OK) {
1565 ERROR(RDT_PLUGIN ": read_cores_data: Failed to poll monitoring data for "
1566 "cores. Error [%d].",
1571 for (size_t i = 0; i < g_rdt->cores.num_cgroups; i++) {
1572 core_group_t *cgroup = g_rdt->cores.cgroups + i;
1573 enum pqos_mon_event mbm_events =
1574 (PQOS_MON_EVENT_LMEM_BW | PQOS_MON_EVENT_TMEM_BW |
1575 PQOS_MON_EVENT_RMEM_BW);
1577 const struct pqos_event_values *pv = &g_rdt->pcgroups[i]->values;
1579 /* Submit only monitored events data */
1581 if (g_rdt->events[i] & PQOS_MON_EVENT_L3_OCCUP)
1582 rdt_submit_gauge(cgroup->desc, "bytes", "llc", pv->llc);
1584 if (g_rdt->events[i] & PQOS_PERF_EVENT_IPC)
1585 rdt_submit_gauge(cgroup->desc, "ipc", NULL, pv->ipc);
1587 if (g_rdt->events[i] & mbm_events) {
1588 rdt_submit_derive(cgroup->desc, "memory_bandwidth", "local",
1589 pv->mbm_local_delta);
1590 rdt_submit_derive(cgroup->desc, "memory_bandwidth", "remote",
1591 pv->mbm_remote_delta);
1596 rdt_dump_cores_data();
1597 #endif /* COLLECT_DEBUG */
1602 static int rdt_read(__attribute__((unused)) user_data_t *ud) {
1604 if (g_rdt == NULL) {
1605 ERROR(RDT_PLUGIN ": rdt_read: plugin not initialized.");
1609 int cores_read_result = read_cores_data();
1612 int pids_read_result = read_pids_data();
1613 #endif /* LIBPQOS2 */
1615 if (0 != cores_read_result)
1616 return cores_read_result;
1619 if (0 != pids_read_result)
1620 return pids_read_result;
1621 #endif /* LIBPQOS2 */
1626 static void rdt_init_cores_monitoring() {
1627 for (size_t i = 0; i < g_rdt->cores.num_cgroups; i++) {
1628 core_group_t *cg = g_rdt->cores.cgroups + i;
1630 int mon_start_result =
1631 pqos_mon_start(cg->num_cores, cg->cores, g_rdt->events[i],
1632 (void *)cg->desc, g_rdt->pcgroups[i]);
1634 if (mon_start_result != PQOS_RETVAL_OK)
1636 ": Error starting cores monitoring group %s (pqos status=%d)",
1637 cg->desc, mon_start_result);
1641 static int rdt_init(void) {
1643 if (g_state == CONFIGURATION_ERROR)
1646 int rdt_preinint_result = rdt_preinit();
1647 if (rdt_preinint_result != 0)
1648 return rdt_preinint_result;
1650 rdt_init_cores_monitoring();
1652 rdt_init_pids_monitoring();
1653 #endif /* LIBPQOS2 */
1658 static int rdt_shutdown(void) {
1661 DEBUG(RDT_PLUGIN ": rdt_shutdown.");
1666 /* Stop monitoring cores */
1667 for (size_t i = 0; i < g_rdt->cores.num_cgroups; i++) {
1668 pqos_mon_stop(g_rdt->pcgroups[i]);
1671 /* Stop pids monitoring */
1673 for (size_t i = 0; i < g_rdt->num_ngroups; i++)
1674 pqos_mon_stop(g_rdt->pngroups[i]);
1678 if (ret != PQOS_RETVAL_OK)
1679 ERROR(RDT_PLUGIN ": Error shutting down PQoS library.");
1683 rdt_free_ngroups(g_rdt);
1684 #endif /* LIBPQOS2 */
1690 void module_register(void) {
1691 plugin_register_init(RDT_PLUGIN, rdt_init);
1692 plugin_register_complex_config(RDT_PLUGIN, rdt_config);
1693 plugin_register_complex_read(NULL, RDT_PLUGIN, rdt_read, 0, NULL);
1694 plugin_register_shutdown(RDT_PLUGIN, rdt_shutdown);