FD.io VPP  v18.10-34-gcce845e
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>
24 
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  vector_index++;
119  }
120 
121  stat_segment_directory_entry_t *ep = &sm->directory_vector[vector_index];
122  ep->offset = stat_segment_offset (shared_header, cm->counters); /* Vector of threads of vectors of counters */
123  u64 *offset_vector =
124  ep->offset_vector ? stat_segment_pointer (shared_header,
125  ep->offset_vector) : 0;
126 
127  /* Update the 2nd dimension offset vector */
128  int i;
129  vec_validate (offset_vector, vec_len (cm->counters) - 1);
130  for (i = 0; i < vec_len (cm->counters); i++)
131  offset_vector[i] = stat_segment_offset (shared_header, cm->counters[i]);
132  ep->offset_vector = stat_segment_offset (shared_header, offset_vector);
133  sm->directory_vector[vector_index].offset =
134  stat_segment_offset (shared_header, cm->counters);
135 
136  /* Reset the client hash table pointer, since it WILL change! */
137  shared_header->directory_offset =
138  stat_segment_offset (shared_header, sm->directory_vector);
139 
141  clib_mem_set_heap (oldheap);
142 }
143 
144 void
146 {
148  stat_segment_shared_header_t *shared_header = sm->shared_header;
150  hash_pair_t *hp;
151 
152  ASSERT (shared_header);
153 
155 
156  memcpy (e.name, name, vec_len (name));
157  e.name[vec_len (name)] = '\0';
159  e.offset = index;
160  e.offset_vector = 0;
161  vec_add1 (sm->directory_vector, e);
162 
163  /* Warn clients to refresh any pointers they might be holding */
164  shared_header->directory_offset =
165  stat_segment_offset (shared_header, sm->directory_vector);
166 
168 }
169 
170 static void
172 {
174  stat_segment_shared_header_t *shared_header = sm->shared_header;
175  counter_t **counters = 0;
177  int i;
178  u64 *offset_vector = 0;
179 
180  vec_validate_aligned (counters, tm->n_vlib_mains - 1,
182  for (i = 0; i < tm->n_vlib_mains; i++)
183  {
184  vec_validate_aligned (counters[i], max, CLIB_CACHE_LINE_BYTES);
185  vec_add1 (offset_vector,
186  stat_segment_offset (shared_header, counters[i]));
187  }
188  ep->offset = stat_segment_offset (shared_header, counters);
189  ep->offset_vector = stat_segment_offset (shared_header, offset_vector);
190 }
191 
192 void
193 vlib_stats_pop_heap2 (u64 * error_vector, u32 thread_index, void *oldheap)
194 {
196  stat_segment_shared_header_t *shared_header = sm->shared_header;
197 
198  ASSERT (shared_header);
199 
201 
202  /* Reset the client hash table pointer, since it WILL change! */
203  shared_header->error_offset =
204  stat_segment_offset (shared_header, error_vector);
205  shared_header->directory_offset =
206  stat_segment_offset (shared_header, sm->directory_vector);
207 
209  clib_mem_set_heap (oldheap);
210 }
211 
212 clib_error_t *
214 {
216  stat_segment_shared_header_t *shared_header;
218 
219  f64 *scalar_data;
220  u8 *name;
221  void *oldheap;
222  u32 *lock;
223  int rv;
224  ssize_t memory_size;
225 
226 
227  int mfd;
228  char *mem_name = "stat_segment_test";
229  void *memaddr;
230 
231  memory_size = sm->memory_size;
232  if (memory_size == 0)
233  memory_size = STAT_SEGMENT_DEFAULT_SIZE;
234 
235  /* Create shared memory segment */
236  if ((mfd = memfd_create (mem_name, 0)) < 0)
237  return clib_error_return (0, "stat segment memfd_create failure");
238 
239  /* Set size */
240  if ((ftruncate (mfd, memory_size)) == -1)
241  return clib_error_return (0, "stat segment ftruncate failure");
242 
243  if ((memaddr =
244  mmap (NULL, memory_size, PROT_READ | PROT_WRITE, MAP_SHARED, mfd,
245  0)) == MAP_FAILED)
246  return clib_error_return (0, "stat segment mmap failure");
247 
248  void *heap;
249 #if USE_DLMALLOC == 0
250  heap = mheap_alloc_with_flags (((u8 *) memaddr) + getpagesize (),
251  memory_size - getpagesize (),
254 #else
255  heap =
256  create_mspace_with_base (((u8 *) memaddr) + getpagesize (),
257  memory_size - getpagesize (), 1 /* locked */ );
258  mspace_disable_expand (heap);
259 #endif
260 
261  sm->heap = heap;
262  sm->memfd = mfd;
263 
265  sm->shared_header = shared_header = memaddr;
268 
269  oldheap = clib_mem_set_heap (sm->heap);
270 
271  /* Set up the name to counter-vector hash table */
272  sm->directory_vector = 0;
273 
274  shared_header->epoch = 1;
275 
276  /* Scalar stats and node counters */
278 #define _(E,t,n,p) \
279  strcpy(sm->directory_vector[STAT_COUNTER_##E].name, "/sys" #p "/" #n); \
280  sm->directory_vector[STAT_COUNTER_##E].type = STAT_DIR_TYPE_##t;
282 #undef _
283  /* Save the vector offset in the shared segment, for clients */
284  shared_header->directory_offset =
285  stat_segment_offset (shared_header, sm->directory_vector);
286 
287  clib_mem_set_heap (oldheap);
288 
289  return 0;
290 }
291 
292 static int
293 name_sort_cmp (void *a1, void *a2)
294 {
297 
298  return strcmp ((char *) n1->name, (char *) n2->name);
299 }
300 
301 static u8 *
302 format_stat_dir_entry (u8 * s, va_list * args)
303 {
305  va_arg (*args, stat_segment_directory_entry_t *);
306  char *type_name;
307  char *format_string;
308 
309  format_string = "%-74s %-10s %10lld";
310 
311  switch (ep->type)
312  {
314  type_name = "ScalarPtr";
315  break;
316 
319  type_name = "CMainPtr";
320  break;
321 
323  type_name = "ErrIndex";
324  break;
325 
326  default:
327  type_name = "illegal!";
328  break;
329  }
330 
331  return format (s, format_string, ep->name, type_name, ep->offset);
332 }
333 
334 static clib_error_t *
336  unformat_input_t * input,
337  vlib_cli_command_t * cmd)
338 {
340  counter_t *counter;
341  hash_pair_t *p;
342  stat_segment_directory_entry_t *show_data, *this;
343  int i, j;
344 
345  int verbose = 0;
346  u8 *s;
347 
348  if (unformat (input, "verbose"))
349  verbose = 1;
350 
351  /* Lock even as reader, as this command doesn't handle epoch changes */
353  show_data = vec_dup (sm->directory_vector);
355 
357 
358  vlib_cli_output (vm, "%-74s %10s %10s", "Name", "Type", "Value");
359 
360  for (i = 0; i < vec_len (show_data); i++)
361  {
362  vlib_cli_output (vm, "%-100U", format_stat_dir_entry,
363  vec_elt_at_index (show_data, i));
364  }
365 
366  if (verbose)
367  {
368  ASSERT (sm->heap);
369  vlib_cli_output (vm, "%U", format_mheap, sm->heap, 0 /* verbose */ );
370  }
371 
372  return 0;
373 }
374 
375 /* *INDENT-OFF* */
376 VLIB_CLI_COMMAND (show_stat_segment_command, static) =
377 {
378  .path = "show statistics segment",
379  .short_help = "show statistics segment [verbose]",
380  .function = show_stat_segment_command_fn,
381 };
382 /* *INDENT-ON* */
383 
384 /*
385  * Node performance counters:
386  * total_calls [threads][node-index]
387  * total_vectors
388  * total_calls
389  * total suspends
390  */
391 
392 static inline void
394 {
395  vlib_main_t *vm = vlib_mains[0];
396  vlib_main_t **stat_vms = 0;
397  vlib_node_t ***node_dups = 0;
398  int i, j;
399  stat_segment_shared_header_t *shared_header = sm->shared_header;
400  static u32 no_max_nodes = 0;
401 
402  vlib_node_get_nodes (0 /* vm, for barrier sync */ ,
403  (u32) ~ 0 /* all threads */ ,
404  1 /* include stats */ ,
405  0 /* barrier sync */ ,
406  &node_dups, &stat_vms);
407 
408  u32 l = vec_len (node_dups[0]);
409 
410  /*
411  * Extend performance nodes if necessary
412  */
413  if (l > no_max_nodes)
414  {
415  void *oldheap = clib_mem_set_heap (sm->heap);
417 
426 
428  clib_mem_set_heap (oldheap);
429  no_max_nodes = l;
430  }
431 
432  for (j = 0; j < vec_len (node_dups); j++)
433  {
434  vlib_node_t **nodes = node_dups[j];
435  u32 l = vec_len (nodes);
436 
437  for (i = 0; i < vec_len (nodes); i++)
438  {
439  counter_t **counters;
440  counter_t *c;
441  vlib_node_t *n = nodes[i];
442 
443  counters =
444  stat_segment_pointer (shared_header,
445  sm->directory_vector
447  c = counters[j];
449 
450  counters =
451  stat_segment_pointer (shared_header,
452  sm->directory_vector
454  c = counters[j];
456 
457  counters =
458  stat_segment_pointer (shared_header,
459  sm->directory_vector
461  c = counters[j];
462  c[n->index] = n->stats_total.calls - n->stats_last_clear.calls;
463 
464  counters =
465  stat_segment_pointer (shared_header,
466  sm->directory_vector
468  c = counters[j];
469  c[n->index] =
471  }
472  }
473 }
474 
475 static void
477 {
478  vlib_main_t *vm = vlib_mains[0];
479  f64 vector_rate;
480  u64 input_packets, last_input_packets;
481  f64 dt, now;
482  vlib_main_t *this_vlib_main;
483  int i, start;
484 
485  /*
486  * Compute the average vector rate across all workers
487  */
488  vector_rate = 0.0;
489 
490  start = vec_len (vlib_mains) > 1 ? 1 : 0;
491 
492  for (i = start; i < vec_len (vlib_mains); i++)
493  {
494  this_vlib_main = vlib_mains[i];
495  vector_rate += vlib_last_vector_length_per_node (this_vlib_main);
496  }
497  vector_rate /= (f64) (i - start);
498 
500  vector_rate / ((f64) (vec_len (vlib_mains) - start));
501 
502  /*
503  * Compute the aggregate input rate
504  */
505  now = vlib_time_now (vm);
507  input_packets = vnet_get_aggregate_rx_packets ();
509  (f64) (input_packets - sm->last_input_packets) / dt;
511  sm->last_input_packets = input_packets;
514 
515  if (sm->node_counters_enabled)
517 
518  /* Heartbeat, so clients detect we're still here */
520 }
521 
522 /*
523  * Accept connection on the socket and exchange the fd for the shared
524  * memory segment.
525  */
526 static clib_error_t *
528 {
530  clib_error_t *err;
531  clib_socket_t client = { 0 };
532 
533  err = clib_socket_accept (sm->socket, &client);
534  if (err)
535  {
536  clib_error_report (err);
537  return err;
538  }
539 
540  /* Send the fd across and close */
541  err = clib_socket_sendmsg (&client, 0, 0, &sm->memfd, 1);
542  if (err)
543  clib_error_report (err);
544  clib_socket_close (&client);
545 
546  return 0;
547 }
548 
549 static void
551 {
553  clib_error_t *error;
555 
556  s->config = (char *) sm->socket_name;
559  if ((error = clib_socket_init (s)))
560  {
561  clib_error_report (error);
562  return;
563  }
564 
565  clib_file_t template = { 0 };
567  template.file_descriptor = s->fd;
568  template.description =
569  format (0, "stats segment listener %s", STAT_SEGMENT_SOCKET_FILE);
570  clib_file_add (&file_main, &template);
571 
572  sm->socket = s;
573 }
574 
575 static uword
577  vlib_frame_t * f)
578 {
580 
581  /* Wait for Godot... */
582  f64 sleep_duration = 10;
583 
584  while (1)
585  {
587  vlib_process_suspend (vm, sleep_duration);
588  }
589  return 0; /* or not */
590 }
591 
592 static clib_error_t *
594 {
596  clib_error_t *error;
597 
598  if ((error = vlib_call_init_function (vm, unix_input_init)))
599  return error;
600 
601  if (sm->socket_name)
603 
604  return 0;
605 }
606 
607 static clib_error_t *
609 {
611 
613  {
614  if (unformat (input, "socket-name %s", &sm->socket_name))
615  ;
616  else if (unformat (input, "default"))
618  else
619  if (unformat
620  (input, "size %U", unformat_memory_size, &sm->memory_size))
621  ;
622  else if (unformat (input, "per-node-counters on"))
623  sm->node_counters_enabled = 1;
624  else if (unformat (input, "per-node-counters off"))
625  sm->node_counters_enabled = 0;
626  else
627  return clib_error_return (0, "unknown input `%U'",
628  format_unformat_error, input);
629  }
630 
631  return 0;
632 }
633 
636 
637 /* *INDENT-OFF* */
639 {
640 .function = stat_segment_collector_process,.name =
641  "statseg-collector-process",.type = VLIB_NODE_TYPE_PROCESS,};
642 
643 /* *INDENT-ON* */
644 
645 /*
646  * fd.io coding-style-patch-verification: ON
647  *
648  * Local Variables:
649  * eval: (c-set-style "gnu")
650  * End:
651  */
static clib_error_t * statseg_config(vlib_main_t *vm, unformat_input_t *input)
Definition: stat_segment.c:608
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:437
void vlib_stats_pop_heap(void *cm_arg, void *oldheap, stat_directory_type_t type)
Definition: stat_segment.c:82
Definition: stat_segment.h:60
#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:376
void vlib_stats_register_error_index(u8 *name, u64 *em_vec, u64 index)
Definition: stat_segment.c:145
static u64 vnet_get_aggregate_rx_packets(void)
Definition: devices.h:98
stat_segment_shared_header_t * shared_header
Definition: stat_segment.h:110
static clib_error_t * stats_socket_accept_ready(clib_file_t *uf)
Definition: stat_segment.c:527
stat_segment_main_t stat_segment_main
Definition: stat_segment.c:25
stat_segment_directory_entry_t * directory_vector
Definition: stat_segment.h:103
unsigned long u64
Definition: types.h:89
#define NULL
Definition: clib.h:57
u32 index
Definition: node.h:288
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:227
stat_directory_type_t
Definition: stat_segment.h:26
static uint64_t stat_segment_offset(void *start, void *data)
Definition: stat_segment.h:88
static void stat_validate_counter_vector(stat_segment_directory_entry_t *ep, u32 max)
Definition: stat_segment.c:171
static int memfd_create(const char *name, unsigned int flags)
Definition: syscall.h:44
#define STAT_SEGMENT_DEFAULT_SIZE
Definition: stat_segment.h:73
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:523
int i
clib_error_t * clib_socket_init(clib_socket_t *s)
Definition: socket.c:383
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
#define foreach_stat_segment_counter_name
Definition: stat_segment.h:49
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:448
#define MHEAP_FLAG_THREAD_SAFE
vlib_main_t ** vlib_mains
Definition: buffer.c:303
unsigned char u8
Definition: types.h:56
atomic_int_fast64_t in_progress
Definition: stat_segment.h:81
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:318
#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:448
DLMALLOC_EXPORT mspace create_mspace_with_base(void *base, size_t capacity, int locked)
vlib_node_stats_t stats_last_clear
Definition: node.h:282
uint64_t value
Definition: stat_segment.h:66
static void do_stat_segment_updates(stat_segment_main_t *sm)
Definition: stat_segment.c:476
#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:568
#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:593
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:381
vlib_node_stats_t stats_total
Definition: node.h:278
static void * stat_segment_pointer(void *start, uint64_t offset)
Definition: stat_segment.h:94
static void stats_segment_socket_init(void)
Definition: stat_segment.c:550
clib_error_t * clib_socket_accept(clib_socket_t *server, clib_socket_t *client)
Definition: socket.c:523
f64 time_last_runtime_stats_clear
Definition: node.h:759
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:302
void vlib_stat_segment_unlock(void)
Definition: stat_segment.c:39
uint64_t offset
Definition: stat_segment.h:64
DLMALLOC_EXPORT void mspace_disable_expand(mspace msp)
struct _unformat_input_t unformat_input_t
u64 memory_size
Definition: vhost_user.h:115
#define vec_dup(V)
Return copy of vector (no header, no alignment)
Definition: vec.h:373
u8 name[64]
Definition: memclnt.api:151
#define STAT_SEGMENT_SOCKET_FILE
Definition: stat_segment.h:24
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
Definition: init.h:216
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:155
#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:294
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:638
void vlib_stat_segment_lock(void)
Definition: stat_segment.c:31
uint64_t offset_vector
Definition: stat_segment.h:68
#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:69
#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:80
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:576
uword * directory_vector_by_name
Definition: stat_segment.h:102
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:134
#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:393
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:982
static int name_sort_cmp(void *a1, void *a2)
Definition: stat_segment.c:293
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:335
unformat_function_t unformat_memory_size
Definition: format.h:295
clib_socket_t * socket
Definition: stat_segment.h:105
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
#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:213
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:725
atomic_int_fast64_t error_offset
Definition: stat_segment.h:83
void vlib_stats_pop_heap2(u64 *error_vector, u32 thread_index, void *oldheap)
Definition: stat_segment.c:193
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
clib_spinlock_t * stat_segment_lockp
Definition: stat_segment.h:104
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:170
atomic_int_fast64_t directory_offset
Definition: stat_segment.h:82
stat_directory_type_t type
Definition: stat_segment.h:62