From nobody Sun Dec 22 09:04:16 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