From: billyom <[email protected]> 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 <[email protected]> --- INSTALL.DPDK-ADVANCED.rst | 13 +++++++------ INSTALL.DPDK.rst | 6 +++--- lib/ovs-numa.c | 11 +++++++++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/INSTALL.DPDK-ADVANCED.rst b/INSTALL.DPDK-ADVANCED.rst index 9b2895b..1c2437d 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 a078093..c50b7a3 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 c8173e0..95a3f68 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) == 0 || strncmp(cmask, "0X", 2) == 0) { + 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. */ -- 1.7.0.7 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
