]> git.proxmox.com Git - mirror_ovs.git/commitdiff
OVS-DPDK: Change "dpdk-socket-mem" default value.
authorMarcin Rybka <marcinx.rybka@intel.com>
Wed, 9 May 2018 10:14:25 +0000 (11:14 +0100)
committerIan Stokes <ian.stokes@intel.com>
Fri, 8 Jun 2018 16:27:56 +0000 (17:27 +0100)
When "dpdk-socket-mem" and "dpdk-alloc-mem" are not specified,
"dpdk-socket-mem" will be set to allocate 1024MB on each NUMA node.
This change will prevent OVS from failing when NIC is attached on
NUMA node 1 and higher. Patch contains documentation update.

Signed-off-by: Marcin Rybka <marcinx.rybka@intel.com>
Co-authored-by: Billy O'Mahony <billy.o.mahony@intel.com>
Signed-off-by: Billy O'Mahony <billy.o.mahony@intel.com>
Tested-by: Hariprasad Govindharajan <hariprasad.govindharajan@intel.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
Documentation/intro/install/dpdk.rst
lib/dpdk.c
vswitchd/vswitch.xml

index 247c41da34fe0ccf3815831f726993c7186e537f..085e479908b0208afcfce9a5c110dfe62641f5cc 100644 (file)
@@ -233,7 +233,8 @@ listed below. Defaults will be provided for all values not explicitly set.
 
 ``dpdk-socket-mem``
   Comma separated list of memory to pre-allocate from hugepages on specific
-  sockets.
+  sockets. If not specified, 1024 MB will be set for each numa node by
+  default.
 
 ``dpdk-hugepage-dir``
   Directory where hugetlbfs is mounted
index 09afd8cc2a5db489dbc8456b69b1f300dad44468..5c68ce430d6b10a2709a6ea6caaa9f6cf64e4845 100644 (file)
@@ -36,6 +36,7 @@
 #include "netdev-dpdk.h"
 #include "openvswitch/dynamic-string.h"
 #include "openvswitch/vlog.h"
+#include "ovs-numa.h"
 #include "smap.h"
 #include "vswitch-idl.h"
 
@@ -167,6 +168,28 @@ construct_dpdk_options(const struct smap *ovs_other_config,
     return ret;
 }
 
+static char *
+construct_dpdk_socket_mem(void)
+{
+    int numa;
+    const char *def_value = "1024";
+    int numa_nodes = ovs_numa_get_n_numas();
+
+    if (numa_nodes == 0 || numa_nodes == OVS_NUMA_UNSPEC) {
+        numa_nodes = 1;
+    }
+    /* Allocate enough memory for digits, comma-sep and terminator. */
+    char *dpdk_socket_mem = xzalloc(numa_nodes * (strlen(def_value) + 1));
+
+    strcat(dpdk_socket_mem, def_value);
+    for (numa = 1; numa < numa_nodes; ++numa) {
+        strcat(dpdk_socket_mem, ",");
+        strcat(dpdk_socket_mem, def_value);
+    }
+
+    return dpdk_socket_mem;
+}
+
 #define MAX_DPDK_EXCL_OPTS 10
 
 static int
@@ -174,6 +197,7 @@ construct_dpdk_mutex_options(const struct smap *ovs_other_config,
                              char ***argv, const int initial_size,
                              char **extra_args, const size_t extra_argc)
 {
+    char *default_dpdk_socket_mem = construct_dpdk_socket_mem();
     struct dpdk_exclusive_options_map {
         const char *category;
         const char *ovs_dpdk_options[MAX_DPDK_EXCL_OPTS];
@@ -184,7 +208,7 @@ construct_dpdk_mutex_options(const struct smap *ovs_other_config,
         {"memory type",
          {"dpdk-alloc-mem", "dpdk-socket-mem", NULL,},
          {"-m",             "--socket-mem",    NULL,},
-         "1024,0", 1
+         default_dpdk_socket_mem, 1
         },
     };
 
@@ -231,6 +255,8 @@ construct_dpdk_mutex_options(const struct smap *ovs_other_config,
         }
     }
 
+    free(default_dpdk_socket_mem);
+
     return ret;
 }
 
index 1e27a022009834731f7a26c282068c622e1462b5..8f67e1263556ede84420a92007e8916dbc39b961 100644 (file)
         </p>
         <p>
           If dpdk-socket-mem and dpdk-alloc-mem are not specified, dpdk-socket-mem
-          will be used and the default value is 1024,0. If dpdk-socket-mem and
-          dpdk-alloc-mem are specified at same time, dpdk-socket-mem will be
-          used as default. Changing this value requires restarting the daemon.
+          will be used and the default value is 1024 for each numa node. If
+          dpdk-socket-mem and dpdk-alloc-mem are specified at same time,
+          dpdk-socket-mem will be used as default. Changing this value
+          requires restarting the daemon.
         </p>
       </column>