From nobody Thu Nov 21 11:36:44 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 7F5A93398E for ; Wed, 30 Oct 2024 06:10:55 +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=1730268655; cv=none; b=OgXLLSXeURlN58dOtgAJQdYh52OPhjyP8BXxOHRsq7kPvOx1EmKmdZQP7PyY0DN4rAw7MKrAQ/Q7Ovi1ZdvrUOMS8XRPXoJKqtZpfG8FaMJ4VTw/zGzl4amd9Nh6ax98TCqgwyCD610sJJfuucMUF1F8TH5G/654qA9LHKxuP8w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730268655; c=relaxed/simple; bh=qr2KDiGNOKDo25wAnh6k8E0UvGHjTRgmthFXxzi1AN4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GggWvfUgMqG1G32OohtQfe/j1F638mgJ2dzzV7sbPx/Z2WtoM/YqS/6QVmZBf14P2exT/3/n8OgCZIj4Mso4V5jZxQnsk93tX0Vss+qm60bHnS9VOXbVlxk8gkQiBw6jTWi1yQVjMIYRr6wq1ysRkvMyAMzHYXyktMaXCAvcUuc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZzDa4+2e; 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="ZzDa4+2e" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8A65C4CEE4; Wed, 30 Oct 2024 06:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730268655; bh=qr2KDiGNOKDo25wAnh6k8E0UvGHjTRgmthFXxzi1AN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZzDa4+2eW+6lwA5z2tkB8umZQVPciNOB8f4riVaR8SNHM8ACmgjoanhxv1vQ65ovu epay7o9TaUwqa+e/3weHyafouI0Z2WWKcParSTRr6hraSjnJkwTlHFQAqmDHsHxy6E f7+yGGD8U8Wfvlb6iRYqcMBnRNRm457DHc7lafzy6kKHWE8sTV09pldZR2q4WLAyqy SJElZZsuoYdAxx+C4mteSXmHrTFQ7UGTshBTM4y6Dxnv1N5dHfLtE5M8CXedRY25kP inSyog6pA1ybfpr3e7ie0qVezv1hYbDamqUfEcB/CU58eJ3I2VZqWzSimaE50Ku6Tn WkU/bM7wPMrUg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v9 01/13] mptcp: check sk_stream_memory_free in loop Date: Wed, 30 Oct 2024 14:10:25 +0800 Message-ID: <85e54452f647a887cdc1643629d06e017c3eef54.1730268415.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 In order to make it easier to implement similar logic to the burst scheduler in BPF program, the sk_stream_memory_free() check is moved forward into mptcp_for_each_subflow loop. Assignment like "ssk =3D send_info[SSK_MODE_ACTIVE].ssk" is not allowed in BPF, so bpf_core_cast() is used to cast it. But a casted pointer can't pass to a kfunc (sk_stream_memory_free). To solve this, In BPF burst scheduler sk_stream_memory_free check is moved forward to the position before "send_info[backup].ssk =3D ssk;" in bpf_for_each() loop. To keep mptcp_subflow_get_send() and BPF burst scheduler code consistent, this patch also synchronizes the change in BPF burst scheduler into mptcp_subflow_get_send(). Signed-off-by: Geliang Tang --- net/mptcp/protocol.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 21bc3586c33e..2ae9b8012dcd 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1460,6 +1460,8 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock= *msk) =20 linger_time =3D div_u64((u64)READ_ONCE(ssk->sk_wmem_queued) << 32, pace); if (linger_time < send_info[backup].linger_time) { + if (!sk_stream_memory_free(ssk)) + continue; send_info[backup].ssk =3D ssk; send_info[backup].linger_time =3D linger_time; } @@ -1482,7 +1484,7 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock= *msk) * to check that subflow has a non empty cwin. */ ssk =3D send_info[SSK_MODE_ACTIVE].ssk; - if (!ssk || !sk_stream_memory_free(ssk)) + if (!ssk) return NULL; =20 burst =3D min_t(int, MPTCP_SEND_BURST_SIZE, mptcp_wnd_end(msk) - msk->snd= _nxt); --=20 2.45.2 From nobody Thu Nov 21 11:36:44 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 201283398E for ; Wed, 30 Oct 2024 06:10:57 +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=1730268657; cv=none; b=jP3JrDqxS1bSPC9pxDDb7kkKAx21DWOEpcaeuaCIsHGqoIoBMSRaddLWhh66swKSRmYSZRQkbtuNv+Z9EtzmioSNEvuO8RP9J5AlOkl7blrxhjgwuHe5StzZvEZ19A6HV3JjcpL6sxYx91MRUXqorTFyQ+GhiRZASvxCDcPI6qw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730268657; c=relaxed/simple; bh=XnuoyV7zowI9ZX1VC6hl8pO8+ML3mKOfidjIwBJeyTs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d10PrPFnJABWMz8GFvOYZg6qpTNLYSZ1lARSkRPehW6UdYC2Vgq/CzYScFLrAu9T3W1DP/5DfXPsM1ojI+pl67wHalyjc/j5L8GDaXRleoKXLF0JRrmmpKtlYu3PRBBe2RNBWRAEfdkopJjXVp+e6PXLFmDne+iRUCYYgsl2Dwk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gTON/jhW; 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="gTON/jhW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2814C4CEE8; Wed, 30 Oct 2024 06:10:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730268657; bh=XnuoyV7zowI9ZX1VC6hl8pO8+ML3mKOfidjIwBJeyTs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gTON/jhWXfLbFRfEaw2D+lFFV3wIKQHf2S0+EN12Bt9P1dC/nzrkfCghG3nr5LHrG hnvhF7oDwDIzcvYB2bFdP6PG+o7swmcqKl54OK1xV4OeMngZzsE9H7nXEmuosA8Lvq ayUK+0wYqPL0ANW8oPWW+GdqMJHf/l4pFy+tee9htvG3yc6gIwzl/HAqsaUtCTL/RE IRHMsUU5fUlFUMNP4dsdBvew8vscPD7U9MM6dfZ5567E3aH2Snkan0oHmLJq78d7Rj SAGLXiC3nBCAfLzyuwdPh+5ytJ2yDXi6CnnBY3x1w6UMvpr2pta5o5Zz9d87OpZ1e8 l6k+siRdp6PtA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v9 02/13] mptcp: make mptcp_subflow_set_scheduled inline Date: Wed, 30 Oct 2024 14:10:26 +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 Now mptcp_subflow_set_scheduled() is no longer used in BPF, but only in kernel. A new mptcp_subflow_set_scheduled() helper will be implemented in BPF specifically for use with BPF. To avoid compilation errors due to duplicate names, this function is made inline in kernel and moved into protocol.h. Signed-off-by: Geliang Tang --- net/mptcp/protocol.h | 9 +++++++-- net/mptcp/sched.c | 6 ------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index b4c72a73594f..ab4e88b40efc 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -750,13 +750,18 @@ void mptcp_sched_init(void); int mptcp_init_sched(struct mptcp_sock *msk, struct mptcp_sched_ops *sched); void mptcp_release_sched(struct mptcp_sock *msk); -void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow, - bool scheduled); struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk); struct sock *mptcp_subflow_get_retrans(struct mptcp_sock *msk); int mptcp_sched_get_send(struct mptcp_sock *msk); int mptcp_sched_get_retrans(struct mptcp_sock *msk); =20 +static inline void +mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow, + bool scheduled) +{ + WRITE_ONCE(subflow->scheduled, scheduled); +} + static inline u64 mptcp_data_avail(const struct mptcp_sock *msk) { return READ_ONCE(msk->bytes_received) - READ_ONCE(msk->bytes_consumed); diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c index 6da60e35932f..73a24b9c96ff 100644 --- a/net/mptcp/sched.c +++ b/net/mptcp/sched.c @@ -135,12 +135,6 @@ void mptcp_release_sched(struct mptcp_sock *msk) bpf_module_put(sched, sched->owner); } =20 -void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow, - bool scheduled) -{ - WRITE_ONCE(subflow->scheduled, scheduled); -} - static void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk, struct mptcp_sched_data *data) { --=20 2.45.2 From nobody Thu Nov 21 11:36:44 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 A048B3398E for ; Wed, 30 Oct 2024 06:10:58 +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=1730268658; cv=none; b=lNodndGPgR7psC1GT3vrw6zf+m2CezJK0Im3YxFhCelTogH0abuJsms1c2ruums74DAm5RbEDvP6soWJqloDKXnL4Wo05ShQd/cp8tpoGp+5OHSvKFdAeVwCvjAat5cVEinrc4nBk1wQxLWT3YwlwW9Jd3R7MldkBoKfO9r5NQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730268658; c=relaxed/simple; bh=bgcJI9o+HDpsRmCDdCwRU187zlp71oMZqvGjnM7fDJI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=es6LSh4F0eDr0gpGmIDr8x3vxWdSBPx6rmxG6uXjp0JNI6x2cxUwz85lcdcis7aPTKbq9OCQtG76F01ulo1sJBSgQS3iLfMw0Bk0Eh5XYhquM9MTccayx7gJzxvZaf+CnUwhjvpeQFeXUYGHt2mGrU/upeAPSUoJIxlrDNUEpxE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XT4TFGgu; 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="XT4TFGgu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83CD7C4CEE6; Wed, 30 Oct 2024 06:10:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730268658; bh=bgcJI9o+HDpsRmCDdCwRU187zlp71oMZqvGjnM7fDJI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XT4TFGguSlB8XCAqRnEuWGeUYFHELAAk6tk70KpR6z/3tsCeWbRtTUiGkFZyLdTd/ dUhtB8jpjFWkYQFiGLUAa6p4s6KHOVwXb9LAhBAi4/gvjPg86mBXPIr/IQdgH/Mvjy PY7uuFx18gOQAInY9hzas5cIRWLcK7Q6lKggj4lEduBzaHqwHhRckqszD7IC3REeOy cBxlvcu0Zbau8FxJWxc+gzqX2vFuXvBDbZRoGFBwWDC7zZYckhluz9rg5u6rlIY/m5 fgA8OIhBtfds1eJ18z8iJb0HjZz4Ti1yiBF3o+6P2EzypSaiTSCBLqkozWRtlF0vZ/ iqo2p5sXbMuwg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v9 03/13] mptcp: add mptcp_validate_scheduler helper Date: Wed, 30 Oct 2024 14:10:27 +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 New interface .validate is added in struct bpf_struct_ops recently, this patch implements it as a new helper mptcp_validate_scheduler() for struct mptcp_sched_ops. In this helper, check whether the required ops "get_subflow" of struct mptcp_sched_ops has been implemented. Signed-off-by: Geliang Tang --- net/mptcp/protocol.h | 1 + net/mptcp/sched.c | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index ab4e88b40efc..46bc7adb4763 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -744,6 +744,7 @@ void mptcp_info2sockaddr(const struct mptcp_addr_info *= info, struct sockaddr_storage *addr, unsigned short family); struct mptcp_sched_ops *mptcp_sched_find(const char *name); +int mptcp_validate_scheduler(struct mptcp_sched_ops *sched); int mptcp_register_scheduler(struct mptcp_sched_ops *sched); void mptcp_unregister_scheduler(struct mptcp_sched_ops *sched); void mptcp_sched_init(void); diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c index 73a24b9c96ff..d7be9c453488 100644 --- a/net/mptcp/sched.c +++ b/net/mptcp/sched.c @@ -71,10 +71,23 @@ void mptcp_get_available_schedulers(char *buf, size_t m= axlen) rcu_read_unlock(); } =20 -int mptcp_register_scheduler(struct mptcp_sched_ops *sched) +int mptcp_validate_scheduler(struct mptcp_sched_ops *sched) { - if (!sched->get_subflow) + if (!sched->get_subflow) { + pr_err("%s does not implement required ops\n", sched->name); return -EINVAL; + } + + return 0; +} + +int mptcp_register_scheduler(struct mptcp_sched_ops *sched) +{ + int ret; + + ret =3D mptcp_validate_scheduler(sched); + if (ret) + return ret; =20 spin_lock(&mptcp_sched_list_lock); if (mptcp_sched_find(sched->name)) { --=20 2.45.2 From nobody Thu Nov 21 11:36:44 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 A1CED1D0F51 for ; Wed, 30 Oct 2024 06:11:00 +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=1730268660; cv=none; b=IEqvis1wEyeKi/O9JZoEiA/cOdZVrgaXktTH6VWHVNjfcZGjCYvw/X0XP51mSYo81e+bQl/U0mthr/9QRtGIVT0+wMRHhfZszHL/jaGXR6uuYINf+OCvgwe6Xq70AtCacO4P6hb9/Ihqd87Plk+KQT1hUkwW79c2SOWF8IfRHKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730268660; c=relaxed/simple; bh=dJcPCgbGiTa4yy5psNCb78HvU99dRnZgn8tP3b+U/b0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kVK9+Y3E+X8KF4cc9ti9Mg2nN5/rwzitXQ44+4wCoFQvogy4K4ohnHLekxsIP0050pW/IRsux3uoAS/SdBHVccvGSaL38VnQiiTubCvKVJSCTH+Mp+L1KCAtJnwuRIKfnJ5MvoVFiwnsFXkvxdjlu6kvlJJ2niHaRNgqsIx3JHo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t4S1GwW+; 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="t4S1GwW+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C1C8C4CEE5; Wed, 30 Oct 2024 06:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730268660; bh=dJcPCgbGiTa4yy5psNCb78HvU99dRnZgn8tP3b+U/b0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t4S1GwW+Stb+68YU6Nm7QF+/p0iAPDrLdQR5H2VXYfLxCn+Pih7hx0G+5LcbI6JAv o2FiWvj1M9EtYOHl2tOSYQ1WwgBMbtL+SJOdP3dtSF5OAkxWVeodkMAo+EDGYQWWc5 N2aas+DrMNKOcHwDwVs2mjEdxbnmSn2pQD+jBDGP3PtI28cX8iESDuRD3Id7dmfuPN QSBKmjWvNVc5RJxppSnjuHn1Ggh7Y88R5X2n3X0++qjqnsZ7CFZ/8CVvVc4vOtx/4o 3ipjnNd8pYH7vEvFapRdM48ABWgmwQW8XqZazTIqbgE8HHMtGGZDHyNUj5wlSKsNRG PXsoS5YMUtLLw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v9 04/13] Squash to "bpf: Add bpf_mptcp_sched_ops" Date: Wed, 30 Oct 2024 14:10:28 +0800 Message-ID: <9bd1f2cf77ff6be354c89f37cefb37bf981ee1e9.1730268415.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 Please update the subject to bpf: Add mptcp packet scheduler struct_ops 1. validate interface is added in bpf_struct_ops by commit 68b04864ca42 ("bpf: Create links for BPF struct_ops maps."), implement it in mptcp_sched_ops. 2. Drop mptcp_sched_find. This part of mptcp_sched_find() code comes from bpf_tcp_ca_init_member, but it was recently deleted by commit 68b04864ca42. 3. Add write access for scheduled of mptcp_subflow_context. 4. Drop mptcp_sock_type and mptcp_subflow_type. Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index e9db856972cb..c6d2efc6cf0e 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -18,8 +18,10 @@ =20 #ifdef CONFIG_BPF_JIT 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; +static u32 mptcp_sock_id, + mptcp_subflow_id; + +/* MPTCP BPF packet scheduler */ =20 static const struct bpf_func_proto * bpf_mptcp_sched_get_func_proto(enum bpf_func_id func_id, @@ -43,12 +45,10 @@ static int bpf_mptcp_sched_btf_struct_access(struct bpf= _verifier_log *log, const struct bpf_reg_state *reg, int off, int size) { - const struct btf_type *t; + u32 id =3D reg->btf_id; size_t end; =20 - t =3D btf_type_by_id(reg->btf, reg->btf_id); - - if (t =3D=3D mptcp_sock_type) { + if (id =3D=3D mptcp_sock_id) { switch (off) { case offsetof(struct mptcp_sock, snd_burst): end =3D offsetofend(struct mptcp_sock, snd_burst); @@ -58,11 +58,14 @@ static int bpf_mptcp_sched_btf_struct_access(struct bpf= _verifier_log *log, off); return -EACCES; } - } else if (t =3D=3D mptcp_subflow_type) { + } else if (id =3D=3D mptcp_subflow_id) { switch (off) { case offsetof(struct mptcp_subflow_context, avg_pacing_rate): end =3D offsetofend(struct mptcp_subflow_context, avg_pacing_rate); break; + case offsetof(struct mptcp_subflow_context, scheduled): + end =3D offsetofend(struct mptcp_subflow_context, scheduled); + break; default: bpf_log(log, "no write support to mptcp_subflow_context at off %d\n", off); @@ -75,7 +78,7 @@ static int bpf_mptcp_sched_btf_struct_access(struct bpf_v= erifier_log *log, =20 if (off + size > end) { bpf_log(log, "access beyond %s at off %u size %u ended at %zu", - t =3D=3D mptcp_sock_type ? "mptcp_sock" : "mptcp_subflow_context", + id =3D=3D mptcp_sock_id ? "mptcp_sock" : "mptcp_subflow_context", off, size, end); return -EACCES; } @@ -113,7 +116,6 @@ static int bpf_mptcp_sched_init_member(const struct btf= _type *t, const struct mptcp_sched_ops *usched; struct mptcp_sched_ops *sched; u32 moff; - int ret; =20 usched =3D (const struct mptcp_sched_ops *)udata; sched =3D (struct mptcp_sched_ops *)kdata; @@ -124,12 +126,7 @@ static int bpf_mptcp_sched_init_member(const struct bt= f_type *t, if (bpf_obj_name_cpy(sched->name, usched->name, sizeof(sched->name)) <=3D 0) return -EINVAL; - - rcu_read_lock(); - ret =3D mptcp_sched_find(usched->name) ? -EEXIST : 1; - rcu_read_unlock(); - - return ret; + return 1; } =20 return 0; @@ -144,18 +141,21 @@ static int bpf_mptcp_sched_init(struct btf *btf) if (type_id < 0) return -EINVAL; mptcp_sock_id =3D type_id; - mptcp_sock_type =3D btf_type_by_id(btf, mptcp_sock_id); =20 type_id =3D btf_find_by_name_kind(btf, "mptcp_subflow_context", BTF_KIND_STRUCT); if (type_id < 0) return -EINVAL; mptcp_subflow_id =3D type_id; - mptcp_subflow_type =3D btf_type_by_id(btf, mptcp_subflow_id); =20 return 0; } =20 +static int bpf_mptcp_sched_validate(void *kdata) +{ + return mptcp_validate_scheduler(kdata); +} + static int __bpf_mptcp_sched_get_subflow(struct mptcp_sock *msk, struct mptcp_sched_data *data) { @@ -183,6 +183,7 @@ static struct bpf_struct_ops bpf_mptcp_sched_ops =3D { .check_member =3D bpf_mptcp_sched_check_member, .init_member =3D bpf_mptcp_sched_init_member, .init =3D bpf_mptcp_sched_init, + .validate =3D bpf_mptcp_sched_validate, .name =3D "mptcp_sched_ops", .cfi_stubs =3D &__bpf_mptcp_sched_ops, }; --=20 2.45.2 From nobody Thu Nov 21 11:36:44 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 9011D3398E for ; Wed, 30 Oct 2024 06:11:02 +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=1730268662; cv=none; b=SFjLlPWYpc9xNA6zBrT14upmgch1qCbV1StpmkcUbijdywpuzSeoz5Tr+9d6MbY6JKsJQd1vI5+vLnqEf0iivYj2ooBc0doyT4dttlUatcvcfnCqcSGjujhFlSAmFm/yLpfkm2SSBj2A9K8TOKj1GPeLYmoToO38VeKeDAfQPko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730268662; c=relaxed/simple; bh=UVCSjBGP/+cKzmmPkyzOqkuWiLSr68m8qV2V8UJdsms=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JOgw7jUw+xdri59+oKKujc8/F59MVxfrkgfmPOplJWnG1PwUXvq6JLNHKob8VHaaGrWR2UEissV39jf5qd9YZgJLRAqWjCPM/T6fsCAfJygvaMe3hvpFCzVffeQC70JjTcjWu5swzzBWJzG9wt4CJrlBx/wuCDyumzDFMBQv1kc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JcVMFyrf; 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="JcVMFyrf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E116FC4CEE4; Wed, 30 Oct 2024 06:11:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730268662; bh=UVCSjBGP/+cKzmmPkyzOqkuWiLSr68m8qV2V8UJdsms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JcVMFyrfZ+hG2oQaRVgtMwCr6K5V9jMrfgxNKrWJT/2X52gOuVigi0K0hmDrPRNvo 8ahs0ES9So3pTOGsXoUfBxt2KL5nx9V3+aPvONoeU8Unu1QVuc5Z01diQVgsem7rRT 2wiQPcoBeemUJfx+i/0Sp7h7zcKvR3dTAM2siAVl809Rzsw+XQZ+mRIYAu3f8dY7cs BaeE4M1oSMQD4fdYoZomWa7bid8A7rWz2b5XaXhvC5qRIpDbCWmVr9bN/vrjOsHW8i oxPO9BJ7YL6Qvvt2FBHthu71mKS1oEvX69jbhO0xHYCrxD1hr6VK4TQoqAAA0SfY7t JDJLHPhVfoe8Q== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v9 05/13] Squash to "selftests/bpf: Add bpf scheduler test" Date: Wed, 30 Oct 2024 14:10:29 +0800 Message-ID: <8641dcb7e7de4d503a82b3bdcde27290c3ea233c.1730268415.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 A cleanup, move netns_new() out of sched_init(). Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/prog_tests/mptcp.c | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing= /selftests/bpf/prog_tests/mptcp.c index 1d68bbda3370..b00af99c5c9d 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -562,23 +562,16 @@ static void test_iters_subflow(void) close(cgroup_fd); } =20 -static struct netns_obj *sched_init(char *flags, char *sched) +static int sched_init(char *flags, char *sched) { - struct netns_obj *netns; - - netns =3D netns_new(NS_TEST, true); - if (!ASSERT_OK_PTR(netns, "netns_new")) - return NULL; - - if (endpoint_init("subflow", 2) < 0) + if (endpoint_init(flags, 2) < 0) goto fail; =20 SYS(fail, "ip netns exec %s sysctl -qw net.mptcp.scheduler=3D%s", NS_TEST= , sched); =20 - return netns; + return 0; fail: - netns_free(netns); - return NULL; + return -1; } =20 static int ss_search(char *src, char *dst, char *port, char *keyword) @@ -636,11 +629,16 @@ static void send_data_and_verify(char *sched, bool ad= dr1, bool addr2) static void test_default(void) { struct netns_obj *netns; + int err; =20 - netns =3D sched_init("subflow", "default"); + netns =3D netns_new(NS_TEST, true); if (!netns) goto fail; =20 + err =3D sched_init("subflow", "default"); + if (!ASSERT_OK(err, "sched_init")) + goto fail; + send_data_and_verify("default", WITH_DATA, WITH_DATA); =20 fail: --=20 2.45.2 From nobody Thu Nov 21 11:36:44 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 1DCFF3398E for ; Wed, 30 Oct 2024 06:11:03 +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=1730268664; cv=none; b=PHbCOn0XQzGDPqSduS5FB8Oh5YR4D7O9TzEIStnUqWCpipO/HilPKDb4lg9/csBlPKxmR5Z/zVEVI4OK7M22Z8IP31zDmO4w/Bm3pOEC1ciVwAA9nD1dWyzqqyq275UoGnswnYic0icHOgN1mTE+CvijrCkXzFx9pD45snG49Ok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730268664; c=relaxed/simple; bh=y2ViatPVa5pK207JnCO7C/LxZfG95RUTZ4tCwBFVc2A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mi1hgTxRXEboEPWZKjUTUViAfuiDn5lWV0hfCvGG4KoTBxN0CxBmrmV9r1VxNy7gmAMETHOjwMhPiC5ZCxHMeIfbomkyelyFj1MTJYrvPQcUoXa+WLznUh3kMHyADLN/sw/Dwv18DxuoqCq0sQHlqJ9gPMpJf/jZWjoOEaueBPk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aLT8PKUb; 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="aLT8PKUb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88E06C4CEE5; Wed, 30 Oct 2024 06:11:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730268663; bh=y2ViatPVa5pK207JnCO7C/LxZfG95RUTZ4tCwBFVc2A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aLT8PKUbIGE7OqyNqhSYBnpANChd4zH0qAv5qJoobw9sXISCjqIbe0aqY4z3eVZqq tmPkHpWIKNeaVZGWLLf6Kw+ZiyF/fl3hdoj398uPGaWpiXgoCR5QY6SzDr6EbKgR93 go0M+ze3kAmtutVORI+9OvWPLB7M413DLrbJCoVQN1c+CgJ+Dm6Z3NEVEZs8xISDwo YObAsUxEC8Pwgv6nQnJsk8zSfar6AfYFBS5VjAweiN3HbrSqRVnk0fwNozRjgQnClc DM/ehDTN5n0osbQrtG2g7atW8WA4hk97TkTHyXjz4ZydhxbUFkXHABV8Y5QgL0o79b bS3RPP8FERwrQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v9 06/13] Squash to "selftests/bpf: Add bpf_first scheduler & test" Date: Wed, 30 Oct 2024 14:10:30 +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 1. Update sched_init. 2. For drop bpf_object__find_map_by_name in test_bpf_sched(), change the first parameter of it as bpf_map. 3. Implement mptcp_subflow_set_scheduled in BPF. 4. Drop bpf_mptcp_subflow_ctx_by_pos. 5. Use the newly added bpf_for_each() helper to walk the conn_list. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/prog_tests/mptcp.c | 15 +++++++++------ tools/testing/selftests/bpf/progs/mptcp_bpf.h | 14 ++++++++------ .../testing/selftests/bpf/progs/mptcp_bpf_first.c | 4 ++-- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing= /selftests/bpf/prog_tests/mptcp.c index b00af99c5c9d..a6574a537679 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -645,27 +645,30 @@ static void test_default(void) netns_free(netns); } =20 -static void test_bpf_sched(struct bpf_object *obj, char *sched, +static void test_bpf_sched(struct bpf_map *map, char *sched, bool addr1, bool addr2) { char bpf_sched[MPTCP_SCHED_NAME_MAX] =3D "bpf_"; struct netns_obj *netns; struct bpf_link *link; - struct bpf_map *map; + int err; =20 if (!ASSERT_LT(strlen(bpf_sched) + strlen(sched), MPTCP_SCHED_NAME_MAX, "Scheduler name too long")) return; =20 - map =3D bpf_object__find_map_by_name(obj, sched); link =3D bpf_map__attach_struct_ops(map); - if (CHECK(!link, sched, "attach_struct_ops: %d\n", errno)) + if (!ASSERT_OK_PTR(link, "attach_struct_ops")) return; =20 - netns =3D sched_init("subflow", strcat(bpf_sched, sched)); + netns =3D netns_new(NS_TEST, true); if (!netns) goto fail; =20 + err =3D sched_init("subflow", strcat(bpf_sched, sched)); + if (!ASSERT_OK(err, "sched_init")) + goto fail; + send_data_and_verify(sched, addr1, addr2); =20 fail: @@ -681,7 +684,7 @@ static void test_first(void) if (!ASSERT_OK_PTR(skel, "open_and_load: first")) return; =20 - test_bpf_sched(skel->obj, "first", WITH_DATA, WITHOUT_DATA); + test_bpf_sched(skel->maps.first, "first", WITH_DATA, WITHOUT_DATA); mptcp_bpf_first__destroy(skel); } =20 diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf.h b/tools/testing/= selftests/bpf/progs/mptcp_bpf.h index 3b20cfd44505..f8c917dc2c1c 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf.h +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf.h @@ -42,6 +42,14 @@ mptcp_subflow_tcp_sock(const struct mptcp_subflow_contex= t *subflow) return subflow->tcp_sock; } =20 +#define WRITE_ONCE(x, val) ((*(volatile typeof(x) *) &(x)) =3D (val)) + +static __always_inline void +mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow, bool sc= heduled) +{ + WRITE_ONCE(subflow->scheduled, scheduled); +} + /* ksym */ extern struct mptcp_sock *bpf_mptcp_sock_acquire(struct mptcp_sock *msk) _= _ksym; extern void bpf_mptcp_sock_release(struct mptcp_sock *msk) __ksym; @@ -52,10 +60,4 @@ bpf_mptcp_subflow_ctx(const struct sock *sk) __ksym; extern struct sock * bpf_mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow) __= ksym; =20 -extern void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subf= low, - bool scheduled) __ksym; - -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..5d0f89c636f0 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c @@ -20,11 +20,11 @@ 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); + mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx(msk->first), true); return 0; } =20 -SEC(".struct_ops") +SEC(".struct_ops.link") struct mptcp_sched_ops first =3D { .init =3D (void *)mptcp_sched_first_init, .release =3D (void *)mptcp_sched_first_release, --=20 2.45.2 From nobody Thu Nov 21 11:36:44 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 D84A51D0F66 for ; Wed, 30 Oct 2024 06:11:05 +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=1730268665; cv=none; b=CNVn/r7NXzrlvY+uYmIhIQB7nY++waKoD5nc+f9NxgBAhaxqa9qxE5jyC4kbkFuQqEVPtQmWgS5yuwnWkWsERzGPYUhMszdrnmfs8p/YQf3Y8CSB4O4yDcyPetIRnQHiFqjJpcIYu48CRmCz/ORquAO9ZVKAfbhiu1sRzU58yPs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730268665; c=relaxed/simple; bh=2XQB3Zpf5clOuT0T2zVPlnvDISa6+1HSn5y51VFTke8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hG4kTjKlWaqFlwCBlYqk4nP/pLU/i7kPVzvDoHxutOLP3kKuurvmIcMfeN3e42QHbfQmc9ZCSAkLcTPV7LDA576xZrq+tiujMxnLgjPK/tbJnzxGWOM4zu9+IyPrlv+PJw1Djl45Ieb+VJqi9fMhJDFLEOyYXKwtpLUqxxldLKw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mNBaNJPu; 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="mNBaNJPu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62E2FC4CEE5; Wed, 30 Oct 2024 06:11:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730268665; bh=2XQB3Zpf5clOuT0T2zVPlnvDISa6+1HSn5y51VFTke8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mNBaNJPuoOb7VK/w0cQkafDA4KsuSxkF1ibxKI1iHMv/p+KKkCYk3oKGohQvykUbp Ljh8qts/7+TBRtf+eGhQEUF7B32Qk/I8WzX7AuEf6XXkW8eiVuVEwXf9U+QCuHD0n/ pTi/Zwykp+omM9YDOlwA7TUrvTPC7OuD94KF1rIhSEciqNQHyYNce1wNu6SKhbSSm0 PNe3hJLk964bfsJUZlc40e9BCLd2SnY9O00w10CQUKW4QFTmLStmCZxRTMAbbIiFE5 /79NddT5x5mwIZ+rGi1xnzcw/xv3TJimpsw26UoOk8RykaqRk7wfu49NixXs0e/zVZ 7DXuPesnT1ggA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v9 07/13] Squash to "selftests/bpf: Add bpf_bkup scheduler & test" Date: Wed, 30 Oct 2024 14:10:31 +0800 Message-ID: <5843a90bb1e04bd7b635798fc6b1a0667c77f963.1730268415.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 Update test_bpf_sched(). Use the newly added bpf_for_each() helper to walk the conn_list. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/prog_tests/mptcp.c | 2 +- .../selftests/bpf/progs/mptcp_bpf_bkup.c | 18 ++++-------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing= /selftests/bpf/prog_tests/mptcp.c index a6574a537679..d388bfca21bf 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -696,7 +696,7 @@ static void test_bkup(void) if (!ASSERT_OK_PTR(skel, "open_and_load: bkup")) return; =20 - test_bpf_sched(skel->obj, "bkup", WITH_DATA, WITHOUT_DATA); + test_bpf_sched(skel->maps.bkup, "bkup", WITH_DATA, WITHOUT_DATA); mptcp_bpf_bkup__destroy(skel); } =20 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..0c32ce623bab 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c @@ -20,30 +20,20 @@ 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 -SEC(".struct_ops") +SEC(".struct_ops.link") struct mptcp_sched_ops bkup =3D { .init =3D (void *)mptcp_sched_bkup_init, .release =3D (void *)mptcp_sched_bkup_release, --=20 2.45.2 From nobody Thu Nov 21 11:36:44 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 C369A1D0F66 for ; Wed, 30 Oct 2024 06:11:07 +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=1730268667; cv=none; b=Cgwj4ODicQEThsUB9uKQod7PQxQcnrLR0jKdH2nLDvUB6nshoHRL04nWdXPZJsQAqFn4crNQLkPteOAQP317XB0F89oXZKFKsqlfSZ2sUw5SuOZ8o0/m4yODzm84EEctgLXeycKgUMCYXnGl4ZhZAZNgXIYdW9hb5yncwOnbIx4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730268667; c=relaxed/simple; bh=dBGH5/nk1NGmoLa1epcOa0DzlFzpTxH0NmWEl3LX+vQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Pq8jm6LKVCWemr1d4+4MGPMNsiCNxbawFVSnunquIS7NqDxw+0l3ErhhSScdPdBJ8DbWhwrX6wMsiGPfvJn0rmfA26+Cmo2hgeT18lGXCYctjbfhaGAOw0tX3nr8ppBY/PD4I7+rKUqLu/v1K9z+JHOeJKFI0BP1xG25DGnTsUM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KzG5iDsf; 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="KzG5iDsf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23C9AC4CEE4; Wed, 30 Oct 2024 06:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730268667; bh=dBGH5/nk1NGmoLa1epcOa0DzlFzpTxH0NmWEl3LX+vQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KzG5iDsfn+NbJOXR5wtlx2TZziaR6i40rlDrpMgZySUJcbDPbi0WbvvyD+ZSU6j91 3WnZkGFKM1ZfinkCOX6VOU8FfM6jR0b1v2iB3TMtJPifGOb3sQFii3WVlwxFLFdhXM 0HL4/32n2ep424TShF7orSqoWWwpRLxzLfl1ChDM+fLaxf9VQtmNwZ8BC2M0V7bZVj bS8wfOrnbF/DCNeXKXy/lPiPmMy6tZ7R6qhS8KKmISTdxmXEUQ+D8S8ADbf65KPWY9 mCperYqsrMVKZooYvDdwWAljytiK/Tpc+3yILWsTZJxvyhiZGfnDtPs2Ug4HVRStdP jR3BkQgLi7uJg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v9 08/13] Squash to "selftests/bpf: Add bpf_rr scheduler & test" Date: Wed, 30 Oct 2024 14:10:32 +0800 Message-ID: <59e32803f687c2b1369f4aa9a513cd2de84c40ff.1730268415.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 Update test_bpf_sched(). Use the newly added bpf_for_each() helper to walk the conn_list. Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/prog_tests/mptcp.c | 2 +- .../selftests/bpf/progs/mptcp_bpf_rr.c | 33 ++++++++----------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing= /selftests/bpf/prog_tests/mptcp.c index d388bfca21bf..524527306958 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -708,7 +708,7 @@ static void test_rr(void) if (!ASSERT_OK_PTR(skel, "open_and_load: rr")) return; =20 - test_bpf_sched(skel->obj, "rr", WITH_DATA, WITH_DATA); + test_bpf_sched(skel->maps.rr, "rr", WITH_DATA, WITH_DATA); mptcp_bpf_rr__destroy(skel); } =20 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..c901ed045fdc 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c @@ -34,42 +34,37 @@ 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 (!ptr->last_snd) + goto out; =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 (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: + next =3D bpf_core_cast(next, struct mptcp_subflow_context); + mptcp_subflow_set_scheduled(next, true); + ptr->last_snd =3D mptcp_subflow_tcp_sock(next); return 0; } =20 -SEC(".struct_ops") +SEC(".struct_ops.link") struct mptcp_sched_ops rr =3D { .init =3D (void *)mptcp_sched_rr_init, .release =3D (void *)mptcp_sched_rr_release, --=20 2.45.2 From nobody Thu Nov 21 11:36:44 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 757ED1D0E2D for ; Wed, 30 Oct 2024 06:11:09 +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=1730268669; cv=none; b=ncA2zeblFjhQk/+9jRyGJWjuvnfkC+K7YAcV+kiCQ3wn8duLxLId6owKLQ6sNoDI7wVVxpa/5Z9AG7CXjotrTsLwbsgjpROnPteZgH9TLjf5JO8rOxgihl0Qo6OsvKZ70rMa0rYqUQwDTEc0yrRcCsQKF+kvdFAQ/sB0FHhBphA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730268669; c=relaxed/simple; bh=eug7vwOMD9L0g82Pf6+rW3vQHVWWUKMoNLkijWNB9lg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sf4nKXsEF1GCw3gpGAyo0us4cbz9/hWrvdINi7iH3qk2pAyYvrTBPXyZN25xdZ0dc+6RgbwzovUSaLCwWe5/RCNZ0/aldnFChjMOK0Uu+cdiXm/HxAnTlfjLpqeMNdiGwnz5CZERojfV78zzAiiTjL6+Mj0grtjN3AaNI4OpeHQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FJlW3IOi; 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="FJlW3IOi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1532C4CEE4; Wed, 30 Oct 2024 06:11:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730268669; bh=eug7vwOMD9L0g82Pf6+rW3vQHVWWUKMoNLkijWNB9lg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FJlW3IOiCaLvZUm8LZ5P5DtKk0l/SrIt8yKmeXVNmZenLmrdF/NQlwPCnJuZLRJqj Nc8iPlnmZGqAYISyrAb5k1j0CtIDquP7NOimQ7n3B/kxWVYTZCxk/q/Xc/8cOevE/1 OUhCewUorCuL4RbAkGPRKhpdFxQHJw0d0JGBoLXrFzfUuLBOcJu8FZgnxdQkUUKgGK hmRsONbsFX4LAsTsJOEIN5kaSaCQ427xZmIXvFGCPAfbaRlEuBV19/fU82xo2j9fQC lgGt0LRsioZT1e2acoxFXJ9zXZnM69/7BBEU/ceNIV5ydjjeyz44+WqIoz3/Bydc2N ZlMDqSBLIblOQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v9 09/13] Squash to "selftests/bpf: Add bpf_red scheduler & test" Date: Wed, 30 Oct 2024 14:10:33 +0800 Message-ID: <4d6f46e87cd8b9c645da2dc1445c46f7421bb941.1730268415.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 Update test_bpf_sched(). Use the newly added bpf_for_each() helper to walk the conn_list. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/prog_tests/mptcp.c | 2 +- tools/testing/selftests/bpf/progs/mptcp_bpf_red.c | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing= /selftests/bpf/prog_tests/mptcp.c index 524527306958..e845809cd2a8 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -720,7 +720,7 @@ static void test_red(void) if (!ASSERT_OK_PTR(skel, "open_and_load: red")) return; =20 - test_bpf_sched(skel->obj, "red", WITH_DATA, WITH_DATA); + test_bpf_sched(skel->maps.red, "red", WITH_DATA, WITH_DATA); mptcp_bpf_red__destroy(skel); } =20 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..35150771e174 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c @@ -20,17 +20,15 @@ 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 -SEC(".struct_ops") +SEC(".struct_ops.link") struct mptcp_sched_ops red =3D { .init =3D (void *)mptcp_sched_red_init, .release =3D (void *)mptcp_sched_red_release, --=20 2.45.2 From nobody Thu Nov 21 11:36:44 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 A13521D0F51 for ; Wed, 30 Oct 2024 06:11: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=1730268670; cv=none; b=MJQhHmq5PlzD+T+oPn1xRNFOMIXaEAV2waAqD06Z/fW3IcKzS9WlkQEVm5lEpwIqs6MKWZQ+X+vpIa5+wWGo31is004I6KdVE9X5K7uOmBz2yaQ2AzFIh9cci+LSDMzbNOinyVZSvHmrOWiky5EQadazdNO+iyRQE0YWRz7zLcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730268670; c=relaxed/simple; bh=j6ENN/YA7zBot/DvaKGO32Z9qk2Hwh/KtfV0D8zWm6U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T7zpA4CqcwdhD10LkAHcqzmLmuUpMND/ox1vQ/u8kV0lutI3SP/qbFkkNHBtyIytclt5T1vRCUVEljSYm4iXJwlxgL93OwUiBWJFA0cdLq3UtJnTxnZHem/OCTaS8W+1X6WYVUunVbidd3RSVOMhhAqZJ4CR3Lcqcn71j5HDPp0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XZX+iuSR; 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="XZX+iuSR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98B3FC4CEE4; Wed, 30 Oct 2024 06:11:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730268670; bh=j6ENN/YA7zBot/DvaKGO32Z9qk2Hwh/KtfV0D8zWm6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XZX+iuSR1y2ocEPjaqlMdZgE1YHnU6EJsqQc1MhN+V/Eg9VNeSTCERLB1O9HURSwk +3LJS6WjzyOBRP2l1BTHlQlfZv3nZ9gJOJkNcGHLm/rBYhmpv0z+bpwwE1NEcJcZTh 1CeKONgOU/PpYg6zQNWKATH3n2Chn/zAa+SMc175ZG8RbFd0+ycOk6j+GUiMAM8WB5 /QXbwWct2j4noBtZkwJACHdp/fV8TDxLh7zdl0CHUi4suvXTxtlMK3RbJBygn6HMHX NT4suIiEd5zzo+k20PQGmyJPLrCXZe7YXO//TJ7+F1e4TiGtpBJXHBtFyRKI6HorpV WaL8noqBbPJfA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v9 10/13] Squash to "selftests/bpf: Add bpf_burst scheduler & test" Date: Wed, 30 Oct 2024 14:10:34 +0800 Message-ID: <7af9d9c97ab72caef4facd23c7d78cf1c8aa83fd.1730268415.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 Update test_bpf_sched(). Use the newly added bpf_for_each() helper to walk the conn_list. Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/prog_tests/mptcp.c | 2 +- .../selftests/bpf/progs/mptcp_bpf_burst.c | 73 ++++++++----------- 2 files changed, 33 insertions(+), 42 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing= /selftests/bpf/prog_tests/mptcp.c index e845809cd2a8..dbdff62e430f 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -732,7 +732,7 @@ static void test_burst(void) if (!ASSERT_OK_PTR(skel, "open_and_load: burst")) return; =20 - test_bpf_sched(skel->obj, "burst", WITH_DATA, WITH_DATA); + test_bpf_sched(skel->maps.burst, "burst", WITH_DATA, WITH_DATA); mptcp_bpf_burst__destroy(skel); } =20 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..f0c9f5984736 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c @@ -9,10 +9,14 @@ char _license[] SEC("license") =3D "GPL"; =20 #define MPTCP_SEND_BURST_SIZE 65428 =20 +#define SSK_MODE_ACTIVE 0 +#define SSK_MODE_BACKUP 1 +#define SSK_MODE_MAX 2 + #define min(a, b) ((a) < (b) ? (a) : (b)) =20 struct bpf_subflow_send_info { - __u8 subflow_id; + struct mptcp_subflow_context *subflow; __u64 linger_time; }; =20 @@ -23,10 +27,6 @@ extern bool tcp_stream_memory_free(const struct sock *sk= , int wake) __ksym; extern bool bpf_mptcp_subflow_queues_empty(struct sock *sk) __ksym; extern void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struc= t sock *ssk) __ksym; =20 -#define SSK_MODE_ACTIVE 0 -#define SSK_MODE_BACKUP 1 -#define SSK_MODE_MAX 2 - static __always_inline __u64 div_u64(__u64 dividend, __u32 divisor) { return dividend / divisor; @@ -67,8 +67,7 @@ void BPF_PROG(mptcp_sched_burst_release, struct mptcp_soc= k *msk) { } =20 -static int bpf_burst_get_send(struct mptcp_sock *msk, - struct mptcp_sched_data *data) +static int bpf_burst_get_send(struct mptcp_sock *msk) { struct bpf_subflow_send_info send_info[SSK_MODE_MAX]; struct mptcp_subflow_context *subflow; @@ -80,18 +79,12 @@ 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].subflow =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; - - backup =3D subflow->backup || subflow->request_bkup; + bpf_for_each(mptcp_subflow, subflow, msk) { + bool backup =3D subflow->backup || subflow->request_bkup; =20 ssk =3D mptcp_subflow_tcp_sock(subflow); if (!mptcp_subflow_active(subflow)) @@ -109,7 +102,9 @@ 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; + if (!sk_stream_memory_free(ssk)) + continue; + send_info[backup].subflow =3D subflow; send_info[backup].linger_time =3D linger_time; } } @@ -117,13 +112,14 @@ 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].subflow =3D send_info[SSK_MODE_BACKUP].subflo= w; =20 - subflow =3D bpf_mptcp_subflow_ctx_by_pos(data, send_info[SSK_MODE_ACTIVE]= .subflow_id); + subflow =3D bpf_core_cast(send_info[SSK_MODE_ACTIVE].subflow, + struct mptcp_subflow_context); if (!subflow) return -1; ssk =3D mptcp_subflow_tcp_sock(subflow); - if (!ssk || !sk_stream_memory_free(ssk)) + if (!ssk) return -1; =20 burst =3D min(MPTCP_SEND_BURST_SIZE, mptcp_wnd_end(msk) - msk->snd_nxt); @@ -141,23 +137,18 @@ static int bpf_burst_get_send(struct mptcp_sock *msk, return 0; } =20 -static int bpf_burst_get_retrans(struct mptcp_sock *msk, - struct mptcp_sched_data *data) +static int bpf_burst_get_retrans(struct mptcp_sock *msk) { - 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 +157,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); @@ -194,11 +185,11 @@ int BPF_PROG(bpf_burst_get_subflow, struct mptcp_sock= *msk, struct mptcp_sched_data *data) { if (data->reinject) - return bpf_burst_get_retrans(msk, data); - return bpf_burst_get_send(msk, data); + return bpf_burst_get_retrans(msk); + return bpf_burst_get_send(msk); } =20 -SEC(".struct_ops") +SEC(".struct_ops.link") struct mptcp_sched_ops burst =3D { .init =3D (void *)mptcp_sched_burst_init, .release =3D (void *)mptcp_sched_burst_release, --=20 2.45.2 From nobody Thu Nov 21 11:36:44 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 2CB321D0E19 for ; Wed, 30 Oct 2024 06:11: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=1730268672; cv=none; b=OS6ltOl47rQcU1tMYf4NTu41gNmubKCzXwkCtxVACiCs5Z7qB9V2+XCCaewIYGJF+OJYZpm/FlkvLimorDDkps3UQtQEQmht+NcVPw6TFV3SgWH9Kt40fWB+Xf72/8PJGAQsduhpDV3aO/pk8j2XBMsoIQhB79QMymqonbL0fmU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730268672; c=relaxed/simple; bh=1/XmonfNcS3aYrR3v6jWSV3X9hDxjUcdOYCh1phGiIA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dEo9hUslrXJ6uraLG1hV/G1BaXvhYoZ+YgPptFXutYWIiuxMH0niyCi5bb7bBTmClgfoBCEfY6q1op0V1EaXj/TQmMyoHcbBAa44E+2bSxi9fwULm/+jEQYiEYACh+U0QwTawjrJYoitPu8F9NwJG/7RpwrnZ/6i+j0MZFNpQhY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qgECu6Z6; 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="qgECu6Z6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 272E4C4CEE6; Wed, 30 Oct 2024 06:11:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730268672; bh=1/XmonfNcS3aYrR3v6jWSV3X9hDxjUcdOYCh1phGiIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qgECu6Z6KvmoCLG/Al/GCNLbOv7aGfsfEHIofphEZuwtMXi2ZPtrLMrfAMNtXriYr VmT86sQVm1wUdLJZCNs7DgBO83w4NrdaajoVkQ4CxRCmRHG6meQH+c//70HJsTYVwJ 1X2647DjF8zJaL/KKGFJG24O65kY8efz/vQJHRLybMbJqfjrrwJcet+BXnuuXrY7JZ TPpyx+eI6nBHGaVdiMUpWrNNsd4Hs1gYgaMpx081YrEiQpeYqTZygRWf0qCYRifxtx DfahXEmIrL9jWwT723ufrs8H2hmuExhiP9MiOJ0RgVAFnBuCJavofT4n4nRBHBe6ui ByTEiKckVOn6A== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v9 11/13] Squash to "bpf: Export mptcp packet scheduler helpers" Date: Wed, 30 Oct 2024 14:10:35 +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 Remove mptcp_subflow_set_scheduled and bpf_mptcp_subflow_ctx_by_pos from BPF kfunc set. Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index c6d2efc6cf0e..4aee81814c82 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -316,8 +316,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 Thu Nov 21 11:36:44 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 CD66D1D0F47 for ; Wed, 30 Oct 2024 06:11:13 +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=1730268673; cv=none; b=FCng2Ak2wWkDOu13E9+pC+0Q/5HPjXhRlYwFVgUMyyZKEc0GV2B98DmdcoRPVeS5ZszbZ7mudUcp3EKHD+N9AvfNbpaW2+nDXxNg5h+zSXAewJSM2cbOzytViESeFW5DU08pvFfjuQFNAh1j1+FeusfM80njIkO2YRTLDXyyO3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730268673; c=relaxed/simple; bh=nwOv9/U6zYgGffloFt06J2kTn5sP+ujGZmTojwCBnmY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b9bYoV5o9ikM2J3SrgRrxCyE4zvFMIzwl1dOl95LsK6ABDFsv3/kVBFWcc7UpPzZgzQi7c9G5Hrr9OM1m/KuV7FQIcBtiHRu0XhYn5EUgGaVcPF4SVIzzelP7jRonXc25LoRx3rwnCA36dUlSkj9MunRBc2xfHwgkMh7ao3kYb4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZDrXVW0F; 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="ZDrXVW0F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9064AC4CEE5; Wed, 30 Oct 2024 06:11:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730268673; bh=nwOv9/U6zYgGffloFt06J2kTn5sP+ujGZmTojwCBnmY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZDrXVW0FhF0DFAl7vJ3Bfg2V7h4cnqLtGJbPuhrhmmank3jh34EJ+f7TnmiMiUlLP mZ23LdnPRcx+grlekBgXdZzh9q0PbGUBq3vv5GuBRWaH/Pq71OK1RASPgfK3j8RzeO gGXpcZWSTJ+Ac4xaQDg3cBpTz27t1qcbbKqx5Rr3b5DcGsYyEBrdvpkQB5KomMIESH +UDCwKUiN8g8/b7+7iuF0N8+AnjxTuqlYI/oC3wT/kqA4N4XPoiO6YkEINGL7r/tuF G4UxSZKkrFc8pBmbmXEyUK2E0qJc3umOQ9YYeFl4SlvCj4jjwxv9FeMGqOeFZyXuq8 dRBBo0CONZL0A== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v9 12/13] Revert "mptcp: add sched_data helpers" Date: Wed, 30 Oct 2024 14:10:36 +0800 Message-ID: <3e5bb37549b28c100a40f64d6168522e1fbedfd1.1730268415.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 4aee81814c82..13bdcbe34e1f 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -284,14 +284,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 46bc7adb4763..1656686b98a3 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -722,8 +722,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 d7be9c453488..d8ab234f4410 100644 --- a/net/mptcp/sched.c +++ b/net/mptcp/sched.c @@ -148,26 +148,6 @@ void mptcp_release_sched(struct mptcp_sock *msk) bpf_module_put(sched, sched->owner); } =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; @@ -194,7 +174,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 @@ -217,6 +196,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 Thu Nov 21 11:36:44 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 B4EBD1D0E19 for ; Wed, 30 Oct 2024 06:11: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=1730268675; cv=none; b=XYkuKRt2noXuHqWEs6Y1KUfkkO0DsW5sKQaJJPYjwEr/J3y6Bkm+jOirzbeGemh3t/XPwIh/dP0+jgfD0BOWxyil/zWcBNYTAGc4gOGDzNfmZSTlYYJ7Y3pwrVgHmYg/fKti+qLSgq4tjIs2KWMEBjPUyoxybWXxiV8OCWaWvc0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730268675; c=relaxed/simple; bh=6bhndwaaGpAVAk7F3FGG00oCg3g2+1FwNFY5REvMeE4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CAwqviySfIubgQ9+rXipZsgSVr54RCdy2ALgy29uFuye6A39tWpBBd3nOuysl0BYp1jTaxOT5TCTDv/8PlR8t7+tZWwz7jOZeZou6Q8FM7oAQxH4oEGuMVH2haNAmGp6zvvOGGMu0pJeVeiP4jRYPvMRgm7WgKKxnieulo+BUIc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Dk4DC0y9; 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="Dk4DC0y9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 524F1C4CEE5; Wed, 30 Oct 2024 06:11:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730268675; bh=6bhndwaaGpAVAk7F3FGG00oCg3g2+1FwNFY5REvMeE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dk4DC0y9Ao4gRTvX1GwsIVRrhW/JSgHxIGdRIew+E6M7rr6QHofDRFakgUv6Rdmsi 3DK7w1fMWxox3GJWd1gDHqIpmuKdtQyDiP8nv/D0xfTAFPHAq9s2FnJI8XRtD9YoeN ZkGUdShiJDMiNi8zzzvUq3+m/QyDkVINB1uISdz5xKsG/TomJR6Kh7f/1v6UersXSt XEJAL3agxVyLdFBvKpF+8UR99WNRexh4qHlJmmkvLyVblyuonTbXJDfMdjOVhCrm8Q hRyyOiTRwA+hx8+R0fqh5FuLXLsMoM7i3URRa70adLLowXBL7PldKKqwLD4cAWs4/p 2YtY4MLDFWQQA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v9 13/13] mptcp: drop subflow contexts in mptcp_sched_data Date: Wed, 30 Oct 2024 14:10:37 +0800 Message-ID: <2c08f84406e607b8c9063470fed70170bbaac615.1730268415.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