|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
19 #include <perfmon/perfmon.h>
24 #include <vpp/app/version.h>
25 #include <linux/limits.h>
38 r.n_events = n_events;
39 r.n_models = n_models;
47 #if defined(__x86_64__)
49 asm volatile (
"mov $1, %%eax; cpuid; mov %%eax, %0":
"=r" (cpuid)::
"%eax",
50 "%edx",
"%ecx",
"%rbx");
59 u32 n_models,
u8 model,
u8 stepping)
62 for (
i = 0;
i < n_models;
i++)
64 if (mt[
i].model != model)
67 if (mt[
i].has_stepping)
69 if (mt[
i].stepping != stepping)
80 u8 model,
u8 stepping)
129 model = ((cpuid >> 12) & 0xf0) | ((cpuid >> 4) & 0xf);
130 stepping = cpuid & 0xf;
223 if (
unformat (line_input,
"timeout %u", &timeout_seconds))
225 else if (
unformat (line_input,
"instructions-per-clock"))
227 ec.
name =
"instructions";
228 ec.
pe_type = PERF_TYPE_HARDWARE;
229 ec.
pe_config = PERF_COUNT_HW_INSTRUCTIONS;
232 ec.
name =
"cpu-cycles";
233 ec.
pe_type = PERF_TYPE_HARDWARE;
237 else if (
unformat (line_input,
"branch-mispredict-rate"))
239 ec.
name =
"branch-misses";
240 ec.
pe_type = PERF_TYPE_HARDWARE;
241 ec.
pe_config = PERF_COUNT_HW_BRANCH_MISSES;
244 ec.
name =
"branches";
245 ec.
pe_type = PERF_TYPE_HARDWARE;
246 ec.
pe_config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS;
249 else if (
unformat (line_input,
"threads %U",
252 else if (
unformat (line_input,
"thread %U",
259 #define _(type,event,str) \
260 else if (unformat (line_input, str)) \
264 ec.pe_config = event; \
265 vec_add1 (pm->single_events_to_collect, ec); \
281 if (last_set != ~0 && last_set >= num_threads)
332 .short_help =
"set pmc [threads n,n1-n2] c1... [see \"show pmc events\"]",
353 int verbose __attribute__ ((unused)) = va_arg (*args,
int);
359 s =
format (s,
"%=40s%=20s%=16s%=16s%=16s",
360 "Name",
"Counter",
"Count",
"Pkts",
"Counts/Pkt");
369 name =
c->thread_and_node_name;
382 if (
c->counter_values[
i + 1] > 0)
383 ipc_rate = (
f64)
c->counter_values[
i]
384 / (
f64)
c->counter_values[
i + 1];
388 s =
format (s,
"%-40s%+20s%+16llu%+16llu%+16.2e\n",
389 name,
"instructions-per-clock",
390 c->counter_values[
i],
391 c->counter_values[
i + 1], ipc_rate);
400 if (
c->counter_values[
i + 1] > 0)
401 mispredict_rate = (
f64)
c->counter_values[
i]
402 / (
f64)
c->counter_values[
i + 1];
404 mispredict_rate = 0.0;
406 s =
format (s,
"%-40s%+20s%+16llu%+16llu%+16.2e\n",
407 name,
"branch-mispredict-rate",
408 c->counter_values[
i],
409 c->counter_values[
i + 1], mispredict_rate);
413 if (
c->vectors_this_counter[
i])
415 ((
f64)
c->counter_values[
i]) / ((
f64)
c->vectors_this_counter[
i]);
419 s =
format (s,
"%-40s%+20s%+16llu%+16llu%+16.2e",
420 name,
c->counter_names[
i],
421 c->counter_values[
i],
422 c->vectors_this_counter[
i], ticks_per_pkt);
430 int verbose = va_arg (*args,
int);
432 #define _(type,config,name) \
434 s = format (s, "\n %s", name); \
436 s = format (s, "\n %s (%d, %d)", name, type, config);
454 return strcmp ((
char *) nvp1->
name, (
char *) nvp2->
name);
478 int verbose = va_arg (*args,
int);
487 vec_add2 (sort_nvps, sn, 1);
524 else if (
unformat (input,
"verbose"))
583 .short_help =
"show pmc [verbose]",
621 .short_help =
"clear the performance monitor counters",
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
perfmon_main_t perfmon_main
#define hash_create_string(elts, value_bytes)
#define clib_error_return(e, args...)
#define vec_append(v1, v2)
Append v2 after v1.
#define hash_set_mem(h, key, value)
perfmon_capture_t * capture_pool
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
vnet_hw_if_output_node_runtime_t * r
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
#define vlib_log_err(...)
vlib_log_class_t log_class
#define pool_foreach(VAR, POOL)
Iterate through pool.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
vnet_main_t * vnet_get_main(void)
perfmon_event_config_t * single_events_to_collect
u8 * thread_and_node_name
static perfmon_event_t events[]
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
#define VLIB_CLI_COMMAND(x,...)
#define CLIB_CACHE_LINE_BYTES
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
#define vec_free(V)
Free vector's memory (no header).
description fragment has unexpected format
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
uword * capture_by_thread_and_node_name
#define VLIB_INIT_FUNCTION(x)
#define vec_foreach(var, vec)
Vector iterator.
static uword pool_elts(void *v)
Number of active elements in a pool.
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
static uword clib_bitmap_last_set(uword *ai)
Return the higest numbered set bit in a bitmap.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
perfmon_intel_pmc_event_t * perfmon_table
vnet_interface_output_runtime_t * rt
#define hash_get_pair_mem(h, key)
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
#define pool_free(p)
Free a pool.
static void * clib_mem_alloc_aligned(uword size, uword align)
perfmon_intel_pmc_registration_t * perfmon_tables
uword * pmc_event_by_name
#define clib_bitmap_zero(v)
Clear a bitmap.
u32 mispredict_event_index
perfmon_thread_t ** threads
perfmon_event_config_t * paired_events_to_collect
static vlib_thread_main_t * vlib_get_thread_main()
#define hash_foreach_mem(key_var, value_var, h, body)
__clib_export uword unformat_bitmap_list(unformat_input_t *input, va_list *va)
unformat a list of bit ranges into a bitmap (eg "0-3,5-7,11" )