From d8e2f4ccf26cfb81539b198f9a523a71316707ec Mon Sep 17 00:00:00 2001 From: Kevin Traynor Date: Thu, 19 May 2016 13:51:32 +0100 Subject: [PATCH] netdev-dpdk: Improve pthread_getaffinity_np() fail handling. Prevent pthread_setaffinity_np() being called with a potentially invalid cpu_set_t and add a default (core 0x1). Also, only call pthread_getaffinity_np() if no dpdk-lcore-mask specified. Signed-off-by: Kevin Traynor Acked-by: Aaron Conole Acked-by: Daniele Di Proietto --- lib/netdev-dpdk.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 5d5351d7c..9ffa7ff65 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -3084,7 +3084,7 @@ dpdk_init__(const struct smap *ovs_other_config) int result; int argc, argc_tmp; bool auto_determine = true; - int err; + int err = 0; cpu_set_t cpuset; #ifndef VHOST_CUSE char *sock_dir_subcomponent; @@ -3126,14 +3126,6 @@ dpdk_init__(const struct smap *ovs_other_config) #endif } - /* Get the main thread affinity */ - CPU_ZERO(&cpuset); - err = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), - &cpuset); - if (err) { - VLOG_ERR("Thread getaffinity error %d.", err); - } - argv = grow_argv(&argv, 0, 1); argc = 1; argv[0] = xstrdup(ovs_get_program_name()); @@ -3154,13 +3146,26 @@ dpdk_init__(const struct smap *ovs_other_config) */ if (auto_determine) { int i; - for (i = 0; i < CPU_SETSIZE; i++) { - if (CPU_ISSET(i, &cpuset)) { - argv = grow_argv(&argv, argc, 2); - argv[argc++] = xstrdup("-c"); - argv[argc++] = xasprintf("0x%08llX", (1ULL<