2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-30 22:05:19 +00:00

netdev-dpdk: Autofill lcore coremask if absent

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 <aconole@redhat.com>
Tested-by: Sean K Mooney <sean.k.mooney@intel.com>
Tested-by: RobertX Wojciechowicz <robertx.wojciechowicz@intel.com>
Tested-by: Kevin Traynor <kevin.traynor@intel.com>
Acked-by: Panu Matilainen <pmatilai@redhat.com>
Acked-by: Kevin Traynor <kevin.traynor@intel.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
This commit is contained in:
Aaron Conole
2016-04-29 13:44:03 -04:00
committed by Daniele Di Proietto
parent d8a8f353c2
commit 88964e6428

View File

@@ -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) {