diff options
author | Tom Seidenberg <tseidenb@cisco.com> | 2020-07-10 15:49:03 +0000 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2020-07-16 21:44:42 +0000 |
commit | 6c81f5a2493ff65b4dacfef45db8a1ee459a738f (patch) | |
tree | 24343a92e18599be4e4b4aa360ab7b2c13cdb878 /src/plugins/perfmon/perfmon.c | |
parent | bab02f0b184b63c4159ded030cf34044be10da40 (diff) |
misc: add callback hooks and refactor pmc
Callbacks for monitoring and performance measurement:
- Add new callback list type, with context
- Add callbacks for API, CLI, and barrier sync
- Modify node dispatch callback to pass plugin-specific context
- Modify perfmon plugin to keep PMC samples local to the plugin
- Include process nodes in dispatch callback
- Pass dispatch function return value to callback
Type: refactor
Signed-off-by: Tom Seidenberg <tseidenb@cisco.com>
Change-Id: I28b06c58490611e08d76ff5b01b2347ba2109b22
Diffstat (limited to 'src/plugins/perfmon/perfmon.c')
-rw-r--r-- | src/plugins/perfmon/perfmon.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/plugins/perfmon/perfmon.c b/src/plugins/perfmon/perfmon.c index 7e276c30810..525a864b584 100644 --- a/src/plugins/perfmon/perfmon.c +++ b/src/plugins/perfmon/perfmon.c @@ -16,7 +16,6 @@ */ #include <vnet/vnet.h> -#include <vnet/plugin/plugin.h> #include <perfmon/perfmon.h> #include <perfmon/perfmon_intel.h> @@ -98,6 +97,7 @@ perfmon_init (vlib_main_t * vm) u32 cpuid; u8 model, stepping; perfmon_intel_pmc_event_t *ev; + int i; pm->vlib_main = vm; pm->vnet_main = vnet_get_main (); @@ -109,9 +109,17 @@ perfmon_init (vlib_main_t * vm) /* Default data collection interval */ pm->timeout_interval = 2.0; /* seconds */ - vec_validate (pm->pm_fds, 1); - vec_validate (pm->perf_event_pages, 1); - vec_validate (pm->rdpmc_indices, 1); + + vec_validate (pm->threads, vlib_get_thread_main ()->n_vlib_mains - 1); + for (i = 0; i < vec_len (pm->threads); i++) + { + perfmon_thread_t *pt = clib_mem_alloc_aligned + (sizeof (perfmon_thread_t), CLIB_CACHE_LINE_BYTES); + clib_memset (pt, 0, sizeof (*pt)); + pm->threads[i] = pt; + pt->pm_fds[0] = -1; + pt->pm_fds[1] = -1; + } pm->page_size = getpagesize (); pm->perfmon_table = 0; @@ -147,18 +155,7 @@ perfmon_init (vlib_main_t * vm) VLIB_INIT_FUNCTION (perfmon_init); -/* *INDENT-OFF* */ -VLIB_PLUGIN_REGISTER () = -{ - .version = VPP_BUILD_VER, - .description = "Performance Monitor", -#if !defined(__x86_64__) - .default_disabled = 1, -#endif -}; -/* *INDENT-ON* */ - -static uword +uword unformat_processor_event (unformat_input_t * input, va_list * args) { perfmon_main_t *pm = va_arg (*args, perfmon_main_t *); @@ -185,6 +182,10 @@ unformat_processor_event (unformat_input_t * input, va_list * args) pe_config |= pm->perfmon_table[idx].event_code[0]; pe_config |= pm->perfmon_table[idx].umask << 8; + pe_config |= pm->perfmon_table[idx].edge << 18; + pe_config |= pm->perfmon_table[idx].anyt << 21; + pe_config |= pm->perfmon_table[idx].inv << 23; + pe_config |= pm->perfmon_table[idx].cmask << 24; ep->name = (char *) hp->key; ep->pe_type = PERF_TYPE_RAW; |