22 #undef HAVE_MEMFD_CREATE 71 index = next_vector_index;
87 char *stat_segment_name;
113 if (vector_index == next_vector_index)
115 strncpy (e.
name, stat_segment_name, 128 - 1);
178 u64 *offset_vector = 0;
228 char *mem_name =
"stat_segment_test";
232 if (memory_size == 0)
240 if ((ftruncate (mfd, memory_size)) == -1)
244 mmap (
NULL, memory_size, PROT_READ | PROT_WRITE, MAP_SHARED, mfd,
249 #if USE_DLMALLOC == 0 251 memory_size - getpagesize (),
257 memory_size - getpagesize (), 1 );
274 shared_header->
epoch = 1;
279 strcpy(sm->directory_vector[STAT_COUNTER_##E].name, "/sys" #p "/" #n); \ 280 sm->directory_vector[STAT_COUNTER_##E].type = STAT_DIR_TYPE_##t; 298 return strcmp ((
char *) n1->
name, (
char *) n2->
name);
309 format_string =
"%-74s %-10s %10lld";
314 type_name =
"ScalarPtr";
319 type_name =
"CMainPtr";
323 type_name =
"ErrIndex";
327 type_name =
"illegal!";
360 for (i = 0; i <
vec_len (show_data); i++)
378 .path =
"show statistics segment",
379 .short_help =
"show statistics segment [verbose]",
400 static u32 no_max_nodes = 0;
406 &node_dups, &stat_vms);
413 if (l > no_max_nodes)
432 for (j = 0; j <
vec_len (node_dups); j++)
437 for (i = 0; i <
vec_len (nodes); i++)
480 u64 input_packets, last_input_packets;
497 vector_rate /= (
f64) (i - start);
567 template.file_descriptor = s->fd;
568 template.description =
582 f64 sleep_duration = 10;
616 else if (
unformat (input,
"default"))
622 else if (
unformat (input,
"per-node-counters on"))
624 else if (
unformat (input,
"per-node-counters off"))
static clib_error_t * statseg_config(vlib_main_t *vm, unformat_input_t *input)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void vlib_stats_pop_heap(void *cm_arg, void *oldheap, stat_directory_type_t type)
#define hash_set(h, key, value)
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
void vlib_stats_register_error_index(u8 *name, u64 *em_vec, u64 index)
static u64 vnet_get_aggregate_rx_packets(void)
stat_segment_shared_header_t * shared_header
static clib_error_t * stats_socket_accept_ready(clib_file_t *uf)
stat_segment_main_t stat_segment_main
stat_segment_directory_entry_t * directory_vector
static f64 vlib_time_now(vlib_main_t *vm)
static uint64_t stat_segment_offset(void *start, void *data)
static void stat_validate_counter_vector(stat_segment_directory_entry_t *ep, u32 max)
static int memfd_create(const char *name, unsigned int flags)
#define STAT_SEGMENT_DEFAULT_SIZE
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
clib_error_t * clib_socket_init(clib_socket_t *s)
#define foreach_stat_segment_counter_name
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
#define MHEAP_FLAG_THREAD_SAFE
vlib_main_t ** vlib_mains
clib_file_function_t * read_function
static f64 vlib_last_vector_length_per_node(vlib_main_t *vm)
#define CLIB_SOCKET_F_IS_SERVER
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
DLMALLOC_EXPORT mspace create_mspace_with_base(void *base, size_t capacity, int locked)
vlib_node_stats_t stats_last_clear
static void do_stat_segment_updates(stat_segment_main_t *sm)
#define VLIB_INIT_FUNCTION(x)
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.
#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)
uint64_t counter_t
64bit counters
#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...)
clib_file_main_t file_main
#define hash_get_pair(h, key)
static clib_error_t * statseg_init(vlib_main_t *vm)
A collection of simple counters.
#define vlib_call_init_function(vm, x)
void * vlib_stats_push_heap(void)
#define hash_create_string(elts, value_bytes)
static void clib_spinlock_init(clib_spinlock_t *p)
char * name
The counter collection's name.
u8 * format_mheap(u8 *s, va_list *va)
vlib_node_stats_t stats_total
static void * stat_segment_pointer(void *start, uint64_t offset)
static void stats_segment_socket_init(void)
clib_error_t * clib_socket_accept(clib_socket_t *server, clib_socket_t *client)
f64 time_last_runtime_stats_clear
static clib_error_t * clib_socket_close(clib_socket_t *sock)
static u8 * format_stat_dir_entry(u8 *s, va_list *args)
void vlib_stat_segment_unlock(void)
DLMALLOC_EXPORT void mspace_disable_expand(mspace msp)
#define vec_dup(V)
Return copy of vector (no header, no alignment)
#define STAT_SEGMENT_SOCKET_FILE
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
#define VLIB_REGISTER_NODE(x,...)
static u32 lookup_or_create_hash_index(void *oldheap, char *name, u32 next_vector_index)
static void * clib_mem_set_heap(void *heap)
static vlib_node_registration_t stat_segment_collector
(constructor) VLIB_REGISTER_NODE (stat_segment_collector)
void vlib_stat_segment_lock(void)
#define VLIB_CLI_COMMAND(x,...)
void * mheap_alloc_with_flags(void *memory, uword memory_size, uword flags)
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
#define clib_error_report(e)
struct _socket_t clib_socket_t
static void * clib_mem_alloc(uword size)
#define CLIB_SOCKET_F_SEQPACKET
static uword stat_segment_collector_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
uword * directory_vector_by_name
char * stat_segment_name
Name in stat segment directory.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_node_main_t node_main
#define CLIB_SOCKET_F_PASSCRED
static void update_node_counters(stat_segment_main_t *sm)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
static int name_sort_cmp(void *a1, void *a2)
static clib_error_t * show_stat_segment_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
counter_t ** counters
Per-thread u64 non-atomic counters.
static vlib_thread_main_t * vlib_get_thread_main()
#define CLIB_CACHE_LINE_BYTES
#define CLIB_SOCKET_F_ALLOW_GROUP_WRITE
clib_error_t * vlib_map_stat_segment_init(void)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
void vlib_stats_pop_heap2(u64 *error_vector, u32 thread_index, void *oldheap)
clib_spinlock_t * stat_segment_lockp
stat_directory_type_t type