Skip to contentSkip to conversation

Fixes for "use bpf_iter in bpf schedulers" v8

PATCH In review Geliang Tang 2 participants 6 messages Oct 24, 2024 – Oct 25, 2024

Subsystems (5)
lore
Share & tools
lore

Geliang Tang

author reviewer
#0 lore raw

v2 cover Fixes for "use bpf_iter in bpf schedulers" v8

From: Geliang Tang <[email protected]>

v2:
- Use mptcp_stream_memory_free instead of using tcp_stream_memory_free.

Fix mptcp_join.sh (22) and packetdrill errors in "use bpf_iter in bpf schedulers" (v8) reported by CI.

Depends on:
- "use bpf_iter in bpf schedulers" v8

Based-on: <[email protected]>

Geliang Tang (3):
Squash to "mptcp: check sk_stream_memory_free in loop" Squash to "bpf: Export mptcp packet scheduler helpers" Squash to "selftests/bpf: Add bpf_burst scheduler & test"

 net/mptcp/bpf.c                                     | 7 ++++++-
 net/mptcp/protocol.c                                | 5 +++--
 tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c | 9 +++++----
 3 files changed, 14 insertions(+), 7 deletions(-)
Signature · 1 line
2.45.2
author reviewer
#1 lore raw

PATCH v2 1/3 Squash to "mptcp: check sk_stream_memory_free in loop"

From: Geliang Tang <[email protected]>

Fix mptcp_join.sh (22) and packetdrill errors reported by CI.

Move sk_stream_memory_free check before "send_info[backup].ssk = ssk".

---
 net/mptcp/protocol.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
net/mptcp/protocol.c +3 -2
index f36e63b84b88..2ae9b8012dcd 100644
@@ -1444,8 +1444,7 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)
 
 		trace_mptcp_subflow_get_send(subflow);
 		ssk =  mptcp_subflow_tcp_sock(subflow);
-		if (!mptcp_subflow_active(subflow) ||
-		    !sk_stream_memory_free(ssk))
+		if (!mptcp_subflow_active(subflow))
 			continue;
 
 		tout = max(tout, mptcp_timeout_from_subflow(subflow));
@@ -1461,6 +1460,8 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)
 
 		linger_time = div_u64((u64)READ_ONCE(ssk->sk_wmem_queued) << 32, pace);
 		if (linger_time < send_info[backup].linger_time) {
+			if (!sk_stream_memory_free(ssk))
+				continue;
 			send_info[backup].ssk = ssk;
 			send_info[backup].linger_time = linger_time;
 		}
Signature · 1 line
2.45.2
author reviewer
#2 lore raw

PATCH v2 2/3 Squash to "bpf: Export mptcp packet scheduler helpers"

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Should use mptcp_stream_memory_free in burst scheduler, not tcp_stream_memory_free. Add a wrapper for it.

---
 net/mptcp/bpf.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
net/mptcp/bpf.c +6 -1
index 13bdcbe34e1f..72d8be2f3853 100644
@@ -284,6 +284,11 @@ __bpf_kfunc static void bpf_mptcp_sock_release(struct mptcp_sock *msk)
 	WARN_ON_ONCE(!sk || !refcount_dec_not_one(&sk->sk_refcnt));
 }
 
+__bpf_kfunc bool bpf_mptcp_stream_memory_free(const struct sock *sk, int wake)
+{
+	return mptcp_stream_memory_free(sk, wake);
+}
+
 __bpf_kfunc static bool bpf_mptcp_subflow_queues_empty(struct sock *sk)
 {
 	return tcp_rtx_queue_empty(sk);
@@ -311,7 +316,7 @@ BTF_KFUNCS_START(bpf_mptcp_sched_kfunc_ids)
 BTF_ID_FLAGS(func, mptcp_subflow_active)
 BTF_ID_FLAGS(func, mptcp_set_timeout)
 BTF_ID_FLAGS(func, mptcp_wnd_end)
-BTF_ID_FLAGS(func, tcp_stream_memory_free)
+BTF_ID_FLAGS(func, bpf_mptcp_stream_memory_free)
 BTF_ID_FLAGS(func, bpf_mptcp_subflow_queues_empty)
 BTF_ID_FLAGS(func, mptcp_pm_subflow_chk_stale)
 BTF_KFUNCS_END(bpf_mptcp_sched_kfunc_ids)
Signature · 1 line
2.45.2
author reviewer
#3 lore raw

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

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Move sk_stream_memory_free check before "send_info[backup].subflow = subflow".

Use mptcp_stream_memory_free instead of using tcp_stream_memory_free.

---
 tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c +5 -4
index 6242430d0330..1157921d2f0b 100644
@@ -23,7 +23,7 @@ struct bpf_subflow_send_info {
 extern bool mptcp_subflow_active(struct mptcp_subflow_context *subflow) __ksym;
 extern void mptcp_set_timeout(struct sock *sk) __ksym;
 extern __u64 mptcp_wnd_end(const struct mptcp_sock *msk) __ksym;
-extern bool tcp_stream_memory_free(const struct sock *sk, int wake) __ksym;
+extern bool bpf_mptcp_stream_memory_free(const struct sock *sk, int wake) __ksym;
 extern bool bpf_mptcp_subflow_queues_empty(struct sock *sk) __ksym;
 extern void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk) __ksym;
 
@@ -49,7 +49,7 @@ static __always_inline bool __sk_stream_memory_free(const struct sock *sk, int w
 	if (sk->sk_wmem_queued >= sk->sk_sndbuf)
 		return false;
 
-	return tcp_stream_memory_free(sk, wake);
+	return bpf_mptcp_stream_memory_free(sk, wake);
 }
 
 static __always_inline bool sk_stream_memory_free(const struct sock *sk)
@@ -87,8 +87,7 @@ static int bpf_burst_get_send(struct mptcp_sock *msk)
 		bool backup = subflow->backup || subflow->request_bkup;
 
 		ssk = mptcp_subflow_tcp_sock(subflow);
-		if (!mptcp_subflow_active(subflow) ||
-		    !sk_stream_memory_free(ssk))
+		if (!mptcp_subflow_active(subflow))
 			continue;
 
 		nr_active += !backup;
@@ -103,6 +102,8 @@ static int bpf_burst_get_send(struct mptcp_sock *msk)
 
 		linger_time = div_u64((__u64)ssk->sk_wmem_queued << 32, pace);
 		if (linger_time < send_info[backup].linger_time) {
+			if (!sk_stream_memory_free(ssk))
+				continue;
 			send_info[backup].subflow = subflow;
 			send_info[backup].linger_time = linger_time;
 		}
Signature · 1 line
2.45.2
#4 lore raw
In reply to Geliang Tang

Hi Geliang,

Thank you for your modifications, that's great!

But sadly, our CI spotted some issues with it when trying to build it.

You can find more details there:

https://github.com/multipath-tcp/mptcp_net-next/actions/runs/11497633619

Status: failure
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/34d3a58b0bfa
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=902633

Feel free to reply to this email if you cannot access logs, if you need some support to fix the error, if this doesn't seem to be caused by your modifications or if the error is a false positive one.

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)

author reviewer
#5 lore raw
In reply to Geliang Tang
Quoted 5 lines · Geliang Tang

From: Geliang Tang <[email protected]>

v2:
 - Use mptcp_stream_memory_free instead of using
tcp_stream_memory_free.

Sorry, I made a mistake. The parameter of sk_stream_memory_free() is ssk (subsocket), not sk (mptcp socket). We should use tcp_stream_memory_free() here, not mptcp_stream_memory_free().

This set is deprecated and rolled back to the previous version (v1):

https://patchwork.kernel.org/project/mptcp/cover/[email protected]/

Thanks,
-Geliang

Quoted 19 lines

Fix mptcp_join.sh (22) and packetdrill errors in "use bpf_iter in bpf schedulers" (v8) reported by CI.

Depends on:
 - "use bpf_iter in bpf schedulers" v8

Based-on: <[email protected]>

Geliang Tang (3):
  Squash to "mptcp: check sk_stream_memory_free in loop" Squash to "bpf: Export mptcp packet scheduler helpers" Squash to "selftests/bpf: Add bpf_burst scheduler & test"

 net/mptcp/bpf.c                                     | 7 ++++++- net/mptcp/protocol.c                                | 5 +++-- tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c | 9 +++++----

 3 files changed, 14 insertions(+), 7 deletions(-)