diff options
author | billyom <billy.o.mahony@intel.com> | 2016-11-29 10:24:53 +0000 |
---|---|---|
committer | Daniele Di Proietto <diproiettod@vmware.com> | 2016-12-02 14:30:53 -0800 |
commit | 3fa215b15ab0c29c209114a558929474149216d6 (patch) | |
tree | d8f47447c82cd1f3a88aa06037387cbaa4eb81fa | |
parent | 884e0dfe8fe85a8d2b21c9c6138cc239648ba312 (diff) | |
download | openvswitch-3fa215b15ab0c29c209114a558929474149216d6.tar.gz |
ovs-numa: Allow leading 0x on pmd-cpu-mask.
pmd-cpu-mask is interpreted as a hex bit mask. So it should be written
with a leading 0x to indicate this. But if this is done, while the value
is interpreted correctly and the PMDs pinned as expected, a confusing
warning message is also issued.
This patch allows but does not require a leading 0x or 0X to be used
without a warning. Existing functionality is not affected. Relevant DPDK
docs also updated.
Signed-off-by: Billy O'Mahony <billy.o.mahony@intel.com>
Tested-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
-rw-r--r-- | INSTALL.DPDK-ADVANCED.rst | 13 | ||||
-rw-r--r-- | INSTALL.DPDK.rst | 6 | ||||
-rw-r--r-- | lib/ovs-numa.c | 11 | ||||
-rw-r--r-- | tests/pmd.at | 6 |
4 files changed, 22 insertions, 14 deletions
diff --git a/INSTALL.DPDK-ADVANCED.rst b/INSTALL.DPDK-ADVANCED.rst index 9b2895bf6..1c2437d89 100644 --- a/INSTALL.DPDK-ADVANCED.rst +++ b/INSTALL.DPDK-ADVANCED.rst @@ -175,10 +175,11 @@ core shared by two logical cores, run:: where ``N`` is the logical core number. In this example, it would show that cores ``1`` and ``21`` share the same -physical core., thus, the ``pmd-cpu-mask`` can be used to enable these two pmd -threads running on these two logical cores (one physical core) is:: +physical core. As cores are counted from 0, the ``pmd-cpu-mask`` can be used +to enable these two pmd threads running on these two logical cores (one +physical core) is:: - $ ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=100002 + $ ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=0x200002 Isolate Cores ~~~~~~~~~~~~~ @@ -239,7 +240,7 @@ affinitized accordingly. By setting a bit in the mask, a pmd thread is created and pinned to the corresponding CPU core. e.g. to run a pmd thread on core 2:: - $ ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=4 + $ ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=0x4 .. note:: pmd thread on a NUMA node is only created if there is at least one DPDK @@ -269,7 +270,7 @@ is done automatically. A set bit in the mask means a pmd thread is created and pinned to the corresponding CPU core. For example, to run pmd threads on core 1 and 2:: - $ ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=6 + $ ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=0x6 When using dpdk and dpdkvhostuser ports in a bi-directional VM loopback as shown below, spreading the workload over 2 or 4 pmd threads shows significant @@ -436,7 +437,7 @@ guide`_ to create and initialize the database, start ovs-vswitchd and add of rx queues at vhost-user interface gets automatically configured after virtio device connection and doesn't need manual configuration:: - $ ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=c + $ ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=0xC $ ovs-vsctl set Interface dpdk0 options:n_rxq=2 $ ovs-vsctl set Interface dpdk1 options:n_rxq=2 diff --git a/INSTALL.DPDK.rst b/INSTALL.DPDK.rst index c91cc019b..10ccfdf3b 100644 --- a/INSTALL.DPDK.rst +++ b/INSTALL.DPDK.rst @@ -223,10 +223,10 @@ NUMA node 0, run:: Similarly, if you wish to better scale the workloads across cores, then multiple pmd threads can be created and pinned to CPU cores by explicity -specifying ``pmd-cpu-mask``. For example, to spawn two pmd threads and pin -them to cores 1,2, run:: +specifying ``pmd-cpu-mask``. Cores are numbered from 0, so to spawn two pmd +threads and pin them to cores 1,2, run:: - $ ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=6 + $ ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=0x6 For details on using ivshmem with DPDK, refer to `the advanced installation guide <INSTALL.DPDK-ADVANCED.rst>`__. diff --git a/lib/ovs-numa.c b/lib/ovs-numa.c index c8173e0b4..e1e7068a2 100644 --- a/lib/ovs-numa.c +++ b/lib/ovs-numa.c @@ -535,6 +535,7 @@ ovs_numa_set_cpu_mask(const char *cmask) { int core_id = 0; int i; + int end_idx; if (!found_numa_and_core) { return; @@ -551,7 +552,13 @@ ovs_numa_set_cpu_mask(const char *cmask) return; } - for (i = strlen(cmask) - 1; i >= 0; i--) { + /* Ignore leading 0x. */ + end_idx = 0; + if (!strncmp(cmask, "0x", 2) || !strncmp(cmask, "0X", 2)) { + end_idx = 2; + } + + for (i = strlen(cmask) - 1; i >= end_idx; i--) { char hex = toupper((unsigned char)cmask[i]); int bin, j; @@ -575,7 +582,7 @@ ovs_numa_set_cpu_mask(const char *cmask) if (core_id >= hmap_count(&all_cpu_cores)) { return; } - } + } } /* For unspecified cores, sets 'available' to false. */ diff --git a/tests/pmd.at b/tests/pmd.at index 18b29728a..8f05d74b7 100644 --- a/tests/pmd.at +++ b/tests/pmd.at @@ -123,7 +123,7 @@ pmd thread numa_id <cleared> core_id <cleared>: ]) TMP=$(cat ovs-vswitchd.log | wc -l | tr -d [[:blank:]]) -AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=3]) +AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=0x3]) CHECK_PMD_THREADS_CREATED([2], [], [+$TMP]) AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | sed SED_NUMA_CORE_PATTERN], [0], [dnl @@ -136,7 +136,7 @@ pmd thread numa_id <cleared> core_id <cleared>: ]) TMP=$(cat ovs-vswitchd.log | wc -l | tr -d [[:blank:]]) -AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=1]) +AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=0x1]) CHECK_PMD_THREADS_CREATED([1], [], [+$TMP]) AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | sed SED_NUMA_CORE_PATTERN], [0], [dnl @@ -471,7 +471,7 @@ AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg]) AT_CHECK([ovs-ofctl add-flow br0 actions=controller]) -AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=1fe]) +AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=0x1fe]) AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dummy-pmd ofport_request=1 options:n_rxq=4 other_config:pmd-rxq-affinity="0:3,1:7,2:2,3:8"]) |