The user has control over the DPDK internal lcore coremask, but this
parameter can be autofilled with a bit more intelligence. If the user
does not fill this parameter in, we use the lowest set bit in the
current task CPU affinity. Otherwise, we will reassign the current
thread to the specified lcore mask, in addition to the dpdk lcore
threads.

Signed-off-by: Aaron Conole <acon...@redhat.com>
Tested-by: Sean K Mooney <sean.k.moo...@intel.com>
Tested-by: RobertX Wojciechowicz <robertx.wojciechow...@intel.com>
Tested-by: Kevin Traynor <kevin.tray...@intel.com>
Acked-by: Panu Matilainen <pmati...@redhat.com>
Acked-by: Kevin Traynor <kevin.tray...@intel.com>
Acked-by: Flavio Leitner <f...@sysclose.org>
---
v13:
* No change

 lib/netdev-dpdk.c | 38 +++++++++++++++++++++++++++++++++-----
 1 file changed, 33 insertions(+), 5 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 8706f9f..2207266 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2866,9 +2866,10 @@ construct_dpdk_mutex_options(const struct smap 
*ovs_other_config,
 }
 
 static int
-get_dpdk_args(const struct smap *ovs_other_config, char ***argv)
+get_dpdk_args(const struct smap *ovs_other_config, char ***argv,
+              int argc)
 {
-    int i = construct_dpdk_options(ovs_other_config, argv, 1);
+    int i = construct_dpdk_options(ovs_other_config, argv, argc);
     i = construct_dpdk_mutex_options(ovs_other_config, argv, i);
     return i;
 }
@@ -2892,7 +2893,8 @@ dpdk_init__(const struct smap *ovs_other_config)
 {
     char **argv = NULL;
     int result;
-    int argc;
+    int argc, argc_tmp;
+    bool auto_determine = true;
     int err;
     cpu_set_t cpuset;
 #ifndef VHOST_CUSE
@@ -2945,8 +2947,34 @@ dpdk_init__(const struct smap *ovs_other_config)
     }
 
     argv = grow_argv(&argv, 0, 1);
+    argc = 1;
     argv[0] = xstrdup(ovs_get_program_name());
-    argc = get_dpdk_args(ovs_other_config, &argv);
+    argc_tmp = get_dpdk_args(ovs_other_config, &argv, argc);
+
+    while (argc_tmp != argc) {
+        if (!strcmp("-c", argv[argc]) || !strcmp("-l", argv[argc])) {
+            auto_determine = false;
+            break;
+        }
+        argc++;
+    }
+    argc = argc_tmp;
+
+    /**
+     * NOTE: This is an unsophisticated mechanism for determining the DPDK
+     * lcore for the DPDK Master.
+     */
+    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<<i));
+                i = CPU_SETSIZE;
+            }
+        }
+    }
 
     argv = grow_argv(&argv, argc, 1);
     argv[argc] = NULL;
@@ -2960,7 +2988,7 @@ dpdk_init__(const struct smap *ovs_other_config)
     }
 
     /* Set the main thread affinity back to pre rte_eal_init() value */
-    if (!err) {
+    if (!auto_determine) {
         err = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t),
                                      &cpuset);
         if (err) {
-- 
2.5.5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to