MPTCP Linux Development
 help / color / mirror / Atom feed
From: Gang Yan <gang.yan@linux.dev>
To: mptcp@lists.linux.dev
Cc: matttbe@kernel.org, geliang@kernel.org, Gang Yan <yangang@kylinos.cn>
Subject: [PATCH mptcp-next v2] Squash-to "mptcp: pm: init and release mptcp_pm_ops"
Date: Wed,  1 Jul 2026 15:37:13 +0800	[thread overview]
Message-ID: <20260701073713.197616-1-gang.yan@linux.dev> (raw)

From: Gang Yan <yangang@kylinos.cn>

This patch removes the need to handle a NULL pm_ops in the fallback
path, and moves the rcu_read_lock\unlock into mptcp_pm_ops_init.

Following sashiko's comments, it also moves the pr_debug() before
bpf_module_put() in mptcp_pm_ops_release.

Signed-off-by: Gang Yan <yangang@kylinos.cn>
---
 net/mptcp/pm.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 9dc7b41fb562..5fe4276cf895 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -1137,12 +1137,14 @@ void mptcp_pm_worker(struct mptcp_sock *msk)
 	spin_unlock_bh(&msk->pm.lock);
 }
 
-static void mptcp_pm_ops_init(struct mptcp_sock *msk,
-			      struct mptcp_pm_ops *pm_ops)
+static void mptcp_pm_ops_init(struct mptcp_sock *msk, const char *pm_name)
 {
+	struct mptcp_pm_ops *pm_ops;
+
+	rcu_read_lock();
+	pm_ops = mptcp_pm_find(pm_name);
 	if (!pm_ops || !bpf_try_module_get(pm_ops, pm_ops->owner)) {
-		pr_warn_once("pm %s fails, fallback to default pm",
-			     pm_ops->name);
+		pr_warn_once("pm %s fails, fallback to default pm", pm_name);
 		pm_ops = &mptcp_pm_kernel;
 	}
 
@@ -1151,6 +1153,7 @@ static void mptcp_pm_ops_init(struct mptcp_sock *msk,
 		msk->pm.ops->init(msk);
 
 	pr_debug("pm %s initialized\n", pm_ops->name);
+	rcu_read_unlock();
 }
 
 static void mptcp_pm_ops_release(struct mptcp_sock *msk)
@@ -1161,9 +1164,9 @@ static void mptcp_pm_ops_release(struct mptcp_sock *msk)
 	if (pm_ops->release)
 		pm_ops->release(msk);
 
-	bpf_module_put(pm_ops, pm_ops->owner);
-
 	pr_debug("pm %s released\n", pm_ops->name);
+
+	bpf_module_put(pm_ops, pm_ops->owner);
 }
 
 void mptcp_pm_destroy(struct mptcp_sock *msk)
@@ -1184,9 +1187,7 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk)
 	pm->rm_list_rx.nr = 0;
 	WRITE_ONCE(pm->pm_type, pm_type);
 
-	rcu_read_lock();
-	mptcp_pm_ops_init(msk, mptcp_pm_find(pm_name));
-	rcu_read_unlock();
+	mptcp_pm_ops_init(msk, pm_name);
 }
 
 void mptcp_pm_data_init(struct mptcp_sock *msk)
-- 
2.43.0


             reply	other threads:[~2026-07-01  7:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01  7:37 Gang Yan [this message]
2026-07-01  8:58 ` [PATCH mptcp-next v2] Squash-to "mptcp: pm: init and release mptcp_pm_ops" MPTCP CI
2026-07-02  2:15 ` Geliang Tang
2026-07-02  6:06   ` gang.yan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260701073713.197616-1-gang.yan@linux.dev \
    --to=gang.yan@linux.dev \
    --cc=geliang@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=yangang@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox