diff mbox series

[mptcp-next,v3,10/10] mptcp: pm: drop is_userspace in subflow_check_next

Message ID 7d236597235768dcf1885f317acb767840cb9e42.1742521397.git.tanggeliang@kylinos.cn (mailing list archive)
State Superseded, archived
Delegated to: Matthieu Baerts
Headers show
Series BPF path manager, part 6 | expand

Checks

Context Check Description
matttbe/checkpatch warning total: 0 errors, 1 warnings, 0 checks, 27 lines checked
matttbe/shellcheck success MPTCP selftests files have not been modified
matttbe/build success Build and static analysis OK
matttbe/KVM_Validation__normal success Success! ✅
matttbe/KVM_Validation__debug success Success! ✅
matttbe/KVM_Validation__btf-normal__only_bpftest_all_ success Success! ✅
matttbe/KVM_Validation__btf-debug__only_bpftest_all_ success Success! ✅

Commit Message

Geliang Tang March 21, 2025, 1:45 a.m. UTC
From: Geliang Tang <tanggeliang@kylinos.cn>

In mptcp_pm_subflow_check_next(), instead of reducing "pm->subflows"
for the in-kernel PM in __mptcp_pm_close_subflow(), this patch moves
"pm->subflows--;" forward to let it be used by both the userspace PM
and the in-kernel PM. Then mptcp_pm_is_userspace() here can be dropped.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 net/mptcp/pm.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

Comments

Matthieu Baerts March 21, 2025, 10:46 a.m. UTC | #1
Hi Geliang,

On 21/03/2025 02:45, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> In mptcp_pm_subflow_check_next(), instead of reducing "pm->subflows"
> for the in-kernel PM in __mptcp_pm_close_subflow(), this patch moves
> "pm->subflows--;" forward to let it be used by both the userspace PM
> and the in-kernel PM. Then mptcp_pm_is_userspace() here can be dropped.
> 
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
>  net/mptcp/pm.c | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
> index bb456e203665..a3fcb335c717 100644
> --- a/net/mptcp/pm.c
> +++ b/net/mptcp/pm.c
> @@ -531,13 +531,10 @@ void mptcp_pm_subflow_check_next(struct mptcp_sock *msk,
>  	bool update_subflows;
>  
>  	update_subflows = subflow->request_join || subflow->mp_join;
> -	if (mptcp_pm_is_userspace(msk)) {
> -		if (update_subflows) {
> -			spin_lock_bh(&pm->lock);
> -			pm->subflows--;
> -			spin_unlock_bh(&pm->lock);
> -		}
> -		return;
> +	if (update_subflows) {
> +		spin_lock_bh(&pm->lock);
> +		pm->subflows--;
> +		spin_unlock_bh(&pm->lock);

Should we not simply call mptcp_pm_close_subflow() instead? It should be
fine to call it for the userspace or BPF PMs as well, no?

>  	}
>  
>  	if (!pm->ops->subflow_established)
> @@ -547,8 +544,8 @@ void mptcp_pm_subflow_check_next(struct mptcp_sock *msk,
>  		return;
>  
>  	spin_lock_bh(&pm->lock);
> -	if (update_subflows)
> -		__mptcp_pm_close_subflow(msk);
> +	if (update_subflows && msk->pm.subflows < mptcp_pm_get_subflows_max(msk))
> +		WRITE_ONCE(msk->pm.accept_subflow, true);
>  
>  	/* Even if this subflow is not really established, tell the PM to try
>  	 * to pick the next ones, if possible.

Cheers,
Matt
diff mbox series

Patch

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index bb456e203665..a3fcb335c717 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -531,13 +531,10 @@  void mptcp_pm_subflow_check_next(struct mptcp_sock *msk,
 	bool update_subflows;
 
 	update_subflows = subflow->request_join || subflow->mp_join;
-	if (mptcp_pm_is_userspace(msk)) {
-		if (update_subflows) {
-			spin_lock_bh(&pm->lock);
-			pm->subflows--;
-			spin_unlock_bh(&pm->lock);
-		}
-		return;
+	if (update_subflows) {
+		spin_lock_bh(&pm->lock);
+		pm->subflows--;
+		spin_unlock_bh(&pm->lock);
 	}
 
 	if (!pm->ops->subflow_established)
@@ -547,8 +544,8 @@  void mptcp_pm_subflow_check_next(struct mptcp_sock *msk,
 		return;
 
 	spin_lock_bh(&pm->lock);
-	if (update_subflows)
-		__mptcp_pm_close_subflow(msk);
+	if (update_subflows && msk->pm.subflows < mptcp_pm_get_subflows_max(msk))
+		WRITE_ONCE(msk->pm.accept_subflow, true);
 
 	/* Even if this subflow is not really established, tell the PM to try
 	 * to pick the next ones, if possible.