FD.io VPP  v19.01.3-6-g70449b9b9
Vector Packet Processing
stat_segment.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <vppinfra/mem.h>
17 #include <vlib/vlib.h>
18 #include <vlib/unix/unix.h>
19 #include "stat_segment.h"
20 #include <vnet/vnet.h>
21 #include <vnet/devices/devices.h> /* vnet_get_aggregate_rx_packets */
22 #undef HAVE_MEMFD_CREATE
23 #include <vppinfra/linux/syscall.h>
26 
27 /*
28  * Used only by VPP writers
29  */
30 void
32 {
35  sm->shared_header->in_progress = 1;
36 }
37 
38 void
40 {
42  sm->shared_header->epoch++;
43  sm->shared_header->in_progress = 0;
45 }
46 
47 /*
48  * Change heap to the stats shared memory segment
49  */
50 void *
52 {
54 
55  ASSERT (sm && sm->shared_header);
56  return clib_mem_set_heap (sm->heap);
57 }
58 
59 /* Name to vector index hash */
60 static u32
61 lookup_or_create_hash_index (void *oldheap, char *name, u32 next_vector_index)
62 {
64  u32 index;
65  hash_pair_t *hp;
66 
67  hp = hash_get_pair (sm->directory_vector_by_name, name);
68  if (!hp)
69  {
70  hash_set (sm->directory_vector_by_name, name, next_vector_index);
71  index = next_vector_index;
72  }
73  else
74  {
75  index = hp->value[0];
76  }
77 
78  return index;
79 }
80 
81 void
82 vlib_stats_pop_heap (void *cm_arg, void *oldheap, stat_directory_type_t type)
83 {
86  stat_segment_shared_header_t *shared_header = sm->shared_header;
87  char *stat_segment_name;
89 
90  /* Not all counters have names / hash-table entries */
91  if (!cm->name && !cm->stat_segment_name)
92  {
93  clib_mem_set_heap (oldheap);
94  return;
95  }
96 
97  ASSERT (shared_header);
98 
100 
101  /* Lookup hash-table is on the main heap */
102  stat_segment_name =
103  cm->stat_segment_name ? cm->stat_segment_name : cm->name;
104  u32 next_vector_index = vec_len (sm->directory_vector);
105  clib_mem_set_heap (oldheap); /* Exit stats segment */
106  u32 vector_index = lookup_or_create_hash_index (oldheap, stat_segment_name,
107  next_vector_index);
108  /* Back to stats segment */
109  clib_mem_set_heap (sm->heap); /* Re-enter stat segment */
110 
111 
112  /* Update the vector */
113  if (vector_index == next_vector_index)
114  { /* New */
115  strncpy (e.name, stat_segment_name, 128 - 1);
116  e.type = type;
117  vec_add1 (sm->directory_vector, e);
118  }
119 
120  stat_segment_directory_entry_t *ep = &sm->directory_vector[vector_index];
121  ep->offset = stat_segment_offset (shared_header, cm->counters); /* Vector of threads of vectors of counters */
122  u64 *offset_vector =
123  ep->offset_vector ? stat_segment_pointer (shared_header,
124  ep->offset_vector) : 0;
125 
126  /* Update the 2nd dimension offset vector */
127  int i;
128  vec_validate (offset_vector, vec_len (cm->counters) - 1);
129  for (i = 0; i < vec_len (cm->counters); i++)
130  offset_vector[i] = stat_segment_offset (shared_header, cm->counters[i]);
131  ep->offset_vector = stat_segment_offset (shared_header, offset_vector);
132  sm->directory_vector[vector_index].offset =
133  stat_segment_offset (shared_header, cm->counters);
134 
135  /* Reset the client hash table pointer, since it WILL change! */
136  shared_header->directory_offset =
137  stat_segment_offset (shared_header, sm->directory_vector);
138 
140  clib_mem_set_heap (oldheap);
141 }
142 
143 void
144 vlib_stats_register_error_index (void *oldheap, u8 * name, u64 * em_vec,
145  u64 index)
146 {
148  stat_segment_shared_header_t *shared_header = sm->shared_header;
150  hash_pair_t *hp;
151 
152  ASSERT (shared_header);
153 
155  u32 next_vector_index = vec_len (sm->directory_vector);
156  clib_mem_set_heap (oldheap); /* Exit stats segment */
157 
158  u32 vector_index = lookup_or_create_hash_index (oldheap, (char *) name,
159  next_vector_index);
160 
161  /* Back to stats segment */
162  clib_mem_set_heap (sm->heap); /* Re-enter stat segment */
163 
164  if (next_vector_index == vector_index)
165  {
166  memcpy (e.name, name, vec_len (name));
167  e.name[vec_len (name)] = '\0';
169  e.offset = index;
170  e.offset_vector = 0;
171  vec_add1 (sm->directory_vector, e);
172 
173  /* Warn clients to refresh any pointers they might be holding */
174  shared_header->directory_offset =
175  stat_segment_offset (shared_header, sm->directory_vector);
176  }
177  else
178  {
179  vec_free (name);
180  }
181 
183 }
184 
185 static void
187 {
189  stat_segment_shared_header_t *shared_header = sm->shared_header;
190  counter_t **counters = 0;
192  int i;
193  u64 *offset_vector = 0;
194 
195  vec_validate_aligned (counters, tm->n_vlib_mains - 1,
197  for (i = 0; i < tm->n_vlib_mains; i++)
198  {
199  vec_validate_aligned (counters[i], max, CLIB_CACHE_LINE_BYTES);
200  vec_add1 (offset_vector,
201  stat_segment_offset (shared_header, counters[i]));
202  }
203  ep->offset = stat_segment_offset (shared_header, counters);
204  ep->offset_vector = stat_segment_offset (shared_header, offset_vector);
205 }
206 
207 void
208 vlib_stats_pop_heap2 (u64 * error_vector, u32 thread_index, void *oldheap)
209 {
211  stat_segment_shared_header_t *shared_header = sm->shared_header;
212 
213  ASSERT (shared_header);
214 
216 
217  /* Reset the client hash table pointer, since it WILL change! */
218  shared_header->error_offset =
219  stat_segment_offset (shared_header, error_vector);
220  shared_header->directory_offset =
221  stat_segment_offset (shared_header, sm->directory_vector);
222 
224  clib_mem_set_heap (oldheap);
225 }
226 
227 clib_error_t *
229 {
231  stat_segment_shared_header_t *shared_header;
233 
234  f64 *scalar_data;
235  u8 *name;
236  void *oldheap;
237  u32 *lock;
238  int rv;
239  ssize_t memory_size;
240 
241 
242  int mfd;
243  char *mem_name = "stat_segment_test";
244  void *memaddr;
245 
246  memory_size = sm->memory_size;
247  if (memory_size == 0)
248  memory_size = STAT_SEGMENT_DEFAULT_SIZE;
249 
250  /* Create shared memory segment */
251  if ((mfd = memfd_create (mem_name, 0)) < 0)
252  return clib_error_return (0, "stat segment memfd_create failure");
253 
254  /* Set size */
255  if ((ftruncate (mfd, memory_size)) == -1)
256  return clib_error_return (0, "stat segment ftruncate failure");
257 
258  if ((memaddr =
259  mmap (NULL, memory_size, PROT_READ | PROT_WRITE, MAP_SHARED, mfd,
260  0)) == MAP_FAILED)
261  return clib_error_return (0, "stat segment mmap failure");
262 
263  void *heap;
264 #if USE_DLMALLOC == 0
265  heap = mheap_alloc_with_flags (((u8 *) memaddr) + getpagesize (),
266  memory_size - getpagesize (),
269 #else
270  heap =
271  create_mspace_with_base (((u8 *) memaddr) + getpagesize (),
272  memory_size - getpagesize (), 1 /* locked */ );
273  mspace_disable_expand (heap);
274 #endif
275 
276  sm->heap = heap;
277  sm->memfd = mfd;
278 
280  sm->shared_header = shared_header = memaddr;
283 
284  oldheap = clib_mem_set_heap (sm->heap);
285 
286  /* Set up the name to counter-vector hash table */
287  sm->directory_vector = 0;
288 
289  shared_header->epoch = 1;
290 
291  /* Scalar stats and node counters */
293 #define _(E,t,n,p) \
294  strcpy(sm->directory_vector[STAT_COUNTER_##E].name, "/sys" #p "/" #n); \
295  sm->directory_vector[STAT_COUNTER_##E].type = STAT_DIR_TYPE_##t;
297 #undef _
298  /* Save the vector offset in the shared segment, for clients */
299  shared_header->directory_offset =
300  stat_segment_offset (shared_header, sm->directory_vector);
301 
302  clib_mem_set_heap (oldheap);
303 
304  return 0;
305 }
306 
307 static int
308 name_sort_cmp (void *a1, void *a2)
309 {
312 
313  return strcmp ((char *) n1->name, (char *) n2->name);
314 }
315 
316 static u8 *
317 format_stat_dir_entry (u8 * s, va_list * args)
318 {
320  va_arg (*args, stat_segment_directory_entry_t *);
321  char *type_name;
322  char *format_string;
323 
324  format_string = "%-74s %-10s %10lld";
325 
326  switch (ep->type)
327  {
329  type_name = "ScalarPtr";
330  break;
331 
334  type_name = "CMainPtr";
335  break;
336 
338  type_name = "ErrIndex";
339  break;
340 
341  default:
342  type_name = "illegal!";
343  break;
344  }
345 
346  return format (s, format_string, ep->name, type_name, ep->offset);
347 }
348 
349 static clib_error_t *
351  unformat_input_t * input,
352  vlib_cli_command_t * cmd)
353 {
355  counter_t *counter;
356  hash_pair_t *p;
357  stat_segment_directory_entry_t *show_data, *this;
358  int i, j;
359 
360  int verbose = 0;
361  u8 *s;
362 
363  if (unformat (input, "verbose"))
364  verbose = 1;
365 
366  /* Lock even as reader, as this command doesn't handle epoch changes */
368  show_data = vec_dup (sm->directory_vector);
370 
372 
373  vlib_cli_output (vm, "%-74s %10s %10s", "Name", "Type", "Value");
374 
375  for (i = 0; i < vec_len (show_data); i++)
376  {
377  vlib_cli_output (vm, "%-100U", format_stat_dir_entry,
378  vec_elt_at_index (show_data, i));
379  }
380 
381  if (verbose)
382  {
383  ASSERT (sm->heap);
384  vlib_cli_output (vm, "%U", format_mheap, sm->heap, 0 /* verbose */ );
385  }
386 
387  return 0;
388 }
389 
390 /* *INDENT-OFF* */
391 VLIB_CLI_COMMAND (show_stat_segment_command, static) =
392 {
393  .path = "show statistics segment",
394  .short_help = "show statistics segment [verbose]",
395  .function = show_stat_segment_command_fn,
396 };
397 /* *INDENT-ON* */
398 
399 /*
400  * Node performance counters:
401  * total_calls [threads][node-index]
402  * total_vectors
403  * total_calls
404  * total suspends
405  */
406 
407 static inline void
409 {
410  vlib_main_t *vm = vlib_mains[0];
411  vlib_main_t **stat_vms = 0;
412  vlib_node_t ***node_dups = 0;
413  int i, j;
414  stat_segment_shared_header_t *shared_header = sm->shared_header;
415  static u32 no_max_nodes = 0;
416 
417  vlib_node_get_nodes (0 /* vm, for barrier sync */ ,
418  (u32) ~ 0 /* all threads */ ,
419  1 /* include stats */ ,
420  0 /* barrier sync */ ,
421  &node_dups, &stat_vms);
422 
423  u32 l = vec_len (node_dups[0]);
424 
425  /*
426  * Extend performance nodes if necessary
427  */
428  if (l > no_max_nodes)
429  {
430  void *oldheap = clib_mem_set_heap (sm->heap);
432 
441 
443  clib_mem_set_heap (oldheap);
444  no_max_nodes = l;
445  }
446 
447  for (j = 0; j < vec_len (node_dups); j++)
448  {
449  vlib_node_t **nodes = node_dups[j];
450  u32 l = vec_len (nodes);
451 
452  for (i = 0; i < vec_len (nodes); i++)
453  {
454  counter_t **counters;
455  counter_t *c;
456  vlib_node_t *n = nodes[i];
457 
458  counters =
459  stat_segment_pointer (shared_header,
460  sm->directory_vector
462  c = counters[j];
464 
465  counters =
466  stat_segment_pointer (shared_header,
467  sm->directory_vector
469  c = counters[j];
471 
472  counters =
473  stat_segment_pointer (shared_header,
474  sm->directory_vector
476  c = counters[j];
477  c[n->index] = n->stats_total.calls - n->stats_last_clear.calls;
478 
479  counters =
480  stat_segment_pointer (shared_header,
481  sm->directory_vector
483  c = counters[j];
484  c[n->index] =
486  }
487  }
488 }
489 
490 static void
492 {
493  vlib_main_t *vm = vlib_mains[0];
494  f64 vector_rate;
495  u64 input_packets, last_input_packets;
496  f64 dt, now;
497  vlib_main_t *this_vlib_main;
498  int i, start;
499 
500  /*
501  * Compute the average vector rate across all workers
502  */
503  vector_rate = 0.0;
504 
505  start = vec_len (vlib_mains) > 1 ? 1 : 0;
506 
507  for (i = start; i < vec_len (vlib_mains); i++)
508  {
509  this_vlib_main = vlib_mains[i];
510  vector_rate += vlib_last_vector_length_per_node (this_vlib_main);
511  }
512  vector_rate /= (f64) (i - start);
513 
515  vector_rate / ((f64) (vec_len (vlib_mains) - start));
516 
517  /*
518  * Compute the aggregate input rate
519  */
520  now = vlib_time_now (vm);
522  input_packets = vnet_get_aggregate_rx_packets ();
524  (f64) (input_packets - sm->last_input_packets) / dt;
526  sm->last_input_packets = input_packets;
529 
530  if (sm->node_counters_enabled)
532 
533  /* Heartbeat, so clients detect we're still here */
535 }
536 
537 /*
538  * Accept connection on the socket and exchange the fd for the shared
539  * memory segment.
540  */
541 static clib_error_t *
543 {
545  clib_error_t *err;
546  clib_socket_t client = { 0 };
547 
548  err = clib_socket_accept (sm->socket, &client);
549  if (err)
550  {
551  clib_error_report (err);
552  return err;
553  }
554 
555  /* Send the fd across and close */
556  err = clib_socket_sendmsg (&client, 0, 0, &sm->memfd, 1);
557  if (err)
558  clib_error_report (err);
559  clib_socket_close (&client);
560 
561  return 0;
562 }
563 
564 static void
566 {
568  clib_error_t *error;
570 
571  memset (s, 0, sizeof (clib_socket_t));
572  s->config = (char *) sm->socket_name;
575 
576  if ((error = clib_socket_init (s)))
577  {
578  clib_error_report (error);
579  return;
580  }
581 
582  clib_file_t template = { 0 };
584  template.file_descriptor = s->fd;
585  template.description = format (0, "stats segment listener %s", s->config);
586  clib_file_add (&file_main, &template);
587 
588  sm->socket = s;
589 }
590 
591 static clib_error_t *
593 {
594  /*
595  * cleanup the listener socket on exit.
596  */
598  unlink ((char *) sm->socket_name);
599  return 0;
600 }
601 
603 
604 static uword
606  vlib_frame_t * f)
607 {
609 
610  /* Wait for Godot... */
611  f64 sleep_duration = 10;
612 
613  while (1)
614  {
616  vlib_process_suspend (vm, sleep_duration);
617  }
618  return 0; /* or not */
619 }
620 
621 static clib_error_t *
623 {
625  clib_error_t *error;
626 
627  /* dependent on unix_input_init */
628  if ((error = vlib_call_init_function (vm, unix_input_init)))
629  return error;
630 
631  if (sm->socket_name)
633 
634  return 0;
635 }
636 
637 static clib_error_t *
639 {
641 
642  /* set default socket file name when statseg config stanza is empty. */
644 
646  {
647  if (unformat (input, "socket-name %s", &sm->socket_name))
648  ;
649  else if (unformat (input, "default"))
651  else
652  if (unformat
653  (input, "size %U", unformat_memory_size, &sm->memory_size))
654  ;
655  else if (unformat (input, "per-node-counters on"))
656  sm->node_counters_enabled = 1;
657  else if (unformat (input, "per-node-counters off"))
658  sm->node_counters_enabled = 0;
659  else
660  return clib_error_return (0, "unknown input `%U'",
661  format_unformat_error, input);
662  }
663  return 0;
664 }
665 
668 
669 /* *INDENT-OFF* */
671 {
673 .name = "statseg-collector-process",
674 .type = VLIB_NODE_TYPE_PROCESS,
675 };
676 
677 /* *INDENT-ON* */
678 
679 /*
680  * fd.io coding-style-patch-verification: ON
681  *
682  * Local Variables:
683  * eval: (c-set-style "gnu")
684  * End:
685  */
static clib_error_t * statseg_config(vlib_main_t *vm, unformat_input_t *input)
Definition: stat_segment.c:638
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
void vlib_stats_pop_heap(void *cm_arg, void *oldheap, stat_directory_type_t type)
Definition: stat_segment.c:82
Definition: stat_segment.h:49
#define hash_set(h, key, value)
Definition: hash.h:255
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
Definition: lock.h:89
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
Definition: lock.h:74
static clib_error_t * unix_input_init(vlib_main_t *vm)
Definition: input.c:406
static u64 vnet_get_aggregate_rx_packets(void)
Definition: devices.h:98
stat_segment_shared_header_t * shared_header
Definition: stat_segment.h:99
static clib_error_t * stats_socket_accept_ready(clib_file_t *uf)
Definition: stat_segment.c:542
stat_segment_main_t stat_segment_main
Definition: stat_segment.c:25
stat_segment_directory_entry_t * directory_vector
Definition: stat_segment.h:92
unsigned long u64
Definition: types.h:89
#define NULL
Definition: clib.h:58
u32 index
Definition: node.h:304
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:232
static uint64_t stat_segment_offset(void *start, void *data)
Definition: stat_segment.h:77
static void stat_validate_counter_vector(stat_segment_directory_entry_t *ep, u32 max)
Definition: stat_segment.c:186
static int memfd_create(const char *name, unsigned int flags)
Definition: syscall.h:50
#define STAT_SEGMENT_DEFAULT_SIZE
Definition: stat_segment.h:62
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:525
int i
clib_error_t * clib_socket_init(clib_socket_t *s)
Definition: socket.c:384
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
#define foreach_stat_segment_counter_name
Definition: stat_segment.h:38
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:450
#define MHEAP_FLAG_THREAD_SAFE
vlib_main_t ** vlib_mains
Definition: buffer.c:310
unsigned char u8
Definition: types.h:56
atomic_int_fast64_t in_progress
Definition: stat_segment.h:70
clib_file_function_t * read_function
Definition: file.h:67
double f64
Definition: types.h:142
uword value[0]
Definition: hash.h:165
static f64 vlib_last_vector_length_per_node(vlib_main_t *vm)
Definition: main.h:323
#define CLIB_SOCKET_F_IS_SERVER
Definition: socket.h:58
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
Definition: node_funcs.h:422
DLMALLOC_EXPORT mspace create_mspace_with_base(void *base, size_t capacity, int locked)
vlib_node_stats_t stats_last_clear
Definition: node.h:298
uint64_t value
Definition: stat_segment.h:55
static void do_stat_segment_updates(stat_segment_main_t *sm)
Definition: stat_segment.c:491
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:163
void vlib_node_get_nodes(vlib_main_t *vm, u32 max_threads, int include_stats, int barrier_sync, vlib_node_t ****node_dupsp, vlib_main_t ***stat_vmsp)
Get list of nodes.
Definition: node.c:569
#define MHEAP_FLAG_DISABLE_VM
static clib_error_t * clib_socket_sendmsg(clib_socket_t *s, void *msg, int msglen, int fds[], int num_fds)
Definition: socket.h:151
uint64_t counter_t
64bit counters
Definition: counter_types.h:22
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
Definition: error.h:99
clib_file_main_t file_main
Definition: main.c:63
#define hash_get_pair(h, key)
Definition: hash.h:252
unsigned int u32
Definition: types.h:88
static clib_error_t * statseg_init(vlib_main_t *vm)
Definition: stat_segment.c:622
A collection of simple counters.
Definition: counter.h:57
#define vlib_call_init_function(vm, x)
Definition: init.h:260
void * vlib_stats_push_heap(void)
Definition: stat_segment.c:51
#define hash_create_string(elts, value_bytes)
Definition: hash.h:690
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:57
char * name
The counter collection&#39;s name.
Definition: counter.h:64
u8 * format_mheap(u8 *s, va_list *va)
Definition: mem_dlmalloc.c:354
vlib_node_stats_t stats_total
Definition: node.h:294
static void * stat_segment_pointer(void *start, uint64_t offset)
Definition: stat_segment.h:83
static void stats_segment_socket_init(void)
Definition: stat_segment.c:565
clib_error_t * clib_socket_accept(clib_socket_t *server, clib_socket_t *client)
Definition: socket.c:524
f64 time_last_runtime_stats_clear
Definition: node.h:783
static clib_error_t * clib_socket_close(clib_socket_t *sock)
Definition: socket.h:175
static u8 * format_stat_dir_entry(u8 *s, va_list *args)
Definition: stat_segment.c:317
void vlib_stat_segment_unlock(void)
Definition: stat_segment.c:39
uint64_t offset
Definition: stat_segment.h:53
DLMALLOC_EXPORT void mspace_disable_expand(mspace msp)
struct _unformat_input_t unformat_input_t
u64 memory_size
Definition: vhost_user.h:115
static clib_error_t * stats_segment_socket_exit(vlib_main_t *vm)
Definition: stat_segment.c:592
#define vec_dup(V)
Return copy of vector (no header, no alignment)
Definition: vec.h:375
u8 name[64]
Definition: memclnt.api:152
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
Definition: init.h:216
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
#define UNFORMAT_END_OF_INPUT
Definition: format.h:144
svmdb_client_t * c
static u32 lookup_or_create_hash_index(void *oldheap, char *name, u32 next_vector_index)
Definition: stat_segment.c:61
vlib_main_t * vm
Definition: buffer.c:301
#define STAT_SEGMENT_SOCKET_FILE
Definition: stat_client.h:34
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
#define VLIB_MAIN_LOOP_EXIT_FUNCTION(x)
Definition: init.h:168
stat_directory_type_t
Definition: stat_client.h:24
static void * clib_mem_set_heap(void *heap)
Definition: mem.h:261
static vlib_node_registration_t stat_segment_collector
(constructor) VLIB_REGISTER_NODE (stat_segment_collector)
Definition: stat_segment.c:670
void vlib_stat_segment_lock(void)
Definition: stat_segment.c:31
uint64_t offset_vector
Definition: stat_segment.h:57
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:155
void * mheap_alloc_with_flags(void *memory, uword memory_size, uword flags)
Definition: mheap.c:885
char name[128]
Definition: stat_segment.h:58
#define ASSERT(truth)
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
Definition: file.h:96
#define clib_error_report(e)
Definition: error.h:113
struct _socket_t clib_socket_t
atomic_int_fast64_t epoch
Definition: stat_segment.h:69
static void * clib_mem_alloc(uword size)
Definition: mem.h:132
#define CLIB_SOCKET_F_SEQPACKET
Definition: socket.h:63
static uword stat_segment_collector_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: stat_segment.c:605
uword * directory_vector_by_name
Definition: stat_segment.h:91
char * stat_segment_name
Name in stat segment directory.
Definition: counter.h:65
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_node_main_t node_main
Definition: main.h:129
#define CLIB_SOCKET_F_PASSCRED
Definition: socket.h:64
u64 uword
Definition: types.h:112
static void update_node_counters(stat_segment_main_t *sm)
Definition: stat_segment.c:408
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:984
static int name_sort_cmp(void *a1, void *a2)
Definition: stat_segment.c:308
static clib_error_t * show_stat_segment_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: stat_segment.c:350
unformat_function_t unformat_memory_size
Definition: format.h:295
clib_socket_t * socket
Definition: stat_segment.h:94
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
counter_t ** counters
Per-thread u64 non-atomic counters.
Definition: counter.h:59
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:32
Definition: file.h:51
void vlib_stats_register_error_index(void *oldheap, u8 *name, u64 *em_vec, u64 index)
Definition: stat_segment.c:144
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
#define CLIB_SOCKET_F_ALLOW_GROUP_WRITE
Definition: socket.h:62
clib_error_t * vlib_map_stat_segment_init(void)
Definition: stat_segment.c:228
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:762
atomic_int_fast64_t error_offset
Definition: stat_segment.h:72
void vlib_stats_pop_heap2(u64 *error_vector, u32 thread_index, void *oldheap)
Definition: stat_segment.c:208
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
clib_spinlock_t * stat_segment_lockp
Definition: stat_segment.h:93
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:170
atomic_int_fast64_t directory_offset
Definition: stat_segment.h:71
stat_directory_type_t type
Definition: stat_segment.h:51