[RFC mptcp-next 5/6] selftests: mptcp: add NVMe-over-MPTCP test

Geliang Tang posted 6 patches 2 weeks, 6 days ago
There is a newer version of this series
[RFC mptcp-next 5/6] selftests: mptcp: add NVMe-over-MPTCP test
Posted by Geliang Tang 2 weeks, 6 days ago
From: Geliang Tang <tanggeliang@kylinos.cn>

This patch introduces a new selftest that evaluates NVMe-over-Fabrics
performance when using MPTCP as the transport protocol. The test:

1. Sets up a local NVMe target configuration using:
   - A loopback device as storage backend
   - MPTCP as the transport type
   - IPv4 addressing

2. Performs standard NVMe operations including:
   - Discovery and connection
   - Device listing
   - Random read/write performance tests using fio

3. Cleans up all test resources

The test script (mptcp_nvme.sh) accepts parameters for transport type
and target address, defaulting to MPTCP and localhost. It measures
performance using fio with:
- 4 parallel jobs
- 256 I/O depth
- 4KB block size
- 10 second runtime
- Both random read and write patterns

Required kernel config options are added to the MPTCP selftest config
file to support NVMe-over-TCP functionality.

This test helps validate MPTCP's suitability for storage networking
workloads and provides a benchmark for performance comparisons.

Co-Developed-by: Hui Zhu <zhuhui@kylinos.cn>
Signed-off-by: Hui Zhu <zhuhui@kylinos.cn>
Co-Developed-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
Co-Developed-by: zhenwei pi <zhenwei.pi@linux.dev>
Signed-off-by: zhenwei pi <zhenwei.pi@linux.dev>
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 tools/testing/selftests/net/mptcp/config      |  7 +++
 .../testing/selftests/net/mptcp/mptcp_nvme.sh | 57 +++++++++++++++++++
 2 files changed, 64 insertions(+)
 create mode 100755 tools/testing/selftests/net/mptcp/mptcp_nvme.sh

diff --git a/tools/testing/selftests/net/mptcp/config b/tools/testing/selftests/net/mptcp/config
index 59051ee2a986..0eee348eff8b 100644
--- a/tools/testing/selftests/net/mptcp/config
+++ b/tools/testing/selftests/net/mptcp/config
@@ -34,3 +34,10 @@ CONFIG_NFT_SOCKET=m
 CONFIG_NFT_TPROXY=m
 CONFIG_SYN_COOKIES=y
 CONFIG_VETH=y
+CONFIG_CONFIGFS_FS=y
+CONFIG_NVME_CORE=y
+CONFIG_NVME_FABRICS=y
+CONFIG_NVME_TCP=y
+CONFIG_NVME_TARGET=y
+CONFIG_NVME_TARGET_TCP=y
+CONFIG_NVME_MULTIPATH=y
diff --git a/tools/testing/selftests/net/mptcp/mptcp_nvme.sh b/tools/testing/selftests/net/mptcp/mptcp_nvme.sh
new file mode 100755
index 000000000000..329169fac4ca
--- /dev/null
+++ b/tools/testing/selftests/net/mptcp/mptcp_nvme.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+trtype="${1:-mptcp}"
+traddr="${2:-127.0.0.1}"
+ns=1
+port=1234
+trsvcid=4420
+nqn=nqn.2014-08.org.nvmexpress.${trtype}dev
+
+dd if=/dev/zero of=/tmp/test.raw bs=1M count=0 seek=512
+losetup /dev/loop100 /tmp/test.raw
+cd /sys/kernel/config/nvmet/subsystems
+mkdir ${nqn}
+cd ${nqn}
+echo 1 > attr_allow_any_host
+cd namespaces
+mkdir ${ns}
+cd ${ns}
+echo /dev/loop100 > device_path
+echo 1 > enable
+cd /sys/kernel/config/nvmet/ports
+mkdir ${port}
+cd ${port}
+echo ${trtype} > addr_trtype
+echo ipv4 > addr_adrfam
+echo ${traddr} > addr_traddr
+echo ${trsvcid} > addr_trsvcid
+cd subsystems
+ln -s ../../../subsystems/${nqn} ${trtype}subsys
+
+echo "nvme discover"
+nvme discover -t ${trtype} -a ${traddr} -s ${trsvcid}
+
+echo "nvme connect"
+devname=$(nvme connect -t ${trtype} -a ${traddr} -s ${trsvcid} -n ${nqn} | awk '{print $4}')
+
+sleep 0.5
+echo "nvme list"
+nvme list
+
+fio --name=global --direct=1 --norandommap --randrepeat=0 --ioengine=libaio --thread=1 --blocksize=4k --runtime=10 --time_based --rw=randread --numjobs=4 --iodepth=256 --group_reporting --size=100% --name=libaio_4_256_4k_randread --filename=/dev/${devname}n1
+
+fio --name=global --direct=1 --norandommap --randrepeat=0 --ioengine=libaio --thread=1 --blocksize=4k --runtime=10 --time_based --rw=randwrite --numjobs=4 --iodepth=256 --group_reporting --size=100% --name=libaio_4_256_4k_randread --filename=/dev/${devname}n1
+
+sleep 0.5
+echo "nvme disconnect"
+nvme disconnect -n ${nqn}
+
+rm -rf /sys/kernel/config/nvmet/ports/${port}/subsystems/${trtype}subsys
+rmdir /sys/kernel/config/nvmet/ports/${port}
+echo 0 > /sys/kernel/config/nvmet/subsystems/${nqn}/namespaces/${ns}/enable
+echo -n 0 > /sys/kernel/config/nvmet/subsystems/${nqn}/namespaces/${ns}/device_path
+rmdir /sys/kernel/config/nvmet/subsystems/${nqn}/namespaces/${ns}
+rmdir /sys/kernel/config/nvmet/subsystems/${nqn}
+losetup -d /dev/loop100
+rm -rf /tmp/test.raw
-- 
2.43.0