@@ -83,6 +83,7 @@ static odp_ticketlock_t tm_profile_lock;
static odp_barrier_t tm_first_enq;
static int g_main_thread_cpu = -1;
+static int g_tm_cpu_num = 0;
/* Forward function declarations. */
static void tm_queue_cnts_decrement(tm_system_t *tm_system,
@@ -2559,6 +2560,7 @@ static uint32_t tm_thread_cpu_select(void)
{
odp_cpumask_t odp_cpu_mask;
int cpu_count;
+ int cpu;
odp_cpumask_default_worker(&odp_cpu_mask, 0);
if ((g_main_thread_cpu != -1) &&
@@ -2576,7 +2578,18 @@ static uint32_t tm_thread_cpu_select(void)
odp_cpumask_all_available(&odp_cpu_mask);
}
- return odp_cpumask_first(&odp_cpu_mask);
+ if (g_tm_cpu_num == 0) {
+ cpu = odp_cpumask_first(&odp_cpu_mask);
+ } else {
+ cpu = odp_cpumask_next(&odp_cpu_mask, g_tm_cpu_num);
+ if (cpu == -1) {
+ g_tm_cpu_num = 0;
+ cpu = odp_cpumask_first(&odp_cpu_mask);
+ }
+ }
+
+ g_tm_cpu_num++;
+ return cpu;
}
static int tm_thread_create(tm_system_t *tm_system)
@@ -2770,6 +2783,9 @@ int odp_tm_destroy(odp_tm_t odp_tm)
ODP_ASSERT(rc == 0);
pthread_attr_destroy(&tm_system->attr);
+ if (g_tm_cpu_num > 0)
+ g_tm_cpu_num--;
+
input_work_queue_destroy(tm_system->input_work_queue);
_odp_sorted_pool_destroy(tm_system->_odp_int_sorted_pool);
_odp_queue_pool_destroy(tm_system->_odp_int_queue_pool);
When creating multiple TM service threads, attempt to assign them to separate cores to avoid overloading a single core. This addresses the issue raised in Bug https://bugs.linaro.org/show_bug.cgi?id=2444 Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org> --- platform/linux-generic/odp_traffic_mngr.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) -- 2.7.4