intel_pmu: refactor pmu_event_get_meta function.
[collectd.git] / src / intel_pmu.c
1 /**
2  * collectd - src/intel_pmu.c
3  *
4  * Copyright(c) 2017 Intel Corporation. All rights reserved.
5  *
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:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
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
22  * SOFTWARE.
23  *
24  * Authors:
25  *   Serhiy Pshyk <serhiyx.pshyk@intel.com>
26  **/
27
28 #include "collectd.h"
29 #include "common.h"
30
31 #include <jevents.h>
32 #include <jsession.h>
33
34 #define PMU_PLUGIN "intel_pmu"
35
36 #define HW_CACHE_READ_ACCESS                                                   \
37   (((PERF_COUNT_HW_CACHE_OP_READ) << 8) |                                      \
38    ((PERF_COUNT_HW_CACHE_RESULT_ACCESS) << 16))
39
40 #define HW_CACHE_WRITE_ACCESS                                                  \
41   (((PERF_COUNT_HW_CACHE_OP_WRITE) << 8) |                                     \
42    ((PERF_COUNT_HW_CACHE_RESULT_ACCESS) << 16))
43
44 #define HW_CACHE_PREFETCH_ACCESS                                               \
45   (((PERF_COUNT_HW_CACHE_OP_PREFETCH) << 8) |                                  \
46    ((PERF_COUNT_HW_CACHE_RESULT_ACCESS) << 16))
47
48 #define HW_CACHE_READ_MISS                                                     \
49   (((PERF_COUNT_HW_CACHE_OP_READ) << 8) |                                      \
50    ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))
51
52 #define HW_CACHE_WRITE_MISS                                                    \
53   (((PERF_COUNT_HW_CACHE_OP_WRITE) << 8) |                                     \
54    ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))
55
56 #define HW_CACHE_PREFETCH_MISS                                                 \
57   (((PERF_COUNT_HW_CACHE_OP_PREFETCH) << 8) |                                  \
58    ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))
59
60 struct event_info {
61   char *name;
62   uint64_t config;
63 };
64 typedef struct event_info event_info_t;
65
66 struct intel_pmu_ctx_s {
67   _Bool hw_cache_events;
68   _Bool kernel_pmu_events;
69   _Bool sw_events;
70   char event_list_fn[PATH_MAX];
71   char **hw_events;
72   size_t hw_events_count;
73   struct eventlist *event_list;
74 };
75 typedef struct intel_pmu_ctx_s intel_pmu_ctx_t;
76
77 event_info_t g_kernel_pmu_events[] = {
78     {.name = "cpu-cycles", .config = PERF_COUNT_HW_CPU_CYCLES},
79     {.name = "instructions", .config = PERF_COUNT_HW_INSTRUCTIONS},
80     {.name = "cache-references", .config = PERF_COUNT_HW_CACHE_REFERENCES},
81     {.name = "cache-misses", .config = PERF_COUNT_HW_CACHE_MISSES},
82     {.name = "branches", .config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS},
83     {.name = "branch-misses", .config = PERF_COUNT_HW_BRANCH_MISSES},
84     {.name = "bus-cycles", .config = PERF_COUNT_HW_BUS_CYCLES},
85 };
86
87 event_info_t g_hw_cache_events[] = {
88
89     {.name = "L1-dcache-loads",
90      .config = (PERF_COUNT_HW_CACHE_L1D | HW_CACHE_READ_ACCESS)},
91     {.name = "L1-dcache-load-misses",
92      .config = (PERF_COUNT_HW_CACHE_L1D | HW_CACHE_READ_MISS)},
93     {.name = "L1-dcache-stores",
94      .config = (PERF_COUNT_HW_CACHE_L1D | HW_CACHE_WRITE_ACCESS)},
95     {.name = "L1-dcache-store-misses",
96      .config = (PERF_COUNT_HW_CACHE_L1D | HW_CACHE_WRITE_MISS)},
97     {.name = "L1-dcache-prefetches",
98      .config = (PERF_COUNT_HW_CACHE_L1D | HW_CACHE_PREFETCH_ACCESS)},
99     {.name = "L1-dcache-prefetch-misses",
100      .config = (PERF_COUNT_HW_CACHE_L1D | HW_CACHE_PREFETCH_MISS)},
101
102     {.name = "L1-icache-loads",
103      .config = (PERF_COUNT_HW_CACHE_L1I | HW_CACHE_READ_ACCESS)},
104     {.name = "L1-icache-load-misses",
105      .config = (PERF_COUNT_HW_CACHE_L1I | HW_CACHE_READ_MISS)},
106     {.name = "L1-icache-prefetches",
107      .config = (PERF_COUNT_HW_CACHE_L1I | HW_CACHE_PREFETCH_ACCESS)},
108     {.name = "L1-icache-prefetch-misses",
109      .config = (PERF_COUNT_HW_CACHE_L1I | HW_CACHE_PREFETCH_MISS)},
110
111     {.name = "LLC-loads",
112      .config = (PERF_COUNT_HW_CACHE_LL | HW_CACHE_READ_ACCESS)},
113     {.name = "LLC-load-misses",
114      .config = (PERF_COUNT_HW_CACHE_LL | HW_CACHE_READ_MISS)},
115     {.name = "LLC-stores",
116      .config = (PERF_COUNT_HW_CACHE_LL | HW_CACHE_WRITE_ACCESS)},
117     {.name = "LLC-store-misses",
118      .config = (PERF_COUNT_HW_CACHE_LL | HW_CACHE_WRITE_MISS)},
119     {.name = "LLC-prefetches",
120      .config = (PERF_COUNT_HW_CACHE_LL | HW_CACHE_PREFETCH_ACCESS)},
121     {.name = "LLC-prefetch-misses",
122      .config = (PERF_COUNT_HW_CACHE_LL | HW_CACHE_PREFETCH_MISS)},
123
124     {.name = "dTLB-loads",
125      .config = (PERF_COUNT_HW_CACHE_DTLB | HW_CACHE_READ_ACCESS)},
126     {.name = "dTLB-load-misses",
127      .config = (PERF_COUNT_HW_CACHE_DTLB | HW_CACHE_READ_MISS)},
128     {.name = "dTLB-stores",
129      .config = (PERF_COUNT_HW_CACHE_DTLB | HW_CACHE_WRITE_ACCESS)},
130     {.name = "dTLB-store-misses",
131      .config = (PERF_COUNT_HW_CACHE_DTLB | HW_CACHE_WRITE_MISS)},
132     {.name = "dTLB-prefetches",
133      .config = (PERF_COUNT_HW_CACHE_DTLB | HW_CACHE_PREFETCH_ACCESS)},
134     {.name = "dTLB-prefetch-misses",
135      .config = (PERF_COUNT_HW_CACHE_DTLB | HW_CACHE_PREFETCH_MISS)},
136
137     {.name = "iTLB-loads",
138      .config = (PERF_COUNT_HW_CACHE_ITLB | HW_CACHE_READ_ACCESS)},
139     {.name = "iTLB-load-misses",
140      .config = (PERF_COUNT_HW_CACHE_ITLB | HW_CACHE_READ_MISS)},
141
142     {.name = "branch-loads",
143      .config = (PERF_COUNT_HW_CACHE_BPU | HW_CACHE_READ_ACCESS)},
144     {.name = "branch-load-misses",
145      .config = (PERF_COUNT_HW_CACHE_BPU | HW_CACHE_READ_MISS)},
146 };
147
148 event_info_t g_sw_events[] = {
149     {.name = "cpu-clock", .config = PERF_COUNT_SW_CPU_CLOCK},
150
151     {.name = "task-clock", .config = PERF_COUNT_SW_TASK_CLOCK},
152
153     {.name = "context-switches", .config = PERF_COUNT_SW_CONTEXT_SWITCHES},
154
155     {.name = "cpu-migrations", .config = PERF_COUNT_SW_CPU_MIGRATIONS},
156
157     {.name = "page-faults", .config = PERF_COUNT_SW_PAGE_FAULTS},
158
159     {.name = "minor-faults", .config = PERF_COUNT_SW_PAGE_FAULTS_MIN},
160
161     {.name = "major-faults", .config = PERF_COUNT_SW_PAGE_FAULTS_MAJ},
162
163     {.name = "alignment-faults", .config = PERF_COUNT_SW_ALIGNMENT_FAULTS},
164
165     {.name = "emulation-faults", .config = PERF_COUNT_SW_EMULATION_FAULTS},
166 };
167
168 static intel_pmu_ctx_t g_ctx;
169
170 #if COLLECT_DEBUG
171 static void pmu_dump_events() {
172
173   DEBUG(PMU_PLUGIN ": Events:");
174
175   struct event *e;
176
177   for (e = g_ctx.event_list->eventlist; e; e = e->next) {
178     DEBUG(PMU_PLUGIN ":   event       : %s", e->event);
179     DEBUG(PMU_PLUGIN ":     group_lead: %d", e->group_leader);
180     DEBUG(PMU_PLUGIN ":     end_group : %d", e->end_group);
181     DEBUG(PMU_PLUGIN ":     type      : %#x", e->attr.type);
182     DEBUG(PMU_PLUGIN ":     config    : %#x", (unsigned)e->attr.config);
183     DEBUG(PMU_PLUGIN ":     size      : %d", e->attr.size);
184   }
185 }
186
187 static void pmu_dump_config(void) {
188
189   DEBUG(PMU_PLUGIN ": Config:");
190   DEBUG(PMU_PLUGIN ":   hw_cache_events   : %d", g_ctx.hw_cache_events);
191   DEBUG(PMU_PLUGIN ":   kernel_pmu_events : %d", g_ctx.kernel_pmu_events);
192   DEBUG(PMU_PLUGIN ":   software_events   : %d", g_ctx.sw_events);
193
194   for (size_t i = 0; i < g_ctx.hw_events_count; i++) {
195     DEBUG(PMU_PLUGIN ":   hardware_events[%zu]: %s", i, g_ctx.hw_events[i]);
196   }
197 }
198
199 #endif /* COLLECT_DEBUG */
200
201 static int pmu_config_hw_events(oconfig_item_t *ci) {
202
203   if (strcasecmp("HardwareEvents", ci->key) != 0) {
204     return -EINVAL;
205   }
206
207   g_ctx.hw_events = calloc(ci->values_num, sizeof(char *));
208   if (g_ctx.hw_events == NULL) {
209     ERROR(PMU_PLUGIN ": Failed to allocate hw events.");
210     return -ENOMEM;
211   }
212
213   for (int i = 0; i < ci->values_num; i++) {
214     if (ci->values[i].type != OCONFIG_TYPE_STRING) {
215       WARNING(PMU_PLUGIN ": The %s option requires string arguments.", ci->key);
216       continue;
217     }
218
219     g_ctx.hw_events[g_ctx.hw_events_count] = strdup(ci->values[i].value.string);
220     if (g_ctx.hw_events[g_ctx.hw_events_count] == NULL) {
221       ERROR(PMU_PLUGIN ": Failed to allocate hw events entry.");
222       return -ENOMEM;
223     }
224
225     g_ctx.hw_events_count++;
226   }
227
228   return 0;
229 }
230
231 static int pmu_config(oconfig_item_t *ci) {
232
233   DEBUG(PMU_PLUGIN ": %s:%d", __FUNCTION__, __LINE__);
234
235   for (int i = 0; i < ci->children_num; i++) {
236     int ret = 0;
237     oconfig_item_t *child = ci->children + i;
238
239     if (strcasecmp("ReportHardwareCacheEvents", child->key) == 0) {
240       ret = cf_util_get_boolean(child, &g_ctx.hw_cache_events);
241     } else if (strcasecmp("ReportKernelPMUEvents", child->key) == 0) {
242       ret = cf_util_get_boolean(child, &g_ctx.kernel_pmu_events);
243     } else if (strcasecmp("EventList", child->key) == 0) {
244       ret = cf_util_get_string_buffer(child, g_ctx.event_list_fn,
245                                       sizeof(g_ctx.event_list_fn));
246     } else if (strcasecmp("HardwareEvents", child->key) == 0) {
247       ret = pmu_config_hw_events(child);
248     } else if (strcasecmp("ReportSoftwareEvents", child->key) == 0) {
249       ret = cf_util_get_boolean(child, &g_ctx.sw_events);
250     } else {
251       ERROR(PMU_PLUGIN ": Unknown configuration parameter \"%s\".", child->key);
252       ret = -1;
253     }
254
255     if (ret != 0) {
256       DEBUG(PMU_PLUGIN ": %s:%d ret=%d", __FUNCTION__, __LINE__, ret);
257       return ret;
258     }
259   }
260
261 #if COLLECT_DEBUG
262   pmu_dump_config();
263 #endif
264
265   return 0;
266 }
267
268 static void pmu_submit_counter(int cpu, char *event, counter_t value,
269                                meta_data_t *meta) {
270   value_list_t vl = VALUE_LIST_INIT;
271
272   vl.values = &(value_t){.counter = value};
273   vl.values_len = 1;
274
275   sstrncpy(vl.plugin, PMU_PLUGIN, sizeof(vl.plugin));
276   if (cpu == -1) {
277     snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "all");
278   } else {
279     vl.meta = meta;
280     snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%d", cpu);
281   }
282   sstrncpy(vl.type, "counter", sizeof(vl.type));
283   sstrncpy(vl.type_instance, event, sizeof(vl.type_instance));
284
285   plugin_dispatch_values(&vl);
286 }
287
288 meta_data_t *pmu_meta_data_create(const struct efd *efd) {
289   meta_data_t *meta = NULL;
290
291   /* create meta data only if value was scaled */
292   if (efd->val[1] != efd->val[2] && efd->val[2]) {
293     meta = meta_data_create();
294     if (meta == NULL) {
295       ERROR(PMU_PLUGIN ": meta_data_create failed.");
296       return NULL;
297     }
298
299     meta_data_add_unsigned_int(meta, "intel_pmu:raw_count", efd->val[0]);
300     meta_data_add_unsigned_int(meta, "intel_pmu:time_enabled", efd->val[1]);
301     meta_data_add_unsigned_int(meta, "intel_pmu:time_running", efd->val[2]);
302   }
303
304   return meta;
305 }
306
307 static void pmu_dispatch_data(void) {
308
309   struct event *e;
310
311   for (e = g_ctx.event_list->eventlist; e; e = e->next) {
312     uint64_t all_value = 0;
313     int event_enabled = 0;
314     for (int i = 0; i < g_ctx.event_list->num_cpus; i++) {
315
316       if (e->efd[i].fd < 0)
317         continue;
318
319       event_enabled++;
320
321       /* If there are more events than counters, the kernel uses time
322        * multiplexing. With multiplexing, at the end of the run,
323        * the counter is scaled basing on total time enabled vs time running.
324        * final_count = raw_count * time_enabled/time_running
325        */
326       uint64_t value = event_scaled_value(e, i);
327       all_value += value;
328
329       /* get meta data with information about scaling */
330       meta_data_t *meta = pmu_meta_data_create(&e->efd[i]);
331
332       /* dispatch per CPU value */
333       pmu_submit_counter(i, e->event, value, meta);
334
335       if (meta) {
336         meta_data_destroy(meta);
337         meta = NULL;
338       }
339     }
340
341     if (event_enabled > 0) {
342       DEBUG(PMU_PLUGIN ": %-20s %'10lu", e->event, all_value);
343       /* dispatch all CPU value */
344       pmu_submit_counter(-1, e->event, all_value, NULL);
345     }
346   }
347 }
348
349 static int pmu_read(__attribute__((unused)) user_data_t *ud) {
350   int ret;
351
352   DEBUG(PMU_PLUGIN ": %s:%d", __FUNCTION__, __LINE__);
353
354   ret = read_all_events(g_ctx.event_list);
355   if (ret != 0) {
356     ERROR(PMU_PLUGIN ": Failed to read values of all events.");
357     return ret;
358   }
359
360   pmu_dispatch_data();
361
362   return 0;
363 }
364
365 static int pmu_add_events(struct eventlist *el, uint32_t type,
366                           event_info_t *events, size_t count) {
367
368   for (size_t i = 0; i < count; i++) {
369     /* Allocate memory for event struct that contains array of efd structs
370        for all cores */
371     struct event *e =
372         calloc(sizeof(struct event) + sizeof(struct efd) * el->num_cpus, 1);
373     if (e == NULL) {
374       ERROR(PMU_PLUGIN ": Failed to allocate event structure");
375       return -ENOMEM;
376     }
377
378     e->attr.type = type;
379     e->attr.config = events[i].config;
380     e->attr.size = PERF_ATTR_SIZE_VER0;
381     if (!el->eventlist)
382       el->eventlist = e;
383     if (el->eventlist_last)
384       el->eventlist_last->next = e;
385     el->eventlist_last = e;
386     e->event = strdup(events[i].name);
387   }
388
389   return 0;
390 }
391
392 static int pmu_add_hw_events(struct eventlist *el, char **e, size_t count) {
393
394   for (size_t i = 0; i < count; i++) {
395
396     size_t group_events_count = 0;
397
398     char *events = strdup(e[i]);
399     if (!events)
400       return -1;
401
402     char *s, *tmp;
403     for (s = strtok_r(events, ",", &tmp); s; s = strtok_r(NULL, ",", &tmp)) {
404
405       /* Multiple events parsed in one entry */
406       if (group_events_count == 1) {
407         /* Mark previously added event as group leader */
408         el->eventlist_last->group_leader = 1;
409       }
410
411       /* Allocate memory for event struct that contains array of efd structs
412          for all cores */
413       struct event *e =
414           calloc(sizeof(struct event) + sizeof(struct efd) * el->num_cpus, 1);
415       if (e == NULL) {
416         free(events);
417         return -ENOMEM;
418       }
419
420       if (resolve_event(s, &e->attr) == 0) {
421         e->next = NULL;
422         if (!el->eventlist)
423           el->eventlist = e;
424         if (el->eventlist_last)
425           el->eventlist_last->next = e;
426         el->eventlist_last = e;
427         e->event = strdup(s);
428       } else {
429         DEBUG(PMU_PLUGIN ": Cannot resolve %s", s);
430         sfree(e);
431       }
432
433       group_events_count++;
434     }
435
436     /* Multiple events parsed in one entry */
437     if (group_events_count > 1) {
438       /* Mark last added event as group end */
439       el->eventlist_last->end_group = 1;
440     }
441
442     free(events);
443   }
444
445   return 0;
446 }
447
448 static void pmu_free_events(struct eventlist *el) {
449
450   if (el == NULL)
451     return;
452
453   struct event *e = el->eventlist;
454
455   while (e) {
456     struct event *next = e->next;
457     sfree(e);
458     e = next;
459   }
460
461   el->eventlist = NULL;
462 }
463
464 static int pmu_setup_events(struct eventlist *el, bool measure_all,
465                             int measure_pid) {
466   struct event *e, *leader = NULL;
467   int ret = -1;
468
469   for (e = el->eventlist; e; e = e->next) {
470
471     for (int i = 0; i < el->num_cpus; i++) {
472       if (setup_event(e, i, leader, measure_all, measure_pid) < 0) {
473         WARNING(PMU_PLUGIN ": perf event '%s' is not available (cpu=%d).",
474                 e->event, i);
475       } else {
476         /* success if at least one event was set */
477         ret = 0;
478       }
479     }
480
481     if (e->group_leader)
482       leader = e;
483     if (e->end_group)
484       leader = NULL;
485   }
486
487   return ret;
488 }
489
490 static int pmu_init(void) {
491   int ret;
492
493   DEBUG(PMU_PLUGIN ": %s:%d", __FUNCTION__, __LINE__);
494
495   g_ctx.event_list = alloc_eventlist();
496   if (g_ctx.event_list == NULL) {
497     ERROR(PMU_PLUGIN ": Failed to allocate event list.");
498     return -ENOMEM;
499   }
500
501   if (g_ctx.hw_cache_events) {
502     ret =
503         pmu_add_events(g_ctx.event_list, PERF_TYPE_HW_CACHE, g_hw_cache_events,
504                        STATIC_ARRAY_SIZE(g_hw_cache_events));
505     if (ret != 0) {
506       ERROR(PMU_PLUGIN ": Failed to add hw cache events.");
507       goto init_error;
508     }
509   }
510
511   if (g_ctx.kernel_pmu_events) {
512     ret = pmu_add_events(g_ctx.event_list, PERF_TYPE_HARDWARE,
513                          g_kernel_pmu_events,
514                          STATIC_ARRAY_SIZE(g_kernel_pmu_events));
515     if (ret != 0) {
516       ERROR(PMU_PLUGIN ": Failed to add kernel PMU events.");
517       goto init_error;
518     }
519   }
520
521   /* parse events names if config option is present and is not empty */
522   if (g_ctx.hw_events_count) {
523
524     ret = read_events(g_ctx.event_list_fn);
525     if (ret != 0) {
526       ERROR(PMU_PLUGIN ": Failed to read event list file '%s'.",
527             g_ctx.event_list_fn);
528       return ret;
529     }
530
531     ret = pmu_add_hw_events(g_ctx.event_list, g_ctx.hw_events,
532                             g_ctx.hw_events_count);
533     if (ret != 0) {
534       ERROR(PMU_PLUGIN ": Failed to add hardware events.");
535       goto init_error;
536     }
537   }
538
539   if (g_ctx.sw_events) {
540     ret = pmu_add_events(g_ctx.event_list, PERF_TYPE_SOFTWARE, g_sw_events,
541                          STATIC_ARRAY_SIZE(g_sw_events));
542     if (ret != 0) {
543       ERROR(PMU_PLUGIN ": Failed to add software events.");
544       goto init_error;
545     }
546   }
547
548 #if COLLECT_DEBUG
549   pmu_dump_events();
550 #endif
551
552   if (g_ctx.event_list->eventlist != NULL) {
553     /* measure all processes */
554     ret = pmu_setup_events(g_ctx.event_list, true, -1);
555     if (ret != 0) {
556       ERROR(PMU_PLUGIN ": Failed to setup perf events for the event list.");
557       goto init_error;
558     }
559   } else {
560     WARNING(PMU_PLUGIN
561             ": Events list is empty. No events were setup for monitoring.");
562   }
563
564   return 0;
565
566 init_error:
567
568   pmu_free_events(g_ctx.event_list);
569   sfree(g_ctx.event_list);
570   for (size_t i = 0; i < g_ctx.hw_events_count; i++) {
571     sfree(g_ctx.hw_events[i]);
572   }
573   sfree(g_ctx.hw_events);
574   g_ctx.hw_events_count = 0;
575
576   return ret;
577 }
578
579 static int pmu_shutdown(void) {
580
581   DEBUG(PMU_PLUGIN ": %s:%d", __FUNCTION__, __LINE__);
582
583   pmu_free_events(g_ctx.event_list);
584   sfree(g_ctx.event_list);
585   for (size_t i = 0; i < g_ctx.hw_events_count; i++) {
586     sfree(g_ctx.hw_events[i]);
587   }
588   sfree(g_ctx.hw_events);
589   g_ctx.hw_events_count = 0;
590
591   return 0;
592 }
593
594 void module_register(void) {
595   plugin_register_init(PMU_PLUGIN, pmu_init);
596   plugin_register_complex_config(PMU_PLUGIN, pmu_config);
597   plugin_register_complex_read(NULL, PMU_PLUGIN, pmu_read, 0, NULL);
598   plugin_register_shutdown(PMU_PLUGIN, pmu_shutdown);
599 }