From patchwork Fri Oct 4 12:59:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13822275 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 C55F269D2B for ; Fri, 4 Oct 2024 12:59:56 +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=1728046796; cv=none; b=RqDCT2A71VIFz54rH5QItUk7Q68qOVDFDjGgkSEg6qBbOFWKl6HAEsyXP14FLCHmtOt7Tc29dqK4z12EsHjhhdACdumE2/a3nvxfEnEAS7lXYN7E+lUe5tyd80nyjgfG5SRVU8atASaP2o/d6Lm3MmWXaJnmdsAXJKzCaDLJPM4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728046796; c=relaxed/simple; bh=8uqrbsw5F3PKe8wZQNJKINzZyfH7oTc5Z/90atNIVpw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r2PBCgfBWHkpOO/xEOjwf65VnkxRL7ZV+Mtzljc04OiVW7lvuFnupW9eUtYrmZ95V9g1BClZkoILf0ec57nNflnV7aFcXSfne/b4IKr1h/FO5/AOZQDYHR9aIa/n9/GItHObkb3eQbOQf0m14tSl74FaGl0lcpHoxjj+yEbq7o0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lqMkoZOK; 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="lqMkoZOK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAAAAC4CEC6; Fri, 4 Oct 2024 12:59:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728046796; bh=8uqrbsw5F3PKe8wZQNJKINzZyfH7oTc5Z/90atNIVpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lqMkoZOK3VIAWKtgsXy1WO0W2g3HJfFHJGECH71U6VUF1LbLBEIC2PSbfajemky/P 3b6C+cd6UH4djl896IRSpPBxKUNZmjkW6KJ7iv+Y/DQKfLK04eOGbbKnvYH7y705Sa 5/o0WKsVWAJGyFgIRPnG4lcX5xrOcNm6xyUJPEYbJddEA6GPmDE5OyzJuwMMhZtbQB yvjlNScj/nvyYuTGpEBid055j9ot5FP6NebLiXrt8bzU+0UHogbcnOOAXW7lR7O/3Z SgPfZXTYK1nfBPy8QDYtqbLPwe9UbsSiIBL+7elUi0UnJ40e4AMwvfVHvmHuIejjcv W0EcscOQ+GbzA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 1/9] Squash to "bpf: Add bpf_mptcp_sched_kfunc_set" Date: Fri, 4 Oct 2024 20:59:41 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Please update the subject to "bpf: Register mptcp struct_ops kfunc set" Rename bpf_mptcp_sched_kfunc_set to bpf_mptcp_struct_ops_kfunc_set, since this kfunc set will not only use in bpf packet schedulers, but also in other struct_ops like bpf path managers. Rename bpf_mptcp_subflow_ctx_by_pos to bpf_mptcp_lookup_subflow_by_id. Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 1dd98765e2d1..02f5fadd0f89 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -309,18 +309,18 @@ static const struct btf_kfunc_id_set bpf_mptcp_common_kfunc_set = { .set = &bpf_mptcp_common_kfunc_ids, }; -BTF_KFUNCS_START(bpf_mptcp_sched_kfunc_ids) +BTF_KFUNCS_START(bpf_mptcp_struct_ops_kfunc_ids) BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx_by_pos) BTF_ID_FLAGS(func, mptcp_set_timeout) BTF_ID_FLAGS(func, mptcp_wnd_end) BTF_ID_FLAGS(func, tcp_stream_memory_free) BTF_ID_FLAGS(func, bpf_mptcp_subflow_queues_empty) BTF_ID_FLAGS(func, mptcp_pm_subflow_chk_stale) -BTF_KFUNCS_END(bpf_mptcp_sched_kfunc_ids) +BTF_KFUNCS_END(bpf_mptcp_struct_ops_kfunc_ids) -static const struct btf_kfunc_id_set bpf_mptcp_sched_kfunc_set = { +static const struct btf_kfunc_id_set bpf_mptcp_struct_ops_kfunc_set = { .owner = THIS_MODULE, - .set = &bpf_mptcp_sched_kfunc_ids, + .set = &bpf_mptcp_struct_ops_kfunc_ids, }; static int __init bpf_mptcp_kfunc_init(void) @@ -331,7 +331,7 @@ static int __init bpf_mptcp_kfunc_init(void) ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_UNSPEC, &bpf_mptcp_common_kfunc_set); ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, - &bpf_mptcp_sched_kfunc_set); + &bpf_mptcp_struct_ops_kfunc_set); #ifdef CONFIG_BPF_JIT ret = ret ?: register_bpf_struct_ops(&bpf_mptcp_sched_ops, mptcp_sched_ops); #endif From patchwork Fri Oct 4 12:59:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13822276 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 90C5369D2B for ; Fri, 4 Oct 2024 12:59: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=1728046798; cv=none; b=A7Q0gPm9WUF8r1jh2dyAM3iQPQOuwQfCzGx4ZNTCBg+mqQY7WVyhcgWyel4OWaRzX5UXaziglCPMm5027CfJBqLjZy4HWKVLcPl9yprSR3pRkWkhtpXBzfAdL97FKgjeEoiufp31/S8w/t+akbbfiRczOXYOt+VJ68TRXUhP7lg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728046798; c=relaxed/simple; bh=8fB+UmCs8R0kK5rvVEIqyaaVVQE6NSzQW3cZYewl1DA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gsnVOufiuJIqGfWq3MCGhnUdgH/Qs+yExzR4sJBRAvwTISiUR+uRaTrx4B31USiYGQp7Stet7Jmb05JW/vOYWLl/vHjmxwm+/F8RThrOJ34qi7eGOGzc710ZS4/fxcYin+euDXWy+d9vM6Y0HeOAocDR0RgvCuOJbmURSF7Bjw4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pKjqD5qd; 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="pKjqD5qd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5A54C4CEC7; Fri, 4 Oct 2024 12:59:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728046798; bh=8fB+UmCs8R0kK5rvVEIqyaaVVQE6NSzQW3cZYewl1DA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pKjqD5qdA6vA3in5zUecr/OpiYo7gcJu3vMSRBa2fEgGNaZ6SAN69Ho7GnWgAjzut XnoG7hxv4IGwLg3sYV7xpGFiRIkDPEMnOc7pbUdES961c0FNWisqeh/qZf0cszTR/T TUovS8v5BlPq1aPxpbCslfiR+Peu5nER4VOScrJMgZp0bnTn8ZkvLQtp4SPGixCecg 44SIIloraltW2vD9GyTlgv//07iHX2Zrvl+JUFKQfQ3MLPNqfJUdoWUj39MV2QJjn6 SywpInDS+17cjcWfQwKQ0WdbbxeIwkbxijWbRNnzAMaS3hu5DCIfxMDKyVWBWDl973 54dPaVk3vT4Fg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 2/9] Squash to "selftests/bpf: Add bpf_first scheduler & test" Date: Fri, 4 Oct 2024 20:59:42 +0800 Message-ID: <518c7c2a4b67036de2473d1094bb90db17729fed.1728046491.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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.h | 2 +- tools/testing/selftests/bpf/progs/mptcp_bpf_first.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf.h b/tools/testing/selftests/bpf/progs/mptcp_bpf.h index ada2273bf7b6..9ca152a99dbf 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf.h +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf.h @@ -57,6 +57,6 @@ extern struct sock * bpf_mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow) __ksym; extern struct mptcp_subflow_context * -bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos) __ksym; +bpf_mptcp_subflow_ctx(const struct sock *sk) __ksym; #endif diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c index d57399b407a7..807685b3ab97 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; + + bpf_for_each(mptcp_subflow, subflow, msk) { + mptcp_subflow_set_scheduled(subflow, true); + break; + } + return 0; } From patchwork Fri Oct 4 12:59:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13822277 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 45AD21D88B0 for ; Fri, 4 Oct 2024 12:59:59 +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=1728046800; cv=none; b=JBfC02nxrOQSJwbn+ItdasWGqSvWP5m7dkYD6TsH4U+L1aYzonN2wQJOnuUxmDi2ssE2xtth693KkojgdnBSYChyndNV5OY32cPufOTpppj5cW5jyLQ5WmN9r+kKx8FMVRGJi2A2eDZa2dC9nv+IXaGk35olPWAMUREwfvYoOeE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728046800; c=relaxed/simple; bh=+Ns9vcAYflyNwdX3DkGpNegQAHdxvHGggo6htLg093M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iwLWypUs2BM+LPW/y8GpW4Hy7f72GIcHL9XVkZ4RdsPeFYTZNmMjcd/KWg95lZNL74AFJ8259fIlgnNRXcs3JwVmTcGm4T8vDXvLWVPsJcV8EEL7Mh6q2B9ZHsM98Bx+SwwhRM5eiDU2/i1R+3+XimvyiFcuw2uWU4/EL6Wr8Zg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Qp+Vfmtl; 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="Qp+Vfmtl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA68AC4CECF; Fri, 4 Oct 2024 12:59:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728046799; bh=+Ns9vcAYflyNwdX3DkGpNegQAHdxvHGggo6htLg093M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qp+VfmtlqtJUF1rzD2aHwc6jp8ngWnwLxXfK0XsdYcuJEp3bGXdSEcIw/oEzhywLE SSa0IfLQ3ULVgLwOdlPUul5y60jtQ3w4LB5ssuTZxYg1eMqumiFDpK1gB2MlwEyYc6 ClrlVXidG0qyjngNzKbJn8aZixck795uRPfNBYPP6k4NNp2B093iUT52z4+gkHOPIf Mca7mIXzAxl2tI20YYKpFIVeGt5ovfA7TxlnFpeIdm91cjCLGPYl1XkRSGpl9slYyZ FFyCN4BPRKncwbBpChPQDyVfMzrsnQem4WPJJzVse6h2WdDjsWVCILft7mwLu4eQzV Kva/DH98OxN7w== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 3/9] Squash to "selftests/bpf: Add bpf_bkup scheduler & test" Date: Fri, 4 Oct 2024 20:59:43 +0800 Message-ID: <4fa80f804539410bbde5d66f93ea27260c997076.1728046491.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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/testing/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 = -1; - - for (int i = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - struct mptcp_subflow_context *subflow; - - subflow = bpf_mptcp_subflow_ctx_by_pos(data, i); - if (!subflow) - break; + struct mptcp_subflow_context *subflow; + bpf_for_each(mptcp_subflow, subflow, msk) { if (!BPF_CORE_READ_BITFIELD_PROBED(subflow, backup) || !BPF_CORE_READ_BITFIELD_PROBED(subflow, request_bkup)) { - nr = i; + mptcp_subflow_set_scheduled(subflow, true); break; } } - if (nr != -1) { - mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx_by_pos(data, nr), true); - return -1; - } return 0; } From patchwork Fri Oct 4 12:59:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13822278 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 0B47B20FAA7 for ; Fri, 4 Oct 2024 13:00:01 +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=1728046802; cv=none; b=KdBLt4Z8KNvIxXbYZMga3txeZk9FGnUdNOvX9HlFQyB0GYwEcRbofTE4xLn96M+42UvDCAdszhuQnPs2dbRvkTfOvGvWFLmk84Ul59vxDiYHlrY7TvfFIVXZhi7vs9CMZIiPeFGf2O3GWNl1KRpBWoydbgZav52MM3coigfI0Ek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728046802; c=relaxed/simple; bh=GWK8Emu7Xenj6RbjmBgCMLp8+y4zcVDWsQH+sR0uMj0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uI2ah+rV1o06uPiAzS0I7cXmQ1axjWKTfXrt6KoDRfq4lp2cuKe+MVB9osqZHDS5Ev3sid80JuLkSl3AePeKpwekPpTUbuTjmy5eK+aPkZRGSxB64hS/5luOgG57qvW8OFOSG5F2R2dMQgW9wLXnzsfSwDqi48pcLRwz/Vh83og= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f4yr4HKo; 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="f4yr4HKo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 701BEC4CEC6; Fri, 4 Oct 2024 13:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728046801; bh=GWK8Emu7Xenj6RbjmBgCMLp8+y4zcVDWsQH+sR0uMj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f4yr4HKownUUIApeAWbcW7Na3NcGAuxl+BG7P9jFtOS9TF2UA8QsCirWJMtz/BLwN 32Uv2mvXVdXvs8tYqkIK5UFvMLDRAC4W12i5RJKq8EXkbbx+ea3BS3ZU4A+x2x7DRK c/nqY8iawkZSB+ja8VDd3rOnxORmcANg+9ZTJq6sjtCbhEEc9Rie387htpMsh+AySE oUNnRc+jCpEM415F2jZogSb+5LoWPsdmsuqo0QVqvytJhE5vQApPFFQ8oLnwn3Y4iw uffiajwRp6RoRKS5K5uZCEfDX5T/DILHxiXw7MIcieeN0MM/PHTY88B7EyjD8Q/Xyu SsZ7GLtCWvAng== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 4/9] Squash to "selftests/bpf: Add bpf_rr scheduler & test" Date: Fri, 4 Oct 2024 20:59:44 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c index 638ea6aa63b7..0e806caa10df 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c @@ -34,10 +34,9 @@ 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 = NULL; - int nr = 0; ptr = bpf_sk_storage_get(&mptcp_rr_map, msk, 0, BPF_LOCAL_STORAGE_GET_F_CREATE); @@ -45,27 +44,24 @@ int BPF_PROG(bpf_rr_get_subflow, struct mptcp_sock *msk, return -1; last_snd = ptr->last_snd; + next = bpf_mptcp_subflow_ctx(msk->first); - for (int i = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - subflow = bpf_mptcp_subflow_ctx_by_pos(data, i); - if (!last_snd || !subflow) + bpf_for_each(mptcp_subflow, subflow, msk) { + if (!last_snd) break; - if (mptcp_subflow_tcp_sock(subflow) == last_snd) { - if (i + 1 == MPTCP_SUBFLOWS_MAX || - !bpf_mptcp_subflow_ctx_by_pos(data, i + 1)) + if (bpf_mptcp_subflow_tcp_sock(subflow) == last_snd) { + subflow = bpf_iter_mptcp_subflow_next(&___it); + if (!subflow) break; - nr = i + 1; + next = subflow; break; } } - subflow = bpf_mptcp_subflow_ctx_by_pos(data, nr); - if (!subflow) - return -1; - mptcp_subflow_set_scheduled(subflow, true); - ptr->last_snd = mptcp_subflow_tcp_sock(subflow); + mptcp_subflow_set_scheduled(next, true); + ptr->last_snd = bpf_mptcp_subflow_tcp_sock(next); return 0; } From patchwork Fri Oct 4 12:59:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13822279 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 7EC0520FAA6 for ; Fri, 4 Oct 2024 13:00: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=1728046803; cv=none; b=aU1wTU2K3voDDsHvjZXklLv4CNZ/py9Fj4JBOTejSkWI0gG3FHZnC2+uqHkdzvOERz2WKLwrAQsaGemp9dlJ5WcL3X+4MGifLQZom3/M6bg+Q9RV8ShQcUrZjAPoegxeUxVCX57WTLhDZ7TZpE9ciOYsiOxze7RR68I1U479NTU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728046803; c=relaxed/simple; bh=vAGk2SNZxJ2K0XaAAadSTnWA8wtWMYR0tx03ZiqDhLQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jZM7t/LoevZAsVtpxnsosvrZv7i//WqFxuybwujj9IgYCel4nX76NpVnyYlVY7wgJwge8+hcuO4WDS6PWf6zbtjLnSx8K8SM2FUZzTNCPkQrl3o2QAxAGeZgkrPSnW7VJYSkgqdDmiSL7/S+wV59tmFbMtt5hvaiBAqcT0hewXM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZtRRwcJ7; 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="ZtRRwcJ7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30C0FC4CEC6; Fri, 4 Oct 2024 13:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728046803; bh=vAGk2SNZxJ2K0XaAAadSTnWA8wtWMYR0tx03ZiqDhLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZtRRwcJ7/gz/BhUubWvbsy0ffE/xPXY2AkHEx38KCysv8maDX3pPU6Xn5WEs5epCi /eGNYQAIKob1sKCvmp5QzE1EPuB7uUNFt5fBfAncD4tDw5AWsn5HowLm7a12xPjVKj drBoU0IRrEazJcv7CIXnd5zBJAQCnQTHYTg2LY6cv9Ce5eI4hGNG9ciFjRe4XA5AuI vVniA91KhAANFRyUAyeJ8swjZ2C4CTc1js8xwKaHoWSBnjZVdCJBZ1uUfLhOHf3c+u ZzdmMNzPMpG22pwrQhnJqPgUXkL5gcKtJKA7+L3nMTwqi5/fjJeZABITNnNedTLLq7 GcExVF272ugfg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 5/9] Squash to "selftests/bpf: Add bpf_red scheduler & test" Date: Fri, 4 Oct 2024 20:59:45 +0800 Message-ID: <4a1be29662f76e0222aafa8dc5da3551731644cc.1728046491.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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/testing/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 = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - if (!bpf_mptcp_subflow_ctx_by_pos(data, i)) - break; + struct mptcp_subflow_context *subflow; - 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); return 0; } From patchwork Fri Oct 4 12:59:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13822280 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 3D9CA15CD64 for ; Fri, 4 Oct 2024 13:00: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=1728046805; cv=none; b=QcJLEgXkbIUEz0yrHetNf6Rv5KJE1mCtrc2e9mpC3YFYUYfvH25mbJZLI7S4Z7O5v/gyahiv3hizIfOrtOEkZfQsF4PhX3D+QcZ9SsnSxzIT+92SZmexcaXbFYaO8Im10ISREFc9M4z6+TSM54R4IQBddNhCat03Zuu7hpRt+nk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728046805; c=relaxed/simple; bh=wPSQZ2+OJoT5vaEJtWUM9005coDDnnS24lyWp0XW+2s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mthECiTxsyar5rLHtlKXxc0FkScMXN33kIjpLF90By3bqrx6WIaW5+HCNUBr+Z9CKEeXW94Sh6JdIcbwlfBxpH8AL05mhEKU4GddslbjN7m9N2q4lMeq5j/AvHs/c4H/6RUDvkP05mMB/ObQ9mjYLUTN/kAjbJRvvzyzVm104ZI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sLMOWGX9; 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="sLMOWGX9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A802C4CEC6; Fri, 4 Oct 2024 13:00:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728046805; bh=wPSQZ2+OJoT5vaEJtWUM9005coDDnnS24lyWp0XW+2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sLMOWGX9Ma8wHgLB7l6+i9Z0S6nPTLRUKCCwOYJ1Z1d0cUMbAarIz2c959NVYuUHk Z2OCd0BzY0ipg44Yt2ytM/hWce7V7LH14ckteXxj1FMHxHfUESSpEsdLkE4JjPkZxU tcD+CQaPStOPe+O7R8zxtSJo8zqppIQQw5qfPc2X6XKIcfMvBaVQYmYjxhaF3oA57r EtQOrg1D88zxoKwXooVvykCE7zIjy5TC0XiyBjXqed+8+UuXrZJY6mqfJNDZ5LENsO /BcoRWb2Q/+MlY8BGhCWc7iDXAmQmhVyt+EfOUOipXNQyL3OTQC15XzrEyvuyNXFFM GUqIx5IrtJ8Ow== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 6/9] Squash to "bpf: Export more bpf_burst related functions" Date: Fri, 4 Oct 2024 20:59:46 +0800 Message-ID: <9cab58ab8790150dd205a1e6bf69c0b69900526c.1728046491.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Drop bpf_mptcp_subflow_queues_empty declaration. Signed-off-by: Geliang Tang --- net/mptcp/protocol.h | 1 - 1 file changed, 1 deletion(-) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index da6341008aa9..a47aa7938afa 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -725,7 +725,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); -bool bpf_mptcp_subflow_queues_empty(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); From patchwork Fri Oct 4 12:59:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13822281 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 3DA7420FAA5 for ; Fri, 4 Oct 2024 13:00:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728046807; cv=none; b=A3ihKTI2HTY/Q9DWAPb48Q7K1j9u/oIG2wgi/TUFQdE6Q1vKs2CwKwtWdZIAxWMdbBtWIZOV5oOnV3D1rO8BTgq53GRk6y80vLyX2uuq6ToTbFBZ2o8ceofDawGcMLCGodZvgLJ5XpAat3dzQ0gT1PCEWpmsGTJlVnc7hjhnCU8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728046807; c=relaxed/simple; bh=BuOgDD+bm6N14m3sIF4M6yO0GJOC3GY4OAJjbWNeIp0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BuXovyb3dNsVhUTPgVzl/SM3pEUzbqJw3MHNdmtzHwaD70nCBg3cdxxbEfv8htB6lWkiXOQbNYZ+tFLwlAdeeZ2flZqpKqG5O3gJRXIhAUHL31q3s6rbUstaxlH3J9IzPCcXY5K2bNd7gWzZxVhMMWtL6LV8I1BnsLJU1QAnDSM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dBd8CUPP; 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="dBd8CUPP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A55ACC4CEC6; Fri, 4 Oct 2024 13:00:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728046806; bh=BuOgDD+bm6N14m3sIF4M6yO0GJOC3GY4OAJjbWNeIp0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dBd8CUPPxiPNqsljEdOfWmF2tuqMCdZwlOzBzQGTdFJcGqZ3TnK+GuBlbOZ5ZhbHv qppW4XzVkUf1S2iLsIkfrX1qRj4UvEb/F+kyWl9rNhE0FqHTT3mVp/AYxwHPk2+5eo 5WZ1BvcsjtYvEIaUqK0jl4PiqTv5PvT1PxXbTFrq0zBFamYy6Nf9ZBhaaQbUbVcIUv rKHyM+0aS3PkHx3qm3witfg5Ut9MbzKT3SbBCWrNiwOpPJ6BSC5gJq7bnAF/6XPylR ZztjDQcDWdbYnU25NDJ+6o9gCNmIVjcEJR00+f9mw6MaqjVXODWQgyAhbWz5t56g8/ msiWXNs6D/svA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 7/9] Squash to "selftests/bpf: Add bpf_burst scheduler & test" Date: Fri, 4 Oct 2024 20:59:47 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Use the newly added bpf_for_each() helper to walk the conn_list. Drop mptcp_subflow_active declaration. Signed-off-by: Geliang Tang --- .../selftests/bpf/progs/mptcp_bpf_burst.c | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c index eb21119aa8f7..87b6d9dc876b 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c @@ -11,22 +11,21 @@ char _license[] SEC("license") = "GPL"; #define min(a, b) ((a) < (b) ? (a) : (b)) +#define SSK_MODE_ACTIVE 0 +#define SSK_MODE_BACKUP 1 +#define SSK_MODE_MAX 2 + 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; 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, struct sock *ssk) __ksym; -#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; @@ -57,6 +56,19 @@ static __always_inline bool sk_stream_memory_free(const struct sock *sk) return __sk_stream_memory_free(sk, 0); } +static struct mptcp_subflow_context * +mptcp_lookup_subflow_by_id(struct mptcp_sock *msk, unsigned int id) +{ + struct mptcp_subflow_context *subflow; + + bpf_for_each(mptcp_subflow, subflow, msk) { + if (subflow->subflow_id == id) + return subflow; + } + + return NULL; +} + SEC("struct_ops") void BPF_PROG(mptcp_sched_burst_init, struct mptcp_sock *msk) { @@ -67,8 +79,7 @@ void BPF_PROG(mptcp_sched_burst_release, struct mptcp_sock *msk) { } -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; @@ -84,16 +95,10 @@ static int bpf_burst_get_send(struct mptcp_sock *msk, send_info[i].linger_time = -1; } - for (i = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - bool backup; + bpf_for_each(mptcp_subflow, subflow, msk) { + bool backup = subflow->backup || subflow->request_bkup; - subflow = bpf_mptcp_subflow_ctx_by_pos(data, i); - if (!subflow) - break; - - backup = subflow->backup || subflow->request_bkup; - - ssk = mptcp_subflow_tcp_sock(subflow); + ssk = bpf_mptcp_subflow_tcp_sock(subflow); if (!mptcp_subflow_active(subflow)) continue; @@ -109,7 +114,7 @@ static int bpf_burst_get_send(struct mptcp_sock *msk, linger_time = div_u64((__u64)ssk->sk_wmem_queued << 32, pace); if (linger_time < send_info[backup].linger_time) { - send_info[backup].subflow_id = i; + send_info[backup].subflow_id = subflow->subflow_id; send_info[backup].linger_time = linger_time; } } @@ -119,10 +124,10 @@ static int bpf_burst_get_send(struct mptcp_sock *msk, if (!nr_active) send_info[SSK_MODE_ACTIVE].subflow_id = send_info[SSK_MODE_BACKUP].subflow_id; - subflow = bpf_mptcp_subflow_ctx_by_pos(data, send_info[SSK_MODE_ACTIVE].subflow_id); + subflow = mptcp_lookup_subflow_by_id(msk, send_info[SSK_MODE_ACTIVE].subflow_id); if (!subflow) return -1; - ssk = mptcp_subflow_tcp_sock(subflow); + ssk = bpf_mptcp_subflow_tcp_sock(subflow); if (!ssk || !sk_stream_memory_free(ssk)) return -1; @@ -141,23 +146,18 @@ static int bpf_burst_get_send(struct mptcp_sock *msk, return 0; } -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 = MPTCP_SUBFLOWS_MAX, pick = MPTCP_SUBFLOWS_MAX, subflow_id; + struct sock *backup = NULL, *pick = NULL; struct mptcp_subflow_context *subflow; int min_stale_count = INT_MAX; - struct sock *ssk; - for (int i = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - subflow = bpf_mptcp_subflow_ctx_by_pos(data, i); - if (!subflow) - break; + bpf_for_each(mptcp_subflow, subflow, msk) { + struct sock *ssk = bpf_mptcp_subflow_tcp_sock(subflow); if (!mptcp_subflow_active(subflow)) continue; - ssk = 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 +166,23 @@ static int bpf_burst_get_retrans(struct mptcp_sock *msk, } if (subflow->backup || subflow->request_bkup) { - if (backup == MPTCP_SUBFLOWS_MAX) - backup = i; + if (!backup) + backup = ssk; continue; } - if (pick == MPTCP_SUBFLOWS_MAX) - pick = i; + if (!pick) + pick = ssk; } - if (pick < MPTCP_SUBFLOWS_MAX) { - subflow_id = pick; + if (pick) goto out; - } - subflow_id = min_stale_count > 1 ? backup : MPTCP_SUBFLOWS_MAX; + pick = min_stale_count > 1 ? backup : NULL; out: - subflow = bpf_mptcp_subflow_ctx_by_pos(data, subflow_id); + if (!pick) + return -1; + subflow = bpf_mptcp_subflow_ctx(pick); if (!subflow) return -1; mptcp_subflow_set_scheduled(subflow, true); @@ -194,8 +194,8 @@ 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); } SEC(".struct_ops") From patchwork Fri Oct 4 12:59:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13822282 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 9994D20FAA5 for ; Fri, 4 Oct 2024 13:00:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728046808; cv=none; b=Ss7r66HW8aac7HSZmMcBve9l/kAHesUAI7QQw3YTi4p5JeHdhTwcIjm1BOMlL2VtbzAqb5Im3/bsvfd6adliQhHoB42re2wj2A7FALo3Dp03qrgR8ZJdkUQMBsZwgLDWjE9r/t/SMk14wBMmqeG2uREj+/Cd3svbDN/0d+212w0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728046808; c=relaxed/simple; bh=r01hSFySfF4YeqSWniiKuZPkj6/4PQQ8wZvIJB7E9WI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bcOdi98VjzJTkJt1RtZyfCpC2UqtOw4a0zDSXRKZ3EZByKNuuv4lAK8fSd23XRwIf7Ea01ASeCNQzgVbI9JF6VGT7bjtg+Pw/4Dc3ck8RGExdJfcXHf6Q8J/TV6MHnIaBxs5XPJlbat/7WgpGiRFW7AxN1Rb2hxxhdbUyq32EHE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WVnFhbuu; 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="WVnFhbuu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 781EBC4CEC6; Fri, 4 Oct 2024 13:00:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728046808; bh=r01hSFySfF4YeqSWniiKuZPkj6/4PQQ8wZvIJB7E9WI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WVnFhbuuuAHt3flS1OhhFUN2g2Q75pxkJvskNcj6DIxsABK40fsS5Z3MyLXhsW1Dr dUmbl/2kW0IHkmOxhHt3wQSZ3i79WP1xmxvF1Kh/cmlqbOrxdBatKpshlVh0cDV7HM qHMziwq+dywem4UvagfzmYSiOZfmC0JjDdbhHjeHuYuZChHuV6cwKOJ9mOXXhcH7mK LAxRQdPB1LNHcQxfn7ePXaudk3uJx187uqyJMNgwKvfP49LKhcqLpF2YxfyqR4OOtS 0gwtSLSP3D60trH31416tkpNGauhp22IY2q+g3UI4FodnMCXzpXe8Slu4TWd3p0rby 0ujGrDuslcXoQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 8/9] Revert "mptcp: add sched_data helpers" Date: Fri, 4 Oct 2024 20:59:48 +0800 Message-ID: <3eaae3c3c85914174f1185217b816a49332004ed.1728046491.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 9 --------- net/mptcp/protocol.h | 2 -- net/mptcp/sched.c | 22 ---------------------- 3 files changed, 33 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 02f5fadd0f89..2980129a4bc6 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -276,14 +276,6 @@ __bpf_kfunc void bpf_mptcp_sock_release(struct mptcp_sock *msk) WARN_ON_ONCE(!sk || !refcount_dec_not_one(&sk->sk_refcnt)); } -__bpf_kfunc struct mptcp_subflow_context * -bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos) -{ - if (pos >= MPTCP_SUBFLOWS_MAX) - return NULL; - return data->contexts[pos]; -} - __bpf_kfunc bool bpf_mptcp_subflow_queues_empty(struct sock *sk) { return tcp_rtx_queue_empty(sk); @@ -310,7 +302,6 @@ static const struct btf_kfunc_id_set bpf_mptcp_common_kfunc_set = { }; BTF_KFUNCS_START(bpf_mptcp_struct_ops_kfunc_ids) -BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx_by_pos) BTF_ID_FLAGS(func, mptcp_set_timeout) BTF_ID_FLAGS(func, mptcp_wnd_end) BTF_ID_FLAGS(func, tcp_stream_memory_free) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index a47aa7938afa..6c39c54a3889 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -725,8 +725,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 5257bc6c8cd6..78ed508ebc1b 100644 --- a/net/mptcp/sched.c +++ b/net/mptcp/sched.c @@ -143,26 +143,6 @@ void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow, WRITE_ONCE(subflow->scheduled, scheduled); } -static void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk, - struct mptcp_sched_data *data) -{ - struct mptcp_subflow_context *subflow; - int i = 0; - - mptcp_for_each_subflow(msk, subflow) { - if (i == MPTCP_SUBFLOWS_MAX) { - pr_warn_once("too many subflows"); - break; - } - mptcp_subflow_set_scheduled(subflow, false); - data->contexts[i++] = subflow; - } - data->subflows = i; - - for (; i < MPTCP_SUBFLOWS_MAX; i++) - data->contexts[i] = NULL; -} - int mptcp_sched_get_send(struct mptcp_sock *msk) { struct mptcp_subflow_context *subflow; @@ -189,7 +169,6 @@ int mptcp_sched_get_send(struct mptcp_sock *msk) data.reinject = false; if (msk->sched == &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); } @@ -212,6 +191,5 @@ int mptcp_sched_get_retrans(struct mptcp_sock *msk) data.reinject = true; if (msk->sched == &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); } From patchwork Fri Oct 4 12:59:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13822283 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 BB5C679F3 for ; Fri, 4 Oct 2024 13:00: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=1728046810; cv=none; b=WJt01LZHXYlVClvm0nvLZ01yYKU4Ovp4g3+OWERB9v32AOTko69aYbR/byxAeUOA3o/DF66begEWXIxk2alLYvtxHh+6X/xtRt+XL8TVczA4b28sQ7YlZbz2fZhDxEoS3tE0iU0a3p9t8Y47KuWJOK2xG95bmrde34YkOifHLpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728046810; c=relaxed/simple; bh=hN3agyD3X5i/gzavJ94nZKXl6iKgXdKHAjxn48A3d+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f8MvkSTTYXlHAVSVzlPKEvGVJhY5vzGX4Hi5Y5QDfiykO137CRc0a3gIC3Z5Y76J/vbnGr2CjhTtLmbuzMSQPbvLyquJHeCIHwWJYZKA9EkT8i2wIR0F79GEu5Epp5DklFy+uc8ul7/+LpNp9pkOARLTsWRCQkZLR3YUKSRCmOM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gvhJva69; 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="gvhJva69" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28073C4CEC6; Fri, 4 Oct 2024 13:00:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728046810; bh=hN3agyD3X5i/gzavJ94nZKXl6iKgXdKHAjxn48A3d+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gvhJva69VoLQ9QF91/LSAIPWrm+UL067AL0FDVv8tsUdaOpagDmAkuEH8MQkOxOkZ 6Fs9FCMK690fTjPHTyG/kdqkL72ePvE+/Te0SFxY2yKVl53/Q20vABilKUztnJHHS0 oou7Wbn3cagkq57nHY80S7kNuxMOppir0X9YdMe9yMx3sxuDWYxU1aExrC3Rr7sAi6 GlKgqia+Ir3z/3/eV6KYlh3E7WpGIWoLctW4F575sLiMA/GaUgtgQh8k72L8TYRaz0 01+VbQo/RYUpe0JWUfcSd06OOMXsaWOHzVgqq/V2OWHt1sAb0SdpsimLFVWn1HzeLu qQpe25DyPTP2g== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 9/9] mptcp: drop subflow contexts in mptcp_sched_data Date: Fri, 4 Oct 2024 20:59:49 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 { struct mptcp_sched_data { bool reinject; - u8 subflows; - struct mptcp_subflow_context *contexts[MPTCP_SUBFLOWS_MAX]; }; struct mptcp_sched_ops {