From: Pavel Begunkov <asml.silence@gmail.com>
To: Jens Axboe <axboe@kernel.dk>,
io-uring@vger.kernel.org,
Vadim Fedorenko <vadim.fedorenko@linux.dev>
Cc: netdev@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
Kuniyuki Iwashima <kuniyu@amazon.com>,
Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Richard Cochran <richardcochran@gmail.com>
Subject: Re: [PATCH v2 5/5] io_uring/netcmd: add tx timestamping cmd support
Date: Wed, 4 Jun 2025 13:33:17 +0100 [thread overview]
Message-ID: <db7e43e3-89bf-4ec4-a225-0c352b6fc306@gmail.com> (raw)
In-Reply-To: <b82bd278-1562-4901-971a-aa111c749747@kernel.dk>
On 6/4/25 13:04, Jens Axboe wrote:
> On 6/4/25 2:42 AM, Pavel Begunkov wrote:
>> Add a new socket command which returns tx time stamps to the user. It
>> provide an alternative to the existing error queue recvmsg interface.
>> The command works in a polled multishot mode, which means io_uring will
>> poll the socket and keep posting timestamps until the request is
>> cancelled or fails in any other way (e.g. with no space in the CQ). It
>> reuses the net infra and grabs timestamps from the socket's error queue.
>>
>> The command requires IORING_SETUP_CQE32. All non-final CQEs (marked with
>> IORING_CQE_F_MORE) have cqe->res set to the tskey, and the upper 16 bits
>> of cqe->flags keep tstype (i.e. offset by IORING_CQE_BUFFER_SHIFT). The
>> timevalue is store in the upper part of the extended CQE. The final
>> completion won't have IORING_CQR_F_MORE and will have cqe->res storing
> ^^
>
> CQE_F_MORE
>
> Minor nit below.
>
>> +static bool io_process_timestamp_skb(struct io_uring_cmd *cmd, struct sock *sk,
>> + struct sk_buff *skb, unsigned issue_flags)
>> +{
>> + struct sock_exterr_skb *serr = SKB_EXT_ERR(skb);
>> + struct io_uring_cqe cqe[2];
>> + struct io_timespec *iots;
>> + struct timespec64 ts;
>> + u32 tskey;
>> +
>> + BUILD_BUG_ON(sizeof(struct io_uring_cqe) != sizeof(struct io_timespec));
>> +
>> + if (!skb_get_tx_timestamp(skb, sk, &ts))
>> + return false;
>> +
>> + tskey = serr->ee.ee_data;
>> +
>> + cqe->user_data = 0;
>> + cqe->res = tskey;
>> + cqe->flags = IORING_CQE_F_MORE;
>> + cqe->flags |= (u32)serr->ee.ee_info << IORING_CQE_BUFFER_SHIFT;
>
> Get rid of the tskey variable?
Why? I named it specifically so that it's obvious what the field
means, and "cqe->res = serr->ee.ee_data" hardly tells the meaning
of the fields without extra digging.
And I think this would be more easily
> readable if it used:
>
> cqe[0].user_data = 0;
I don't see how it'd be easier to read by cluttering the code
with "[0]" in multiple statements. Combined with that it's
one extended cqe and not some array of them.
> etc.
>
>> + iots = (struct io_timespec *)&cqe[1];
>> + iots->tv_sec = ts.tv_sec;
>> + iots->tv_nsec = ts.tv_nsec;
>> + return io_uring_cmd_post_mshot_cqe32(cmd, issue_flags, cqe);
>> +}
>
> A bit of a shame we can't just get the double CQE and fill it in, rather
> than fill it on stack and copy it. But probably doesn't matter much.
>
--
Pavel Begunkov
next prev parent reply other threads:[~2025-06-04 12:31 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-04 8:42 [PATCH v2 0/5] io_uring cmd for tx timestamps Pavel Begunkov
2025-06-04 8:42 ` [PATCH v2 1/5] net: timestamp: add helper returning skb's tx tstamp Pavel Begunkov
2025-06-04 15:37 ` Stanislav Fomichev
2025-06-05 0:52 ` Willem de Bruijn
2025-06-05 3:51 ` Jason Xing
2025-06-04 8:42 ` [PATCH v2 2/5] io_uring/poll: introduce io_arm_apoll() Pavel Begunkov
2025-06-04 8:42 ` [PATCH v2 3/5] io_uring/cmd: allow multishot polled commands Pavel Begunkov
2025-06-04 8:42 ` [PATCH v2 4/5] io_uring: add mshot helper for posting CQE32 Pavel Begunkov
2025-06-04 8:42 ` [PATCH v2 5/5] io_uring/netcmd: add tx timestamping cmd support Pavel Begunkov
2025-06-04 12:04 ` Jens Axboe
2025-06-04 12:33 ` Pavel Begunkov [this message]
2025-06-05 0:59 ` Willem de Bruijn
2025-06-05 10:25 ` Vadim Fedorenko
2025-06-05 11:01 ` Pavel Begunkov
2025-06-05 23:54 ` Willem de Bruijn
2025-06-06 0:17 ` Jason Xing
2025-06-06 0:02 ` Jason Xing
2025-06-06 8:12 ` Pavel Begunkov
2025-06-06 8:33 ` Jason Xing
2025-06-06 9:08 ` Pavel Begunkov
2025-06-04 8:53 ` [PATCH v2 0/5] io_uring cmd for tx timestamps Pavel Begunkov
2025-06-04 12:06 ` Jens Axboe
2025-06-04 12:38 ` Pavel Begunkov
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=db7e43e3-89bf-4ec4-a225-0c352b6fc306@gmail.com \
--to=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=io-uring@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=vadim.fedorenko@linux.dev \
--cc=willemb@google.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