aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);