From nobody Sun Dec 22 02:50:02 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F40931ACECB for ; Tue, 10 Dec 2024 03:32:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801527; cv=none; b=OSElqon3I7EG4lUmTD+mxISkUdqm/71Ytb5aiDXi9+Zm27K4Lnm2uTiVYVROCtnjr9qHWRldu8hqH7e/xOMR6P33t+NCgWT7p2f1MoK3E9aUcRlTHZCEIXxDfgbiiQz1lCdTWihV3Ak4OoVaFP5vXNxuZN1pfW79bDkH6Rwm/78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801527; c=relaxed/simple; bh=+0+LegOoavcu/Ao/6seLEq8YpRAosj+5JYBPDWdjb9c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e2t5aj4T1zFQA5mAv2JOf4j3MMBBqDzj3h+eR9YaZo4EvZunmd0lYaI+UEIygqe3PwYgwuFBjUM+uzRlXg99bgVO7gPVRLQlOuhJREz/VHDGGq/WVscYtHhcNvnDCGxUU2rttszjElfRHBZLSywE+s/elRsmQvgnkQ8WlV3n+P0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FFlSLTjT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FFlSLTjT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56FC1C4CED6; Tue, 10 Dec 2024 03:32:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733801526; bh=+0+LegOoavcu/Ao/6seLEq8YpRAosj+5JYBPDWdjb9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FFlSLTjTVHd6AptkOblXDe+qvHidlIc2RkD3nWkRw+Z/oppa5JNd5BJF5AqO3fC+c m6W9EVLvNLzfTv4TtqzoLodIl+qsMwrfKNyrcq0QyAs1cczYdfmoLrl5COgUv2Cdys bbaucSkOOD/REvwWB5K0CQOFUZRYU+xd6MTrnbLskPtRUHqXcVSVoKuGxvoz6/GbAM XwwLjGf+yIETmr2GaOSoCAID4vYvhXBp5NraNBAbdU8Hn6HdAKwJsBe8C9mjKBh/JV 707JKdc7+6QA3DIujVvlseKd++Bjcj2flF1bu4gqc8j9kFL2/5MrX0xS9QACsD7BOB jd/T4QdtoAieA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v11 1/9] bpf: Add bpf_mptcp_send_info_to_ssk Date: Tue, 10 Dec 2024 11:31:38 +0800 Message-ID: <7e18b01d07f005b4934deeaf5af677d26a783680.1733800334.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Burst scheduler needs to allocate an array of struct subflow_send_info on the stack and then select a subflow to send data. In order to implement burst scheduler in BPF, this patch adds a new bpf_mptcp_send_info_to_ssk() helper to get ssk from subflow_send_info and sets its parameter type as ARG_PTR_TO_STACK. Signed-off-by: Geliang Tang --- include/uapi/linux/bpf.h | 7 +++++++ net/mptcp/bpf.c | 22 ++++++++++++++++++++++ net/mptcp/protocol.c | 5 ----- net/mptcp/protocol.h | 5 +++++ tools/include/uapi/linux/bpf.h | 7 +++++++ 5 files changed, 41 insertions(+), 5 deletions(-) diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 4162afc6b5d0..0d7a5846bd77 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -5795,6 +5795,12 @@ union bpf_attr { * 0 on success. * * **-ENOENT** if the bpf_local_storage cannot be found. + * + * void *bpf_mptcp_send_info_to_ssk(void *info) + * Description + * Dynamically cast a *info* pointer to a *sock* pointer. + * Return + * *info* if casting is valid, or **NULL** otherwise. */ #define ___BPF_FUNC_MAPPER(FN, ctx...) \ FN(unspec, 0, ##ctx) \ @@ -6009,6 +6015,7 @@ union bpf_attr { FN(user_ringbuf_drain, 209, ##ctx) \ FN(cgrp_storage_get, 210, ##ctx) \ FN(cgrp_storage_delete, 211, ##ctx) \ + FN(mptcp_send_info_to_ssk, 212, ##ctx) \ /* */ =20 /* backwards-compatibility macros for users of __BPF_FUNC_MAPPER that don't diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index e9db856972cb..10d3db6323dc 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -21,6 +21,26 @@ static struct bpf_struct_ops bpf_mptcp_sched_ops; static const struct btf_type *mptcp_sock_type, *mptcp_subflow_type __read_= mostly; static u32 mptcp_sock_id, mptcp_subflow_id; =20 +BPF_CALL_1(bpf_mptcp_send_info_to_ssk, struct subflow_send_info *, info) +{ + BTF_TYPE_EMIT(struct sock); + + if (info && info->ssk && sk_fullsock(info->ssk) && + info->ssk->sk_protocol =3D=3D IPPROTO_TCP && + sk_is_mptcp(info->ssk)) + return (unsigned long)info->ssk; + + return (unsigned long)NULL; +} + +static const struct bpf_func_proto bpf_mptcp_send_info_to_ssk_proto =3D { + .func =3D bpf_mptcp_send_info_to_ssk, + .gpl_only =3D false, + .ret_type =3D RET_PTR_TO_BTF_ID_OR_NULL, + .arg1_type =3D ARG_PTR_TO_STACK, + .ret_btf_id =3D &btf_sock_ids[BTF_SOCK_TYPE_SOCK], +}; + static const struct bpf_func_proto * bpf_mptcp_sched_get_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) @@ -34,6 +54,8 @@ bpf_mptcp_sched_get_func_proto(enum bpf_func_id func_id, return &bpf_skc_to_tcp6_sock_proto; case BPF_FUNC_skc_to_tcp_sock: return &bpf_skc_to_tcp_sock_proto; + case BPF_FUNC_mptcp_send_info_to_ssk: + return &bpf_mptcp_send_info_to_ssk_proto; default: return bpf_base_func_proto(func_id, prog); } diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index f768aa4473fb..791c1c0149ee 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1387,11 +1387,6 @@ static int mptcp_sendmsg_frag(struct sock *sk, struc= t sock *ssk, sizeof(struct ipv6hdr) - \ sizeof(struct frag_hdr)) =20 -struct subflow_send_info { - struct sock *ssk; - u64 linger_time; -}; - void mptcp_subflow_set_active(struct mptcp_subflow_context *subflow) { if (!subflow->stale) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 19a811220621..78a7cfb84c69 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -598,6 +598,11 @@ mptcp_subflow_ctx_reset(struct mptcp_subflow_context *= subflow) WRITE_ONCE(subflow->local_id, -1); } =20 +struct subflow_send_info { + struct sock *ssk; + u64 linger_time; +}; + /* Convert reset reasons in MPTCP to enum sk_rst_reason type */ static inline enum sk_rst_reason sk_rst_convert_mptcp_reason(u32 reason) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 4162afc6b5d0..0d7a5846bd77 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h @@ -5795,6 +5795,12 @@ union bpf_attr { * 0 on success. * * **-ENOENT** if the bpf_local_storage cannot be found. + * + * void *bpf_mptcp_send_info_to_ssk(void *info) + * Description + * Dynamically cast a *info* pointer to a *sock* pointer. + * Return + * *info* if casting is valid, or **NULL** otherwise. */ #define ___BPF_FUNC_MAPPER(FN, ctx...) \ FN(unspec, 0, ##ctx) \ @@ -6009,6 +6015,7 @@ union bpf_attr { FN(user_ringbuf_drain, 209, ##ctx) \ FN(cgrp_storage_get, 210, ##ctx) \ FN(cgrp_storage_delete, 211, ##ctx) \ + FN(mptcp_send_info_to_ssk, 212, ##ctx) \ /* */ =20 /* backwards-compatibility macros for users of __BPF_FUNC_MAPPER that don't --=20 2.45.2 From nobody Sun Dec 22 02:50:02 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 874A119DF41 for ; Tue, 10 Dec 2024 03:32:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801528; cv=none; b=exFafvNx2ePbZRWTmoVSraqAdSzIIG8dgCzgJ9SJX4PbcoaZmyJWPSIoHk9AYMJcM8gxjYv6QAnPi0JEoY/FWNsUydv7TQFJE6fDLsZwrJd6HZxk/9mgng5uinQHJOhX4nwkyts7ir6LdO4pQlasdkR3U4XC1GLXZ9dD0tOsq8I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801528; c=relaxed/simple; bh=Ae5ZluSOvGKGy4++0Dz1LYKoAm6vXOPxH/8pQHBeTqM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RcH1munD1C75rYfPdVJlcbJ4mmjXWI7bNlyTFDRYlms3VpFBQ601OQ6DruZtepcu/qxVkdlOWq22YVMDAzU8H0QmEWB1FJdYA0gQa+9eL1E3/yRLrd88ebSmadZ0j/i/WwMJWfbBw6WMgxoinczS6/ryF7F6REJFm2s0palB2HU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WZnA85yD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WZnA85yD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 309D6C4CED6; Tue, 10 Dec 2024 03:32:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733801528; bh=Ae5ZluSOvGKGy4++0Dz1LYKoAm6vXOPxH/8pQHBeTqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WZnA85yDHZF9oZH6Sqkmz+ILzfEzwDRn4LXS6Pc42SDRyVlw6vbcl8zqVQ13ZQ9ce 4lhhwn0uaVGmfy/PXMSTgvTww9n+gXSgVm+DvBwYOPYoKAukEamAsw3+LK3swKIYc/ hdGFr4a32+wD+0IkSF2VQCJulwZjui5zOg2dGapvoFn+8RLBssOdpAPmuu72chERKZ osnxlhRFSnY+akuLrCgLBPF4F55NvJ3UalX1T3PUrNDkpva3mCP11k8NISuTG4hUwC MvPz8GFsyT9ldvD+iONTGIgM42Tg5elLmOMuf+JFA8TaDOw8uFZoMNXKv22YJKInIg tk8+dOr7+6ZgQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v11 2/9] Squash to "selftests/bpf: Add bpf_bkup scheduler & test" Date: Tue, 10 Dec 2024 11:31:39 +0800 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Use the newly added bpf_for_each() helper to walk the conn_list. Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/progs/mptcp_bpf_bkup.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c b/tools/tes= ting/selftests/bpf/progs/mptcp_bpf_bkup.c index 296f0318d843..70c3a69d4a47 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c @@ -20,26 +20,16 @@ SEC("struct_ops") int BPF_PROG(bpf_bkup_get_subflow, struct mptcp_sock *msk, struct mptcp_sched_data *data) { - int nr =3D -1; - - for (int i =3D 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - struct mptcp_subflow_context *subflow; - - subflow =3D bpf_mptcp_subflow_ctx_by_pos(data, i); - if (!subflow) - break; + struct mptcp_subflow_context *subflow; =20 + bpf_for_each(mptcp_subflow, subflow, msk) { if (!BPF_CORE_READ_BITFIELD_PROBED(subflow, backup) || !BPF_CORE_READ_BITFIELD_PROBED(subflow, request_bkup)) { - nr =3D i; + mptcp_subflow_set_scheduled(subflow, true); break; } } =20 - if (nr !=3D -1) { - mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx_by_pos(data, nr), true= ); - return -1; - } return 0; } =20 --=20 2.45.2 From nobody Sun Dec 22 02:50:02 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF9E91C242C for ; Tue, 10 Dec 2024 03:32:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801530; cv=none; b=uj68sIhLSvrE4hJGksTG6NbXPYdPE2rBEGDDBi1jVRhEnYR/SoIiozTPooabnQqi5o673GuNyfb4lK0e1BNxgzPQ0xU/5gqhlC06Bg84KpK/tw9+tQ6FnBvG+PreWsi3KURkULz4A5XbBXH5Kfyn/boKpjhhnfB6m0XDH7FXwzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801530; c=relaxed/simple; bh=f2tjXufOMXq32hAWjBOmYOFogpGgwgMFndc3T1aP6Mg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JjocIW6sl3mbOpb32OBW4WyURH8573qfggs2HKm0K0ax6D2QcihYC0+OFFk6JsXyynxHIjb+BMlYoB7UWtl+xb1/6MdVvWN4JR/v+OwAF0T6bZtVlt3AdA81dMs+N2GUC9lj8LbtG2iAEAKXILM1INS+2363ulgSjR+J7XezNpo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fk7p7MLe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fk7p7MLe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A7F8C4CED6; Tue, 10 Dec 2024 03:32:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733801530; bh=f2tjXufOMXq32hAWjBOmYOFogpGgwgMFndc3T1aP6Mg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fk7p7MLekfl1AGTLWrsodeHAVyDhmKMgVC6i/N6Zdnb+ZBi4Cj3h0afhe+XTFJvab G/I7QeAhwRIExR2rOpaMaKn8x+Op0B55uPky/y74KVv+7enV1T2snQ5W/6dExqevKD UN+2aUqEnRIkV5CdVrjzjLHCbYV4U4j208p3NhHh0eRDTSGBf7UYE+5jF/OgIrBc9B A5VS6Rs+ZbTwZWHbsFdq8/71j+dOrsU20sDn5mxOLvpw+PP8F8E+OtLOUD/eeTgHUZ nRYfSi1VFja2nUvaDr9da5YWw8ynIbjVtQjJcMjhtErQVBWKV8UR3rTspcJZvcwO8Q M/w+H8VQeJOrQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v11 3/9] Squash to "selftests/bpf: Add bpf_rr scheduler & test" Date: Tue, 10 Dec 2024 11:31:40 +0800 Message-ID: <026738a87b4382abf8452e029a69c52eb9fd353b.1733800335.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Use the newly added bpf_for_each() helper to walk the conn_list. Signed-off-by: Geliang Tang --- .../selftests/bpf/progs/mptcp_bpf_rr.c | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c b/tools/testi= ng/selftests/bpf/progs/mptcp_bpf_rr.c index 638ea6aa63b7..cc9f73de1005 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c @@ -34,38 +34,35 @@ SEC("struct_ops") int BPF_PROG(bpf_rr_get_subflow, struct mptcp_sock *msk, struct mptcp_sched_data *data) { - struct mptcp_subflow_context *subflow; + struct mptcp_subflow_context *subflow, *next; struct mptcp_rr_storage *ptr; - struct sock *last_snd =3D NULL; - int nr =3D 0; =20 ptr =3D bpf_sk_storage_get(&mptcp_rr_map, msk, 0, BPF_LOCAL_STORAGE_GET_F_CREATE); if (!ptr) return -1; =20 - last_snd =3D ptr->last_snd; + next =3D bpf_mptcp_subflow_ctx(msk->first); + if (!next) + return -1; =20 - for (int i =3D 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - subflow =3D bpf_mptcp_subflow_ctx_by_pos(data, i); - if (!last_snd || !subflow) - break; + if (!ptr->last_snd) + goto out; =20 - if (mptcp_subflow_tcp_sock(subflow) =3D=3D last_snd) { - if (i + 1 =3D=3D MPTCP_SUBFLOWS_MAX || - !bpf_mptcp_subflow_ctx_by_pos(data, i + 1)) + bpf_for_each(mptcp_subflow, subflow, msk) { + if (mptcp_subflow_tcp_sock(subflow) =3D=3D ptr->last_snd) { + subflow =3D bpf_iter_mptcp_subflow_next(&___it); + if (!subflow) break; =20 - nr =3D i + 1; + next =3D subflow; break; } } =20 - subflow =3D bpf_mptcp_subflow_ctx_by_pos(data, nr); - if (!subflow) - return -1; - mptcp_subflow_set_scheduled(subflow, true); - ptr->last_snd =3D mptcp_subflow_tcp_sock(subflow); +out: + mptcp_subflow_set_scheduled(next, true); + ptr->last_snd =3D mptcp_subflow_tcp_sock(next); return 0; } =20 --=20 2.45.2 From nobody Sun Dec 22 02:50:02 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 782E8111A8 for ; Tue, 10 Dec 2024 03:32:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801532; cv=none; b=E7ILV3l+L6GrJDHx0rOdlD1zWtrVBSapNYlnnGgkxC4cWTOlUboJk3GAGY+ioiFxsNfy/I0MV/5nAnXX01mdixjNDhei7n5EIalU/qZkvE+ICD38R2HtEFvZacyMank0q+fvcaEB23NN7JROGUejWYE0k6NF1ne2J972/RR3pBY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801532; c=relaxed/simple; bh=ddTfnLgEZoI1Cw8aheiOu4s52mnraFeRRqdqvon/4/s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bABymAtVsI/kUg5PKUpKAZg7HIc8Y5WFTtnB6bEaa9rJAYedOqtf8cc11qdWA/fv5r4aFSdN8Aj9Bb7xbA84KAoU7LckaVXZgRAMq6VocPLG14EgvGawGZRXSvy6IpIxUA+penMMXSp6TeKgeKSmxHtaqt5A0559B8gHOfou73Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SnPaW1Ft; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SnPaW1Ft" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8320C4CEDE; Tue, 10 Dec 2024 03:32:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733801532; bh=ddTfnLgEZoI1Cw8aheiOu4s52mnraFeRRqdqvon/4/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SnPaW1Ft2zzOaEgu++B4Y5boB/ujgUF3LuZnSn48qzAn3/Yv/2Mltf6vyDXTjB43+ Y5zh4dyDELIqfjALdMGQ358gDwiNpyo6sJ4ExzIJ7DOa9afbNpVFSk2g2FsE5zqjwC ljFdcJdjtxYe2N51pGawkva8I3w2HgwdsC58ruGL/aXt0xYXq5jWxelOlWjsJ+Z5sK rMTdzquT70O9cN960RTtgkYxM3+bkxKt0n/AcZJm4V6EnTX3/Ayq1pE4E9FsY2neBv xJMCLeXJHwSrKH2VZFXh4HTb8WD1/nUMM3fs84/KunGFaI6zaE2JMoMnpg7Z+FyBLM GGr1TvfjurYOA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v11 4/9] Squash to "selftests/bpf: Add bpf_red scheduler & test" Date: Tue, 10 Dec 2024 11:31:41 +0800 Message-ID: <77166477ff86902f591621e8f544cff43ad63554.1733800335.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Use the newly added bpf_for_each() helper to walk the conn_list. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/progs/mptcp_bpf_red.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c b/tools/test= ing/selftests/bpf/progs/mptcp_bpf_red.c index cc0aab732fc4..ce19d604b898 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c @@ -20,12 +20,10 @@ SEC("struct_ops") int BPF_PROG(bpf_red_get_subflow, struct mptcp_sock *msk, struct mptcp_sched_data *data) { - for (int i =3D 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - if (!bpf_mptcp_subflow_ctx_by_pos(data, i)) - break; + struct mptcp_subflow_context *subflow; =20 - mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx_by_pos(data, i), true); - } + bpf_for_each(mptcp_subflow, subflow, msk) + mptcp_subflow_set_scheduled(subflow, true); =20 return 0; } --=20 2.45.2 From nobody Sun Dec 22 02:50:02 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F29FB1A0BE1 for ; Tue, 10 Dec 2024 03:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801535; cv=none; b=AgO34naG9B+nb2jb7pmmbC4+/bLJTt5kvIYDyrYJPyKWBy+i+LNElvVCQTGc8x4sW4uwG+hCsMtlk9ytnamaPSK+XghoAIB+ExtPI8en4mBFnpUEszcEQOnvEAZYhiT9XClZZyMkpXxGtI2zlJQjq3/lyCVpXCQlAzD1CqxNS8I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801535; c=relaxed/simple; bh=50O5atakWFEU/PZauLujbz1lfOIbAa3ZggS1EpKh1zg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q+6ei8ja73Pos3r7lsJWHQBJTnUifCR8t6dsMPumgRWxxCms/akuf8IaeR08hQHo+7UYx2LcSY0ETZhq9zr2k2aTijoG2V4N5EfiwSJouJERalV4Veh2szTy2vNpPzCWIM9gsOwf06/9rIVKmVT+4alaTtTOLt1SWI0Hc2h3Vc0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FYG6GLxi; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FYG6GLxi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2F3DC4CED6; Tue, 10 Dec 2024 03:32:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733801533; bh=50O5atakWFEU/PZauLujbz1lfOIbAa3ZggS1EpKh1zg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FYG6GLxiQ78iJd3ZBXm5R8lIE1Bso8DfZ6B3axMh87RyigT0Y/oy3CGofE7J3CbEb lY6SYkF2hkENaefdKOzhy4wkgKg4RzXO2mruNO3t2Lpj8SI8Pfuca0CxNFh5ZOLoak JDy4LYB+BWUSjtQeAOKMXmdtN+fJC6W2ukffZMaLP5+5ZEIIeYqwUwrxmuuZjSUQVB YHbhDhBPY9Q8pF60E2Xu1xkywzMR7WQmhFZHPhhc6TassiNagWnzPNmfW8dXgkUVgL 76c6b3y1c/LglFT+jykzpEzaD8VrgRJ8uRODKWMjKsMeTT+OrOF4WQj1Ajb8WBaNCD +XWCQtlAMiy1g== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v11 5/9] Squash to "selftests/bpf: Add bpf_burst scheduler & test" Date: Tue, 10 Dec 2024 11:31:42 +0800 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Use the newly added bpf_for_each() helper to walk the conn_list. Use bpf_mptcp_send_info_to_ssk() helper. Drop bpf_subflow_send_info, use subflow_send_info instead. Signed-off-by: Geliang Tang --- .../selftests/bpf/progs/mptcp_bpf_burst.c | 54 ++++++++----------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c b/tools/te= sting/selftests/bpf/progs/mptcp_bpf_burst.c index eb21119aa8f7..1cfc6d9bb458 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c @@ -11,11 +11,6 @@ char _license[] SEC("license") =3D "GPL"; =20 #define min(a, b) ((a) < (b) ? (a) : (b)) =20 -struct bpf_subflow_send_info { - __u8 subflow_id; - __u64 linger_time; -}; - 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; @@ -70,7 +65,7 @@ void BPF_PROG(mptcp_sched_burst_release, struct mptcp_soc= k *msk) static int bpf_burst_get_send(struct mptcp_sock *msk, struct mptcp_sched_data *data) { - struct bpf_subflow_send_info send_info[SSK_MODE_MAX]; + struct subflow_send_info send_info[SSK_MODE_MAX]; struct mptcp_subflow_context *subflow; struct sock *sk =3D (struct sock *)msk; __u32 pace, burst, wmem; @@ -80,17 +75,13 @@ static int bpf_burst_get_send(struct mptcp_sock *msk, =20 /* pick the subflow with the lower wmem/wspace ratio */ for (i =3D 0; i < SSK_MODE_MAX; ++i) { - send_info[i].subflow_id =3D MPTCP_SUBFLOWS_MAX; + send_info[i].ssk =3D NULL; send_info[i].linger_time =3D -1; } =20 - for (i =3D 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { + bpf_for_each(mptcp_subflow, subflow, msk) { bool backup; =20 - subflow =3D bpf_mptcp_subflow_ctx_by_pos(data, i); - if (!subflow) - break; - backup =3D subflow->backup || subflow->request_bkup; =20 ssk =3D mptcp_subflow_tcp_sock(subflow); @@ -109,7 +100,7 @@ static int bpf_burst_get_send(struct mptcp_sock *msk, =20 linger_time =3D div_u64((__u64)ssk->sk_wmem_queued << 32, pace); if (linger_time < send_info[backup].linger_time) { - send_info[backup].subflow_id =3D i; + send_info[backup].ssk =3D ssk; send_info[backup].linger_time =3D linger_time; } } @@ -117,15 +108,16 @@ static int bpf_burst_get_send(struct mptcp_sock *msk, =20 /* pick the best backup if no other subflow is active */ if (!nr_active) - send_info[SSK_MODE_ACTIVE].subflow_id =3D send_info[SSK_MODE_BACKUP].sub= flow_id; + send_info[SSK_MODE_ACTIVE].ssk =3D send_info[SSK_MODE_BACKUP].ssk; =20 - subflow =3D bpf_mptcp_subflow_ctx_by_pos(data, send_info[SSK_MODE_ACTIVE]= .subflow_id); - if (!subflow) - return -1; - ssk =3D mptcp_subflow_tcp_sock(subflow); + ssk =3D bpf_mptcp_send_info_to_ssk(&send_info[SSK_MODE_ACTIVE]); if (!ssk || !sk_stream_memory_free(ssk)) return -1; =20 + subflow =3D bpf_mptcp_subflow_ctx(ssk); + if (!subflow) + return -1; + burst =3D min(MPTCP_SEND_BURST_SIZE, mptcp_wnd_end(msk) - msk->snd_nxt); wmem =3D ssk->sk_wmem_queued; if (!burst) @@ -144,16 +136,12 @@ static int bpf_burst_get_send(struct mptcp_sock *msk, static int bpf_burst_get_retrans(struct mptcp_sock *msk, struct mptcp_sched_data *data) { - int backup =3D MPTCP_SUBFLOWS_MAX, pick =3D MPTCP_SUBFLOWS_MAX, subflow_i= d; + struct sock *backup =3D NULL, *pick =3D NULL; struct mptcp_subflow_context *subflow; int min_stale_count =3D INT_MAX; struct sock *ssk; =20 - for (int i =3D 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - subflow =3D bpf_mptcp_subflow_ctx_by_pos(data, i); - if (!subflow) - break; - + bpf_for_each(mptcp_subflow, subflow, msk) { if (!mptcp_subflow_active(subflow)) continue; =20 @@ -166,23 +154,23 @@ static int bpf_burst_get_retrans(struct mptcp_sock *m= sk, } =20 if (subflow->backup || subflow->request_bkup) { - if (backup =3D=3D MPTCP_SUBFLOWS_MAX) - backup =3D i; + if (!backup) + backup =3D ssk; continue; } =20 - if (pick =3D=3D MPTCP_SUBFLOWS_MAX) - pick =3D i; + if (!pick) + pick =3D ssk; } =20 - if (pick < MPTCP_SUBFLOWS_MAX) { - subflow_id =3D pick; + if (pick) goto out; - } - subflow_id =3D min_stale_count > 1 ? backup : MPTCP_SUBFLOWS_MAX; + pick =3D min_stale_count > 1 ? backup : NULL; =20 out: - subflow =3D bpf_mptcp_subflow_ctx_by_pos(data, subflow_id); + if (!pick) + return -1; + subflow =3D bpf_mptcp_subflow_ctx(pick); if (!subflow) return -1; mptcp_subflow_set_scheduled(subflow, true); --=20 2.45.2 From nobody Sun Dec 22 02:50:02 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A98E1D0F62 for ; Tue, 10 Dec 2024 03:32:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801536; cv=none; b=p9G7qYOXILevFSWusSrb8Lrqms/gUmZHlqWglZxsqtLesUhGGZhTmxqbCeuHT3AArj1I6ZgnFlvX/oYtqSmLFJFFmDo8bD7NFwa9S8nqbH8E+mvDsP44SLa5ddRdn9pkpnj/dTfm/VS6qsj1UxQhgcTSwhNtKIjb0TbNPuL4kXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801536; c=relaxed/simple; bh=c/nN0hAnbFaNg1uFbuo4jdpJfRpzQ9T6ME6dElk9r44=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OTHk4hYdTPLmVeWPcM5kHIgwsvoomZ+BS6ef3+hv6CPuByY3MeaeD2FTRsbuS7K+HHKoTVE2iPRd/u7+hVojV+wHleUCN2oXs5YcIakrMXS/8VCuN6HnLXs+tKUfwyWbe6Chwsa/fLk0P4r88hgDT+7mCjSJm/8tu8pTRhrj4hM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s69GF1WU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="s69GF1WU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C0B3C4CEDE; Tue, 10 Dec 2024 03:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733801535; bh=c/nN0hAnbFaNg1uFbuo4jdpJfRpzQ9T6ME6dElk9r44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s69GF1WU25fasAihX/St29JQNPod3eOZQJMZVNyQc1SvCNq4TpSlnTL0l+leo7CaG 9UMp+qsGw8zfrGA35N+JG/tqEI8vEZDDc740PkJMNcP1OkFm4hT4IIHsHxSoB5rTjS OjjV1mKfybhqXujBEV2fRSfmKkcdoVLgI3zgyqh7z+b7wIbSOtsi8YykTeRbBl+VKm NXW6HLxbWdwqcZab9e9QgIFtyFz+n6EZSGVoVm6Bm2/+nBgy2jPAPJxnCVlJVvAeps myoby5Ye4YukKscdeHWQzflyYdCiZaRTj+4/BRSFp+ry+/I99zo/O4p+z93Naysw5k 6l5b1DUr3nFTw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v11 6/9] Squash to "selftests/bpf: Add bpf_first scheduler & test" Date: Tue, 10 Dec 2024 11:31:43 +0800 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Use the newly added bpf_for_each() helper to walk the conn_list. Drop bpf_mptcp_subflow_ctx_by_pos declaration. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/progs/mptcp_bpf.h | 3 --- tools/testing/selftests/bpf/progs/mptcp_bpf_first.c | 8 +++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf.h b/tools/testing/= selftests/bpf/progs/mptcp_bpf.h index 3b20cfd44505..c393176496f0 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf.h +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf.h @@ -55,7 +55,4 @@ bpf_mptcp_subflow_tcp_sock(const struct mptcp_subflow_con= text *subflow) __ksym; extern void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subf= low, bool scheduled) __ksym; =20 -extern struct mptcp_subflow_context * -bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned= int pos) __ksym; - #endif diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c b/tools/te= sting/selftests/bpf/progs/mptcp_bpf_first.c index d57399b407a7..00cb4953c487 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c @@ -20,7 +20,13 @@ SEC("struct_ops") int BPF_PROG(bpf_first_get_subflow, struct mptcp_sock *msk, struct mptcp_sched_data *data) { - mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx_by_pos(data, 0), true); + struct mptcp_subflow_context *subflow; + + subflow =3D bpf_mptcp_subflow_ctx(msk->first); + if (!subflow) + return -1; + + mptcp_subflow_set_scheduled(subflow, true); return 0; } =20 --=20 2.45.2 From nobody Sun Dec 22 02:50:02 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9B2C111A8 for ; Tue, 10 Dec 2024 03:32:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801538; cv=none; b=omXP+EMvAyI3MKa0uZi3MKYUOoXWx4YfqQwmQC+vYnb8IXy75haemDN+/73TjAeMwiW6jRTW18Clwykb7LHjUpS3RyUMbQONXazf8Lbs7OZbpKOhPwwIrO0zdo4wNYFXy0eyAy7FmUX8khv6kcGnaS5yWoBOljWzKtldMA4Jb8w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801538; c=relaxed/simple; bh=wyrmivQNQCfbSFI4XHlRb9hYdqZQG4n+lfAtLYCea/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k8jhpqufV2mg2kmo7CJOa33AX0kshiFRYYKeG6P7xuyLTdrzr/y+KPvWmJBbZxHDrCN8ZpE3rJvqTGqp++vGqWkp1PTm85wnuTRIxY0q9b4jQ0U9S4ssUpj0H5cj9sGRksMlW+gStWueslRTekHAmWtd9fEsVMOBC83FHR0yc9Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lsWdQbcL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lsWdQbcL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 655D3C4CED6; Tue, 10 Dec 2024 03:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733801537; bh=wyrmivQNQCfbSFI4XHlRb9hYdqZQG4n+lfAtLYCea/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lsWdQbcL6nrylZq3cWkQE+3xycGx/cnmjPB4UHS/hylgS7cq5Y3d+rGNMF1tjkcMP SUjNg5azIVhEd2LLaPl/K2LtrGKEbexN8V9deWP6FvidPJGiALH4eTr8VHwezCjB14 K62TYleHURSMt1M1BiHWMpC79TZnWDsD562hskPlX6O9nxtzAao+bws81mHFzFpa9o 2bdfpbpNxyJYK/r+Dr4Fc1i+okdMLbq8WlLaBmiPr1iT9GDmejnK6yq+WBmCkU+k7X xXLqvYAnEFj8uNYCiYOD8ehaYQHj9afLEAYZpDdKYFR9jBQOAwMx+sTcRBkvIZ1D28 Y5U9iqaVw8ZjA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v11 7/9] Revert "mptcp: add sched_data helpers" Date: Tue, 10 Dec 2024 11:31:44 +0800 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Drop this patch. bpf_mptcp_subflow_ctx_by_pos and mptcp_sched_data_set_contexts are uesless now. Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 8 -------- net/mptcp/protocol.h | 2 -- net/mptcp/sched.c | 22 ---------------------- 3 files changed, 32 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 10d3db6323dc..8a9c7a91dd7a 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -305,14 +305,6 @@ __bpf_kfunc static void bpf_mptcp_sock_release(struct = mptcp_sock *msk) WARN_ON_ONCE(!sk || !refcount_dec_not_one(&sk->sk_refcnt)); } =20 -__bpf_kfunc struct mptcp_subflow_context * -bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned= int pos) -{ - if (pos >=3D MPTCP_SUBFLOWS_MAX) - return NULL; - return data->contexts[pos]; -} - __bpf_kfunc static bool bpf_mptcp_subflow_queues_empty(struct sock *sk) { return tcp_rtx_queue_empty(sk); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 78a7cfb84c69..1e6b6b85b850 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -727,8 +727,6 @@ void mptcp_subflow_queue_clean(struct sock *sk, struct = sock *ssk); void mptcp_sock_graft(struct sock *sk, struct socket *parent); u64 mptcp_wnd_end(const struct mptcp_sock *msk); void mptcp_set_timeout(struct sock *sk); -struct mptcp_subflow_context * -bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned= int pos); struct sock *__mptcp_nmpc_sk(struct mptcp_sock *msk); bool __mptcp_close(struct sock *sk, long timeout); void mptcp_cancel_work(struct sock *sk); diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c index 6da60e35932f..df7dbcfa3b71 100644 --- a/net/mptcp/sched.c +++ b/net/mptcp/sched.c @@ -141,26 +141,6 @@ void mptcp_subflow_set_scheduled(struct mptcp_subflow_= context *subflow, WRITE_ONCE(subflow->scheduled, scheduled); } =20 -static void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk, - struct mptcp_sched_data *data) -{ - struct mptcp_subflow_context *subflow; - int i =3D 0; - - mptcp_for_each_subflow(msk, subflow) { - if (i =3D=3D MPTCP_SUBFLOWS_MAX) { - pr_warn_once("too many subflows"); - break; - } - mptcp_subflow_set_scheduled(subflow, false); - data->contexts[i++] =3D subflow; - } - data->subflows =3D i; - - for (; i < MPTCP_SUBFLOWS_MAX; i++) - data->contexts[i] =3D NULL; -} - int mptcp_sched_get_send(struct mptcp_sock *msk) { struct mptcp_subflow_context *subflow; @@ -187,7 +167,6 @@ int mptcp_sched_get_send(struct mptcp_sock *msk) data.reinject =3D false; if (msk->sched =3D=3D &mptcp_sched_default || !msk->sched) return mptcp_sched_default_get_subflow(msk, &data); - mptcp_sched_data_set_contexts(msk, &data); return msk->sched->get_subflow(msk, &data); } =20 @@ -210,6 +189,5 @@ int mptcp_sched_get_retrans(struct mptcp_sock *msk) data.reinject =3D true; if (msk->sched =3D=3D &mptcp_sched_default || !msk->sched) return mptcp_sched_default_get_subflow(msk, &data); - mptcp_sched_data_set_contexts(msk, &data); return msk->sched->get_subflow(msk, &data); } --=20 2.45.2 From nobody Sun Dec 22 02:50:02 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2A8E1A0BE1 for ; Tue, 10 Dec 2024 03:32:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801541; cv=none; b=ebAQIPUnkjd2V7v/6AUDXxZ8AbtU7e1BqO7SyvDbmteD8ZLk1und4JUAUgsFvMJApuz78pf2Zi8v3K4Dueajtuba3BRc9ThDORTCNw8HZuDjwy5znK9UKi4hY4ZAVdojYU+Y5sYO/JEBW2v7JhaNF7q+uxQnlPyPD/jyfTjUL20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801541; c=relaxed/simple; bh=5IBg0zzlOEIp6c4dUinkZxwxyokgH0hk0VuGn7nIjvg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XYpo0WNG98KmCiRPMeCsBz3zKKwNCUCRv2AJIjD5+3IWFx9/rS9QhdGPZIfItM33AbyGx3CkG86NzcsjMWwtnsYjnzrFu+9gX8QA8+dAUWpnuTWhXW7L2xltqASioOkokb8HUuWG5280T5zxwiNteGIzYpPxmnbsn5g2RZJbmaU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YfB5EcWO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YfB5EcWO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 271FDC4CED6; Tue, 10 Dec 2024 03:32:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733801539; bh=5IBg0zzlOEIp6c4dUinkZxwxyokgH0hk0VuGn7nIjvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YfB5EcWOmszQdGupCvTGBzg//2tUTRvxIolV8A4GDr3YfXLcIAoLQYUrAMb/Q8IYk TK0xCxBtbi3wGs9IwTFG7i2sN+5Gt/M60KJlz1mjVl4wXPVZwsX06tFYEjiGqlWRCw hs7u4VIZ1X0MRnww3IUF2Kp18EtPHfKJ0eihz1ACBvzMmCs+ufM4CdK24cicau/UES ABeTc473q+BrcOtbCARzLeLhbkaYzbInFj+rB14f9xr6EOL8mNWS1NJZZGdp/CBb5T 3bKxemorvmNpAh4vEjz9rtsKGBJtZT8ilOmKMCha+Dq0clJtuirYjZSzJiSNeRIqC4 DgUohUDxwvTZg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v11 8/9] Squash to "bpf: Export mptcp packet scheduler helpers" Date: Tue, 10 Dec 2024 11:31:45 +0800 Message-ID: <5a05fc430573e3173336b401e7350740bcac38cb.1733800335.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Remove bpf_mptcp_subflow_ctx_by_pos from BPF kfunc set. Drop bpf_mptcp_sched_kfunc_set, use bpf_mptcp_common_kfunc_set instead. Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 8a9c7a91dd7a..1d1727ac1fc6 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -321,27 +321,18 @@ BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_next, KF_IT= ER_NEXT | KF_RET_NULL) BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_destroy, KF_ITER_DESTROY) BTF_ID_FLAGS(func, bpf_mptcp_sock_acquire, KF_ACQUIRE | KF_RET_NULL) BTF_ID_FLAGS(func, bpf_mptcp_sock_release, KF_RELEASE) -BTF_KFUNCS_END(bpf_mptcp_common_kfunc_ids) - -static const struct btf_kfunc_id_set bpf_mptcp_common_kfunc_set =3D { - .owner =3D THIS_MODULE, - .set =3D &bpf_mptcp_common_kfunc_ids, -}; - -BTF_KFUNCS_START(bpf_mptcp_sched_kfunc_ids) BTF_ID_FLAGS(func, mptcp_subflow_set_scheduled) -BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx_by_pos) 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_subflow_queues_empty) BTF_ID_FLAGS(func, mptcp_pm_subflow_chk_stale) -BTF_KFUNCS_END(bpf_mptcp_sched_kfunc_ids) +BTF_KFUNCS_END(bpf_mptcp_common_kfunc_ids) =20 -static const struct btf_kfunc_id_set bpf_mptcp_sched_kfunc_set =3D { +static const struct btf_kfunc_id_set bpf_mptcp_common_kfunc_set =3D { .owner =3D THIS_MODULE, - .set =3D &bpf_mptcp_sched_kfunc_ids, + .set =3D &bpf_mptcp_common_kfunc_ids, }; =20 static int __init bpf_mptcp_kfunc_init(void) @@ -352,7 +343,7 @@ static int __init bpf_mptcp_kfunc_init(void) ret =3D ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_UNSPEC, &bpf_mptcp_common_kfunc_set); ret =3D ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, - &bpf_mptcp_sched_kfunc_set); + &bpf_mptcp_common_kfunc_set); #ifdef CONFIG_BPF_JIT ret =3D ret ?: register_bpf_struct_ops(&bpf_mptcp_sched_ops, mptcp_sched_= ops); #endif --=20 2.45.2 From nobody Sun Dec 22 02:50:02 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2B201C242C for ; Tue, 10 Dec 2024 03:32:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801541; cv=none; b=eTNhL3lIAm0FMG1eX+lgEzphpFLDVBp1b7mYxkxZSV1ZmfZ5mB8vQDuN/OGmxe7EV/DdTDenLgwm84A1CjSPpokip1xf7HvrjQoexe8cRVtHIuOXOV1BMn/dO+yToDAKBKfBarX2AeOCKRTqqWj+Vtqn7+6rNb0et3qMjsS70bs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733801541; c=relaxed/simple; bh=6bhndwaaGpAVAk7F3FGG00oCg3g2+1FwNFY5REvMeE4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Im6HiJCEW+up2EdpIGeaRfHG8KpAgZJzgwhoum9ukYaFEDKyJBVnpE6K2llsA+m3yC5aVXnm6bjqh4AWLIm/WuZLjMEuXEBGmiHyNC2mSJQBj6RcxnJplsk1aQu6UIjFCxlKT86AsR5ZR+IfEulEYyDtmyJuShJ/KWN8MI2H6Ys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cHMtlgZw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cHMtlgZw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00136C4CEDE; Tue, 10 Dec 2024 03:32:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733801541; bh=6bhndwaaGpAVAk7F3FGG00oCg3g2+1FwNFY5REvMeE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cHMtlgZwjuLTde6KwnxXl5HF2dcXUEypM5cSDldN5Xc+Fa+bujQna+ipeYsUy5pDk sIOQQ+bvYPyfhegftWP+2z7Me+mdwZvK71ECfEDJNTAx6xpUh/Ararva3eoYahmxLL WnEZlmHhSazKzUg+U4EcxwLoSa8xGdAHiWmDE2BMVHfwPJvp2kqVR5wWsP9qhXsBUa sjCHY5UtnPgURzq0v2HKLhC5tL2sin5AGIEqLFIPOaZ6VhoJ+CT72PPUDnV3MNDLLd 3rnhe+D4HxOBztahdK3qCUu1nnPjPQl1v2SSKKtsR827QEtm5iKuBa69x1BSET5XXq Nq4hhP/tDDl6g== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v11 9/9] mptcp: drop subflow contexts in mptcp_sched_data Date: Tue, 10 Dec 2024 11:31:46 +0800 Message-ID: <471aac979f039d00e8bd0334e7b5a3ab8223b5a7.1733800335.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang The mptcp_subflow bpf_iter is added now, it's better to use the helper bpf_for_each(mptcp_subflow) to traverse all subflows on the conn_list of an MPTCP socket and then call kfunc to modify the fields of each subflow in the WIP MPTCP BPF packet scheduler examples, instead of converting them to a fixed array. With this helper, we can get rid of this subflow array "contexts" and the size of it "subflows" in struct mptcp_sched_data. Signed-off-by: Geliang Tang --- include/net/mptcp.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 814b5f2e3ed5..84d67947a517 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -104,8 +104,6 @@ struct mptcp_out_options { =20 struct mptcp_sched_data { bool reinject; - u8 subflows; - struct mptcp_subflow_context *contexts[MPTCP_SUBFLOWS_MAX]; }; =20 struct mptcp_sched_ops { --=20 2.45.2