From: Mat Martineau <mathew.j.martineau@linux.intel.com>
To: menglong8.dong@gmail.com
Cc: pabeni@redhat.com, mptcp@lists.linux.dev,
Menglong Dong <imagedong@tencent.com>
Subject: Re: [PATCH mptcp] net: mptcp: add statistics for mptcp socket in use
Date: Mon, 19 Sep 2022 15:37:23 -0700 (PDT) [thread overview]
Message-ID: <61ca3016-5f92-7779-9213-f8b75ff9ff55@linux.intel.com> (raw)
In-Reply-To: <20220919132156.3649522-1-imagedong@tencent.com>
On Mon, 19 Sep 2022, menglong8.dong@gmail.com wrote:
> From: Menglong Dong <imagedong@tencent.com>
>
> Do the statistics of mptcp socket in use with sock_prot_inuse_add().
> Therefore, we can get the count of used mptcp socket from
> /proc/net/protocols:
>
> & cat /proc/net/protocols
> protocol size sockets memory press maxhdr slab module cl co di ac io in de sh ss gs se re sp bi br ha uh gp em
> MPTCPv6 2048 0 0 no 0 yes kernel y n y y y y y y y y y y n n n y y y n
> MPTCP 1896 1 0 no 0 yes kernel y n y y y y y y y y y y n n n y y y n
>
> Signed-off-by: Menglong Dong <imagedong@tencent.com>
Hello Menglong -
Thanks for your patch.
One minor thing: please use the subject line tags listed in
https://github.com/multipath-tcp/mptcp_net-next/wiki/Patch-prefixes :
either "[PATCH mptcp-net]" or "[PATCH mptcp-next]", so it's clear which
tree the patch is intended for.
> ---
> net/mptcp/protocol.c | 19 +++++++++++++------
> net/mptcp/subflow.c | 3 +++
> 2 files changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 45ed50e9aec9..4da77aa8b070 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -2311,6 +2311,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
> tcp_set_state(ssk, TCP_CLOSE);
> mptcp_subflow_queue_clean(ssk);
> inet_csk_listen_stop(ssk);
> + sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
The code in this function is for a closing subflow, not a closing MPTCP
socket. I don't think this call belongs here.
> }
> __tcp_close(ssk, 0);
>
> @@ -3067,6 +3068,9 @@ void mptcp_destroy_common(struct mptcp_sock *msk, unsigned int flags)
> skb_rbtree_purge(&msk->out_of_order_queue);
> mptcp_data_unlock(sk);
>
> + if (!sk_unhashed(sk) || __mptcp_check_fallback(msk))
> + sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
> +
> /* move all the rx fwd alloc into the sk_mem_reclaim_final in
> * inet_sock_destruct() will dispose it
> */
> @@ -3513,6 +3517,7 @@ static int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr,
> mptcp_token_destroy(msk);
> inet_sk_state_store(sock->sk, TCP_SYN_SENT);
> subflow = mptcp_subflow_ctx(ssock->sk);
> + sock_prot_inuse_add(sock_net(sock->sk), sock->sk->sk_prot, 1);
> #ifdef CONFIG_TCP_MD5SIG
> /* no MPTCP if MD5SIG is enabled on this socket or we may run out of
> * TCP option space.
> @@ -3547,12 +3552,13 @@ static int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr,
> static int mptcp_listen(struct socket *sock, int backlog)
> {
> struct mptcp_sock *msk = mptcp_sk(sock->sk);
> + struct sock *sk = sock->sk;
Changing all of the "sock->sk" text in this function to "sk" creates a lot
of diffs that aren't related to maintaining the inuse statistics. If you'd
like to do that refactoring change, please split that into a separate
patch for mptcp-next.
-Mat
> struct socket *ssock;
> int err;
>
> pr_debug("msk=%p", msk);
>
> - lock_sock(sock->sk);
> + lock_sock(sk);
> ssock = __mptcp_nmpc_socket(msk);
> if (!ssock) {
> err = -EINVAL;
> @@ -3560,16 +3566,17 @@ static int mptcp_listen(struct socket *sock, int backlog)
> }
>
> mptcp_token_destroy(msk);
> - inet_sk_state_store(sock->sk, TCP_LISTEN);
> - sock_set_flag(sock->sk, SOCK_RCU_FREE);
> + inet_sk_state_store(sk, TCP_LISTEN);
> + sock_set_flag(sk, SOCK_RCU_FREE);
> + sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
>
> err = ssock->ops->listen(ssock, backlog);
> - inet_sk_state_store(sock->sk, inet_sk_state_load(ssock->sk));
> + inet_sk_state_store(sk, inet_sk_state_load(ssock->sk));
> if (!err)
> - mptcp_copy_inaddrs(sock->sk, ssock->sk);
> + mptcp_copy_inaddrs(sk, ssock->sk);
>
> unlock:
> - release_sock(sock->sk);
> + release_sock(sk);
> return err;
> }
>
> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index 07dd23d0fe04..da6cfa73a3bd 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
> @@ -747,6 +747,9 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
> mptcp_sk(new_msk)->setsockopt_seq = ctx->setsockopt_seq;
> mptcp_pm_new_connection(mptcp_sk(new_msk), child, 1);
> mptcp_token_accept(subflow_req, mptcp_sk(new_msk));
> + sock_prot_inuse_add(sock_net(new_msk),
> + new_msk->sk_prot,
> + 1);
> ctx->conn = new_msk;
> new_msk = NULL;
>
> --
> 2.37.2
>
>
>
--
Mat Martineau
Intel
next prev parent reply other threads:[~2022-09-19 22:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-19 13:21 [PATCH mptcp] net: mptcp: add statistics for mptcp socket in use menglong8.dong
2022-09-19 15:14 ` net: mptcp: add statistics for mptcp socket in use: Tests Results MPTCP CI
2022-09-19 22:37 ` Mat Martineau [this message]
2022-09-20 2:10 ` [PATCH mptcp] net: mptcp: add statistics for mptcp socket in use Menglong Dong
2022-09-20 11:44 ` Matthieu Baerts
2022-09-20 13:47 ` Menglong Dong
2022-09-20 22:36 ` Mat Martineau
2022-09-21 3:25 ` Menglong Dong
2022-09-20 10:52 ` net: mptcp: add statistics for mptcp socket in use: 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=61ca3016-5f92-7779-9213-f8b75ff9ff55@linux.intel.com \
--to=mathew.j.martineau@linux.intel.com \
--cc=imagedong@tencent.com \
--cc=menglong8.dong@gmail.com \
--cc=mptcp@lists.linux.dev \
--cc=pabeni@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).