mptcp: sched: let schedulers mark a subflow to avoid
Subsystems (5)
cover mptcp: sched: let schedulers mark a subflow to avoid
The core benches a subflow via the "stale" bit after net.mptcp.stale_loss_cnt retransmission intervals without progress. That bit is owned by the core and tightly coupled to the RTO: it is cleared as soon as a packet is acked on the subflow, in mptcp_subflow_active(). A packet scheduler therefore cannot repurpose it to bench a subflow for its own reasons (too high latency, too unstable) and keep it benched: the core would clear it on the next ack, unrelated to the scheduler's intent.
Add a separate, scheduler-owned "avoid" flag on the subflow context, set and cleared only through mptcp_subflow_set_avoid(), exposed to BPF struct_ops schedulers as a kfunc (same registration and filter as mptcp_subflow_set_scheduled(), so only schedulers can call it). The flag is scheduler-local state: the scheduler sets it to remember a subflow should be skipped and consults it when picking a subflow to send on. It lives in the struct_group(reset) block, so it is cleared on subflow reset and a re-established path is re-evaluated. The core send and retransmit paths are left unchanged.
This is the "manage a new bit" option from issue #349, kept independent of the RTO-driven stale bit as that issue requests. Regular probing of an avoided subflow (#348) and any core-side consumption of the flag are left for follow-up.
Patch 1 adds the flag, the setter and the kfunc. Patch 2 adds a BPF struct_ops scheduler selftest that marks all but the first subflow avoided, reads the flag back, and schedules only a non-avoided subflow; the existing harness confirms the avoided path carries no data, exercising the kfunc round-trip from eBPF.
Tested with the mptcp-upstream-virtme-docker CI (auto-normal and auto-btf):
all selftests, packetdrill and BPF tests pass, including the new avoid subtest.
Kalpan Jani (2):
mptcp: sched: add subflow avoid flag and kfunc
selftests: mptcp: bpf: exercise the subflow avoid flag
net/mptcp/bpf.c | 1 + net/mptcp/protocol.h | 3 ++ net/mptcp/sched.c | 6 +++ .../testing/selftests/bpf/prog_tests/mptcp.c | 15 ++++++ tools/testing/selftests/bpf/progs/mptcp_bpf.h | 2 + .../selftests/bpf/progs/mptcp_bpf_avoid.c | 49 +++++++++++++++++++ 6 files changed, 76 insertions(+) create mode 100644 tools/testing/selftests/bpf/progs/mptcp_bpf_avoid.c
base-commit: 490b4823cb98b233af2b7562bddc90ecb5dfbf4e
Signature · 1 line
2.43.0
PATCH 1/2 mptcp: sched: add subflow avoid flag and kfunc
The core benches a subflow via the "stale" bit after net.mptcp.stale_loss_cnt retransmission intervals without progress. That bit is owned by the core and tightly coupled to the RTO: it is cleared automatically as soon as a packet is acked on the subflow (mptcp_subflow_active() calls mptcp_subflow_set_active() when rcv_tstamp advances).
A packet scheduler may want to bench a subflow for unrelated reasons (too high latency, too unstable) and keep it benched until it decides otherwise. Reusing the stale bit does not work: the core would clear it on the next incoming ack.
Add a separate, scheduler-owned "avoid" flag to mptcp_subflow_context:
- it is never set or cleared by the core, only through mptcp_subflow_set_avoid(), exposed to BPF struct_ops schedulers as a kfunc, with the same registration and filter as mptcp_subflow_set_scheduled() so only schedulers can call it;
- it lives in the struct_group(reset) block and is therefore cleared when the subflow is reset, so a re-established path is re-evaluated.
The flag is scheduler-local state: a scheduler sets it to remember that a subflow should be skipped, and consults it when picking a subflow to send on. The core send and retransmit paths are left unchanged.
--- net/mptcp/bpf.c | 1 + net/mptcp/protocol.h | 3 +++ net/mptcp/sched.c | 6 ++++++ 3 files changed, 10 insertions(+)
net/mptcp/bpf.c +1 -0
@@ -318,6 +318,7 @@ BTF_KFUNCS_START(bpf_mptcp_common_kfunc_ids) BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx, KF_RET_NULL) BTF_ID_FLAGS(func, bpf_mptcp_subflow_tcp_sock, KF_RET_NULL) BTF_ID_FLAGS(func, mptcp_subflow_set_scheduled) +BTF_ID_FLAGS(func, mptcp_subflow_set_avoid) BTF_ID_FLAGS(func, mptcp_subflow_active) BTF_ID_FLAGS(func, mptcp_set_timeout)BTF_ID_FLAGS (func, mptcp_wnd_end)
net/mptcp/protocol.h +3 -0
@@ -587,6 +587,7 @@ struct mptcp_subflow_context { __unused :8 ;bool data_avail;bool scheduled; +bool avoid;/* pkt scheduler: skip subflow if possible */ bool pm_listener;/* a listener managed by the kernel PM? */ bool fully_established;/* path validated */ u32 lent_mem_frag;
@@ -897,6 +898,8 @@ static inline bool __mptcp_subflow_active(struct mptcp_subflow_context *subflow)void mptcp_subflow_set_active (struct mptcp_subflow_context *subflow); +void mptcp_subflow_set_avoid (struct mptcp_subflow_context *subflow,bool avoid); +bool mptcp_subflow_active (struct mptcp_subflow_context *subflow);void mptcp_subflow_drop_ctx (struct sock *ssk);
net/mptcp/sched.c +6 -0
@@ -165,6 +165,12 @@ void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,WRITE_ONCE (subflow->scheduled, scheduled); } +void mptcp_subflow_set_avoid (struct mptcp_subflow_context *subflow, +bool avoid) +{ +WRITE_ONCE (subflow->avoid, avoid); +} +int mptcp_sched_get_send (struct mptcp_sock *msk) {struct mptcp_subflow_context *subflow;
Signature · 1 line
2.43.0
PATCH 2/2 selftests: mptcp: bpf: exercise the subflow avoid flag
In reply to Kalpan JaniAdd a BPF struct_ops scheduler selftest for the new mptcp_subflow_set_avoid() kfunc. The scheduler marks every subflow except the first as "avoid", then schedules only a subflow whose avoid flag is clear. The existing send_data_and_verify() harness confirms the avoided path carried no data, exercising the kfunc round-trip from eBPF: set the flag, read it back, and honour it.
This also adds the BPF-side extern declaration for mptcp_subflow_set_avoid(); without it a BPF program cannot compile a call to the kfunc, as the kernel-side BTF registration alone is not enough.
--- .../testing/selftests/bpf/prog_tests/mptcp.c | 15 ++++++ tools/testing/selftests/bpf/progs/mptcp_bpf.h | 2 + .../selftests/bpf/progs/mptcp_bpf_avoid.c | 49 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 tools/testing/selftests/bpf/progs/mptcp_bpf_avoid.c
tools/testing/selftests/bpf/prog_tests/mptcp.c +15 -0
@@ -17,6 +17,7 @@#include "mptcp_bpf_bkup.skel.h" #include "mptcp_bpf_rr.skel.h" #include "mptcp_bpf_red.skel.h" +#include "mptcp_bpf_avoid.skel.h" #include "mptcp_bpf_burst.skel.h" #define NS_TEST "mptcp_ns"
@@ -813,6 +814,18 @@ static void test_burst(void)mptcp_bpf_burst__destroy (skel); } +static void test_avoid (void ) +{ +struct mptcp_bpf_avoid *skel; + + skel =mptcp_bpf_avoid__open_and_load (); +if (!ASSERT_OK_PTR (skel,"open_and_load: avoid" )) +return ; + +test_bpf_sched (skel->maps.avoid,"avoid" ,WITH_DATA ,WITHOUT_DATA ); +mptcp_bpf_avoid__destroy (skel); +} +void test_mptcp (void ) {if (test__start_subtest ("base" ))
@@ -835,4 +848,6 @@ void test_mptcp(void)test_red ();if (test__start_subtest ("burst" ))test_burst (); +if (test__start_subtest ("avoid" )) +test_avoid (); }
tools/testing/selftests/bpf/progs/mptcp_bpf.h +2 -0
@@ -48,5 +48,7 @@ bpf_mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow) __ksym; extern void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow, bool scheduled) __ksym; +extern void mptcp_subflow_set_avoid(struct mptcp_subflow_context *subflow, + bool avoid) __ksym;#endif
tools/testing/selftests/bpf/progs/mptcp_bpf_avoid.c new file +49 -0
49 lines not on this page · raw message
Signature · 1 line
2.43.0
Hi Kalpan,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): 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/29409472750
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/11781b9663bb
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1128052
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-normalFor 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)
Paolo Abeni
maintainerQuoted 29 lines · Kalpan Jani
The core benches a subflow via the "stale" bit after net.mptcp.stale_loss_cnt retransmission intervals without progress. That bit is owned by the core and tightly coupled to the RTO: it is cleared as soon as a packet is acked on the subflow, in
mptcp_subflow_active(). A packet scheduler therefore cannot repurpose it to bench a subflow for its own reasons (too high latency, too unstable) and keep it benched: the core would clear it on the next ack, unrelated to the scheduler's intent.Add a separate, scheduler-owned "avoid" flag on the subflow context, set and cleared only through
mptcp_subflow_set_avoid(), exposed to BPFstruct_opsschedulers as a kfunc (same registration and filter asmptcp_subflow_set_scheduled(), so only schedulers can call it). The flag is scheduler-local state: the scheduler sets it to remember a subflow should be skipped and consults it when picking a subflow to send on. It lives in thestruct_group(reset)block, so it is cleared on subflow reset and a re-established path is re-evaluated. The core send and retransmit paths are left unchanged.This is the "manage a new bit" option from issue #349, kept independent of the RTO-driven stale bit as that issue requests. Regular probing of an avoided subflow (#348) and any core-side consumption of the flag are left for follow-up.
Patch 1 adds the flag, the setter and the kfunc. Patch 2 adds a BPF
struct_opsscheduler selftest that marks all but the first subflow avoided, reads the flag back, and schedules only a non-avoided subflow; the existing harness confirms the avoided path carries no data, exercising the kfunc round-trip from eBPF.
Quoted 5 lines
Tested with the mptcp-upstream-virtme-docker CI (auto-normal and auto-btf):
all selftests, packetdrill and BPF tests pass, including the new avoid subtest.
Please note that the above issue was filed before the introduction of the 'scheduled' flag.
I don't see the avoid bool adding more capabilities on top of the other field, and without any usage from the core I think this change misses a relevant point from the linked issue.
Finally the proposed patch creates a 4 bytes hole in the subflow struct, possibly a better location is available.
More importantly you need to provide a meaningful working scenario demonstrating a relevant use-case not covered by the scheduled bit.
/P