Skip to contentSkip to conversation

cleanups for bpf schedulers

PATCH In review Geliang Tang 3 participants 8 messages Sep 9, 2024

Subsystems (5)
lore
Share & tools
lore

Geliang Tang

author reviewer
#0 lore raw

v2 cover cleanups for bpf schedulers

From: Geliang Tang <[email protected]>

v2:
- include two more squash-to patches into this set.

Two cleanups for bpf schedulers.

Geliang Tang (4):
Squash to "bpf: Add bpf_mptcp_sched_ops"
Squash to "selftests/bpf: Add mptcp subflow subtest" Squash to "selftests/bpf: Add bpf scheduler test" Squash to "selftests/bpf: Add bpf_burst scheduler & test"

 net/mptcp/bpf.c                                     |  3 ---
 tools/testing/selftests/bpf/prog_tests/mptcp.c      | 10 +++++-----
 tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c |  5 +++--
 3 files changed, 8 insertions(+), 10 deletions(-)
Signature · 1 line
2.43.0
author reviewer
#1 lore raw

PATCH v2 1/4 Squash to "bpf: Add bpf_mptcp_sched_ops"

From: Geliang Tang <[email protected]>

The helper mptcp_subflow_set_scheduled() is used to update the scheduled flags of a subflow. BPF schedulers are not allowed to directly modify this flags. So the write access permission for this flag shouldn't be allow.

---
 net/mptcp/bpf.c | 3 ---
 1 file changed, 3 deletions(-)
net/mptcp/bpf.c +0 -3
index 9672a70c24b0..6414824402e6 100644
@@ -60,9 +60,6 @@ static int bpf_mptcp_sched_btf_struct_access(struct bpf_verifier_log *log,
 		}
 	} else if (t == mptcp_subflow_type) {
 		switch (off) {
-		case offsetof(struct mptcp_subflow_context, scheduled):
-			end = offsetofend(struct mptcp_subflow_context, scheduled);
-			break;
 		case offsetof(struct mptcp_subflow_context, avg_pacing_rate):
 			end = offsetofend(struct mptcp_subflow_context, avg_pacing_rate);
 			break;
Signature · 1 line
2.43.0
author reviewer
#2 lore raw

PATCH v2 2/4 Squash to "selftests/bpf: Add mptcp subflow subtest"

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Should use dedicated ASSERT_OK_FD() to check the fds.

---
 tools/testing/selftests/bpf/prog_tests/mptcp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/prog_tests/mptcp.c +3 -3
index 93869c873cad..987692863fde 100644
@@ -394,11 +394,11 @@ static void run_subflow(void)
 	socklen_t len;
 
 	server_fd = start_mptcp_server(AF_INET, ADDR_1, PORT_1, 0);
-	if (!ASSERT_GE(server_fd, 0, "start_mptcp_server"))
+	if (!ASSERT_OK_FD(server_fd, "start_mptcp_server"))
 		return;
 
 	client_fd = connect_to_fd(server_fd, 0);
-	if (!ASSERT_GE(client_fd, 0, "connect to fd"))
+	if (!ASSERT_OK_FD(client_fd, "connect_to_fd"))
 		goto close_server;
 
 	send_byte(client_fd);
@@ -429,7 +429,7 @@ static void test_subflow(void)
 	struct bpf_link *link;
 
 	cgroup_fd = test__join_cgroup("/mptcp_subflow");
-	if (!ASSERT_GE(cgroup_fd, 0, "join_cgroup: mptcp_subflow"))
+	if (!ASSERT_OK_FD(cgroup_fd, "join_cgroup: mptcp_subflow"))
 		return;
 
 	skel = mptcp_subflow__open_and_load();
Signature · 1 line
2.43.0
author reviewer
#3 lore raw

PATCH v2 3/4 Squash to "selftests/bpf: Add bpf scheduler test"

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

---
 tools/testing/selftests/bpf/prog_tests/mptcp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/mptcp.c +2 -2
index 987692863fde..2476f0a083bc 100644
@@ -507,11 +507,11 @@ static void send_data_and_verify(char *sched, bool addr1, bool addr2)
 	unsigned int delta_ms;
 
 	server_fd = start_mptcp_server(AF_INET, ADDR_1, PORT_1, 0);
-	if (CHECK(server_fd < 0, sched, "start_mptcp_server: %d\n", errno))
+	if (!ASSERT_OK_FD(server_fd, "start_mptcp_server"))
 		return;
 
 	client_fd = connect_to_fd(server_fd, 0);
-	if (CHECK(client_fd < 0, sched, "connect_to_fd: %d\n", errno))
+	if (!ASSERT_OK_FD(client_fd, "connect_to_fd"))
 		goto fail;
 
 	if (clock_gettime(CLOCK_MONOTONIC, &start) < 0)
Signature · 1 line
2.43.0
author reviewer
#4 lore raw

Re: [PATCH mptcp-next v2 3/4] Squash to "selftests/bpf: Add bpf scheduler test"

Quoted 1 line · Geliang Tang

From: Geliang Tang <[email protected]>

Should use dedicated ASSERT_OK_FD() to check the fds.

Quoted 28 lines

---
 tools/testing/selftests/bpf/prog_tests/mptcp.c | 4 ++--

 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/mptcp.c +0 -0
index 987692863fde..2476f0a083bc 100644
@@ -507,11 +507,11 @@ static void send_data_and_verify(char *sched,
 bool addr1, bool addr2)
  	unsigned int delta_ms;


  server_fd = start_mptcp_server(AF_INET, ADDR_1, PORT_1, 0);

tools/testing/selftests/bpf/prog_tests/mptcp.c +0 -1
-	if (CHECK(server_fd < 0, sched, "start_mptcp_server: %d\n",

errno))

tools/testing/selftests/bpf/prog_tests/mptcp.c +1 -0
+	if (!ASSERT_OK_FD(server_fd, "start_mptcp_server"))

  return;

  client_fd = connect_to_fd(server_fd, 0);

tools/testing/selftests/bpf/prog_tests/mptcp.c +0 -1
-	if (CHECK(client_fd < 0, sched, "connect_to_fd: %d\n",

errno))

tools/testing/selftests/bpf/prog_tests/mptcp.c +1 -0
+	if (!ASSERT_OK_FD(client_fd, "connect_to_fd"))

  goto fail;

  if (clock_gettime(CLOCK_MONOTONIC, &start) < 0)

author reviewer
#5 lore raw

PATCH v2 4/4 Squash to "selftests/bpf: Add bpf_burst scheduler & test"

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Use nr_active variable just like in mptcp_subflow_get_send().

---
 tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c +3 -2
index 3a673291b4dd..eb21119aa8f7 100644
@@ -74,9 +74,9 @@ static int bpf_burst_get_send(struct mptcp_sock *msk,
 	struct mptcp_subflow_context *subflow;
 	struct sock *sk = (struct sock *)msk;
 	__u32 pace, burst, wmem;
+	int i, nr_active = 0;
 	__u64 linger_time;
 	struct sock *ssk;
-	int i;
 
 	/* pick the subflow with the lower wmem/wspace ratio */
 	for (i = 0; i < SSK_MODE_MAX; ++i) {
@@ -97,6 +97,7 @@ static int bpf_burst_get_send(struct mptcp_sock *msk,
 		if (!mptcp_subflow_active(subflow))
 			continue;
 
+		nr_active += !backup;
 		pace = subflow->avg_pacing_rate;
 		if (!pace) {
 			/* init pacing rate from socket */
@@ -115,7 +116,7 @@ static int bpf_burst_get_send(struct mptcp_sock *msk,
 	mptcp_set_timeout(sk);
 
 	/* pick the best backup if no other subflow is active */
-	if (send_info[SSK_MODE_ACTIVE].subflow_id == MPTCP_SUBFLOWS_MAX)
+	if (!nr_active)
 		send_info[SSK_MODE_ACTIVE].subflow_id = send_info[SSK_MODE_BACKUP].subflow_id;
 
 	subflow = bpf_mptcp_subflow_ctx_by_pos(data, send_info[SSK_MODE_ACTIVE].subflow_id);
Signature · 1 line
2.43.0
#6 lore raw
In reply to Geliang Tang

Hi Geliang,

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 (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/10765309807

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

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)

maintainer
#7 lore raw
In reply to Geliang Tang

Hi Geliang,

Quoted 5 lines · Geliang Tang

From: Geliang Tang <[email protected]>

v2:
- include two more squash-to patches into this set.

Quoted 7 lines

Two cleanups for bpf schedulers.

Geliang Tang (4):
Squash to "bpf: Add bpf_mptcp_sched_ops"
Squash to "selftests/bpf: Add mptcp subflow subtest" Squash to "selftests/bpf: Add bpf scheduler test" Squash to "selftests/bpf: Add bpf_burst scheduler & test"

Thank you for the clean-up patches. Now in our tree:

New patches for t/upstream:
- 07a029a9a232: "squashed" patch 1/4 in "bpf: Add bpf_mptcp_sched_ops"
- 05c716b8999b: "squashed" patch 2/4 in "selftests/bpf: Add mptcp subflow subtest"
- 0aed3898d704: "squashed" patch 3/4 in "selftests/bpf: Add bpf scheduler test"
- 56ed019f23ff: "squashed" patch 4/4 in "selftests/bpf: Add bpf_burst scheduler & test"
- Results: 2e425b685ff0..29da3bae8ab9 (export)

Tests are now in progress:

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

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.