diff mbox series

[ovs-dev,2/3] system-dpdk: use optimum hugepages for dpdk tests

Message ID 445b5adb9ebfb2af3f0af3925c202d1a99f83357.1589456076.git.gmuthukr@redhat.com
State New
Headers show
Series system-dpdk: add userspace-tso tests | expand

Commit Message

Gowrishankar Muthukrishnan May 14, 2020, 11:48 a.m. UTC
Today we need 1GB from hugepages for running dpdk tests (i.e
512MB for ovs-vswitchd including phy ports and 512MB for testpmd
app). This patch optimize the usage as:
  - 1GB for dpdk tests including phy ports, vhu ports and testpmd
  - 512MB for dpdk tests including vhu ports and testpmd

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukr@redhat.com>
---
 tests/system-dpdk-macros.at | 20 +++++++++++++++++++-
 tests/system-dpdk.at        | 10 ++++++----
 2 files changed, 25 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/tests/system-dpdk-macros.at b/tests/system-dpdk-macros.at
index b3a46d1..943cbdf 100644
--- a/tests/system-dpdk-macros.at
+++ b/tests/system-dpdk-macros.at
@@ -46,7 +46,21 @@  m4_define([OVS_DPDK_PRE_PHY_SKIP],
 ])
 
 
-# OVS_DPDK_START()
+# OVS_DPDK_SET_SOCKET_MEM()
+#
+# Set optimum memory required for tests.
+#
+m4_define([OVS_DPDK_SET_SOCKET_MEM],
+  [
+   AT_CHECK([$DPDK_DIR/usertools/dpdk-devbind.py -s],[],[stdout])
+   AT_CHECK([sed -n '/DPDK/,/kernel/{//!p;}' stdout|sed '/^=/d'],[],[stdout])
+   AT_CHECK([egrep -c '^....:..:..\..' stdout],[ignore],[stdout])
+   AS_IF([test $(cat stdout) -eq 0],[echo 64 > SOCKET_MEM],
+         [echo $((64+512)) > SOCKET_MEM])
+
+])
+
+
 #
 # Create an empty database and start ovsdb-server. Add special configuration
 # dpdk-init to enable DPDK functionality. Start ovs-vswitchd connected to that
@@ -70,6 +84,10 @@  m4_define([OVS_DPDK_START],
 
    dnl Enable DPDK functionality
    AT_CHECK([ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-init=true])
+   OVS_DPDK_SET_SOCKET_MEM()
+   AT_CHECK([lscpu], [], [stdout])
+   AT_CHECK([cat stdout | grep "NUMA node(s)" | awk -v m=$(cat SOCKET_MEM) '{c=1; while (c++<$(3)) {printf m","}; print m}' > NUMA_NODE])
+   AT_CHECK([ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-socket-mem=$(cat NUMA_NODE)])
 
    dnl Start ovs-vswitchd.
    AT_CHECK([ovs-vswitchd --detach --no-chdir --pidfile --log-file -vvconn -vofproto_dpif -vunixctl], [0], [stdout], [stderr])
diff --git a/tests/system-dpdk.at b/tests/system-dpdk.at
index 01ac970..b032c5b 100644
--- a/tests/system-dpdk.at
+++ b/tests/system-dpdk.at
@@ -93,7 +93,7 @@  OVS_DPDK_START()
 
 dnl Find number of sockets
 AT_CHECK([lscpu], [], [stdout])
-AT_CHECK([cat stdout | grep "NUMA node(s)" | awk '{c=1; while (c++<$(3)) {printf "512,"}; print "512"}' > NUMA_NODE])
+AT_CHECK([cat stdout | grep "NUMA node(s)" | awk '{c=1; while (c++<$(3)) {printf "448,"}; print "448"}' > NUMA_NODE])
 
 dnl Add userspace bridge and attach it to OVS
 AT_CHECK([ovs-vsctl add-br br10 -- set bridge br10 datapath_type=netdev])
@@ -118,7 +118,8 @@  ADD_VETH(tap1, ns2, br10, "172.31.110.12/24")
 
 dnl Execute testpmd in background
 on_exit "pkill -f -x -9 'tail -f /dev/null'"
-tail -f /dev/null | testpmd --socket-mem="$(cat NUMA_NODE)" --no-pci\
+tail -f /dev/null | testpmd --no-pci \
+           --socket-mem="$(cat NUMA_NODE)" --socket-limit="$(cat NUMA_NODE)" \
            --vdev="net_virtio_user,path=$OVS_RUNDIR/dpdkvhostuser0" \
            --vdev="net_tap0,iface=tap0" --file-prefix page0 \
            --single-file-segments -- -a >$OVS_RUNDIR/testpmd-dpdkvhostuser0.log 2>&1 &
@@ -172,7 +173,7 @@  OVS_DPDK_START()
 
 dnl Find number of sockets
 AT_CHECK([lscpu], [], [stdout])
-AT_CHECK([cat stdout | grep "NUMA node(s)" | awk '{c=1; while (c++<$(3)) {printf "512,"}; print "512"}' > NUMA_NODE])
+AT_CHECK([cat stdout | grep "NUMA node(s)" | awk '{c=1; while (c++<$(3)) {printf "448,"}; print "448"}' > NUMA_NODE])
 
 dnl Add userspace bridge and attach it to OVS
 AT_CHECK([ovs-vsctl add-br br10 -- set bridge br10 datapath_type=netdev])
@@ -196,7 +197,8 @@  ADD_VETH(tap1, ns2, br10, "172.31.110.12/24")
 
 dnl Execute testpmd in background
 on_exit "pkill -f -x -9 'tail -f /dev/null'"
-tail -f /dev/null | testpmd --socket-mem="$(cat NUMA_NODE)" --no-pci\
+tail -f /dev/null | testpmd --no-pci \
+           --socket-mem="$(cat NUMA_NODE)" --socket-limit="$(cat NUMA_NODE)" \
            --vdev="net_virtio_user,path=$OVS_RUNDIR/dpdkvhostclient0,server=1" \
            --vdev="net_tap0,iface=tap0" --file-prefix page0 \
            --single-file-segments -- -a >$OVS_RUNDIR/testpmd-dpdkvhostuserclient0.log 2>&1 &