aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vlib/threads.c71
-rw-r--r--src/vlib/threads.h5
-rw-r--r--src/vppinfra/unix-misc.c31
-rw-r--r--src/vppinfra/unix.h3
4 files changed, 7 insertions, 103 deletions
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index bbcb4ec2979..87b71adc2bc 100644
--- a/src/vlib/threads.c
+++ b/src/vlib/threads.c
@@ -182,9 +182,7 @@ vlib_thread_init (vlib_main_t * vm)
u32 n_vlib_mains = 1;
u32 first_index = 1;
u32 i;
- pid_t pid;
- uword *avail_cpu, *affinity_cpu;
- uword n_cpus;
+ uword *avail_cpu;
u32 stats_num_worker_threads_dir_index;
stats_num_worker_threads_dir_index =
@@ -195,39 +193,16 @@ vlib_thread_init (vlib_main_t * vm)
tm->cpu_core_bitmap = os_get_online_cpu_core_bitmap ();
tm->cpu_socket_bitmap = os_get_online_cpu_node_bitmap ();
- /* get bitmap of active cpu cores vpp has affinity to */
- pid = getpid ();
- tm->cpu_affinity_bitmap = os_get_cpu_affinity_bitmap (pid);
-
- /* if fetching affinity fails, return online cpu core bmp */
- if (tm->cpu_affinity_bitmap == 0)
- tm->cpu_affinity_bitmap = os_get_online_cpu_core_bitmap ();
-
avail_cpu = clib_bitmap_dup (tm->cpu_core_bitmap);
- affinity_cpu = clib_bitmap_dup (tm->cpu_affinity_bitmap);
/* skip cores */
- n_cpus = clib_bitmap_count_set_bits (avail_cpu);
- if (tm->skip_cores >= n_cpus)
- return clib_error_return (0, "skip-core greater than available cpus");
- n_cpus = clib_bitmap_count_set_bits (affinity_cpu);
- if (tm->skip_cores >= n_cpus)
- return clib_error_return (0, "skip-core greater than affinity cpus");
-
for (i = 0; i < tm->skip_cores; i++)
{
- uword c;
- c = clib_bitmap_first_set (avail_cpu);
+ uword c = clib_bitmap_first_set (avail_cpu);
if (c == ~0)
return clib_error_return (0, "no available cpus to skip");
avail_cpu = clib_bitmap_set (avail_cpu, c, 0);
-
- c = clib_bitmap_first_set (affinity_cpu);
- if (c == ~0)
- return clib_error_return (0, "no available env cpus to skip");
-
- affinity_cpu = clib_bitmap_set (affinity_cpu, c, 0);
}
/* grab cpu for main thread */
@@ -237,17 +212,6 @@ vlib_thread_init (vlib_main_t * vm)
return clib_error_return (0, "cpu %u is not available to be used"
" for the main thread", tm->main_lcore);
avail_cpu = clib_bitmap_set (avail_cpu, tm->main_lcore, 0);
- affinity_cpu = clib_bitmap_set (affinity_cpu, tm->main_lcore, 0);
- }
- /* if auto enabled, grab first cpu vpp has affinity to for main thread */
- else if (tm->use_main_core_auto)
- {
- uword c = clib_bitmap_first_set (affinity_cpu);
- if (c != ~0)
- tm->main_lcore = c;
-
- avail_cpu = clib_bitmap_set (avail_cpu, tm->main_lcore, 0);
- affinity_cpu = clib_bitmap_set (affinity_cpu, tm->main_lcore, 0);
}
/* assume that there is socket 0 only if there is no data from sysfs */
@@ -332,23 +296,13 @@ vlib_thread_init (vlib_main_t * vm)
}
else
{
- /* for automatic pinning, use cpu affinity list */
- uword n_env_cpu = 0;
- n_env_cpu = clib_bitmap_count_set_bits (affinity_cpu);
-
- if (n_env_cpu < tr->count)
- return clib_error_return (0,
- "no available cpus to be used for"
- " the '%s' thread #%u",
- tr->name, n_env_cpu);
-
for (j = 0; j < tr->count; j++)
{
/* Do not use CPU 0 by default - leave it to the host and IRQs */
- uword avail_c0 = clib_bitmap_get (affinity_cpu, 0);
- affinity_cpu = clib_bitmap_set (affinity_cpu, 0, 0);
+ uword avail_c0 = clib_bitmap_get (avail_cpu, 0);
+ avail_cpu = clib_bitmap_set (avail_cpu, 0, 0);
- uword c = clib_bitmap_first_set (affinity_cpu);
+ uword c = clib_bitmap_first_set (avail_cpu);
/* Use CPU 0 as a last resort */
if (c == ~0 && avail_c0)
{
@@ -362,15 +316,14 @@ vlib_thread_init (vlib_main_t * vm)
" the '%s' thread #%u",
tr->name, tr->count);
- affinity_cpu = clib_bitmap_set (affinity_cpu, 0, avail_c0);
- affinity_cpu = clib_bitmap_set (affinity_cpu, c, 0);
+ avail_cpu = clib_bitmap_set (avail_cpu, 0, avail_c0);
+ avail_cpu = clib_bitmap_set (avail_cpu, c, 0);
tr->coremask = clib_bitmap_set (tr->coremask, c, 1);
}
}
}
clib_bitmap_free (avail_cpu);
- clib_bitmap_free (affinity_cpu);
tm->n_vlib_mains = n_vlib_mains;
vlib_stats_set_gauge (stats_num_worker_threads_dir_index, n_vlib_mains - 1);
@@ -1176,7 +1129,6 @@ cpu_config (vlib_main_t * vm, unformat_input_t * input)
tm->sched_policy = ~0;
tm->sched_priority = ~0;
tm->main_lcore = ~0;
- tm->use_main_core_auto = 0;
tr = tm->next;
@@ -1192,8 +1144,6 @@ cpu_config (vlib_main_t * vm, unformat_input_t * input)
tm->use_pthreads = 1;
else if (unformat (input, "thread-prefix %v", &tm->thread_prefix))
;
- else if (unformat (input, "main-core auto"))
- tm->use_main_core_auto = 1;
else if (unformat (input, "main-core %u", &tm->main_lcore))
;
else if (unformat (input, "skip-cores %u", &tm->skip_cores))
@@ -1252,13 +1202,6 @@ cpu_config (vlib_main_t * vm, unformat_input_t * input)
break;
}
- if (tm->main_lcore != ~0 && tm->use_main_core_auto)
- {
- return clib_error_return (
- 0, "cannot set both 'main-core %u' and 'main-core auto'",
- tm->main_lcore);
- }
-
if (tm->sched_priority != ~0)
{
if (tm->sched_policy == SCHED_FIFO || tm->sched_policy == SCHED_RR)
diff --git a/src/vlib/threads.h b/src/vlib/threads.h
index 3072d0e67dd..ac0c1d5d266 100644
--- a/src/vlib/threads.h
+++ b/src/vlib/threads.h
@@ -255,8 +255,6 @@ typedef struct
int use_pthreads;
- int use_main_core_auto;
-
/* Number of vlib_main / vnet_main clones */
u32 n_vlib_mains;
@@ -284,9 +282,6 @@ typedef struct
/* Bitmap of available CPU sockets (NUMA nodes) */
uword *cpu_socket_bitmap;
- /* Bitmap of CPU affinity for VPP process */
- uword *cpu_affinity_bitmap;
-
/* Worker handoff queues */
vlib_frame_queue_main_t *frame_queue_mains;
diff --git a/src/vppinfra/unix-misc.c b/src/vppinfra/unix-misc.c
index a72e55dd043..5008f82c493 100644
--- a/src/vppinfra/unix-misc.c
+++ b/src/vppinfra/unix-misc.c
@@ -49,7 +49,6 @@
#include <sys/stat.h>
#include <sys/types.h>
-#include <sys/syscall.h>
#include <sys/uio.h> /* writev */
#include <fcntl.h>
#include <stdio.h> /* for sprintf */
@@ -279,36 +278,6 @@ os_get_online_cpu_core_bitmap ()
}
__clib_export clib_bitmap_t *
-os_get_cpu_affinity_bitmap (int pid)
-{
-#if __linux
- int index, ret;
- cpu_set_t cpuset;
- uword *affinity_cpus;
-
- clib_bitmap_alloc (affinity_cpus, sizeof (cpu_set_t));
- clib_bitmap_zero (affinity_cpus);
-
- __CPU_ZERO_S (sizeof (cpu_set_t), &cpuset);
-
- ret = syscall (SYS_sched_getaffinity, 0, sizeof (cpu_set_t), &cpuset);
-
- if (ret < 0)
- {
- clib_bitmap_free (affinity_cpus);
- return 0;
- }
-
- for (index = 0; index < sizeof (cpu_set_t); index++)
- if (__CPU_ISSET_S (index, sizeof (cpu_set_t), &cpuset))
- clib_bitmap_set (affinity_cpus, index, 1);
- return affinity_cpus;
-#else
- return 0;
-#endif
-}
-
-__clib_export clib_bitmap_t *
os_get_online_cpu_node_bitmap ()
{
#if __linux__
diff --git a/src/vppinfra/unix.h b/src/vppinfra/unix.h
index abda21879f9..d0ddb93a46f 100644
--- a/src/vppinfra/unix.h
+++ b/src/vppinfra/unix.h
@@ -56,9 +56,6 @@ clib_error_t *unix_proc_file_contents (char *file, u8 ** result);
/* Retrieve bitmap of online cpu cures */
clib_bitmap_t *os_get_online_cpu_core_bitmap ();
-/* Retrieve bitmap of cpus vpp has affinity to */
-clib_bitmap_t *os_get_cpu_affinity_bitmap (int pid);
-
/* Retrieve bitmap of online cpu nodes (sockets) */
clib_bitmap_t *os_get_online_cpu_node_bitmap ();