[PATCH mptcp-next] Squash to "selftests: mptcp: get stats just before timing out"

Matthieu Baerts (NGI0) posted 1 patch 1 week, 6 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/20251113-slft-timeout-stats-kill-v1-1-9a09d8f46392@kernel.org
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(-)
[PATCH mptcp-next] Squash to "selftests: mptcp: get stats just before timing out"
Posted by Matthieu Baerts (NGI0) 1 week, 6 days ago
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.

Link: https://lore.kernel.org/2a6869ca39bda7ddf8b486cd03e0867b30e0d565.camel@kernel.org
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 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(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
index 458b07673910..a6447f7a31fe 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
@@ -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)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 222babd43682..7a72efcf1403 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -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
 
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
index 326466f2f6eb..ab8bce06b262 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
@@ -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}"
diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh
index cc4d40d149e2..806aaa7d2d61 100755
--- a/tools/testing/selftests/net/mptcp/simult_flows.sh
+++ b/tools/testing/selftests/net/mptcp/simult_flows.sh
@@ -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,
-- 
Matthieu Baerts (NGI0) <matttbe@kernel.org>
Re: [PATCH mptcp-next] Squash to "selftests: mptcp: get stats just before timing out"
Posted by Geliang Tang 1 week, 6 days ago
Hi Matt,

Thanks for this fix.

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.
> 
> Link:
> https://lore.kernel.org/2a6869ca39bda7ddf8b486cd03e0867b30e0d565.camel@kernel.org
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>

It works.

    Reviewed-by: Geliang Tang <geliang@kernel.org>

-Geliang

> ---
>  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(-)
> 
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> index 458b07673910..a6447f7a31fe 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> @@ -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)
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index 222babd43682..7a72efcf1403 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> @@ -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
>  
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
> b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
> index 326466f2f6eb..ab8bce06b262 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
> @@ -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}"
> diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh
> b/tools/testing/selftests/net/mptcp/simult_flows.sh
> index cc4d40d149e2..806aaa7d2d61 100755
> --- a/tools/testing/selftests/net/mptcp/simult_flows.sh
> +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh
> @@ -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,
Re: [PATCH mptcp-next] Squash to "selftests: mptcp: get stats just before timing out"
Posted by Matthieu Baerts 1 week, 6 days ago
Hi Geliang,

On 14/11/2025 02:30, Geliang Tang wrote:
> Hi Matt,
> 
> Thanks for this fix.
> 
> 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.
>>
>> Link:
>> https://lore.kernel.org/2a6869ca39bda7ddf8b486cd03e0867b30e0d565.camel@kernel.org
>> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> 
> It works.
> 
>     Reviewed-by: Geliang Tang <geliang@kernel.org>

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
-- 
Sponsored by the NGI0 Core fund.
Re: [PATCH mptcp-next] Squash to "selftests: mptcp: get stats just before timing out"
Posted by MPTCP CI 1 week, 6 days ago
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)