From: Mat Martineau <mathew.j.martineau@linux.intel.com>
To: Geliang Tang <geliang.tang@suse.com>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v7 4/8] mptcp: add sched in mptcp_sock
Date: Mon, 28 Mar 2022 15:47:46 -0700 (PDT) [thread overview]
Message-ID: <bb912e65-412f-1f2a-dab8-2c1f3fa374b@linux.intel.com> (raw)
In-Reply-To: <2812381119c23048dadbf5372293c724ff4b7970.1648459865.git.geliang.tang@suse.com>
On Mon, 28 Mar 2022, Geliang Tang wrote:
> This patch adds a new struct member sched in struct mptcp_sock.
> And two helpers mptcp_init_sched() and mptcp_release_sched() to
> init and release it.
>
> Init it with the sysctl scheduler in mptcp_init_sock(), copy the
> scheduler from the parent in mptcp_sk_clone(), and release it in
> __mptcp_destroy_sock().
>
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> ---
> net/mptcp/protocol.c | 4 ++++
> net/mptcp/protocol.h | 4 ++++
> net/mptcp/sched.c | 27 +++++++++++++++++++++++++++
> 3 files changed, 35 insertions(+)
>
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 2c684034fe7a..82b3846147a6 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -2662,6 +2662,8 @@ static int mptcp_init_sock(struct sock *sk)
> * propagate the correct value
> */
> mptcp_ca_reset(sk);
> + mptcp_init_sched(mptcp_sk(sk),
> + mptcp_sched_find(net, mptcp_get_scheduler(net)));
>
> sk_sockets_allocated_inc(sk);
> sk->sk_rcvbuf = sock_net(sk)->ipv4.sysctl_tcp_rmem[1];
> @@ -2817,6 +2819,7 @@ static void __mptcp_destroy_sock(struct sock *sk)
> sk_stop_timer(sk, &sk->sk_timer);
> mptcp_data_unlock(sk);
> msk->pm.status = 0;
> + mptcp_release_sched(msk);
>
> /* clears msk->subflow, allowing the following loop to close
> * even the initial subflow
> @@ -2994,6 +2997,7 @@ struct sock *mptcp_sk_clone(const struct sock *sk,
> msk->snd_una = msk->write_seq;
> msk->wnd_end = msk->snd_nxt + req->rsk_rcv_wnd;
> msk->setsockopt_seq = mptcp_sk(sk)->setsockopt_seq;
> + mptcp_init_sched(msk, mptcp_sk(sk)->sched);
>
> if (mp_opt->suboptions & OPTIONS_MPTCP_MPC) {
> msk->can_ack = true;
> diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
> index dd4a2afdb38b..81c35af7ade5 100644
> --- a/net/mptcp/protocol.h
> +++ b/net/mptcp/protocol.h
> @@ -288,6 +288,7 @@ struct mptcp_sock {
> struct socket *subflow; /* outgoing connect/listener/!mp_capable */
> struct sock *first;
> struct mptcp_pm_data pm;
> + struct mptcp_sched_ops *sched;
> struct {
> u32 space; /* bytes copied in last measurement window */
> u32 copied; /* bytes copied in this measurement window */
> @@ -618,6 +619,9 @@ void mptcp_unregister_scheduler(const struct net *net,
> void mptcp_sched_init(void);
> struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk);
> void mptcp_sched_data_init(struct sock *sk);
> +int mptcp_init_sched(struct mptcp_sock *msk,
> + struct mptcp_sched_ops *sched);
> +void mptcp_release_sched(struct mptcp_sock *msk);
>
> static inline bool __mptcp_subflow_active(struct mptcp_subflow_context *subflow)
> {
> diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c
> index 1fb3dd24d6ff..9b3a3157111d 100644
> --- a/net/mptcp/sched.c
> +++ b/net/mptcp/sched.c
> @@ -125,3 +125,30 @@ void mptcp_sched_data_init(struct sock *sk)
> {
> mptcp_register_scheduler(sock_net(sk), &mptcp_sched_default);
> }
> +
> +int mptcp_init_sched(struct mptcp_sock *msk,
> + struct mptcp_sched_ops *sched)
> +{
> + if (!sched)
> + msk->sched = &mptcp_sched_default;
> + else
> + msk->sched = sched;
> +
> + if (!bpf_try_module_get(msk->sched, msk->sched->owner))
> + return -EBUSY;
The bpf_try_module_get() should be before msk->sched is assigned.
> +
> + if (msk->sched->init)
> + msk->sched->init(msk);
> +
> + pr_debug("sched=%s", msk->sched->name);
> +
> + return 0;
> +}
> +
> +void mptcp_release_sched(struct mptcp_sock *msk)
> +{
> + if (msk->sched && msk->sched->release)
> + msk->sched->release(msk);
Looks like the null check here is already addressed in the squash-to
patch.
> + bpf_module_put(msk->sched, msk->sched->owner);
Would be better to store a local pointer to the sched struct and clear
msk->sched before doing the bpf_module_put() call. With the RCU grace
period it's not likely to be a problem but might as well do the put last.
> + msk->sched = NULL;
> +}
> --
> 2.34.1
>
>
>
--
Mat Martineau
Intel
next prev parent reply other threads:[~2022-03-28 22:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-28 9:37 [PATCH mptcp-next v7 0/8] BPF packet scheduler Geliang Tang
2022-03-28 9:37 ` [PATCH mptcp-next v7 1/8] mptcp: add struct mptcp_sched_ops Geliang Tang
2022-03-28 9:49 ` Florian Westphal
2022-03-28 13:11 ` Geliang Tang
2022-03-28 13:49 ` Florian Westphal
2022-03-28 9:37 ` [PATCH mptcp-next v7 2/8] mptcp: register default scheduler Geliang Tang
2022-03-28 9:37 ` [PATCH mptcp-next v7 3/8] mptcp: add a new sysctl scheduler Geliang Tang
2022-03-28 9:37 ` [PATCH mptcp-next v7 4/8] mptcp: add sched in mptcp_sock Geliang Tang
2022-03-28 9:51 ` Florian Westphal
2022-03-28 22:47 ` Mat Martineau [this message]
2022-03-28 9:37 ` [PATCH mptcp-next v7 5/8] mptcp: add get_subflow wrapper Geliang Tang
2022-03-28 9:38 ` [PATCH mptcp-next v7 6/8] mptcp: add bpf_mptcp_sched_ops Geliang Tang
2022-03-28 9:38 ` [PATCH mptcp-next v7 7/8] selftests: bpf: add mptcp_bpf_first scheduler Geliang Tang
2022-03-28 9:38 ` [PATCH mptcp-next v7 8/8] selftests: bpf: add mptcp_bpf_first test Geliang Tang
2022-03-28 22:49 ` Mat Martineau
2022-03-30 17:03 ` selftests: bpf: add mptcp_bpf_first test: Build Failure MPTCP CI
2022-03-30 21:10 ` selftests: bpf: add mptcp_bpf_first test: Tests Results MPTCP CI
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bb912e65-412f-1f2a-dab8-2c1f3fa374b@linux.intel.com \
--to=mathew.j.martineau@linux.intel.com \
--cc=geliang.tang@suse.com \
--cc=mptcp@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.