Skip to contentSkip to conversation

Squash to "selftests: mptcp: get stats just before timing out"

PATCH In review Matthieu Baerts (NGI0) 3 participants 4 messages Nov 13, 2025 – Nov 14, 2025

Subsystems (3)
lore
Share & tools
lore

Matthieu Baerts (NGI0)

author maintainer
#0 lore raw

PATCH 1/1 Squash to "selftests: mptcp: get stats just before timing out"

Geliang reported that mptcp_connect.sh test runtime got increased after this patch.

That's because the previous 'kill' command was only killing the background job, but the 'sleep' command was still running.

It is not very clear to me why there was a delay at the end, but switching to mptcp_lib_kill_group_wait to kill the background job and the running command fixed the issue. The new code is also looking clearer I think, so that's good.

---
 tools/testing/selftests/net/mptcp/mptcp_connect.sh | 7 ++++++-
 tools/testing/selftests/net/mptcp/mptcp_join.sh    | 7 ++++++-
 tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 7 ++++++-
 tools/testing/selftests/net/mptcp/simult_flows.sh  | 7 ++++++-
 4 files changed, 24 insertions(+), 4 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +6 -1
index 458b07673910..a6447f7a31fe 100755
@@ -415,7 +415,12 @@ do_transfer()
 	local retc=$?
 	wait $spid
 	local rets=$?
-	kill $timeout_pid 2>/dev/null && timeout_pid=0
+
+	if kill -0 $timeout_pid; then
+		# Finished before the timeout: kill the background job
+		mptcp_lib_kill_group_wait $timeout_pid
+		timeout_pid=0
+	fi
 
 	local stop
 	stop=$(date +%s%3N)
tools/testing/selftests/net/mptcp/mptcp_join.sh +6 -1
index 222babd43682..7a72efcf1403 100755
@@ -1063,7 +1063,12 @@ do_transfer()
 	local retc=$?
 	wait $spid
 	local rets=$?
-	kill $timeout_pid 2>/dev/null && timeout_pid=0
+
+	if kill -0 $timeout_pid; then
+		# Finished before the timeout: kill the background job
+		mptcp_lib_kill_group_wait $timeout_pid
+		timeout_pid=0
+	fi
 
 	cond_stop_capture
 
tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +6 -1
index 326466f2f6eb..ab8bce06b262 100755
@@ -193,7 +193,12 @@ do_transfer()
 	local retc=$?
 	wait $spid
 	local rets=$?
-	kill $timeout_pid 2>/dev/null && timeout_pid=0
+
+	if kill -0 $timeout_pid; then
+		# Finished before the timeout: kill the background job
+		mptcp_lib_kill_group_wait $timeout_pid
+		timeout_pid=0
+	fi
 
 	mptcp_lib_nstat_get "${listener_ns}"
 	mptcp_lib_nstat_get "${connector_ns}"
tools/testing/selftests/net/mptcp/simult_flows.sh +6 -1
index cc4d40d149e2..806aaa7d2d61 100755
@@ -178,7 +178,12 @@ do_transfer()
 	local retc=$?
 	wait $spid
 	local rets=$?
-	kill $timeout_pid 2>/dev/null && timeout_pid=0
+
+	if kill -0 $timeout_pid; then
+		# Finished before the timeout: kill the background job
+		mptcp_lib_kill_group_wait $timeout_pid
+		timeout_pid=0
+	fi
 
 	if $capture; then
 		sleep 1

---
base-commit: 6861f291b7a3bc40235e996f5605c477f55ce9e0
change-id: 20251113-slft-timeout-stats-kill-444931425af7

Best regards,

Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>
#1 lore raw

Hi Matthieu,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/19330080819

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/9a2c02054a5b
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1022917

If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

https://github.com/multipath-tcp/mptcp-upstream-virtme-docker

Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)

reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Matthieu Baerts (NGI0)

Hi Matt,

Thanks for this fix.

Quoted 7 lines · On Thu, 2025-11-13 at 12:11 +0100, Matthieu Baerts (NGI0) wrote:

Geliang reported that mptcp_connect.sh test runtime got increased after
this patch.

That's because the previous 'kill' command was only killing the background job, but the 'sleep' command was still running.

Quoted 8 lines

It is not very clear to me why there was a delay at the end, but switching to mptcp_lib_kill_group_wait to kill the background job and the running command fixed the issue. The new code is also looking clearer I think, so that's good.

Link:
https://lore.kernel.org/[email protected]

It works.

-Geliang

Quoted 93 lines

---
 tools/testing/selftests/net/mptcp/mptcp_connect.sh | 7 ++++++- tools/testing/selftests/net/mptcp/mptcp_join.sh    | 7 ++++++- tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 7 ++++++- tools/testing/selftests/net/mptcp/simult_flows.sh  | 7 ++++++-

 4 files changed, 24 insertions(+), 4 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +0 -0
index 458b07673910..a6447f7a31fe 100755
@@ -415,7 +415,12 @@ do_transfer()

  local retc=$?
  wait $spid
  local rets=$?

tools/testing/selftests/net/mptcp/mptcp_connect.sh +3 -1
-	kill $timeout_pid 2>/dev/null && timeout_pid=0
+
+	if kill -0 $timeout_pid; then
+		# Finished before the timeout: kill the background

job

tools/testing/selftests/net/mptcp/mptcp_connect.sh +3 -0
+		mptcp_lib_kill_group_wait $timeout_pid
+		timeout_pid=0
+	fi


  local stop
  stop=$(date +%s%3N)

tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -0
index 222babd43682..7a72efcf1403 100755
@@ -1063,7 +1063,12 @@ do_transfer()

  local retc=$?
  wait $spid
  local rets=$?

tools/testing/selftests/net/mptcp/mptcp_join.sh +3 -1
-	kill $timeout_pid 2>/dev/null && timeout_pid=0
+
+	if kill -0 $timeout_pid; then
+		# Finished before the timeout: kill the background

job

tools/testing/selftests/net/mptcp/mptcp_join.sh +3 -0
+		mptcp_lib_kill_group_wait $timeout_pid
+		timeout_pid=0
+	fi


  cond_stop_capture

tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +0 -0
index 326466f2f6eb..ab8bce06b262 100755
@@ -193,7 +193,12 @@ do_transfer()

  local retc=$?
  wait $spid
  local rets=$?

tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +3 -1
-	kill $timeout_pid 2>/dev/null && timeout_pid=0
+
+	if kill -0 $timeout_pid; then
+		# Finished before the timeout: kill the background

job

tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +3 -0
+		mptcp_lib_kill_group_wait $timeout_pid
+		timeout_pid=0
+	fi


  mptcp_lib_nstat_get "${listener_ns}"
  mptcp_lib_nstat_get "${connector_ns}"

tools/testing/selftests/net/mptcp/simult_flows.sh +0 -0
index cc4d40d149e2..806aaa7d2d61 100755
@@ -178,7 +178,12 @@ do_transfer()

  local retc=$?
  wait $spid
  local rets=$?

tools/testing/selftests/net/mptcp/simult_flows.sh +3 -1
-	kill $timeout_pid 2>/dev/null && timeout_pid=0
+
+	if kill -0 $timeout_pid; then
+		# Finished before the timeout: kill the background

job

tools/testing/selftests/net/mptcp/simult_flows.sh +3 -0
+		mptcp_lib_kill_group_wait $timeout_pid
+		timeout_pid=0
+	fi


  if $capture; then
  sleep 1

---
base-commit: 6861f291b7a3bc40235e996f5605c477f55ce9e0
change-id: 20251113-slft-timeout-stats-kill-444931425af7

Best regards,

author maintainer
#3 lore raw

Hi Geliang,

Quoted 17 lines · Geliang Tang

Hi Matt,

Thanks for this fix.

Quoted 12 lines · On Thu, 2025-11-13 at 12:11 +0100, Matthieu Baerts (NGI0) wrote:

Geliang reported that mptcp_connect.sh test runtime got increased after
this patch.

That's because the previous 'kill' command was only killing the background job, but the 'sleep' command was still running.

It is not very clear to me why there was a delay at the end, but switching to mptcp_lib_kill_group_wait to kill the background job and the running command fixed the issue. The new code is also looking clearer I think, so that's good.

Quoted 7 lines
Quoted 3 lines

Link:
https://lore.kernel.org/[email protected]

It works.

Thank you for the review, just applied:

New patches for t/upstream:
- 39266eb8cdba: Squash to "selftests: mptcp: get stats just before timing out"
- Results: 24d7b3380fc2..e804ecd59ca4 (export)

Tests are now in progress:

- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/3210c91543d4fb12e46c89fefb9d9ff78be4a471/checks

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.