From 7176b800fa5570a14d9d403183131f5115158baf Mon Sep 17 00:00:00 2001 From: Benoît Ganne Date: Mon, 16 Dec 2019 15:26:49 +0100 Subject: perfmon: fix per-worker data initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When perfmon_init is called at initialization time worker threads are not created yet and vec_len(vlib_mains) returns 1. Initialize per-worker data when the number of workers is known, when enabling data collection instead. Type: fix Change-Id: I36887cc7b2a3e88d9728d3cd7262d9b1c968dd3c Signed-off-by: Benoît Ganne --- MAINTAINERS | 5 +++++ src/plugins/perfmon/perfmon.c | 6 ------ src/plugins/perfmon/perfmon_periodic.c | 17 ++++++++++++++--- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 32b8914a4cd..158d503f6f6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -426,6 +426,11 @@ I: marvell M: Damjan Marion F: src/plugins/marvell/ +Plugin - performance counter +I: perfmon +M: Dave Barach +F: src/plugins/perfmon/ + Plugin - PPPoE I: pppoe M: Hongjun Ni diff --git a/src/plugins/perfmon/perfmon.c b/src/plugins/perfmon/perfmon.c index 552c88757f7..7e276c30810 100644 --- a/src/plugins/perfmon/perfmon.c +++ b/src/plugins/perfmon/perfmon.c @@ -110,14 +110,8 @@ 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->pm_fds[0], vec_len (vlib_mains) - 1); - vec_validate (pm->pm_fds[1], vec_len (vlib_mains) - 1); vec_validate (pm->perf_event_pages, 1); - vec_validate (pm->perf_event_pages[0], vec_len (vlib_mains) - 1); - vec_validate (pm->perf_event_pages[1], vec_len (vlib_mains) - 1); vec_validate (pm->rdpmc_indices, 1); - vec_validate (pm->rdpmc_indices[0], vec_len (vlib_mains) - 1); - vec_validate (pm->rdpmc_indices[1], vec_len (vlib_mains) - 1); pm->page_size = getpagesize (); pm->perfmon_table = 0; diff --git a/src/plugins/perfmon/perfmon_periodic.c b/src/plugins/perfmon/perfmon_periodic.c index ac68c42c219..8498419f36f 100644 --- a/src/plugins/perfmon/perfmon_periodic.c +++ b/src/plugins/perfmon/perfmon_periodic.c @@ -130,6 +130,10 @@ enable_current_events (perfmon_main_t * pm) for (i = 0; i < limit; i++) { + vec_validate (pm->pm_fds[i], vec_len (vlib_mains) - 1); + vec_validate (pm->perf_event_pages[i], vec_len (vlib_mains) - 1); + vec_validate (pm->rdpmc_indices[i], vec_len (vlib_mains) - 1); + c = vec_elt_at_index (pm->single_events_to_collect, pm->current_event + i); @@ -169,6 +173,7 @@ enable_current_events (perfmon_main_t * pm) close (fd); return; } + CLIB_MEM_UNPOISON (p, pm->page_size); } else p = 0; @@ -239,12 +244,18 @@ disable_events (perfmon_main_t * pm) clib_unix_warning ("disable ioctl"); if (pm->perf_event_pages[i][my_thread_index]) - if (munmap (pm->perf_event_pages[i][my_thread_index], - pm->page_size) < 0) - clib_unix_warning ("munmap"); + { + if (munmap (pm->perf_event_pages[i][my_thread_index], + pm->page_size) < 0) + clib_unix_warning ("munmap"); + CLIB_MEM_POISON (pm->perf_event_pages[i][my_thread_index], + pm->page_size); + pm->perf_event_pages[i][my_thread_index] = 0; + } (void) close (pm->pm_fds[i][my_thread_index]); pm->pm_fds[i][my_thread_index] = 0; + } } -- cgit 1.2.3-korg