MPTCP Archive mirror
 help / color / mirror / Atom feed
From: Matthieu Baerts <matttbe@kernel.org>
To: Eric Dumazet <edumazet@google.com>
Cc: mptcp@lists.linux.dev, Mat Martineau <martineau@kernel.org>,
	Geliang Tang <geliang@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Shuah Khan <shuah@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	Geliang Tang <tanggeliang@kylinos.cn>
Subject: Re: [PATCH net-next 1/2] mptcp: add last time fields in mptcp_info
Date: Fri, 5 Apr 2024 15:52:05 +0200	[thread overview]
Message-ID: <39588f6b-b466-4a1a-bd30-729c5da37a22@kernel.org> (raw)
In-Reply-To: <CANn89i+2TMNF7chYaDFEBNRng3iLPaXBqXKNtZYevDd95-PqmQ@mail.gmail.com>

Hi Eric,

Thank you for the review!

On 05/04/2024 15:29, Eric Dumazet wrote:
> On Fri, Apr 5, 2024 at 3:06 PM Matthieu Baerts (NGI0)
> <matttbe@kernel.org> wrote:
>>
>> From: Geliang Tang <tanggeliang@kylinos.cn>
>>
>> This patch adds "last time" fields last_data_sent, last_data_recv and
>> last_ack_recv in struct mptcp_sock to record the last time data_sent,
>> data_recv and ack_recv happened. They all are initialized as
>> tcp_jiffies32 in __mptcp_init_sock(), and updated as tcp_jiffies32 too
>> when data is sent in __subflow_push_pending(), data is received in
>> __mptcp_move_skbs_from_subflow(), and ack is received in ack_update_msk().
>>
>> Similar to tcpi_last_data_sent, tcpi_last_data_recv and tcpi_last_ack_recv
>> exposed with TCP, this patch exposes the last time "an action happened" for
>> MPTCP in mptcp_info, named mptcpi_last_data_sent, mptcpi_last_data_recv and
>> mptcpi_last_ack_recv, calculated in mptcp_diag_fill_info() as the time
>> deltas between now and the newly added last time fields in mptcp_sock.
>>
>> Also add three reserved bytes in struct mptcp_info not to have holes in
>> this structure exposed to userspace.
>>
>> Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/446
>> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
>> Reviewed-by: Mat Martineau <martineau@kernel.org>
>> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
>> ---
>>  include/uapi/linux/mptcp.h | 4 ++++
> 
> 
>> diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
>> index 73fdf423de44..2ec2fdf9f4af 100644
>> --- a/net/mptcp/sockopt.c
>> +++ b/net/mptcp/sockopt.c
>> @@ -896,6 +896,7 @@ static int mptcp_getsockopt_first_sf_only(struct mptcp_sock *msk, int level, int
>>  void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info)
>>  {
>>         struct sock *sk = (struct sock *)msk;
>> +       u32 now = tcp_jiffies32;
>>         u32 flags = 0;
>>         bool slow;
>>
>> @@ -930,6 +931,7 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info)
>>         info->mptcpi_snd_una = msk->snd_una;
>>         info->mptcpi_rcv_nxt = msk->ack_seq;
>>         info->mptcpi_bytes_acked = msk->bytes_acked;
>> +       info->mptcpi_last_ack_recv = jiffies_to_msecs(now - msk->last_ack_recv);
>>         mptcp_data_unlock(sk);
>>
>>         slow = lock_sock_fast(sk);
> 
>  lock_sock_fast(sk) can sleep and be quite slow...
> 
> I suggest you reload now = jiffies32;

Good point, it would make more sense to reload it after this lock!

(or defining "now" only here, under this lock_sock_fast(), and move the
block here above that is under the data spin lock, after, so all the
"time" counter are "in sync"?)

pw-bot: changes-requested

> 
> 
>> @@ -942,6 +944,8 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info)
>>         info->mptcpi_bytes_retrans = msk->bytes_retrans;
>>         info->mptcpi_subflows_total = info->mptcpi_subflows +
>>                 __mptcp_has_initial_subflow(msk);
>> +       info->mptcpi_last_data_sent = jiffies_to_msecs(now - msk->last_data_sent);
>> +       info->mptcpi_last_data_recv = jiffies_to_msecs(now - msk->last_data_recv);
>>         unlock_sock_fast(sk, slow);
>>  }
>>  EXPORT_SYMBOL_GPL(mptcp_diag_fill_info);
>>
>> --
>> 2.43.0
>>
> 

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.


  reply	other threads:[~2024-04-05 13:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-05 13:06 [PATCH net-next 0/2] mptcp: add last time fields in mptcp_info Matthieu Baerts (NGI0)
2024-04-05 13:06 ` [PATCH net-next 1/2] " Matthieu Baerts (NGI0)
2024-04-05 13:29   ` Eric Dumazet
2024-04-05 13:52     ` Matthieu Baerts [this message]
2024-04-05 13:06 ` [PATCH net-next 2/2] selftests: mptcp: test last time mptcp_info Matthieu Baerts (NGI0)

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=39588f6b-b466-4a1a-bd30-729c5da37a22@kernel.org \
    --to=matttbe@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=geliang@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martineau@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    --cc=tanggeliang@kylinos.cn \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).