359555705aa759d4bc9eda98185a02fb4141c871
[vpp.git] / src / plugins / perfmon / perfmon.c
1 /*
2  * perfmon.c - skeleton vpp engine plug-in
3  *
4  * Copyright (c) <current-year> <your-organization>
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #include <vnet/vnet.h>
19 #include <vnet/plugin/plugin.h>
20 #include <perfmon/perfmon.h>
21
22 #include <vlibapi/api.h>
23 #include <vlibmemory/api.h>
24 #include <vpp/app/version.h>
25 #include <linux/limits.h>
26
27 perfmon_main_t perfmon_main;
28
29 static char *perfmon_json_path = "/usr/share/vpp/plugins/perfmon";
30
31 typedef struct
32 {
33   u8 model;
34   u8 stepping;
35   u8 has_stepping;
36   char *filename;
37 } file_by_model_and_stepping_t;
38
39 /* Created by parsing mapfile.csv, see mapfile_tool.c */
40
41 static const file_by_model_and_stepping_t fms_table[] = {
42   /* model, stepping, stepping valid, file */
43   {0x2E, 0x0, 0, "NehalemEX_core_V2.json"},
44   {0x1E, 0x0, 0, "NehalemEP_core_V2.json"},
45   {0x1F, 0x0, 0, "NehalemEP_core_V2.json"},
46   {0x1A, 0x0, 0, "NehalemEP_core_V2.json"},
47   {0x2F, 0x0, 0, "WestmereEX_core_V2.json"},
48   {0x25, 0x0, 0, "WestmereEP-SP_core_V2.json"},
49   {0x2C, 0x0, 0, "WestmereEP-DP_core_V2.json"},
50   {0x37, 0x0, 0, "Silvermont_core_V14.json"},
51   {0x4D, 0x0, 0, "Silvermont_core_V14.json"},
52   {0x4C, 0x0, 0, "Silvermont_core_V14.json"},
53   {0x5C, 0x0, 0, "goldmont_core_v13.json"},
54   {0x5F, 0x0, 0, "goldmont_core_v13.json"},
55   {0x1C, 0x0, 0, "Bonnell_core_V4.json"},
56   {0x26, 0x0, 0, "Bonnell_core_V4.json"},
57   {0x27, 0x0, 0, "Bonnell_core_V4.json"},
58   {0x36, 0x0, 0, "Bonnell_core_V4.json"},
59   {0x35, 0x0, 0, "Bonnell_core_V4.json"},
60   {0x2A, 0x0, 0, "sandybridge_core_v16.json"},
61   {0x2D, 0x0, 0, "Jaketown_core_V20.json"},
62   {0x3A, 0x0, 0, "ivybridge_core_v21.json"},
63   {0x3E, 0x0, 0, "ivytown_core_v20.json"},
64   {0x3C, 0x0, 0, "haswell_core_v28.json"},
65   {0x45, 0x0, 0, "haswell_core_v28.json"},
66   {0x46, 0x0, 0, "haswell_core_v28.json"},
67   {0x3F, 0x0, 0, "haswellx_core_v20.json"},
68   {0x3D, 0x0, 0, "broadwell_core_v23.json"},
69   {0x47, 0x0, 0, "broadwell_core_v23.json"},
70   {0x4F, 0x0, 0, "broadwellx_core_v14.json"},
71   {0x56, 0x0, 0, "broadwellde_core_v7.json"},
72   {0x4E, 0x0, 0, "skylake_core_v42.json"},
73   {0x5E, 0x0, 0, "skylake_core_v42.json"},
74   {0x8E, 0x0, 0, "skylake_core_v42.json"},
75   {0x9E, 0x0, 0, "skylake_core_v42.json"},
76   {0x57, 0x0, 0, "KnightsLanding_core_V9.json"},
77   {0x85, 0x0, 0, "KnightsLanding_core_V9.json"},
78   {0x55, 0x0, 1, "skylakex_core_v1.12.json"},
79   {0x55, 0x1, 1, "skylakex_core_v1.12.json"},
80   {0x55, 0x2, 1, "skylakex_core_v1.12.json"},
81   {0x55, 0x3, 1, "skylakex_core_v1.12.json"},
82   {0x55, 0x4, 1, "skylakex_core_v1.12.json"},
83   {0x55, 0x5, 1, "cascadelakex_core_v1.00.json"},
84   {0x55, 0x6, 1, "cascadelakex_core_v1.00.json"},
85   {0x55, 0x7, 1, "cascadelakex_core_v1.00.json"},
86   {0x55, 0x8, 1, "cascadelakex_core_v1.00.json"},
87   {0x55, 0x9, 1, "cascadelakex_core_v1.00.json"},
88   {0x55, 0xA, 1, "cascadelakex_core_v1.00.json"},
89   {0x55, 0xB, 1, "cascadelakex_core_v1.00.json"},
90   {0x55, 0xC, 1, "cascadelakex_core_v1.00.json"},
91   {0x55, 0xD, 1, "cascadelakex_core_v1.00.json"},
92   {0x55, 0xE, 1, "cascadelakex_core_v1.00.json"},
93   {0x55, 0xF, 1, "cascadelakex_core_v1.00.json"},
94   {0x7A, 0x0, 0, "goldmontplus_core_v1.01.json"},
95 };
96
97 static void
98 set_perfmon_json_path ()
99 {
100   char *p, path[PATH_MAX];
101   int rv;
102   u8 *s;
103
104   /* find executable path */
105   if ((rv = readlink ("/proc/self/exe", path, PATH_MAX - 1)) == -1)
106     return;
107
108   /* readlink doesn't provide null termination */
109   path[rv] = 0;
110
111   /* strip filename */
112   if ((p = strrchr (path, '/')) == 0)
113     return;
114   *p = 0;
115
116   /* strip bin/ */
117   if ((p = strrchr (path, '/')) == 0)
118     return;
119   *p = 0;
120
121   /* cons up the .json file path */
122   s = format (0, "%s/share/vpp/plugins/perfmon", path);
123   vec_add1 (s, 0);
124   perfmon_json_path = (char *) s;
125 }
126
127 static inline u32
128 get_cpuid (void)
129 {
130 #if defined(__x86_64__)
131   u32 cpuid;
132   asm volatile ("mov $1, %%eax; cpuid; mov %%eax, %0":"=r" (cpuid)::"%eax",
133                 "%edx", "%ecx", "%rbx");
134   return cpuid;
135 #else
136   return 0;
137 #endif
138 }
139
140 static clib_error_t *
141 perfmon_init (vlib_main_t * vm)
142 {
143   perfmon_main_t *pm = &perfmon_main;
144   clib_error_t *error = 0;
145   u32 cpuid;
146   uword *ht;
147   int found_a_table = 0;
148   int i;
149   u8 model, stepping;
150
151   pm->vlib_main = vm;
152   pm->vnet_main = vnet_get_main ();
153
154   pm->capture_by_thread_and_node_name =
155     hash_create_string (0, sizeof (uword));
156
157   pm->log_class = vlib_log_register_class ("perfmon", 0);
158
159   /* Default data collection interval */
160   pm->timeout_interval = 2.0;   /* seconds */
161   vec_validate (pm->pm_fds, 1);
162   vec_validate (pm->pm_fds[0], vec_len (vlib_mains) - 1);
163   vec_validate (pm->pm_fds[1], vec_len (vlib_mains) - 1);
164   vec_validate (pm->perf_event_pages, 1);
165   vec_validate (pm->perf_event_pages[0], vec_len (vlib_mains) - 1);
166   vec_validate (pm->perf_event_pages[1], vec_len (vlib_mains) - 1);
167   vec_validate (pm->rdpmc_indices, 1);
168   vec_validate (pm->rdpmc_indices[0], vec_len (vlib_mains) - 1);
169   vec_validate (pm->rdpmc_indices[1], vec_len (vlib_mains) - 1);
170   pm->page_size = getpagesize ();
171
172   ht = pm->perfmon_table = 0;
173
174   set_perfmon_json_path ();
175
176   cpuid = get_cpuid ();
177
178   for (i = 0; i < ARRAY_LEN (fms_table); i++)
179     {
180       model = ((cpuid >> 12) & 0xf0) | ((cpuid >> 4) & 0xf);
181       stepping = cpuid & 0xf;
182
183       if (fms_table[i].model != model)
184         continue;
185
186       if (fms_table[i].has_stepping)
187         {
188           if (fms_table[i].stepping != stepping)
189             continue;
190         }
191
192       found_a_table = 1;
193       ht = perfmon_parse_table (pm, perfmon_json_path, fms_table[i].filename);
194       break;
195     }
196   pm->perfmon_table = ht;
197
198   if (found_a_table == 0 || pm->perfmon_table == 0 || hash_elts (ht) == 0)
199     {
200       vlib_log_err (pm->log_class, "No table for cpuid %x", cpuid);
201       vlib_log_err (pm->log_class, "  model %x, stepping %x",
202                     model, stepping);
203     }
204
205   return error;
206 }
207
208 VLIB_INIT_FUNCTION (perfmon_init);
209
210 /* *INDENT-OFF* */
211 VLIB_PLUGIN_REGISTER () =
212 {
213   .version = VPP_BUILD_VER,
214   .description = "Performance monitor plugin",
215 #if !defined(__x86_64__)
216   .default_disabled = 1,
217 #endif
218 };
219 /* *INDENT-ON* */
220
221 static uword
222 atox (u8 * s)
223 {
224   uword rv = 0;
225
226   while (*s)
227     {
228       if (*s >= '0' && *s <= '9')
229         rv = (rv << 4) | (*s - '0');
230       else if (*s >= 'a' && *s <= 'f')
231         rv = (rv << 4) | (*s - 'a' + 10);
232       else if (*s >= 'A' && *s <= 'A')
233         rv = (rv << 4) | (*s - 'A' + 10);
234       else if (*s == 'x')
235         ;
236       else
237         break;
238       s++;
239     }
240   return rv;
241 }
242
243 static uword
244 unformat_processor_event (unformat_input_t * input, va_list * args)
245 {
246   perfmon_main_t *pm = va_arg (*args, perfmon_main_t *);
247   perfmon_event_config_t *ep = va_arg (*args, perfmon_event_config_t *);
248   u8 *s = 0;
249   name_value_pair_t **nvps, *nvp;
250   hash_pair_t *hp;
251   int i;
252   int set_values = 0;
253   u32 pe_config = 0;
254
255   if (pm->perfmon_table == 0)
256     return 0;
257
258   if (!unformat (input, "%s", &s))
259     return 0;
260
261   hp = hash_get_pair_mem (pm->perfmon_table, s);
262
263   vec_free (s);
264
265   if (hp == 0)
266     return 0;
267
268   nvps = (name_value_pair_t **) (hp->value[0]);
269
270   for (i = 0; i < vec_len (nvps); i++)
271     {
272       nvp = nvps[i];
273       if (!strncmp ((char *) nvp->name, "EventCode", 9))
274         {
275           pe_config |= atox (nvp->value);
276           set_values++;
277         }
278       else if (!strncmp ((char *) nvp->name, "UMask", 5))
279         {
280           pe_config |= (atox (nvp->value) << 8);
281           set_values++;
282         }
283       if (set_values == 2)
284         break;
285     }
286
287   if (set_values != 2)
288     {
289       clib_warning ("BUG: only found %d values", set_values);
290       return 0;
291     }
292
293   ep->name = (char *) hp->key;
294   ep->pe_type = PERF_TYPE_RAW;
295   ep->pe_config = pe_config;
296   return 1;
297 }
298
299 static clib_error_t *
300 set_pmc_command_fn (vlib_main_t * vm,
301                     unformat_input_t * input, vlib_cli_command_t * cmd)
302 {
303   perfmon_main_t *pm = &perfmon_main;
304   unformat_input_t _line_input, *line_input = &_line_input;
305   perfmon_event_config_t ec;
306   f64 delay;
307   u32 timeout_seconds;
308   u32 deadman;
309
310   vec_reset_length (pm->single_events_to_collect);
311   vec_reset_length (pm->paired_events_to_collect);
312   pm->ipc_event_index = ~0;
313   pm->mispredict_event_index = ~0;
314
315   if (!unformat_user (input, unformat_line_input, line_input))
316     return clib_error_return (0, "counter names required...");
317
318   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
319     {
320       if (unformat (line_input, "timeout %u", &timeout_seconds))
321         pm->timeout_interval = (f64) timeout_seconds;
322       else if (unformat (line_input, "instructions-per-clock"))
323         {
324           ec.name = "instructions";
325           ec.pe_type = PERF_TYPE_HARDWARE;
326           ec.pe_config = PERF_COUNT_HW_INSTRUCTIONS;
327           pm->ipc_event_index = vec_len (pm->paired_events_to_collect);
328           vec_add1 (pm->paired_events_to_collect, ec);
329           ec.name = "cpu-cycles";
330           ec.pe_type = PERF_TYPE_HARDWARE;
331           ec.pe_config = PERF_COUNT_HW_CPU_CYCLES;
332           vec_add1 (pm->paired_events_to_collect, ec);
333         }
334       else if (unformat (line_input, "branch-mispredict-rate"))
335         {
336           ec.name = "branch-misses";
337           ec.pe_type = PERF_TYPE_HARDWARE;
338           ec.pe_config = PERF_COUNT_HW_BRANCH_MISSES;
339           pm->mispredict_event_index = vec_len (pm->paired_events_to_collect);
340           vec_add1 (pm->paired_events_to_collect, ec);
341           ec.name = "branches";
342           ec.pe_type = PERF_TYPE_HARDWARE;
343           ec.pe_config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS;
344           vec_add1 (pm->paired_events_to_collect, ec);
345         }
346       else if (unformat (line_input, "%U", unformat_processor_event, pm, &ec))
347         {
348           vec_add1 (pm->single_events_to_collect, ec);
349         }
350 #define _(type,event,str)                       \
351       else if (unformat (line_input, str))      \
352         {                                       \
353           ec.name = str;                        \
354           ec.pe_type = type;                    \
355           ec.pe_config = event;                 \
356           vec_add1 (pm->single_events_to_collect, ec); \
357         }
358       foreach_perfmon_event
359 #undef _
360         else
361         return clib_error_return (0, "unknown input '%U'",
362                                   format_unformat_error, line_input);
363     }
364
365   /* Stick paired events at the front of the (unified) list */
366   if (vec_len (pm->paired_events_to_collect) > 0)
367     {
368       perfmon_event_config_t *tmp;
369       /* first 2n events are pairs... */
370       vec_append (pm->paired_events_to_collect, pm->single_events_to_collect);
371       tmp = pm->single_events_to_collect;
372       pm->single_events_to_collect = pm->paired_events_to_collect;
373       pm->paired_events_to_collect = tmp;
374     }
375
376   if (vec_len (pm->single_events_to_collect) == 0)
377     return clib_error_return (0, "no events specified...");
378
379   /* Figure out how long data collection will take */
380   delay =
381     ((f64) vec_len (pm->single_events_to_collect)) * pm->timeout_interval;
382   delay /= 2.0;                 /* collect 2 stats at once */
383
384   vlib_cli_output (vm, "Start collection for %d events, wait %.2f seconds",
385                    vec_len (pm->single_events_to_collect), delay);
386
387   vlib_process_signal_event (pm->vlib_main, perfmon_periodic_node.index,
388                              PERFMON_START, 0);
389
390   /* Coarse-grained wait */
391   vlib_process_suspend (vm, delay);
392
393   deadman = 0;
394   /* Reasonable to guess that collection may not be quite done... */
395   while (pm->state == PERFMON_STATE_RUNNING)
396     {
397       vlib_process_suspend (vm, 10e-3);
398       if (deadman++ > 200)
399         {
400           vlib_cli_output (vm, "DEADMAN: collection still running...");
401           break;
402         }
403     }
404
405   vlib_cli_output (vm, "Data collection complete...");
406   return 0;
407 }
408
409 /* *INDENT-OFF* */
410 VLIB_CLI_COMMAND (set_pmc_command, static) =
411 {
412   .path = "set pmc",
413   .short_help = "set pmc c1 [..., use \"show pmc events\"]",
414   .function = set_pmc_command_fn,
415   .is_mp_safe = 1,
416 };
417 /* *INDENT-ON* */
418
419 static int
420 capture_name_sort (void *a1, void *a2)
421 {
422   perfmon_capture_t *c1 = a1;
423   perfmon_capture_t *c2 = a2;
424
425   return strcmp ((char *) c1->thread_and_node_name,
426                  (char *) c2->thread_and_node_name);
427 }
428
429 static u8 *
430 format_capture (u8 * s, va_list * args)
431 {
432   perfmon_main_t *pm = va_arg (*args, perfmon_main_t *);
433   perfmon_capture_t *c = va_arg (*args, perfmon_capture_t *);
434   int verbose __attribute__ ((unused)) = va_arg (*args, int);
435   f64 ticks_per_pkt;
436   int i;
437
438   if (c == 0)
439     {
440       s = format (s, "%=40s%=20s%=16s%=16s%=16s",
441                   "Name", "Counter", "Count", "Pkts", "Counts/Pkt");
442       return s;
443     }
444
445   for (i = 0; i < vec_len (c->counter_names); i++)
446     {
447       u8 *name;
448
449       if (i == 0)
450         name = c->thread_and_node_name;
451       else
452         {
453           vec_add1 (s, '\n');
454           name = (u8 *) "";
455         }
456
457       /* Deal with synthetic events right here */
458       if (i == pm->ipc_event_index)
459         {
460           f64 ipc_rate;
461           ASSERT ((i + 1) < vec_len (c->counter_names));
462
463           if (c->counter_values[i + 1] > 0)
464             ipc_rate = (f64) c->counter_values[i]
465               / (f64) c->counter_values[i + 1];
466           else
467             ipc_rate = 0.0;
468
469           s = format (s, "%-40s%+20s%+16llu%+16llu%+16.2e\n",
470                       name, "instructions-per-clock",
471                       c->counter_values[i],
472                       c->counter_values[i + 1], ipc_rate);
473           name = (u8 *) "";
474         }
475
476       if (i == pm->mispredict_event_index)
477         {
478           f64 mispredict_rate;
479           ASSERT (i + 1 < vec_len (c->counter_names));
480
481           if (c->counter_values[i + 1] > 0)
482             mispredict_rate = (f64) c->counter_values[i]
483               / (f64) c->counter_values[i + 1];
484           else
485             mispredict_rate = 0.0;
486
487           s = format (s, "%-40s%+20s%+16llu%+16llu%+16.2e\n",
488                       name, "branch-mispredict-rate",
489                       c->counter_values[i],
490                       c->counter_values[i + 1], mispredict_rate);
491           name = (u8 *) "";
492         }
493
494       if (c->vectors_this_counter[i])
495         ticks_per_pkt =
496           ((f64) c->counter_values[i]) / ((f64) c->vectors_this_counter[i]);
497       else
498         ticks_per_pkt = 0.0;
499
500       s = format (s, "%-40s%+20s%+16llu%+16llu%+16.2e",
501                   name, c->counter_names[i],
502                   c->counter_values[i],
503                   c->vectors_this_counter[i], ticks_per_pkt);
504     }
505   return s;
506 }
507
508 static u8 *
509 format_generic_events (u8 * s, va_list * args)
510 {
511   int verbose = va_arg (*args, int);
512
513 #define _(type,config,name)                             \
514   if (verbose == 0)                                     \
515     s = format (s, "\n  %s", name);                     \
516   else                                                  \
517     s = format (s, "\n  %s (%d, %d)", name, type, config);
518   foreach_perfmon_event;
519 #undef _
520   return s;
521 }
522
523 typedef struct
524 {
525   u8 *name;
526   name_value_pair_t **nvps;
527 } sort_nvp_t;
528
529 static int
530 sort_nvps_by_name (void *a1, void *a2)
531 {
532   sort_nvp_t *nvp1 = a1;
533   sort_nvp_t *nvp2 = a2;
534
535   return strcmp ((char *) nvp1->name, (char *) nvp2->name);
536 }
537
538 static u8 *
539 format_processor_events (u8 * s, va_list * args)
540 {
541   perfmon_main_t *pm = va_arg (*args, perfmon_main_t *);
542   int verbose = va_arg (*args, int);
543   int i, j;
544   sort_nvp_t *sort_nvps = 0;
545   sort_nvp_t *sn;
546   u8 *key;
547   name_value_pair_t **value;
548
549   /* *INDENT-OFF* */
550   hash_foreach_mem (key, value, pm->perfmon_table,
551   ({
552     vec_add2 (sort_nvps, sn, 1);
553     sn->name = key;
554     sn->nvps = value;
555   }));
556
557   vec_sort_with_function (sort_nvps, sort_nvps_by_name);
558
559   if (verbose == 0)
560     {
561       for (i = 0; i < vec_len (sort_nvps); i++)
562         s = format (s, "\n  %s ", sort_nvps[i].name);
563     }
564   else
565     {
566       for (i = 0; i < vec_len (sort_nvps); i++)
567         {
568           name_value_pair_t **nvps;
569           s = format (s, "\n  %s:", sort_nvps[i].name);
570
571           nvps = sort_nvps[i].nvps;
572
573           for (j = 0; j < vec_len (nvps); j++)
574             s = format (s, "\n    %s = %s", nvps[j]->name, nvps[j]->value);
575         }
576     }
577   vec_free (sort_nvps);
578   return s;
579 }
580
581
582 static clib_error_t *
583 show_pmc_command_fn (vlib_main_t * vm,
584                      unformat_input_t * input, vlib_cli_command_t * cmd)
585 {
586   perfmon_main_t *pm = &perfmon_main;
587   int verbose = 0;
588   int events = 0;
589   int i;
590   perfmon_capture_t *c;
591   perfmon_capture_t *captures = 0;
592
593   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
594     {
595       if (unformat (input, "events"))
596         events = 1;
597       else if (unformat (input, "verbose"))
598         verbose = 1;
599       else
600         break;
601     }
602
603   if (events)
604     {
605       vlib_cli_output (vm, "Generic Events %U",
606                        format_generic_events, verbose);
607       vlib_cli_output (vm, "Synthetic Events");
608       vlib_cli_output (vm, "  instructions-per-clock");
609       vlib_cli_output (vm, "  branch-mispredict-rate");
610       if (pm->perfmon_table)
611         vlib_cli_output (vm, "Processor Events %U",
612                          format_processor_events, pm, verbose);
613       return 0;
614     }
615
616   if (pm->state == PERFMON_STATE_RUNNING)
617     {
618       vlib_cli_output (vm, "Data collection in progress...");
619       return 0;
620     }
621
622   if (pool_elts (pm->capture_pool) == 0)
623     {
624       vlib_cli_output (vm, "No data...");
625       return 0;
626     }
627
628   /* *INDENT-OFF* */
629   pool_foreach (c, pm->capture_pool,
630   ({
631     vec_add1 (captures, *c);
632   }));
633   /* *INDENT-ON* */
634
635   vec_sort_with_function (captures, capture_name_sort);
636
637   vlib_cli_output (vm, "%U", format_capture, pm, 0 /* header */ ,
638                    0 /* verbose */ );
639
640   for (i = 0; i < vec_len (captures); i++)
641     {
642       c = captures + i;
643
644       vlib_cli_output (vm, "%U", format_capture, pm, c, verbose);
645     }
646
647   vec_free (captures);
648
649   return 0;
650 }
651
652 /* *INDENT-OFF* */
653 VLIB_CLI_COMMAND (show_pmc_command, static) =
654 {
655   .path = "show pmc",
656   .short_help = "show pmc [verbose]",
657   .function = show_pmc_command_fn,
658   .is_mp_safe = 1,
659 };
660 /* *INDENT-ON* */
661
662 static clib_error_t *
663 clear_pmc_command_fn (vlib_main_t * vm,
664                       unformat_input_t * input, vlib_cli_command_t * cmd)
665 {
666   perfmon_main_t *pm = &perfmon_main;
667   u8 *key;
668   u32 *value;
669
670   if (pm->state == PERFMON_STATE_RUNNING)
671     {
672       vlib_cli_output (vm, "Performance monitor is still running...");
673       return 0;
674     }
675
676   pool_free (pm->capture_pool);
677
678   /* *INDENT-OFF* */
679   hash_foreach_mem (key, value, pm->capture_by_thread_and_node_name,
680   ({
681     vec_free (key);
682   }));
683   /* *INDENT-ON* */
684   hash_free (pm->capture_by_thread_and_node_name);
685   pm->capture_by_thread_and_node_name =
686     hash_create_string (0, sizeof (uword));
687   return 0;
688 }
689
690 /* *INDENT-OFF* */
691 VLIB_CLI_COMMAND (clear_pmc_command, static) =
692 {
693   .path = "clear pmc",
694   .short_help = "clear the performance monitor counters",
695   .function = clear_pmc_command_fn,
696 };
697 /* *INDENT-ON* */
698
699
700 /*
701  * fd.io coding-style-patch-verification: ON
702  *
703  * Local Variables:
704  * eval: (c-set-style "gnu")
705  * End:
706  */