pthread_attr_setaffinity_np is a GLIBC extension. The same can be achieved in a portable way by calling pthread_setaffinity_np after thread is created.
This fixes build with musl libc. Signed-off-by: Ruslan Babayev <[email protected]> --- helper/linux.c | 13 +++++++------ platform/linux-generic/odp_traffic_mngr.c | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/helper/linux.c b/helper/linux.c index a1dbe52..dab7b5d 100644 --- a/helper/linux.c +++ b/helper/linux.c @@ -17,6 +17,7 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> +#include <pthread.h> #include <odp_api.h> #include <odp/helper/linux.h> @@ -80,9 +81,6 @@ int odph_linux_pthread_create(odph_linux_pthread_t *pthread_tbl, pthread_tbl[i].cpu = cpu; - pthread_attr_setaffinity_np(&pthread_tbl[i].attr, - sizeof(cpu_set_t), &cpu_set); - pthread_tbl[i].thr_params.start = thr_params->start; pthread_tbl[i].thr_params.arg = thr_params->arg; pthread_tbl[i].thr_params.thr_type = thr_params->thr_type; @@ -97,6 +95,9 @@ int odph_linux_pthread_create(odph_linux_pthread_t *pthread_tbl, break; } + pthread_setaffinity_np(pthread_tbl[i].thread, + sizeof(cpu_set_t), &cpu_set); + cpu = odp_cpumask_next(mask, cpu); } @@ -353,9 +354,6 @@ static int odph_linux_thread_create(odph_odpthread_t *thread_tbl, thread_tbl->cpu = cpu; - pthread_attr_setaffinity_np(&thread_tbl->thread.attr, - sizeof(cpu_set_t), &cpu_set); - thread_tbl->start_args.thr_params = *thr_params; /* copy */ thread_tbl->start_args.linuxtype = ODPTHREAD_PTHREAD; @@ -369,6 +367,9 @@ static int odph_linux_thread_create(odph_odpthread_t *thread_tbl, return ret; } + pthread_setaffinity_np(thread_tbl->thread.thread_id, + sizeof(cpu_set_t), &cpu_set); + return 0; } diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c index 681df00..4c8f8d4 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -2588,12 +2588,12 @@ static int tm_thread_create(tm_system_t *tm_system) cpu_num = tm_thread_cpu_select(); CPU_ZERO(&cpu_set); CPU_SET(cpu_num, &cpu_set); - pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpu_set); - rc = pthread_create(&thread, &attr, tm_system_thread, tm_system); if (rc != 0) ODP_DBG("Failed to start thread on cpu num=%u\n", cpu_num); + pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpu_set); + return rc; } -- 2.7.4 _______________________________________________ lng-odp mailing list [email protected] https://lists.linaro.org/mailman/listinfo/lng-odp
