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>
---
Previous: http://openvswitch.org/pipermail/dev/2016-April/069029.html

v12:
* Dropped a whitespace change
* Changed argc initialization

 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 9793fc5..e7951df 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2868,9 +2868,10 @@ construct_dpdk_mutex_options(const struct 
ovsrec_open_vswitch *ovs_cfg,
 }
 
 static int
-get_dpdk_args(const struct ovsrec_open_vswitch *ovs_cfg, char ***argv)
+get_dpdk_args(const struct ovsrec_open_vswitch *ovs_cfg, char ***argv,
+              int argc)
 {
-    int i = construct_dpdk_options(ovs_cfg, argv, 1);
+    int i = construct_dpdk_options(ovs_cfg, argv, argc);
     i = construct_dpdk_mutex_options(ovs_cfg, argv, i);
     return i;
 }
@@ -2894,7 +2895,8 @@ dpdk_init__(const struct ovsrec_open_vswitch *ovs_cfg)
 {
     char **argv = NULL;
     int result;
-    int argc;
+    int argc, argc_tmp;
+    bool auto_determine = true;
     int err;
     cpu_set_t cpuset;
 #ifndef VHOST_CUSE
@@ -2943,8 +2945,34 @@ dpdk_init__(const struct ovsrec_open_vswitch *ovs_cfg)
     }
 
     argv = grow_argv(&argv, 0, 1);
+    argc = 1;
     argv[0] = xstrdup(ovs_get_program_name());
-    argc = get_dpdk_args(ovs_cfg, &argv);
+    argc_tmp = get_dpdk_args(ovs_cfg, &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] = 0;
@@ -2958,7 +2986,7 @@ dpdk_init__(const struct ovsrec_open_vswitch *ovs_cfg)
     }
 
     /* 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