From a4498aeb1eff7eed4c8a8d090c599a9d11f36161 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Fri, 2 Jun 2017 12:35:31 +0200 Subject: [PATCH] defaulted cpu affinity to all cores --- lib/src/common/threads.c | 12 +++++------- srsue/src/main.cc | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/src/common/threads.c b/lib/src/common/threads.c index 73234bb9f..ec730d5de 100644 --- a/lib/src/common/threads.c +++ b/lib/src/common/threads.c @@ -65,7 +65,7 @@ bool threads_new_rt_cpu(pthread_t *thread, void *(*start_routine) (void*), void fprintf(stderr, "Error not enough privileges to set Scheduling priority\n"); } } - if(cpu != -1) { + if(cpu > 0) { if(cpu > 50) { int mask; mask = cpu/100; @@ -73,19 +73,17 @@ bool threads_new_rt_cpu(pthread_t *thread, void *(*start_routine) (void*), void CPU_ZERO(&cpuset); for(int i = 0; i < 8;i++){ if(((mask >> i) & 0x01) == 1){ - printf("Setting this worker with affinity to core %d\n", i); CPU_SET((size_t) i , &cpuset); } } } else { CPU_ZERO(&cpuset); CPU_SET((size_t) cpu, &cpuset); - printf("Setting CPU affinity to cpu_id=%d\n", cpu); } if(pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset)) { - perror("pthread_attr_setaffinity_np"); - } + perror("pthread_attr_setaffinity_np"); + } } int err = pthread_create(thread, prio_offset >= 0 ? &attr : NULL, start_routine, arg); @@ -94,9 +92,9 @@ bool threads_new_rt_cpu(pthread_t *thread, void *(*start_routine) (void*), void perror("Warning: Failed to create thread with real-time priority. Creating it with normal priority"); err = pthread_create(thread, NULL, start_routine, arg); if (err) { - perror("pthread_create"); + perror("pthread_create"); } else { - ret = true; + ret = true; } } else { perror("pthread_create"); diff --git a/srsue/src/main.cc b/srsue/src/main.cc index 51d14054e..8065a3571 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -113,11 +113,11 @@ void parse_args(all_args_t *args, int argc, char* argv[]) { /* Expert section */ ("expert.phy.worker_cpu_mask", - bpo::value(&args->expert.phy.worker_cpu_mask)->default_value(254), + bpo::value(&args->expert.phy.worker_cpu_mask)->default_value(-1), "cpu bit mask (eg 255 = 1111 1111)") ("expert.phy.sync_cpu_affinity", - bpo::value(&args->expert.phy.sync_cpu_affinity)->default_value(2), + bpo::value(&args->expert.phy.sync_cpu_affinity)->default_value(-1), "index of the core used by the sync thread") ("expert.ue_category",