19 #include <perfmon/perfmon.h> 24 #include <vpp/app/version.h> 25 #include <linux/limits.h> 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)
303 vlib_cli_output (vm,
"Start collection for %d events, wait %.2f seconds",
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");
388 s =
format (s,
"%-40s%+20s%+16llu%+16llu%+16.2e\n",
389 name,
"instructions-per-clock",
404 mispredict_rate = 0.0;
406 s =
format (s,
"%-40s%+20s%+16llu%+16llu%+16.2e\n",
407 name,
"branch-mispredict-rate",
419 s =
format (s,
"%-40s%+20s%+16llu%+16llu%+16.2e",
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"))
567 for (i = 0; i <
vec_len (captures); i++)
583 .short_help =
"show pmc [verbose]",
621 .short_help =
"clear the performance monitor counters",
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
perfmon_capture_t * capture_pool
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
vnet_interface_output_runtime_t * rt
u64 * vectors_this_counter
perfmon_event_config_t * paired_events_to_collect
perfmon_thread_t ** threads
vnet_hw_if_output_node_runtime_t * r
#define pool_foreach(VAR, POOL)
Iterate through pool.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
u32 mispredict_event_index
#define hash_set_mem(h, key, value)
#define hash_get_pair_mem(h, key)
perfmon_main_t perfmon_main
#define clib_bitmap_zero(v)
Clear a bitmap.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
#define VLIB_INIT_FUNCTION(x)
description fragment has unexpected format
#define clib_error_return(e, args...)
vnet_main_t * vnet_get_main(void)
u8 * thread_and_node_name
static perfmon_event_t events[]
#define hash_create_string(elts, value_bytes)
perfmon_intel_pmc_event_t * events
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
static uword clib_bitmap_last_set(uword *ai)
Return the higest numbered set bit in a bitmap.
uword * pmc_event_by_name
perfmon_intel_pmc_cpu_model_t * models
perfmon_intel_pmc_event_t * perfmon_table
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
#define vlib_log_err(...)
#define hash_foreach_mem(key_var, value_var, h, body)
vlib_log_class_t log_class
#define pool_free(p)
Free a pool.
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
__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" )
#define VLIB_CLI_COMMAND(x,...)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
perfmon_event_config_t * single_events_to_collect
#define vec_append(v1, v2)
Append v2 after v1.
uword * capture_by_thread_and_node_name
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
perfmon_intel_pmc_registration_t * perfmon_tables
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
static void * clib_mem_alloc_aligned(uword size, uword align)
static vlib_thread_main_t * vlib_get_thread_main()
#define vec_foreach(var, vec)
Vector iterator.
#define CLIB_CACHE_LINE_BYTES
static uword pool_elts(void *v)
Number of active elements in a pool.