[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <39588f6b-b466-4a1a-bd30-729c5da37a22@kernel.org>
Date: Fri, 5 Apr 2024 15:52:05 +0200
From: Matthieu Baerts <matttbe@...nel.org>
To: Eric Dumazet <edumazet@...gle.com>
Cc: mptcp@...ts.linux.dev, Mat Martineau <martineau@...nel.org>,
Geliang Tang <geliang@...nel.org>, "David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Shuah Khan <shuah@...nel.org>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
Geliang Tang <tanggeliang@...inos.cn>
Subject: Re: [PATCH net-next 1/2] mptcp: add last time fields in mptcp_info
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@...nel.org> wrote:
>>
>> From: Geliang Tang <tanggeliang@...inos.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@...inos.cn>
>> Reviewed-by: Mat Martineau <martineau@...nel.org>
>> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@...nel.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.
Powered by blists - more mailing lists