From nobody Sun Dec 22 03:06:05 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 5348C215F60 for ; Mon, 9 Dec 2024 09:49:34 +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=1733737774; cv=none; b=im/Z1mRFGszMY1Uq0FXrUXNX9vjDOzcAwAUIs4PSz/Qdzz2MFMzGEGuVhT0tbHRnucIeAH6U9J1qbK3nVLCpRNYTT5mhrxoaAMkKZl6B/2FekBxctjbSO1Nae9CPtYvSfR9Cui9TqPzlP2DrVuQ9bgodCQ+tAZ4Ppmh2BFONrQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733737774; c=relaxed/simple; bh=+0+LegOoavcu/Ao/6seLEq8YpRAosj+5JYBPDWdjb9c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bnaVZftqyXSK2TBmb6nwqjgvYMdiEqrf70KY3GAczJ3p4y92uKPERUwKvBcVVssPGuomgHKPMFg92m5Hi90/fdwwhbAyJzS/Ez7OFYf5bi6fc4T/oq/wMoar8mXq5/uef05uLPVzSnLc009uiJK9fJYR/IArQ98gjrfDXIRnAVg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IWKOJC/r; 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="IWKOJC/r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0643BC4CED1; Mon, 9 Dec 2024 09:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733737774; bh=+0+LegOoavcu/Ao/6seLEq8YpRAosj+5JYBPDWdjb9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IWKOJC/rodNwNGEMFfszSoaF+KOZoFYHafj+mWS5ELze+ZBajpETuun1mBLcWGQ9y YCuggKhnerccxFDDCi3Jr92KYaHuiTkehhCR8g3m/IDrrdqiEKQ7VkhxT8JNzMolGV 5OjNY2wo8B+RqYshyIuwRZ+Cze4CNUSzeXet8G5KsMuPoLotQ3gaH9WnRowIHY4cwc Q1kJJMjW/9fjqQ3FXt94zTGpGKs3zODmOp1s8LwLni35AiVIheum9fS2KXWDv5KQI3 bEBFF5iaQDAOSQHbwvvMGhMt4pz7xB4K8fswFbH6wHrWfq0P7na1ZIhElDJpOrbduE StN2DuFxImcCA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v10 1/9] bpf: Add bpf_mptcp_send_info_to_ssk Date: Mon, 9 Dec 2024 17:49:17 +0800 Message-ID: <593a41dd7a57de0933b55bb42f8faef577c9d75d.1733737459.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 03:06:05 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 4924121661B for ; Mon, 9 Dec 2024 09:49:36 +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=1733737776; cv=none; b=pwfshHT7w3drt7CAxTh9d1azQndchV0qcdfRErfikhGjcORsWoBDWOCqzSCV2vyEvR+tUzff17qZ24G5G2hGsRyaua21KIDA25Wo4gBVB2KJjOADDCzz+oPVWvPdao1BvfKxx6IAGunaY2VpezSJ+eMcMakOFIGQ0l/pJMWAGVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733737776; c=relaxed/simple; bh=Ae5ZluSOvGKGy4++0Dz1LYKoAm6vXOPxH/8pQHBeTqM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nONWI2S87oNwDue/+nhEDUIMbEMpojtZecI3Rwn0vZ5FNOWgn6HJoBnSW84OBUPTe8hnzOfl1DV+etEsJ5sIfTlKVb7WUM6flnj5OnXkZ7uYLOIlV0d8cJ2MuVwHWa2/7xr1mPKltgx2Tv+dHFM9pCgakMkKyJK/ZvevpYJZLv8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=af+qgvkZ; 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="af+qgvkZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2C22C4CED1; Mon, 9 Dec 2024 09:49:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733737776; bh=Ae5ZluSOvGKGy4++0Dz1LYKoAm6vXOPxH/8pQHBeTqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=af+qgvkZ3uUfodOq/JOjMGmLUhiJOhq1sqojvsQ2sVswmTpyBLFswVV7gFP+Vrf8X 8CuPmN1K90+L9KqDoRU1ylLeWFyVqz4ukNYZ3zDPo04idw0G+0kfQvuu34v1w3eEsk z5CxnMMw9byGfcornA7HxAMA++G0WiK4YoWEruxb9AsX43euFPNC1eRsDGjXdAJWt5 wXPJ3eD7lNlq9KfDFYIzKiZkweaQezM9jnBqZCyl3u3vhfUxWuaTld07ywmLmU7B60 LhQ3gzT806dm1y7/cu3vkyPctJfZgAsj2MtFSt7sGbaHV8Zi+qoMXgOdMnEphCraqj LPuscxddg8oLg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v10 2/9] Squash to "selftests/bpf: Add bpf_bkup scheduler & test" Date: Mon, 9 Dec 2024 17:49:18 +0800 Message-ID: <8de3f8f27d3e59da5c9cafcf908562d020966127.1733737459.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 --- .../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 03:06:05 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 739252165E9 for ; Mon, 9 Dec 2024 09:49:38 +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=1733737778; cv=none; b=NogVI/w9jjjlJ+bC4p23cOLQ1Liv5OkwF0ZFyRUErbR9Vie6rTrDCGUSG71OK7A9pG15K0HQOFooIiPUFgr5Pk+bbefF6+8zBuMXrQ9bAudn/fFpPb3FuJerHV0FO6Rvc9n3fIljvn87Dqi/rL+62A3E8WzoVgbNnJxFFsq84tM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733737778; c=relaxed/simple; bh=26lwXCmDkSh51Qah5xXDC6UXToBWAOQeulBdTYPSCH4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y8zITnC5yhhjMbOzac+UCnYMFI+zf6ufrxF9RPpYbinS0NUc88ku2UgAsuGpduxu+k/HuHYvReq/klNOfDE2J+2d3S/yBiiuRTMVsIIVGzSb8KLO5HRFjAlypPH2MKeinuPa+O/RimhD8IwXdmx3wK4XbOY4ULR4KKFuOGmNt+Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=atMR0Ut8; 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="atMR0Ut8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5BF8C4AF0D; Mon, 9 Dec 2024 09:49:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733737778; bh=26lwXCmDkSh51Qah5xXDC6UXToBWAOQeulBdTYPSCH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=atMR0Ut8xUy+hdBht4ay/DZ5rdCZ2pWOJtyadT2Upuq8ICf4W8RtGAbuHx3Vp5HzV qQKE6XJK66TsKiE98Ag1ZpaDkkpTkMe4gouNIXZudnpioVwXFut56ypCqr0QmE7JRW NIpnOyrHLS0YiZFEIRzTywaHBUOmRVSDJAIxf6zey9UIAc8O9fQHrvdNse5Tw3GW0i 2C4Vmy6wx0my14oAj9GDTzZs8kosKhv8D/VS9QJDCd4UxrCMZc/Q1jtD65yBrm+IeS uWEgYX5clPMpEBYCTk/Hnfu5RJOCl7vYZpanqIDWLwKglyF7FrPUWnHka6dyZRBq3w 9wBmBM+3MM3eA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v10 3/9] Squash to "selftests/bpf: Add bpf_rr scheduler & test" Date: Mon, 9 Dec 2024 17:49:19 +0800 Message-ID: <48393380a8ac873d9d115023c0da22f0dbb17218.1733737459.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..eeecbba8973a 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 bpf_mptcp_subflow_tcp_sock(next); return 0; } =20 --=20 2.45.2 From nobody Sun Dec 22 03:06:05 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 EA9D3216E35 for ; Mon, 9 Dec 2024 09:49:39 +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=1733737780; cv=none; b=clKjP9zemk4qF6jJwsQRMeTidsl0FnHthmX2AokvztbT0OQR4+JWzRqrdoYPdwkPgnlb7aR09rK/bksiAHUfJ9XYwwo6Urx03H0zoHbI0CGatBD3Wbj3c2UGTr/KtiFFPjih9pgPH16xOPI7QvoaJWo0zYQLVBmUbwh3GKdSzP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733737780; c=relaxed/simple; bh=ddTfnLgEZoI1Cw8aheiOu4s52mnraFeRRqdqvon/4/s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UuDAsnvt5lKwS5qpVTYaVsJ5MU4z4XnI2zriUOLgAgRr62CkPWOcJWF4cGOKnUnXajiHwRYqMkzDJAanqHkPf5m3p6wqZJnP+9AwMaFRocCB2x4BVeEec4uRn2u1QyzbtmtWtLZzUDzQGN6KglAKm8nZ2vE+/f1jX7yyXSTaZF0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kPXO6QVK; 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="kPXO6QVK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A06C6C4CEE1; Mon, 9 Dec 2024 09:49:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733737779; bh=ddTfnLgEZoI1Cw8aheiOu4s52mnraFeRRqdqvon/4/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kPXO6QVKtGZ67IxGEr2LJBktZedx9MFEejPX3YkqqRJhKmy5360bQ+4WVnyDz6KPa 6a9UjGnwL1h6zmKILn0lqJVcz3q1x2SlrtjDzrmoflYGTrI81Bt6THdHlE0ecC/atK znicXmdKzc4qBet94fxKrQecuFme/XLXe0v2u72SB9PbGsafiY8aefG/wYvcFCbAqt WrulmwvRuteYBN0+ViBWwD8QO87aH/ERjB6MJmkSGRmf8VyhHFGB38DQOp0jReCDbJ /DNKJ9NEMWB8dDDuFjz6H/TikAxTWtEJ4ws3M4o2uwxx+zg2a3j3Na8pyzqU4OAVI3 kkH43xy+A3A0A== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v10 4/9] Squash to "selftests/bpf: Add bpf_red scheduler & test" Date: Mon, 9 Dec 2024 17:49:20 +0800 Message-ID: <99b8ac9c5018ea16c70df18b93862a8fc5776fde.1733737459.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 03:06:05 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 08D212165E6 for ; Mon, 9 Dec 2024 09:49:41 +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=1733737783; cv=none; b=XSQvFm6dGSfJe1CcykSkYfcd666F0VZUXnvVde5qsVEjq8C7euQPBNX8wRwxAfGkdOi+MOSnp6uoJRgLK7TC5aQjBM+a73pTAEp6mT+cFnGpBziYiguXhDBwXE51Ax1n9ObQ6bJiDotHfFno6nqmplajnCPb6P50s6gLNoc3BWQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733737783; c=relaxed/simple; bh=c2fcieJmHCwvULCf+oQbFj0BSemqM4fYSiw7Viduu84=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ITdE0HaIswijY7dmQoKADksjTOm7SYXuXHiLEt8eWTTiZKzL1Y6IsQtnv9f5ac35ezDyHShRhfO4K67Gh1hfVRPxBKjKUSCkmzrgh5Y1B/4kvhFz+ipCG0y7G3sOJzgKtHfvmWrS+FtJ9ECotS7VZ7rEz/Yx0Hq9YTt4vqa8Hj8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b/O30fiP; 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="b/O30fiP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 794E8C4CED1; Mon, 9 Dec 2024 09:49:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733737781; bh=c2fcieJmHCwvULCf+oQbFj0BSemqM4fYSiw7Viduu84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b/O30fiPbnUWy5i/qhukLqZqcHaNh8V/bZo/6OxuGVGZQFyE3pttU0Dti2LKxtRa4 3OzjedEuJiVhbqa6IUthIIJTS4i3qN6keQ0GNVoUdVGtboSicDhIQmROBTO3o4gzq1 63pOxYx6ytXc84fj9XsPGb/M6lajoFju53oXFBPKKqGkG3H4n+yGIofDSwz96fT5LQ ehodebuqnObZPhAn35dgEiEQVHslbELZ2cuiistbH7fjIQJDpIb4xARMhXM/qgiyGU wv6lfaY2UjsXBSlMbSHQeLCef9YKHchHM/94lAU3B1F7vjpp8eRuynxXzIrlsLo2zv z6cbwbdZf5DhA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v10 5/9] Squash to "selftests/bpf: Add bpf_burst scheduler & test" Date: Mon, 9 Dec 2024 17:49:21 +0800 Message-ID: <339006a189bf463eb598c35fa3fc1c061f0b0d75.1733737459.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. 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 | 62 +++++++------------ 1 file changed, 24 insertions(+), 38 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..71094790efaa 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,20 +75,14 @@ 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++) { - bool backup; - - subflow =3D bpf_mptcp_subflow_ctx_by_pos(data, i); - if (!subflow) - break; + bpf_for_each(mptcp_subflow, subflow, msk) { + bool backup =3D subflow->backup || subflow->request_bkup; =20 - backup =3D subflow->backup || subflow->request_bkup; - - ssk =3D mptcp_subflow_tcp_sock(subflow); + ssk =3D bpf_mptcp_subflow_tcp_sock(subflow); if (!mptcp_subflow_active(subflow)) continue; =20 @@ -109,7 +98,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 +106,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,20 +134,16 @@ 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) { + struct sock *ssk =3D mptcp_subflow_tcp_sock(subflow); =20 if (!mptcp_subflow_active(subflow)) continue; =20 - ssk =3D mptcp_subflow_tcp_sock(subflow); /* still data outstanding at TCP level? skip this */ if (!tcp_rtx_and_write_queues_empty(ssk)) { mptcp_pm_subflow_chk_stale(msk, ssk); @@ -166,23 +152,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 03:06:05 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 A76A62165E6 for ; Mon, 9 Dec 2024 09:49:43 +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=1733737783; cv=none; b=ADy3Nm9WdUx5GCwX2HqnQb/eyDsE1po8H5Mr87wmr3Xv24iYzGnBJLoVmwdjnj8aQjhzA4acbcF4wgdmP1M/DOjUQmQ/0a0KfsxqlkOWIy1At5duGfx5YtD021QYivAcxL+/OfGB9oT69eYK0jL5b9uCwmx40HrpZHkhsLTdVyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733737783; c=relaxed/simple; bh=c/nN0hAnbFaNg1uFbuo4jdpJfRpzQ9T6ME6dElk9r44=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TS8UFDTMksDwv7FP6qRMLa4SZPaF6wu8h+FPk7Ydxg9CkfXfceCqNLqC4Dbg1Fv1ZR89H1iqCdrlYG5q0QUscPEsDKrPTPM3FCUfacrV0gyZAPsBqMY3Emp2E+RmJtEBOxuI5+YXLD4PfR1ztvhwEyX4uB95MHA3OG+ZZQUtY54= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T5pyBc2v; 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="T5pyBc2v" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52F3FC4CEDE; Mon, 9 Dec 2024 09:49:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733737783; bh=c/nN0hAnbFaNg1uFbuo4jdpJfRpzQ9T6ME6dElk9r44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T5pyBc2vCbAyon29IBtd//JXI4Ns7MRLPMIgVBvNCPQKyPMnreF2dwl7KDusV4ryI 1dDgZgxOqdTup9RlKl32sTBklfshE6CydjXK1C4LSPTTXAFvSy8qrvHcAO23Nsp7Mf qQ6rhOqkj9VqNAACM/d85fOi6tzdAgO174idAvJ8IBh1FI4FUGd1k2soSBPKannpXR ERgu41coVX3kibC687oFOyUixvoew8fju8aUzfGdrGDLCNKhJAxyIeTBnfxK6XonSI RrnUQAB5QDRgcJhPhSbowF6scD+b2uBE2kddvKKODhs1VRpxDYq6gcSXwlkGP6KzGW P9feVw33iG+wA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v10 6/9] Squash to "selftests/bpf: Add bpf_first scheduler & test" Date: Mon, 9 Dec 2024 17:49:22 +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 03:06:05 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 830FD2163B8 for ; Mon, 9 Dec 2024 09:49:45 +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=1733737785; cv=none; b=qjlb+A+Gq4xADg6gHRTzo1/CTnw5EXcaoT7x3mc8tpZ3j7YV1qnxz8S1OyV5Tjat/1X+SJmxSibvZFBDtR3L0GV2dsBDjzi5ND90yUp5hwTcfHBHuwzT6w5H4BpASR5cV2umHf1purBjUUEohsJnYVUnGtll1NN6fEdTVIlIxRA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733737785; c=relaxed/simple; bh=wyrmivQNQCfbSFI4XHlRb9hYdqZQG4n+lfAtLYCea/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C+6ODs2K7ENjWFwra3kAxlrHOujC5nSPjMoXHZFKEls+Knv8VB4wVrAohvMS0JMZ5znJSz1Fq4m1Vzks+Odm4vDnwG49pVn5R0jIMs7hYVOkuSCQUeg7HBq89aZO3BktbIlGWWXA6t8O0WN3rXCU0wp3WM8ID0++gwAkAcy5J8w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sOg1dx+z; 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="sOg1dx+z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E991C4CEE1; Mon, 9 Dec 2024 09:49:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733737785; bh=wyrmivQNQCfbSFI4XHlRb9hYdqZQG4n+lfAtLYCea/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sOg1dx+zpT6GbdqxfKZeQONH0K2b+nIct31AzQ9SmpZT+V4Mx2FSKYT4R15EX7ryc VM9vec+WyITOHpZoxOdwVguYxUxZ3lfko6D+dUIIXiZ0kDOByjJFLAuPyETjR8EXT2 IxooIcNokBml9G7kCQDjY1Gv9Rx8sCnoimrqf2ptarzAeV/CC05t2nLH36CyyRUwqy KLEVgZx1Ovdn1VKFq1Dk1IbPGOW+DwgRsglogCNRK/ehDN08txg5nBdvdy/P27H8h2 UML+0yk1iS7wmLKdwgd2F+KwgYWEthJxKyfaivEtG7jqq/zFhLCkviv99kdjXDSsdY dmwP6EGA5g7ZA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v10 7/9] Revert "mptcp: add sched_data helpers" Date: Mon, 9 Dec 2024 17:49:23 +0800 Message-ID: <6de10177907a606dfccb8dd6dd7be0d246b8299a.1733737459.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 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 03:06:05 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 88F30215F60 for ; Mon, 9 Dec 2024 09:49:47 +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=1733737787; cv=none; b=Ko0x2fj/gdvFT8bs7+y8eA8b4SLN9QVqoKfBzXWxnripaiT8i14RtAr00UteOtcyacE2u9tZfFYNbcp0HbkFvxBwioo4tsvRrGTMe1CYSlseUwZGiBuafcQcfpup+x8ewTbeuRsDy0Gj8ILJhUiWW+/m2qGw/bNeKq2PQ0smVQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733737787; c=relaxed/simple; bh=PuHzt2847OjwQRCWTngW5c85m+cVxG/nquJ+I01eQNM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YxAZVgfgMl6W68n2PqT8AtQPhSwJ5iKE763t3veh81lrnQwM7SY94SIeiNPrmQR1sI4ZmiJo+i8fLywOcyV0I21kd+XCxVxwHahuOs5xYmAfbCUvCfDxJ88s4C1y6VJzs35JKqe/h1g2QYTBK2e5r0Q6nqrAn31iEU6uonX+MYI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QHHGlEe2; 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="QHHGlEe2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06323C4CEDE; Mon, 9 Dec 2024 09:49:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733737787; bh=PuHzt2847OjwQRCWTngW5c85m+cVxG/nquJ+I01eQNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QHHGlEe21FI1m3ACKg2W2ijDXZdEVK7FyUvjecbRZzvwA2L3Dk8rOk6+0CkOpLw63 3SO0m5GQcp4u14hOg1Jut6MK6jEUofcR+t43sr+cZC1KF4ijN8nDQgVpkTEplSZxzR lU6xcIv+Df8ZWWZNes4CjX39TmuXOomQOMlnmXQTF1yB6TpoC8wi5M5Owm2wUmNZoc FNX4hlAFmQClMrxWEE1C8Bq7i/5XfD+7bFfnvfyXSlHkKPXoC7oyoW0TsWecP8GVYw q80lIadPrQkE1vOtlh28y7lBY6KBSl1S/XRDYzNbMKyupS+sGRZjD5W0TJQSRa3H/a tkMeH0aFVh94g== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v10 8/9] Squash to "bpf: Export mptcp packet scheduler helpers" Date: Mon, 9 Dec 2024 17:49:24 +0800 Message-ID: <1a55c3255f814aa2df35ae7f2e5c5a8b7d9926a6.1733737459.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. Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 8a9c7a91dd7a..025b2af33f28 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -330,7 +330,6 @@ static const struct btf_kfunc_id_set bpf_mptcp_common_k= func_set =3D { =20 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) --=20 2.45.2 From nobody Sun Dec 22 03:06:05 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 144B72163B8 for ; Mon, 9 Dec 2024 09:49:49 +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=1733737789; cv=none; b=cvs3+x0GUD6N1RD2ZsC4g37r0SIO0q3hUjLA+TCUi1ev15EOgSpkAR62s+uMPb0kG4PYb+xufIblJo1RHyWknxiOTVMmRLLcfoK4+1P5Xpu7NDCjHxmcYqoe6gbjUvUmrHfTQ+5wCiIktuI0hUkLwz6BqvB/x+pUD46+zMZRHK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733737789; c=relaxed/simple; bh=6bhndwaaGpAVAk7F3FGG00oCg3g2+1FwNFY5REvMeE4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KrKXAoSoDdb94kd9Z1CfrOhVKOpu1t5Uc2jg2er7vtU9FV3/OYiIk0SRoyJbDuW9bZH3R3EKYMl56szaCyrjnWy6ornQEHjvJLEiprMCDSXswL22jDXSL+1+Lmj2A+GhxjfpUSgks+df9+WHuGYfnxAjVoNfHlFOmqC5b8h1jFA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Wwrr+9ku; 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="Wwrr+9ku" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAE5AC4CED1; Mon, 9 Dec 2024 09:49:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733737788; bh=6bhndwaaGpAVAk7F3FGG00oCg3g2+1FwNFY5REvMeE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wwrr+9kuCYseGeCoRVKnTvyfuWUR9jJETnjaRBEDprhTCqbZ8E8KcDINvjN8e+ZZb 1iRaK51ecktD/BLbJ18GLsPfe8wZG4MSp/YVWPijzAG4ke4ujMxW+zeU5H888PEvWD LpO84qjRcp1ScVrKIvkptx9TW+DpckJ7FZxIH6RQabcIiqVhUdOhYS/V2aAgaFzN64 UinDDiZrpDlijkNvunC6Fm+jZUvU+rUwhvsvpeVB6ufEMzLJvv/iBNMVzNmlFZApXD FBgXv07ztdXDyAg1gkk4UZBVYu1I//Z/PN7T+KtKN8tVri+QN9pA/C0V1LN/6Zu3Zx k70ePD4PleohA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v10 9/9] mptcp: drop subflow contexts in mptcp_sched_data Date: Mon, 9 Dec 2024 17:49:25 +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 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