aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2019-01-27 17:54:11 +0100
committerFlorin Coras <florin.coras@gmail.com>2019-01-27 20:23:17 +0000
commitee721412ebd3434bc6dd60f5a78f53a4f6e97667 (patch)
treebe5d65a55fe68d7de55740fed6dfbfaaf3b7e6a7 /src
parent87c657036a804c1dd20bfc83c665c105fcdda26c (diff)
Fix issue with cpu_id and numa_code captured too early
Change-Id: I79b213b34c6071d14acf1922f89037a4a5a36c45 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/perfmon/perfmon_periodic.c2
-rw-r--r--src/vlib/main.c6
-rw-r--r--src/vlib/main.h2
-rw-r--r--src/vlib/threads.c3
-rwxr-xr-xsrc/vlib/unix/main.c3
-rw-r--r--src/vppinfra/cpu.h2
6 files changed, 11 insertions, 7 deletions
diff --git a/src/plugins/perfmon/perfmon_periodic.c b/src/plugins/perfmon/perfmon_periodic.c
index 0811439d7eb..12a1891518f 100644
--- a/src/plugins/perfmon/perfmon_periodic.c
+++ b/src/plugins/perfmon/perfmon_periodic.c
@@ -142,7 +142,7 @@ enable_current_events (perfmon_main_t * pm)
pe.exclude_hv = 1;
}
- cpu = vm->cpu_index;
+ cpu = vm->cpu_id;
fd = perf_event_open (&pe, 0, cpu, -1, 0);
if (fd == -1)
diff --git a/src/vlib/main.c b/src/vlib/main.c
index 3048a0d72de..cfd23859210 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -1696,6 +1696,12 @@ vlib_main_or_worker_loop (vlib_main_t * vm, int is_main)
{
vlib_node_runtime_t *n;
+ if (PREDICT_FALSE (vm->cpu_id != clib_get_current_cpu_id ()))
+ {
+ vm->cpu_id = clib_get_current_cpu_id ();
+ vm->numa_node = clib_get_current_numa_node ();
+ }
+
if (PREDICT_FALSE (_vec_len (vm->pending_rpc_requests) > 0))
{
if (!is_main)
diff --git a/src/vlib/main.h b/src/vlib/main.h
index 4c6d0f490dd..c6786d8f788 100644
--- a/src/vlib/main.h
+++ b/src/vlib/main.h
@@ -176,7 +176,7 @@ typedef struct vlib_main_t
/* thread, cpu and numa_node indices */
u32 thread_index;
- u32 cpu_index;
+ u32 cpu_id;
u32 numa_node;
/* List of init functions to call, setup by constructors */
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index e6ac6db543a..6257bb64c90 100644
--- a/src/vlib/threads.c
+++ b/src/vlib/threads.c
@@ -1723,8 +1723,7 @@ vlib_worker_thread_fn (void *arg)
ASSERT (vm->thread_index == vlib_get_thread_index ());
- vm->cpu_index = clib_get_current_cpu_index ();
- vm->numa_node = clib_get_current_numa_node ();
+ vm->cpu_id = ~0;
vlib_worker_thread_init (w);
clib_time_init (&vm->clib_time);
diff --git a/src/vlib/unix/main.c b/src/vlib/unix/main.c
index 4d6519ed857..ae92d93adc2 100755
--- a/src/vlib/unix/main.c
+++ b/src/vlib/unix/main.c
@@ -671,8 +671,7 @@ vlib_unix_main (int argc, char *argv[])
__os_thread_index = 0;
vm->thread_index = 0;
- vm->cpu_index = clib_get_current_cpu_index ();
- vm->numa_node = clib_get_current_numa_node ();
+ vm->cpu_id = ~0;
i = clib_calljmp (thread0, (uword) vm,
(void *) (vlib_thread_stacks[0] +
diff --git a/src/vppinfra/cpu.h b/src/vppinfra/cpu.h
index 8341eaf0e54..97e0144be60 100644
--- a/src/vppinfra/cpu.h
+++ b/src/vppinfra/cpu.h
@@ -101,7 +101,7 @@ _ (sha512, 21) \
_ (sve, 22)
static inline u32
-clib_get_current_cpu_index ()
+clib_get_current_cpu_id ()
{
unsigned cpu, node;
syscall (__NR_getcpu, &cpu, &node, 0);