[ovs-dev] [PATCH v2] OVS-DPDK: Change "dpdk-socket-mem" default value.
Aaron Conole
aconole at redhat.com
Tue May 8 19:34:41 UTC 2018
Billy O'Mahony <billy.o.mahony at intel.com> writes:
> From: Marcin Rybka <marcinx.rybka at intel.com>
>
> 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 at intel.com>
> Co-authored-by:: Billy O'Mahony <billy.o.mahony at intel.com>
^^ Needs refactoring. Should be:
Co-authored-by: Billy O'Mahony <billy.o.mahony at intel.com>
Signed-off-by: Billy O'Mahony <billy.o.mahony at intel.com>
> ---
Thanks for the change, Billy!
You can ignore my previous email (on v1).
> Documentation/intro/install/dpdk.rst | 3 ++-
> lib/dpdk.c | 29 ++++++++++++++++++++++++++++-
> vswitchd/vswitch.xml | 7 ++++---
> 3 files changed, 34 insertions(+), 5 deletions(-)
>
> diff --git a/Documentation/intro/install/dpdk.rst b/Documentation/intro/install/dpdk.rst
> index fea4890..b68438d 100644
> --- a/Documentation/intro/install/dpdk.rst
> +++ b/Documentation/intro/install/dpdk.rst
> @@ -228,7 +228,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
> diff --git a/lib/dpdk.c b/lib/dpdk.c
> index 00dd974..733c67d 100644
> --- a/lib/dpdk.c
> +++ b/lib/dpdk.c
> @@ -35,6 +35,7 @@
> #include "netdev-dpdk.h"
> #include "openvswitch/dynamic-string.h"
> #include "openvswitch/vlog.h"
> +#include "ovs-numa.h"
> #include "smap.h"
>
> VLOG_DEFINE_THIS_MODULE(dpdk);
> @@ -163,6 +164,29 @@ construct_dpdk_options(const struct smap *ovs_other_config,
> return ret;
> }
>
> +static char *
> +construct_dpdk_socket_mem(void)
> +{
> + int numa = 0;
> + const char *def_value = "1024";
> + int numa_nodes = ovs_numa_get_n_numas();
> +
> + if (numa_nodes == 0 || numa_nodes == OVS_NUMA_UNSPEC) {
Not sure why the first leg of the || branch is here. It can probably be
removed (or maybe treated as a bigger error?)
> + 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
> @@ -170,6 +194,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];
> @@ -180,7 +205,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
> },
> };
>
> @@ -227,6 +252,8 @@ construct_dpdk_mutex_options(const struct smap *ovs_other_config,
> }
> }
>
> + free(default_dpdk_socket_mem);
> +
> return ret;
> }
>
> diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
> index 9c2a826..d74f28b 100644
> --- a/vswitchd/vswitch.xml
> +++ b/vswitchd/vswitch.xml
> @@ -302,9 +302,10 @@
> </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>
More information about the dev
mailing list