Skip to contentSkip to conversation

mptcp: pm: exit early with ADD_ADDR echo if possible

PATCH In review Matthieu Baerts (NGI0) 3 participants 4 messages Feb 26, 2025 – Feb 27, 2025

Subsystems (2)
lore
Share & tools
lore

Matthieu Baerts (NGI0)

author maintainer
#0 lore raw

PATCH v2 1/1 mptcp: pm: exit early with ADD_ADDR echo if possible

When the userspace PM is used, or when the in-kernel limits are reached, there will be no need to schedule the PM worker to signal new addresses. That corresponds to pm->work_pending set to 0.

In this case, an early exit can be done in mptcp_pm_add_addr_echoed() not to hold the PM lock, and iterate over the announced addresses list, not to schedule the worker anyway in this case. This is similar to what is done when a connection or a subflow has been established.

---
Changes in v2:
- Link to v1: https://lore.kernel.org/r/20250224-mptcp-userspace-avoid-worker-v1-1-127325d3e9a4@kernel.org
---
Notes:
- v2:
- Only modify mptcp_pm_add_addr_echoed().
- The rest doesn't need to or shouldn't be modified (Geliang).
Cc: Geliang Tang <[email protected]>

---
 net/mptcp/pm.c | 3 +++
 1 file changed, 3 insertions(+)
net/mptcp/pm.c +3 -0
index 16cacce6c10fe86467aa7ef8e588f9f535b586fb..6c8cadf84f31f4c7dcc38b787beda048d5362dc8 100644
@@ -251,6 +251,9 @@ void mptcp_pm_add_addr_echoed(struct mptcp_sock *msk,
 
 	pr_debug("msk=%p\n", msk);
 
+	if (!READ_ONCE(pm->work_pending))
+		return;
+
 	spin_lock_bh(&pm->lock);
 
 	if (mptcp_lookup_anno_list_by_saddr(msk, addr) && READ_ONCE(pm->work_pending))

---
base-commit: 1238896935ea03f333a183a32fab666cc0c20e3b
change-id: 20250224-mptcp-userspace-avoid-worker-93f367e39ca6

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: Success! ✅
- KVM Validation: debug: 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/13546321767

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

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 v2 1/1
#2 lore raw
In reply to Matthieu Baerts (NGI0)

Hi Matt,

Quoted 6 lines · On Wed, 2025-02-26 at 15:21 +0100, Matthieu Baerts (NGI0) wrote:

When the userspace PM is used, or when the in-kernel limits are reached,
there will be no need to schedule the PM worker to signal new addresses.
That corresponds to pm->work_pending set to 0.

Quoted 8 lines

In this case, an early exit can be done in mptcp_pm_add_addr_echoed() not to hold the PM lock, and iterate over the announced addresses list,
not to schedule the worker anyway in this case. This is similar to what
is done when a connection or a subflow has been established.

This v2 looks good to me, thanks.

Quoted 38 lines

---
Changes in v2:
- Link to v1:
https://lore.kernel.org/r/20250224-mptcp-userspace-avoid-worker-v1-1-127325d3e9a4@kernel.org
---
Notes:
- v2:
  - Only modify mptcp_pm_add_addr_echoed().
  - The rest doesn't need to or shouldn't be modified (Geliang).
Cc: Geliang Tang <[email protected]>
---
 net/mptcp/pm.c | 3 +++

 1 file changed, 3 insertions(+)
net/mptcp/pm.c +0 -0

index 16cacce6c10fe86467aa7ef8e588f9f535b586fb..6c8cadf84f31f4c7dcc38b787be da048d5362dc8 100644

net/mptcp/pm.c +0 -0
@@ -251,6 +251,9 @@ void mptcp_pm_add_addr_echoed(struct mptcp_sock
 *msk,


  pr_debug("msk=%p\n", msk);

net/mptcp/pm.c +3 -0
+	if (!READ_ONCE(pm->work_pending))
+		return;
+

  spin_lock_bh(&pm->lock);

  if (mptcp_lookup_anno_list_by_saddr(msk, addr) && READ_ONCE(pm->work_pending))

---
base-commit: 1238896935ea03f333a183a32fab666cc0c20e3b
change-id: 20250224-mptcp-userspace-avoid-worker-93f367e39ca6

Best regards,

author maintainer
#3 lore raw

Hi Geliang,

Quoted 16 lines · Geliang Tang

Hi Matt,

Quoted 13 lines · On Wed, 2025-02-26 at 15:21 +0100, Matthieu Baerts (NGI0) wrote:

When the userspace PM is used, or when the in-kernel limits are reached,
there will be no need to schedule the PM worker to signal new addresses.
That corresponds to pm->work_pending set to 0.

In this case, an early exit can be done in mptcp_pm_add_addr_echoed() not to hold the PM lock, and iterate over the announced addresses list,
not to schedule the worker anyway in this case. This is similar to what
is done when a connection or a subflow has been established.

Quoted 3 lines
Quoted 1 line

This v2 looks good to me, thanks.

Thank you for the review!

Now in our tree (feat. for net-next):

New patches for t/upstream:
- 6bb3d64aade7: mptcp: pm: exit early with ADD_ADDR echo if possible
- Results: d8bb22f4550f..6b32949274eb (export)

Tests are now in progress:

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

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.