[ovs-dev,1/2] Adding DPDK configuration option to isolate rte-mempool allocation.

Message ID 1510277313-44817-2-git-send-email-sugesh.chandran@intel.com
State Deferred
Delegated to: Ian Stokes
Headers show
  • Adding ovs configuration options to run multiple DPDK instances on a single platform.
Related show

Commit Message

Chandran, Sugesh Nov. 10, 2017, 1:28 a.m.
DPDK allocate memory regions at the time of vswitchd init. To run multiple
primary instance of DPDK including OVS on a single platform, the memory map
regions in the filesystem should be distinct.

The new configuration option let user to enable the memory isolation in need.
By default, OVS uses default dpdk memory regions.

To isolate the memory regions, DPDK prefix the memory map files with user
input string. This implementation uses the pid of vswitchd process as a memory
map prefix, because its unique in the platform.

For eg: a vswitchd process with pid '1234A' create memory map regions with
prefix 'ovs-1234A-' in the filesystem.

The following configuration option is used to enable the feature and changing
this value requires restarting the daemon.

 ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-isolate-mem=true

Signed-off-by: Sugesh Chandran <sugesh.chandran@intel.com>
 lib/dpdk.c           | 21 +++++++++++++++++++++
 vswitchd/vswitch.xml | 23 +++++++++++++++++++++++
 2 files changed, 44 insertions(+)


diff --git a/lib/dpdk.c b/lib/dpdk.c
index 8da6c32..9d187c7 100644
--- a/lib/dpdk.c
+++ b/lib/dpdk.c
@@ -21,6 +21,7 @@ 
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <getopt.h>
+#include <unistd.h>
 #include <rte_log.h>
 #include <rte_memzone.h>
@@ -302,6 +303,25 @@  static cookie_io_functions_t dpdk_log_func = {
     .write = dpdk_log_write,
+ * Isolate the dpdk rte_memory pool for the vswitch process.
+ * The isolation is achieved by using a specific prefix for rte memory maps.
+ * the prefix is created from the pid of the vswitchd. This allows to run
+ * multiple ovs-dpdk instance on same platform in need.
+ */
+static void
+dpdk_isolate_rte_mem_config(const struct smap *ovs_other_config,
+                            char ***argv, int *argc)
+    if (smap_get_bool(ovs_other_config, "dpdk-isolate-mem", false)) {
+        pid_t pid;
+        pid = getpid();
+        *argv = grow_argv(argv, *argc, 2);
+        (*argv)[(*argc)++] = xstrdup("--file-prefix");
+        (*argv)[(*argc)++] = xasprintf("%s-%lX-", "ovs", (long int)pid);
+    }
 static void
 dpdk_init__(const struct smap *ovs_other_config)
@@ -388,6 +408,7 @@  dpdk_init__(const struct smap *ovs_other_config)
+    dpdk_isolate_rte_mem_config(ovs_other_config, &argv, &argc);
     argv = grow_argv(&argv, argc, 1);
     argv[argc] = NULL;
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index c145e1a..7462b30 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -419,6 +419,29 @@ 
+      <column name="other_config" key="dpdk-isolate-mem"
+              type='{"type": "boolean"}'>
+        <p>
+          Set this value to <code>true</code> to isolate DPDK rte mempool at
+          the time of allocation. The option is valid only when DPDK is enabled
+          in OVS.
+        </p>
+        <p>
+          The default value is <code>false</code>. Changing this value requires
+          restarting the daemon.
+        </p>
+        <p>
+          The rte_mempool map is created at the time of vswitchd init and its
+          been used by all DPDK processes including vswitchd in the platform.
+          <code>dpdk-isolate-mem</code> option let vswitchd to use a separate
+          memory region than other processes for isolation. The separate
+          memory region map are prefixed by <code>ovs-<var>pid</var></code>
+          in the filesystem. <var>pid</var> is the process id of vswitchd
+          process.
+        </p>
+      </column>
     <group title="Status">