Skip to contentSkip to conversation

mptcp: sched: reduce size for unused data

PATCH In review Matthieu Baerts (NGI0) 2 participants 6 messages Feb 21, 2025

Subsystems (2)
lore
Share & tools
lore

Matthieu Baerts (NGI0)

author maintainer
#0 lore raw

cover mptcp: sched: reduce size for unused data

I was going to send "mptcp: sched: split get_subflow interface into two" commit, when I saw again that the "data" structure was no longer used.

Because it will be removed later, when "use bpf_iter in bpf schedulers" series will be applied, a first step is to save 64B from the stack for each scheduling operation.

The first patch can be placed after "mptcp: sched: split get_subflow interface into two", and the second one before or squashed into "mptcp:
add sched_data helpers": this commit can be dropped when "use bpf_iter in bpf schedulers" series will be applied, no need to keep it for future use. Same for the struct mptcp_sched_data.

---
Matthieu Baerts (NGI0) (2):
mptcp: sched: reduce size for unused data
Squash to "mptcp: add sched_data helpers"

---
base-commit: 98f1e7131283309b4684ce977f28c9703d16b516
change-id: 20250221-mptcp-sched-data-ptr-8740fecdbbae

Best regards,

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

PATCH 1/2 mptcp: sched: reduce size for unused data

Thanks for the previous commit ("mptcp: sched: split get_subflow interface into two"), the mptcp_sched_data structure is now currently unused.

This structure has been added to allow future extensions that are not ready yet. At the end, this structure will not even be used at all when mptcp_subflow bpf_iter will be supported [1].

Here is a first step to save 64 bytes on the stack for each scheduling operation. The structure is not removed yet not to break the WIP work on these extensions, but will be done when [1] will be ready and applied.

---
 net/mptcp/sched.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
net/mptcp/sched.c +9 -9
index 37d86aadaeaa523568a82ffb22254d1fb34a3d2d..c8e08f6c300d37584d3d89a01022b5677aa8b6bb 100644
@@ -177,7 +177,7 @@ static void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk,
 int mptcp_sched_get_send(struct mptcp_sock *msk)
 {
 	struct mptcp_subflow_context *subflow;
-	struct mptcp_sched_data data;
+	struct mptcp_sched_data *data = NULL;
 
 	msk_owned_by_me(msk);
 
@@ -198,15 +198,15 @@ int mptcp_sched_get_send(struct mptcp_sock *msk)
 	}
 
 	if (msk->sched == &mptcp_sched_default || !msk->sched)
-		return mptcp_sched_default_get_send(msk, &data);
-	mptcp_sched_data_set_contexts(msk, &data);
-	return msk->sched->get_send(msk, &data);
+		return mptcp_sched_default_get_send(msk, data);
+	mptcp_sched_data_set_contexts(msk, data);
+	return msk->sched->get_send(msk, data);
 }
 
 int mptcp_sched_get_retrans(struct mptcp_sock *msk)
 {
 	struct mptcp_subflow_context *subflow;
-	struct mptcp_sched_data data;
+	struct mptcp_sched_data *data = NULL;
 
 	msk_owned_by_me(msk);
 
@@ -220,10 +220,10 @@ int mptcp_sched_get_retrans(struct mptcp_sock *msk)
 	}
 
 	if (msk->sched == &mptcp_sched_default || !msk->sched)
-		return mptcp_sched_default_get_retrans(msk, &data);
+		return mptcp_sched_default_get_retrans(msk, data);
 
-	mptcp_sched_data_set_contexts(msk, &data);
+	mptcp_sched_data_set_contexts(msk, data);
 	if (msk->sched->get_retrans)
-		return msk->sched->get_retrans(msk, &data);
-	return msk->sched->get_send(msk, &data);
+		return msk->sched->get_retrans(msk, data);
+	return msk->sched->get_send(msk, data);
 }
Signature · 1 line
2.47.1
author maintainer
#2 lore raw

PATCH 2/2 Squash to "mptcp: add sched_data helpers"

In reply to Matthieu Baerts (NGI0)

"mptcp: add sched_data helpers" can be removed when "use bpf_iter in bpf schedulers" series will be applied.

Same for the mptcp_sched_data structure.

---
 net/mptcp/sched.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
net/mptcp/sched.c +9 -9
index c8e08f6c300d37584d3d89a01022b5677aa8b6bb..37d86aadaeaa523568a82ffb22254d1fb34a3d2d 100644
@@ -177,7 +177,7 @@ static void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk,
 int mptcp_sched_get_send(struct mptcp_sock *msk)
 {
 	struct mptcp_subflow_context *subflow;
-	struct mptcp_sched_data *data = NULL;
+	struct mptcp_sched_data data;
 
 	msk_owned_by_me(msk);
 
@@ -198,15 +198,15 @@ int mptcp_sched_get_send(struct mptcp_sock *msk)
 	}
 
 	if (msk->sched == &mptcp_sched_default || !msk->sched)
-		return mptcp_sched_default_get_send(msk, data);
-	mptcp_sched_data_set_contexts(msk, data);
-	return msk->sched->get_send(msk, data);
+		return mptcp_sched_default_get_send(msk, &data);
+	mptcp_sched_data_set_contexts(msk, &data);
+	return msk->sched->get_send(msk, &data);
 }
 
 int mptcp_sched_get_retrans(struct mptcp_sock *msk)
 {
 	struct mptcp_subflow_context *subflow;
-	struct mptcp_sched_data *data = NULL;
+	struct mptcp_sched_data data;
 
 	msk_owned_by_me(msk);
 
@@ -220,10 +220,10 @@ int mptcp_sched_get_retrans(struct mptcp_sock *msk)
 	}
 
 	if (msk->sched == &mptcp_sched_default || !msk->sched)
-		return mptcp_sched_default_get_retrans(msk, data);
+		return mptcp_sched_default_get_retrans(msk, &data);
 
-	mptcp_sched_data_set_contexts(msk, data);
+	mptcp_sched_data_set_contexts(msk, &data);
 	if (msk->sched->get_retrans)
-		return msk->sched->get_retrans(msk, data);
-	return msk->sched->get_send(msk, data);
+		return msk->sched->get_retrans(msk, &data);
+	return msk->sched->get_send(msk, &data);
 }
Signature · 1 line
2.47.1
author maintainer
#3 lore raw
In reply to Matthieu Baerts (NGI0)

Hello,

Quoted 6 lines · On 21/02/2025 16:08, Matthieu Baerts (NGI0) wrote:

I was going to send "mptcp: sched: split get_subflow interface into two" commit, when I saw again that the "data" structure was no longer used.

Because it will be removed later, when "use bpf_iter in bpf schedulers" series will be applied, a first step is to save 64B from the stack for each scheduling operation.

I suggest applying this now, not to block the other patch: this small modification is trivial, and undo only in our tree.

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
author maintainer
#4 lore raw
Quoted 6 lines · Matthieu Baerts

Hello,

Quoted 3 lines · On 21/02/2025 16:08, Matthieu Baerts (NGI0) wrote:

I was going to send "mptcp: sched: split get_subflow interface into two" commit, when I saw again that the "data" structure was no longer used.

Quoted 6 lines
Quoted 3 lines

Because it will be removed later, when "use bpf_iter in bpf schedulers" series will be applied, a first step is to save 64B from the stack for each scheduling operation.

I suggest applying this now, not to block the other patch: this small modification is trivial, and undo only in our tree.

Just did:

New patches for t/upstream:
- 70c366a0a40e: mptcp: sched: reduce size for unused data
- 46de2641147f: conflict in t/mptcp-add-sched_data-helpers-2
- f3c111c797d2: "squashed" patch 2/2 in "mptcp: add sched_data helpers"
- Results: 9afc9d6ddf8b..b5dbbb68e432 (export)

Tests are now in progress:

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

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
#5 lore raw
In reply to Matthieu Baerts (NGI0)

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/13459912721

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

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)